public void ConvertLayerProperties_MapPointDataWithStyle_ConvertsStyleToMapPointLayer(
            [Values(KnownColor.AliceBlue, KnownColor.Azure)]
            KnownColor color,
            [Values(1, 5)] int width,
            [Values(PointSymbol.Circle, PointSymbol.Square)]
            PointSymbol pointStyle)
        {
            // Setup
            var   converter     = new MapPointDataConverter();
            var   mapPointLayer = new MapPointLayer();
            Color expectedColor = Color.FromKnownColor(color);
            var   mapPointData  = new MapPointData("test", new PointStyle
            {
                Color           = expectedColor,
                Size            = width,
                Symbol          = pointStyle,
                StrokeColor     = expectedColor,
                StrokeThickness = 1
            });

            // Call
            converter.ConvertLayerProperties(mapPointData, mapPointLayer);

            // Assert
            PointShape expectedPointShape = pointStyle == PointSymbol.Circle
                                                ? PointShape.Ellipse
                                                : PointShape.Rectangle;

            var expectedSymbolizer = new PointSymbolizer(expectedColor, expectedPointShape, width);

            expectedSymbolizer.SetOutline(expectedColor, 1);

            AssertAreEqual(expectedSymbolizer, mapPointLayer.Symbolizer);
        }
Beispiel #2
0
        public void Update()
        {
            if (!ReferenceEquals(mapPointData.Features, drawnFeatures))
            {
                converter.ConvertLayerFeatures(mapPointData, this);

                drawnFeatures = mapPointData.Features;
            }

            converter.ConvertLayerProperties(mapPointData, this);
        }
        public void ConvertLayerProperties_MapPointDataWithThemeAndMetaDataNameNotInFeatures_OnlyAddsDefaultCategory()
        {
            // Setup
            const string metadataAttribute = "Meta";
            var          random            = new Random(21);
            var          theme             = new MapTheme <PointCategoryTheme>("Other Meta", new[]
            {
                new PointCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                       new PointStyle
                {
                    Color           = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    Size            = random.Next(1, 48),
                    Symbol          = random.NextEnum <PointSymbol>(),
                    StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeThickness = random.Next(1, 48)
                })
            });

            var pointStyle = new PointStyle
            {
                Color           = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                Size            = random.Next(1, 48),
                Symbol          = random.NextEnum <PointSymbol>(),
                StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeThickness = random.Next(1, 48)
            };
            var mapPointData = new MapPointData("test", pointStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData(metadataAttribute)
                }
            };

            var mapPointLayer = new MapPointLayer();

            var converter = new MapPointDataConverter();

            // Call
            converter.ConvertLayerProperties(mapPointData, mapPointLayer);

            // Assert
            PointSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(pointStyle);

            IPointScheme appliedScheme = mapPointLayer.Symbology;

            Assert.AreEqual(1, appliedScheme.Categories.Count);

            IPointCategory baseCategory = appliedScheme.Categories[0];

            AssertAreEqual(expectedSymbolizer, baseCategory.Symbolizer);
            Assert.IsNull(baseCategory.FilterExpression);
        }
        public void ConvertLayerProperties_MapPointDataWithThemeAndMetaDataNameInFeatures_ConvertDataToMapPointLayer()
        {
            // Setup
            const string metadataAttribute = "Meta";
            var          random            = new Random(21);

            var unequalCriterion = new ValueCriterion(ValueCriterionOperator.UnequalValue,
                                                      "unequal value");
            var equalCriterion = new ValueCriterion(ValueCriterionOperator.EqualValue,
                                                    "equal value");
            var theme = new MapTheme <PointCategoryTheme>(metadataAttribute, new[]
            {
                new PointCategoryTheme(equalCriterion, new PointStyle
                {
                    Color           = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    Size            = random.Next(1, 48),
                    Symbol          = random.NextEnum <PointSymbol>(),
                    StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeThickness = random.Next(1, 48)
                }),
                new PointCategoryTheme(unequalCriterion, new PointStyle
                {
                    Color           = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    Size            = random.Next(1, 48),
                    Symbol          = random.NextEnum <PointSymbol>(),
                    StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    StrokeThickness = random.Next(1, 48)
                })
            });

            var pointStyle = new PointStyle
            {
                Color           = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                Size            = random.Next(1, 48),
                Symbol          = random.NextEnum <PointSymbol>(),
                StrokeColor     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                StrokeThickness = random.Next(1, 48)
            };
            var mapPointData = new MapPointData("test", pointStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData(metadataAttribute)
                }
            };

            var mapPointLayer = new MapPointLayer();

            var converter = new MapPointDataConverter();

            // Call
            converter.ConvertLayerProperties(mapPointData, mapPointLayer);

            // Assert
            PointSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(pointStyle);

            IPointScheme appliedScheme = mapPointLayer.Symbology;

            Assert.AreEqual(3, appliedScheme.Categories.Count);

            IPointCategory baseCategory = appliedScheme.Categories[0];

            AssertAreEqual(expectedSymbolizer, baseCategory.Symbolizer);
            Assert.IsNull(baseCategory.FilterExpression);

            IPointCategory equalSchemeCategory = appliedScheme.Categories[1];
            string         expectedFilter      = $"[1] = '{equalCriterion.Value}'";

            Assert.AreEqual(expectedFilter, equalSchemeCategory.FilterExpression);
            PointStyle expectedCategoryStyle = theme.CategoryThemes.ElementAt(0).Style;

            expectedSymbolizer = CreateExpectedSymbolizer(expectedCategoryStyle);
            AssertAreEqual(expectedSymbolizer, equalSchemeCategory.Symbolizer);

            IPointCategory unEqualSchemeCategory = appliedScheme.Categories[2];

            expectedFilter = $"NOT [1] = '{unequalCriterion.Value}'";
            Assert.AreEqual(expectedFilter, unEqualSchemeCategory.FilterExpression);
            expectedCategoryStyle = theme.CategoryThemes.ElementAt(1).Style;
            expectedSymbolizer    = CreateExpectedSymbolizer(expectedCategoryStyle);
            AssertAreEqual(expectedSymbolizer, unEqualSchemeCategory.Symbolizer);
        }