public void ConvertLayerFeatures_MapPointDataWithMultipleFeatures_ConvertsEachGeometryToMapPointLayerAsSingleFeature()
        {
            // Setup
            var converter     = new MapPointDataConverter();
            var mapPointLayer = new MapPointLayer();
            var mapPointData  = new MapPointData("test")
            {
                Features = new[]
                {
                    new MapFeature(new[]
                    {
                        new MapGeometry(new[]
                        {
                            new[]
                            {
                                new Point2D(1, 2)
                            }
                        })
                    }),
                    new MapFeature(Enumerable.Empty <MapGeometry>()),
                    new MapFeature(new[]
                    {
                        new MapGeometry(new[]
                        {
                            new[]
                            {
                                new Point2D(2, 3)
                            }
                        })
                    }),
                    new MapFeature(Enumerable.Empty <MapGeometry>()),
                    new MapFeature(new[]
                    {
                        new MapGeometry(new[]
                        {
                            new[]
                            {
                                new Point2D(3, 4)
                            }
                        }),
                        new MapGeometry(new[]
                        {
                            new[]
                            {
                                new Point2D(5, 6)
                            }
                        })
                    })
                }
            };

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

            // Assert
            Assert.AreEqual(4, mapPointLayer.DataSet.Features.Count);
        }
Beispiel #2
0
        public void Update()
        {
            if (!ReferenceEquals(mapPointData.Features, drawnFeatures))
            {
                converter.ConvertLayerFeatures(mapPointData, this);

                drawnFeatures = mapPointData.Features;
            }

            converter.ConvertLayerProperties(mapPointData, this);
        }
        public void ConvertLayerFeatures_MapPointDataWithFeature_ConvertsFeatureToMapPointLayerAsPointData()
        {
            // Setup
            var converter     = new MapPointDataConverter();
            var mapPointLayer = new MapPointLayer();
            var mapFeature    = new MapFeature(new[]
            {
                new MapGeometry(new[]
                {
                    new[]
                    {
                        new Point2D(1, 2)
                    }
                })
            });

            var mapPointData = new MapPointData("test")
            {
                Features = new[]
                {
                    mapFeature
                }
            };

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

            // Assert
            IFeature feature = mapPointLayer.DataSet.Features[0];

            Assert.AreEqual(mapPointData.Features.Count(), mapPointLayer.DataSet.Features.Count);
            Assert.IsInstanceOf <Point>(feature.Geometry);

            IEnumerable <Coordinate> expectedCoordinates = mapFeature.MapGeometries.ElementAt(0).PointCollections.ElementAt(0).Select(p => new Coordinate(p.X, p.Y));

            CollectionAssert.AreEqual(expectedCoordinates, feature.Geometry.Coordinates);
        }
        public void GivenMapLayerWithScheme_WhenConvertingLayerFeatures_ThenClearsAppliedSchemeAndAppliesDefaultCategory()
        {
            // Given
            const string metadataAttribute = "Meta";

            var mocks       = new MockRepository();
            var categoryOne = mocks.Stub <IPointCategory>();
            var categoryTwo = mocks.Stub <IPointCategory>();

            mocks.ReplayAll();

            var mapPointLayer = new MapPointLayer
            {
                Symbology = new PointScheme
                {
                    Categories =
                    {
                        categoryOne,
                        categoryTwo
                    }
                }
            };

            var converter = new MapPointDataConverter();

            var random     = new Random(21);
            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 theme = new MapTheme <PointCategoryTheme>(metadataAttribute, 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 mapPointData = new MapPointData("test", pointStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData(metadataAttribute)
                }
            };

            // When
            converter.ConvertLayerFeatures(mapPointData, mapPointLayer);

            // Then
            PointCategoryCollection categoryCollection = mapPointLayer.Symbology.Categories;

            Assert.AreEqual(1, categoryCollection.Count);

            IPointSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(pointStyle);

            AssertAreEqual(expectedSymbolizer, categoryCollection.Single().Symbolizer);

            mocks.VerifyAll();
        }