Esempio n. 1
0
        public void OgrDataReaderTestReadGpxTracksViaBabel()
        {
            var babelPath = GetFullPathFromWindows("GPSbabel.exe");

            if (String.IsNullOrEmpty(babelPath))
            {
                Assert.Ignore("GPSbabel.exe was not found! Ignoring Babel based tests! If left to continue a (System.ApplicationException : Could not create process gpsbabel...) would have been thrown! ");
                return;
            }

            var gpxTestFile = GpxTestFileCreator.CreateTrackMakerGpsGpxTestFile();

            using (var dr = new OgrDataReader($"GPSBabel:gpx:features=tracks:{gpxTestFile}", new GpsBabelFileNameExtractor()))
            {
                var layer = dr.GetLayers().Keys.First();
                Assert.NotNull(layer);
                Assert.AreEqual(658, layer.Vertex.Length);
                var geom = layer.Features[0];
                Assert.AreEqual(5, layer.Features.Count);
                Assert.AreEqual(-47.616119460, layer.Vertex[0], _tolerance);
                Assert.AreEqual(-21.616149930, layer.Vertex[1], _tolerance);
                Assert.AreEqual(-47.611553182, layer.Vertex[656], _tolerance);
                Assert.AreEqual(-21.733156522, layer.Vertex[657], _tolerance);
                //layer.SaveAs($"OgrDataReaderTestReadGpxTracksViaBabel\\OgrDataReaderTestReadGpxTracksViaBabel.shp", true);
            }

            GpxTestFileCreator.DeleteTrackMakerGpsGpxTestFile();
        }
Esempio n. 2
0
        public void OgrDataReaderTestReadGpxRoutesViaBabel()
        {
            var babelPath = GetFullPathFromWindows("GPSbabel.exe");

            if (String.IsNullOrEmpty(babelPath))
            {
                Assert.Ignore("GPSbabel.exe was not found! Ignoring Babel based tests! If left to continue a (System.ApplicationException : Could not create process gpsbabel...) would have been thrown! ");
                return;
            }

            var gpxTestFile = GpxTestFileCreator.CreateMapSourceSimpleWaypointERouteTestFile();

            using (var dr = new OgrDataReader($"GPSBabel:gpx:features=routes:{gpxTestFile}", new GpsBabelFileNameExtractor()))
            {
                var layer = dr.GetLayers().Keys.First();
                Assert.NotNull(layer);
                Assert.AreEqual(4, layer.Vertex.Length);
                var geom = layer.Features[0];
                Assert.AreEqual(1, geom.NumParts());
                Assert.AreEqual(-45.707053346559405, layer.Vertex[0], _tolerance);
                Assert.AreEqual(-23.718632999807596, layer.Vertex[1], _tolerance);
                Assert.AreEqual(-45.714390277862549, layer.Vertex[2], _tolerance);
                Assert.AreEqual(-23.71721469797194, layer.Vertex[3], _tolerance);
                //layer.SaveAs($"OgrDataReaderTestReadGpxRoutesViaBabel\\OgrDataReaderTestReadGpxRoutesViaBabel.shp", true);
            }

            GpxTestFileCreator.DeleteMapSourceSimpleWaypointERouteTestFile();
        }
Esempio n. 3
0
        public void OgrDataReaderTestGpsBabelFileNameExtractor()
        {
            var gpxTestFile = GpxTestFileCreator.CreateMapSourceSimpleWaypointERouteTestFile();
            var extracted   = new GpsBabelFileNameExtractor().ExtractFileName($"GPSBabel:gpx:features=tracks:{gpxTestFile}");

            Assert.AreEqual(gpxTestFile, extracted);
            GpxTestFileCreator.DeleteMapSourceSimpleWaypointERouteTestFile();
        }
Esempio n. 4
0
        public void OgrDataReaderTestReadGpx()
        {
            var gpxTestFile = GpxTestFileCreator.CreateMapSourceSimpleWaypointERouteTestFile();

            //standard gpx reader only reads waypoints!
            using (var dr = new OgrDataReader(gpxTestFile))
            {
                var layer = dr.GetLayers().Keys.First();
                Assert.NotNull(layer);
                Assert.AreEqual(8, layer.Vertex.Length);
                var geom = layer.Features[0];
                Assert.AreEqual(1, geom.NumParts());
                Assert.AreEqual(-45.707975439727306, layer.Vertex[0], _tolerance);
                Assert.AreEqual(-23.719357447698712, layer.Vertex[1], _tolerance);
                Assert.AreEqual(-45.714390277862549, layer.Vertex[6], _tolerance);
                Assert.AreEqual(-23.71721469797194, layer.Vertex[7], _tolerance);
                //layer.SaveAs($"OgrDataReaderTestReadGpx\\OgrDataReaderTestReadGpx.shp", true);
            }

            GpxTestFileCreator.DeleteMapSourceSimpleWaypointERouteTestFile();
        }