Ejemplo n.º 1
0
        public void ReadEsriMdbGeodatabase()
        {
            var map = new Map(new Size(400, 200))
            {
                Name = "map1"
            };

            const string fileName = SharpMapTestDataPath + "Turtle.mdb";

            IList <OgrFeatureProvider> providers = new List <OgrFeatureProvider>();

            var numberOfLayers = OgrFeatureProvider.GetNumberOfLayers(fileName);

            for (int i = 0; i < numberOfLayers; i++)
            {
                var provider = new OgrFeatureProvider(fileName, i);
                providers.Add(provider);

                log.DebugFormat("Added layer {0}", provider.Name);
            }

            var vectorLayer = new VectorLayer {
                DataSource = providers[6]
            };

            map.Layers.Add(vectorLayer);

            MapTestHelper.Show(map);
        }
Ejemplo n.º 2
0
        public void GetFeatureShouldWorkForShapeFileWithoutObjectID()
        {
            const string path    = SharpMapTestDataPath + "gemeenten.shp";
            var          s       = new OgrFeatureProvider(path, Path.GetFileNameWithoutExtension(path));
            var          feature = s.Features[0];

            Assert.Less(-1, s.IndexOf((IFeature)feature));
        }
Ejemplo n.º 3
0
        public void GetOgrFeatureAttribites()
        {
            const string path     = SharpMapTestDataPath + "Turtle.mdb";
            var          provider = new OgrFeatureProvider(path, 2);
            var          feature  = (IFeature)provider.Features[0];

            Assert.AreEqual("KST0073", feature.Attributes["ST_ID_STUW"]);
        }
Ejemplo n.º 4
0
        public void ShapeFileWithInvalidShx()
        {
            const string path = SharpMapTestDataPath + "Coquitlam model extents.shp";

            //make sure featureprovider is disposed immediately
            using (var provider = new OgrFeatureProvider(path, Path.GetFileNameWithoutExtension(path)))
            {
                Assert.IsNotNull(provider.Features[0]);
            }
        }
Ejemplo n.º 5
0
        public void ContainsShouldWorkForShapeFile()
        {
            const string path = SharpMapTestDataPath + "Europe_Lakes.shp";

            using (var featureProvider = new OgrFeatureProvider(path, Path.GetFileNameWithoutExtension(path)))
            {
                var feature = featureProvider.Features[0];
                featureProvider.Contains((IFeature)feature);
            } // -> should not throw an exception}
        }
Ejemplo n.º 6
0
        public void GetFeatureShouldWorkForShapeFile()
        {
            const string path = SharpMapTestDataPath + "Europe_Lakes.shp";

            using (var s = new OgrFeatureProvider(path, Path.GetFileNameWithoutExtension(path)))
            {
                var feature = s.Features[0];
                Assert.Less(-1, s.IndexOf((IFeature)feature));
            }
        }