// create using simple feature. useful to read from Shapefile, other generic geospatial data source
        public void CreateUsingAnonymousConstructor()
        {
            var feature1 = new Feature { Geometry = new Point(0, 0, 0), Attributes = { { "Name", "Amsterdam" }, { "Population", 1500000 } } };
            var feature2 = new Feature { Geometry = new Point(1, 1, 1), Attributes = { { "Name", "The Hague" }, { "Population", 900000 } } };

            var dataSource = new MemoryFeatureDataSource { Features = new [] { feature1, feature2 }.AsQueryable() };

            dataSource.FeatureAttributes.Count
                      .Should("query attributes, automatically reconstructed from added features").Be.EqualTo(2);
        }
示例#2
0
        [Category(TestCategory.Jira)] //TOOLS-7021
        public void GetNearestFeatureShouldNotThrowForGeometryNull()
        {
            var nearestFeature = GeometryHelper.GetNearestFeature(new Coordinate(0, 0),
                                                                  new[] { 
                                                                            new Feature {Geometry = null},
                                                                            new Feature {Geometry = null},
                                                                            new Feature {Geometry = null}
                                                                         },
                                                                  2);
            Assert.IsNull(nearestFeature);

            var featureToBeFound = new Feature { Geometry = new Point(0.2, 0.2) };
            nearestFeature = GeometryHelper.GetNearestFeature(new Coordinate(0, 0),
                                                              new[] 
                                                                  { 
                                                                      new Feature {Geometry = null},
                                                                      new Feature {Geometry = new Point(1, 0)},
                                                                      featureToBeFound
                                                                  },
                                                              2);
            Assert.IsNotNull(nearestFeature);
            Assert.IsTrue(featureToBeFound == nearestFeature);
        }
示例#3
0
        [Category(TestCategory.Jira)] //TOOLS-7021
        public void GetFeaturesInRangeShouldNotThrowForGeometryNull()
        {
            var features = GeometryHelper.GetFeaturesInRange(new Coordinate(0, 0),
                                                             new[]
                                                                 {
                                                                     new Feature {Geometry = null},
                                                                     new Feature {Geometry = null},
                                                                     new Feature {Geometry = null}
                                                                 }, 
                                                             5).ToArray();
            Assert.IsEmpty(features);

            var feature1 = new Feature { Geometry = new Point(0.2, 1) };
            var feature2 = new Feature { Geometry = new Point(1, 0, 2) };
            features = GeometryHelper.GetFeaturesInRange(new Coordinate(0, 0),
                                                         new[]
                                                             {
                                                                 feature1,
                                                                 new Feature {Geometry = null},
                                                                 feature2
                                                             },
                                                         5).ToArray();
            Assert.AreEqual(2, features.Count());
            Assert.Contains(feature1, features);
            Assert.Contains(feature2, features);
        }
示例#4
0
        public void GetLayerByFeature()
        {
            var map = new Map();
            var groupLayer1 = new GroupLayer();
            var groupLayer2 = new GroupLayer();
            var childLayer1 = new VectorLayer();
            var childLayer2 = new VectorLayer{ Visible = false };
            var feature = new Feature();

            map.Layers.Add(groupLayer1);
            groupLayer1.Layers.Add(childLayer1);
            groupLayer1.Layers.Add(groupLayer2);
            groupLayer2.Layers.Add(childLayer2);

            Assert.IsNull(map.GetLayerByFeature(feature));
            
            childLayer2.DataSource = new FeatureCollection
                                        {
                                            Features = new List<Feature> { feature },
                                            FeatureType = typeof (Feature)
                                        };

            Assert.AreSame(childLayer2, map.GetLayerByFeature(feature), "Should retrieved invisible layer.");

            childLayer1.DataSource = new FeatureCollection
                                         {
                                             Features = new List<Feature> {feature},
                                             FeatureType = typeof (Feature)
                                         };

            Assert.AreSame(childLayer1, map.GetLayerByFeature(feature), "Should retrieve childLayer1 as it's first in the collection.");
        }