Ejemplo n.º 1
0
        public IHttpActionResult GetPathElevation(Location[] path, int samples = 100)
        {
            try
            {
                var geoPoints = ModelFactory.Create(path);
                var geom      = GeometryService.ParseGeoPointAsGeometryLine(geoPoints);
                _elevationService.DownloadMissingFiles(DEMDataSet.AW3D30, geom.GetBoundingBox());
                geoPoints = _elevationService.GetLineGeometryElevation(geom, DEMDataSet.AW3D30, InterpolationMode.Bilinear);
                ElevationMetrics metrics = GeometryService.ComputeMetrics(geoPoints);

                if (samples > 2)
                {
                    double ratio     = 4 / 2;
                    double tolerance = (metrics.MaxElevation - metrics.MinElevation) / (samples / ratio);
                    geoPoints = DouglasPeucker.DouglasPeuckerReduction(geoPoints, tolerance);
                }


                // Model
                ElevationMetricsModel metricsModel = ModelFactory.CreateElevationMetricsModel(geoPoints, metrics);
                var feature = ModelFactory.CreateFeature(geoPoints, metricsModel);
                return(Ok(feature));
            }
            catch (Exception ex)
            {
                return(InternalServerError(new Exception(ex.Message)));
            }
        }
Ejemplo n.º 2
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}.");
        }
Ejemplo n.º 3
0
        static void LineDEMTest(ElevationService elevationService, DEMDataSet dataSet, string wkt, int numSamples)
        {
            Stopwatch sw = Stopwatch.StartNew();

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

            var lineElevationData         = elevationService.GetLineGeometryElevation(wkt, dataSet, InterpolationMode.Bilinear);
            ElevationMetrics metrics      = GeometryService.ComputeMetrics(ref lineElevationData);
            var lineElevationData_Reduced = DouglasPeucker.DouglasPeuckerReduction(lineElevationData, (metrics.MaxElevation - metrics.MinElevation) / numSamples);

            sw.Stop();
            Console.WriteLine($"LineDEMTest performed in {sw.Elapsed:g}.");

            SpatialTrace.Enable();
            SpatialTrace.Clear();
            SpatialTraceLine(lineElevationData, $"Full resolution line ({lineElevationData.Count} points)");


            SpatialTraceLine(lineElevationData_Reduced, $"Reduced line ({lineElevationData_Reduced.Count} points)");

            SpatialTrace.ShowDialog();
        }