private List <MountainPoint> GetData(HeightRequestDbData requestData)
        {
            var elevationService = new ElevationService();

            var request = new ElevationRequest();

            request.Samples = requestData.ResolutionX;

            var latStep = (requestData.NeLat - requestData.SwLat) / requestData.ResolutionY;
            var lat     = requestData.SwLat + latStep * requestData.RequestNumber;

            request.Path.Add(new LatLng(lat, requestData.SwLng));
            request.Path.Add(new LatLng(lat, requestData.NeLng));

            var response = elevationService.GetResponse(request);

            if (response.Status == ServiceResponseStatus.Ok)
            {
                return(response.Results.Select(i => new MountainPoint
                {
                    height = i.Elevation,
                    lat = (decimal)i.Location.Latitude,
                    lng = (decimal)i.Location.Longitude
                }).ToList());
            }
            throw new Exception("Not supported status: " + response.Status + ". " + response.ErrorMessage);
        }
 public VisualTopoService(MeshService meshService, ElevationService elevationService, ILogger <VisualTopoService> logger)
 {
     _meshService         = meshService;
     _elevationService    = elevationService;
     convers3Reprojection = new Convers3Reprojection();
     _logger = logger;
 }
        public void GetElevationForTwoLocations()
        {
            // expectations
            var expectedStatus             = ServiceResponseStatus.Ok;
            var expectedResultCount        = 2;
            var expectedElevation1         = 1608.8402100m;
            var expectedLocationLatitude1  = 39.7391536m;
            var expectedLocationLongitude1 = -104.9847034m;
            var expectedElevation2         = -50.7890358m;
            var expectedLocationLatitude2  = 36.4555560m;
            var expectedLocationLongitude2 = -116.8666670m;

            // test
            var request = new ElevationRequest();

            request.Locations = "39.7391536,-104.9847034|36.455556,-116.866667";
            request.Sensor    = "false";
            var response = ElevationService.GetResponse(request);

            // asserts
            Assert.AreEqual(expectedStatus, response.Status);
            Assert.AreEqual(expectedResultCount, response.Results.Length);
            Assert.AreEqual(expectedElevation1, response.Results.First().Elevation);
            Assert.AreEqual(expectedLocationLatitude1, response.Results.First().Location.Latitude);
            Assert.AreEqual(expectedLocationLongitude1, response.Results.First().Location.Longitude);
            Assert.AreEqual(expectedElevation2, response.Results.Last().Elevation);
            Assert.AreEqual(expectedLocationLatitude2, response.Results.Last().Location.Latitude);
            Assert.AreEqual(expectedLocationLongitude2, response.Results.Last().Location.Longitude);
        }
示例#4
0
 public glTFTests(DemNetFixture fixture)
 {
     _rasterService    = fixture.ServiceProvider.GetService <RasterService>();
     _elevationService = fixture.ServiceProvider.GetService <ElevationService>();
     _sharpGltfService = fixture.ServiceProvider.GetService <SharpGltfService>();
     _meshService      = fixture.ServiceProvider.GetService <MeshService>();
 }
示例#5
0
        static void Main(string[] args)
        {
            SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
            _DataDirectory = ConfigurationManager.AppSettings["DataDir"];
            IGeoTiffService  geoTiffService   = new GeoTiffService(_DataDirectory);
            ElevationService elevationService = new ElevationService(geoTiffService);

            //geoTiffService.GenerateDirectoryMetadata(DEMDataSet.AW3D30, false, true);
            // geoTiffService.GenerateFileMetadata(@"C:\Users\xfischer\AppData\Roaming\DEM.Net\ETOPO1\ETOPO1_Ice_g_geotiff.tif", false, false);

            //SpatialTrace_GeometryWithDEMGrid(elevationService, geoTiffService, WKT_EXAMPLE_GOOGLE, DEMDataSet.AW3D30);

            //LineDEMBenchmark(elevationService, DEMDataSet.AW3D30, 512);

            PointDEMTest(elevationService, DEMDataSet.AW3D30, 39.713092, -77.725708);
            LineDEMTest(elevationService, DEMDataSet.AW3D30, WKT_LEAFLET_ELEVATION, 100);

            //GeoTiffBenchmark();

            //Test_GetMetadataFromVRT(elevationService, DEMDataSet.AW3D30);

            //elevationService.DownloadMissingFiles(DEMDataSet.AW3D30, GetBoundingBox(WKT_AIX_BAYONNE_EST_OUEST));
            ////elevationService.DownloadMissingFiles(DEMDataSet.SRTM_GL3_srtm, GetBoundingBox(WKT_GRAND_TRAJET_MARSEILLE_ALPES_MULTIPLE_TILES));

            ////GenerateDownloadReports(geoTiffService);

            //geoTiffService.GenerateDirectoryMetadata(DEMDataSet.AW3D30, false, false);

            //Spatial trace of line +segments + interpolated point + dem grid
            //SpatialTrace_GeometryWithDEMGrid(elevationService, geoTiffService, WKT_TEST, DEMDataSet.AW3D30);

            Console.Write("Press any key to exit...");
            Console.ReadLine();
        }
        public double GetElevation(double _latitude, double _longitude, double _altitude = 0)
        {
            ElevationRequest elevationRequest = new ElevationRequest();

            elevationRequest.AddLocations(new LatLng(_latitude, _longitude));
            elevationRequest.Sensor = false;

            try
            {
                ElevationResponse elevation = new ElevationService().GetResponse(elevationRequest);
                if (elevation.Status == ServiceResponseStatus.Ok)
                {
                    return((double)elevation.Results[0].Elevation);
                }
                else
                {
                    return(_altitude);
                }
            }
            catch (Exception ex)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "Error: LocationHelper.cs - GetElevation");
                Logger.ColoredConsoleWrite(ConsoleColor.Red, ex.Message);
                return(_altitude);
            }
        }
示例#7
0
        private static void GeoTiffBenchmark()
        {
            DEMDataSet       dataSet = DEMDataSet.AW3D30;
            ElevationService elevationServiceLibTiff = new ElevationService(new GeoTiffService(_DataDirectory));

            string wkt = WKT_BREST_NICE;

            elevationServiceLibTiff.DownloadMissingFiles(dataSet, GetBoundingBox(wkt));

            const int NUM_ITERATIONS = 10;

            Stopwatch swCoreTiff = new Stopwatch();
            Stopwatch swGeoTiff  = new Stopwatch();

            for (int j = 0; j < 5; j++)
            {
                for (int i = 0; i < NUM_ITERATIONS; i++)
                {
                    swGeoTiff.Start();
                    var lineElevationData = elevationServiceLibTiff.GetLineGeometryElevation(wkt, dataSet, InterpolationMode.Hyperbolic);
                    swGeoTiff.Stop();
                }
            }


            long geoTiffMs = swGeoTiff.ElapsedMilliseconds;

            long codeTiffMs = swCoreTiff.ElapsedMilliseconds;

            Console.WriteLine($"GeoTiff : {geoTiffMs} ms, Native : {codeTiffMs}");
        }
示例#8
0
        public DemNetVisualTopoService()
        {
            var config = new ConfigurationBuilder()
                         .SetBasePath(AppContext.BaseDirectory)
                         .AddJsonFile("appsettings.json", optional: true)
                         .AddJsonFile("secrets.json", optional: true, reloadOnChange: false)
                         .Build();


            this.services = new ServiceCollection()
                            .AddOptions()
                            .AddLogging(loggingBuilder => loggingBuilder
                                        .AddDebug()
                                        .SetMinimumLevel(LogLevel.Debug))
                            .Configure <AppSecrets>(config.GetSection(nameof(AppSecrets)))
                            .Configure <DEMNetOptions>(config.GetSection(nameof(DEMNetOptions)))
                            .AddDemNetCore()
                            .AddDemNetglTF()
                            .AddDemNetVisualTopoExtension()
                            .BuildServiceProvider();



            this.visualTopoService = services.GetService <VisualTopoService>();
            this.elevationService  = services.GetService <ElevationService>();
            this.meshService       = services.GetService <MeshService>();
            this.sharpGltfService  = services.GetService <SharpGltfService>();
            this.imageryService    = services.GetService <ImageryService>();
        }
        public void GetElevationForTwoLocations()
        {
            // expectations
            var expectedStatus      = ServiceResponseStatus.Ok;
            var expectedResultCount = 2;

            var expectedElevation1 = 1608.6m;
            var expectedLocation1  = new LatLng(39.739153, -104.984703);
            var expectedElevation2 = -50.789m;
            var expectedLocation2  = new LatLng(36.4555560, -116.8666670);

            // test
            var request = new ElevationRequest();

            request.AddLocations(expectedLocation1, expectedLocation2);
            request.Sensor = false;
            var response = new ElevationService().GetResponse(request);

            // asserts
            Assert.AreEqual(expectedStatus, response.Status);

            Assert.AreEqual(expectedResultCount, response.Results.Length);

            Assert.That(expectedElevation1, Is.EqualTo(response.Results[0].Elevation).Within(0.1));
            Assert.That(expectedLocation1, Is.EqualTo(response.Results[0].Location));

            Assert.That(expectedElevation2, Is.EqualTo(response.Results[1].Elevation).Within(0.1));
            Assert.That(expectedLocation2, Is.EqualTo(response.Results[1].Location));
        }
示例#10
0
 public CustomSamples(ILogger <CustomSamples> logger
                      , ElevationService elevationService
                      , RasterService rasterService)
 {
     _logger           = logger;
     _elevationService = elevationService;
     _rasterService    = rasterService;
 }
示例#11
0
 public DownloaderSample(ILogger <DownloaderSample> logger
                         , RasterService rasterService
                         , ElevationService elevationService)
 {
     _logger           = logger;
     _rasterService    = rasterService;
     _elevationService = elevationService;
 }
示例#12
0
 public GpxSamples(ILogger <GpxSamples> logger
                   , RasterService rasterService
                   , ElevationService elevationService)
 {
     _logger           = logger;
     _rasterService    = rasterService;
     _elevationService = elevationService;
 }
示例#13
0
        public OsmTests(DemNetFixture fixture)
        {
            _osmProcessor     = fixture.ServiceProvider.GetService <DefaultOsmProcessor>();
            _elevationService = fixture.ServiceProvider.GetService <ElevationService>();

            _imageryService = fixture.ServiceProvider.GetService <ImageryService>();
            _gltfService    = fixture.ServiceProvider.GetService <SharpGltfService>();
        }
示例#14
0
        private static void Test_GetMetadataFromVRT(ElevationService elevationService, DEMDataSet dataSet)
        {
            GDALVRTFileService gdalService = new GDALVRTFileService(elevationService.GetDEMLocalPath(dataSet), dataSet);

            gdalService.Setup(false);

            GDALSource source = gdalService.Sources().FirstOrDefault(s => s.SourceFileName.EndsWith("N043E006_AVE_DSM.tif"));
        }
示例#15
0
 public STLSamples(ILogger <STLSamples> logger
                   , ElevationService elevationService
                   , SharpGltfService sharpGltfService
                   , ISTLExportService stlService)
 {
     _logger           = logger;
     _elevationService = elevationService;
     _sharpGltfService = sharpGltfService;
     _stlService       = stlService;
 }
示例#16
0
 public TINSamples(ILogger <TINSamples> logger
                   , RasterService rasterService
                   , ElevationService elevationService
                   , SharpGltfService glTFService)
 {
     _logger           = logger;
     _rasterService    = rasterService;
     _elevationService = elevationService;
     _glTFService      = glTFService;
 }
示例#17
0
 public glTF3DSamples(ILogger <glTF3DSamples> logger
                      , ElevationService elevationService
                      , SharpGltfService sharpGltfService
                      , ImageryService imageryService)
 {
     _logger           = logger;
     _elevationService = elevationService;
     _sharpGltfService = sharpGltfService;
     _imageryService   = imageryService;
 }
示例#18
0
 public HighestPointFinder(ILogger <HighestPointFinder> logger
                           , ElevationService elevationService
                           , OverpassAPIDataService osmService
                           , DefaultOsmProcessor osmProcessor)
 {
     _logger           = logger;
     _elevationService = elevationService;
     _osmProcessor     = osmProcessor;
     _osmService       = osmService;
 }
示例#19
0
 public ImagerySample(ILogger <ImagerySample> logger
                      , ElevationService elevationService
                      , SharpGltfService sharpGltfService
                      , ImageryService imageryService)
 {
     _logger           = logger;
     _elevationService = elevationService;
     _sharpGltfService = sharpGltfService;
     _imageryService   = imageryService;
 }
示例#20
0
        public ElevationController()
        {
            string dataDirectory = ConfigurationManager.AppSettings["DataDir"];

            if (!Path.IsPathRooted(dataDirectory))
            {
                dataDirectory = Path.Combine(HostingEnvironment.MapPath("~"), dataDirectory);
            }
            _elevationService = new ElevationService(new GeoTiffService(dataDirectory));
        }
示例#21
0
 public Gpx3DSamples(ILogger <Gpx3DSamples> logger
                     , RasterService rasterService
                     , ElevationService elevationService
                     , SharpGltfService sharpGltfService
                     , ImageryService imageryService)
 {
     _logger           = logger;
     _rasterService    = rasterService;
     _elevationService = elevationService;
     _sharpGltfService = sharpGltfService;
     _imageryService   = imageryService;
 }
示例#22
0
 public AerialGpxSample(ILogger <AerialGpxSample> logger
                        , RasterService rasterService
                        , ElevationService elevationService
                        , ImageryService imageryService
                        , SharpGltfService sharpGltfService)
 {
     _logger           = logger;
     _rasterService    = rasterService;
     _elevationService = elevationService;
     _imageryService   = imageryService;
     _sharpGltfService = sharpGltfService;
 }
示例#23
0
 public void Init(ElevationService elevationService
                  , SharpGltfService gltfService
                  , MeshService meshService
                  , IOsmDataService osmDataService
                  , ILogger logger)
 {
     this._elevationService = elevationService;
     this._gltfService      = gltfService;
     this._meshService      = meshService;
     this._osmDataService   = osmDataService;
     this._logger           = logger;
 }
示例#24
0
        static void PointDEMTest(ElevationService elevationService, DEMDataSet dataSet, double lat, double lon)
        {
            elevationService.DownloadMissingFiles(dataSet, lat, lon);

            var geoPoint_Bilinear = elevationService.GetPointElevation(lat, lon, dataSet, InterpolationMode.Bilinear);

            Console.WriteLine($"Elevation with Bilinear model : {geoPoint_Bilinear.Elevation}");

            var geoPoint_Hyperbolic = elevationService.GetPointElevation(lat, lon, dataSet, InterpolationMode.Hyperbolic);

            Console.WriteLine($"Elevation with Hyperbolic model : {geoPoint_Hyperbolic.Elevation}");
        }
示例#25
0
        static void LineDEMBenchmark(ElevationService elevationService, DEMDataSet dataSet, int numSamples)
        {
            Dictionary <string, string> dicWktByName = new Dictionary <string, string>();

            //dicWktByName.Add(nameof(WKT_EXAMPLE_GOOGLE), WKT_EXAMPLE_GOOGLE);

            // Before GeoTiff window optim : 90s
            // After GeoTiff optim : 77s / release : 60s;


            dicWktByName.Add(nameof(WKT_BREST_NICE), WKT_BREST_NICE);
            dicWktByName.Add(nameof(WKT_HORIZONTAL_DEM_EDGE), WKT_HORIZONTAL_DEM_EDGE);
            dicWktByName.Add(nameof(WKT_VERTICAL_DEM_EDGE), WKT_VERTICAL_DEM_EDGE);
            dicWktByName.Add(nameof(WKT_MONACO), WKT_MONACO);
            dicWktByName.Add(nameof(WKT_TEST), WKT_TEST);
            dicWktByName.Add(nameof(WKT_NO_DEM), WKT_NO_DEM);
            dicWktByName.Add(nameof(WKT_ZERO), WKT_ZERO);
            dicWktByName.Add(nameof(WKT_NEG100), WKT_NEG100);
            dicWktByName.Add(nameof(WKT_BREST_SPAIN_OCEAN), WKT_BREST_SPAIN_OCEAN);
            dicWktByName.Add(nameof(WKT_EXAMPLE_GOOGLE), WKT_EXAMPLE_GOOGLE);
            dicWktByName.Add(nameof(WKT_PARIS_AIX), WKT_PARIS_AIX);
            dicWktByName.Add(nameof(WKT_PETITE_BOUCLE), WKT_PETITE_BOUCLE);
            dicWktByName.Add(nameof(WKT_GRAND_TRAJET), WKT_GRAND_TRAJET);
            dicWktByName.Add(nameof(WKT_GRAND_TRAJET_MARSEILLE_ALPES_MULTIPLE_TILES), WKT_GRAND_TRAJET_MARSEILLE_ALPES_MULTIPLE_TILES);
            dicWktByName.Add(nameof(WKT_BAYONNE_AIX_OUEST_EST), WKT_BAYONNE_AIX_OUEST_EST);
            dicWktByName.Add(nameof(WKT_AIX_BAYONNE_EST_OUEST), WKT_AIX_BAYONNE_EST_OUEST);
            dicWktByName.Add(nameof(WKT_BAYONNE_NICE_DIRECT), WKT_BAYONNE_NICE_DIRECT);
            dicWktByName.Add(nameof(WKT_DEM_INTERPOLATION_BUG), WKT_DEM_INTERPOLATION_BUG);

            Stopwatch sw = Stopwatch.StartNew();

            InterpolationMode[] modes = { InterpolationMode.Bilinear, InterpolationMode.Hyperbolic };
            for (int i = 0; i < 5; i++)
            {
                foreach (var wkt in dicWktByName)
                {
                    elevationService.DownloadMissingFiles(dataSet, GetBoundingBox(wkt.Value));

                    foreach (InterpolationMode mode in modes)
                    {
                        var lineElevationData    = elevationService.GetLineGeometryElevation(wkt.Value, dataSet, mode);
                        ElevationMetrics metrics = GeometryService.ComputeMetrics(ref lineElevationData);
                        //var sampledLineElevationData = ReduceList(lineElevationData, numSamples).ToList();
                        //File.WriteAllText($"ElevationData_{wkt.Key}_{mode}.txt", elevationService.ExportElevationTable(lineElevationData));
                        //File.WriteAllText($"ElevationData_{wkt.Key}_{mode}_{numSamples}samples.txt", elevationService.ExportElevationTable(sampledLineElevationData));
                    }
                }
            }

            sw.Stop();
            Console.WriteLine($"LineDEMTests performed in {sw.Elapsed:g}.");
        }
示例#26
0
 public VisualTopoSample(ILogger <VisualTopoSample> logger
                         , SharpGltfService gltfService
                         , MeshService meshService
                         , ElevationService elevationService
                         , ImageryService imageryService
                         , VisualTopoService visualTopoService)
 {
     _logger            = logger;
     _meshService       = meshService;
     _gltfService       = gltfService;
     _elevationService  = elevationService;
     _imageryService    = imageryService;
     _visualTopoService = visualTopoService;
 }
 public CustomRasterElevationSample(ILogger <CustomRasterElevationSample> logger
                                    , RasterService rasterService
                                    , ElevationService elevationService
                                    , MeshService meshService
                                    , SharpGltfService sharpGltfService
                                    , ImageryService imageryService)
 {
     _logger           = logger;
     _rasterService    = rasterService;
     _elevationService = elevationService;
     _sharpGltfService = sharpGltfService;
     _imageryService   = imageryService;
     _meshService      = meshService;
 }
示例#28
0
 public OsmExtensionSample(DefaultOsmProcessor osmProcessor
                           , OverpassAPIDataService osmService
                           , ImageryService imageryService
                           , ElevationService elevationService
                           , SharpGltfService gltfService
                           , ILogger <OsmExtensionSample> logger)
 {
     this._osmProcessor     = osmProcessor;
     this._imageryService   = imageryService;
     this._elevationService = elevationService;
     this._gltfService      = gltfService;
     this._logger           = logger;
     this._osmService       = osmService;
 }
        public async Task B11_YumaPointElevationServiceTest()
        {
            var httpClient = new HttpClient();

            var elevation = await ElevationService.OpenTopoNedElevation(httpClient,
                                                                        GrandCanyonPointInfo.YumaPointContent02.Latitude, GrandCanyonPointInfo.YumaPointContent02.Longitude,
                                                                        DebugTrackers.DebugProgressTracker());

            Assert.NotNull(elevation, "Elevation returned null");

            var concreteElevation = Math.Round(elevation.Value.MetersToFeet(), 0);

            Assert.AreEqual(GrandCanyonPointInfo.YumaPointContent02.Elevation, concreteElevation,
                            "Service Elevation does not match");
        }
        public async Task ElevationService_SinglePointNedTest()
        {
            var client = new HttpClient();

            var testData = GrandCanyonPointsWithNed10Elevations();

            foreach (var loopTests in testData)
            {
                var result = await ElevationService.OpenTopoNedElevation(client, loopTests.Latitude,
                                                                         loopTests.Longitude, DebugTrackers.DebugProgressTracker());

                Assert.NotNull(result, $"Null result from {loopTests.Name}");
                Assert.AreEqual(loopTests.RoundedElevationInMeters, Math.Round(result.Value, 2), $"{loopTests.Name}");
            }
        }