public void TestElevationLine(string dataSetName, double latStart, double lonStart, double latEnd, double lonEnd, double expectedPointCount, double expectedClimb, double expectedDescent, double expectedMin, double expectedMax) { var elevationLine = GeometryService.ParseGeoPointAsGeometryLine(new GeoPoint(latStart, lonStart), new GeoPoint(latEnd, lonEnd)); Assert.NotNull(elevationLine); Assert.Equal(2, elevationLine.Coordinates.Length); DEMDataSet dataSet = DEMDataSet.RegisteredDatasets.FirstOrDefault(d => d.Name == dataSetName); Assert.NotNull(dataSet); _elevationService.DownloadMissingFiles(dataSet, elevationLine.GetBoundingBox()); var geoPoints = _elevationService.GetLineGeometryElevation(elevationLine, dataSet); Assert.NotNull(geoPoints); Assert.Equal(expectedPointCount, geoPoints.Count); var metrics = geoPoints.ComputeMetrics(); Assert.NotNull(metrics); Assert.Equal(expectedClimb, metrics.Climb, 3); Assert.Equal(expectedDescent, metrics.Descent, 3); Assert.Equal(expectedMin, metrics.MinElevation, 3); Assert.Equal(expectedMax, metrics.MaxElevation, 3); }
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))); } }
private void LineSample(DEMDataSet dataSet, double latStart, double lonStart, double latEnd, double lonEnd) { var elevationLine = GeometryService.ParseGeoPointAsGeometryLine(new GeoPoint(latStart, lonStart), new GeoPoint(latEnd, lonEnd)); _elevationService.DownloadMissingFiles(dataSet, elevationLine.GetBoundingBox()); var geoPoints = _elevationService.GetLineGeometryElevation(elevationLine, dataSet); }
public void SegmentsTest() { var lineGeom = GeometryService.ParseGeoPointAsGeometryLine(_linePoints); Assert.NotNull(lineGeom); Assert.True(lineGeom.Coordinates.Length == _linePoints.Length, "Coordinate count mismatch"); var segments = GeometryService.Segments(lineGeom); Assert.True(segments.Count() == lineGeom.Coordinates.Length - 1, "Segment enumeration failed"); }
public void Run() { try { // ventoux //double lat1 = 44.17346; //double lon1 = 5.27829; // ste victoire //double lat1 = 43.532456; //double lon1 = 5.612444; // bottom ste victoire (fuveau) //double lat1 = 43.49029208393125; //double lon1 = 5.587234497070313; //double lat2 = 43.53013134607789; //double lon2 = 5.581398010253906; // geneva //double lat1 = 46.08129825372404; //double lon1 = 3.382026672363281; // mont blanc //double lat2 = 45.833; //double lon2 = 6.864; // bob //double lat1 = 37.212627; //double lon1 = 22.321612; //double lat2 = 37.208179; //double lon2 = 22.324373; double lat2 = 44.116655590545705; double lat1 = 44.19524951146881; double lon2 = 5.802505910396577; double lon1 = 5.806566774845124; Stopwatch sw = new Stopwatch(); _logger.LogInformation("Line elevation"); sw.Restart(); // Line starting at mont ventoux peak to Mont Blanc DEMDataSet dataSet = DEMDataSet.ASTER_GDEMV3; // High level way var metrics = _elevationService.GetIntervisibilityReport(new GeoPoint(lat1, lon1), new GeoPoint(lat2, lon2), dataSet , downloadMissingFiles: true, sourceVerticalOffset: 0); PlotVisibilityReport(metrics, 2048, 600, "VisReport.png"); // Low level (tests from 0 to 2000 m) var elevationLine = GeometryService.ParseGeoPointAsGeometryLine(new GeoPoint(lat1, lon1), new GeoPoint(lat2, lon2)); var geoPoints = _elevationService.GetLineGeometryElevation(elevationLine, dataSet); for (int i = 300; i < 10000; i += 500) { var report = _elevationService.GetIntervisibilityReport(geoPoints, i); PlotVisibilityReport(report, 2048, 600, $"VisReport_{i}.png"); } _logger.LogInformation($"{dataSet.Name} metrics: {metrics.ToString()}"); //var geoJson = ConvertLineElevationResultToGeoJson(simplified); _logger.LogInformation($"Done in {sw.Elapsed.TotalMilliseconds:N1}ms"); } catch (Exception ex) { _logger.LogError(ex, ex.Message); } }
public void Run() { try { double lat1 = 46.00000000000004; double lon1 = 10.000000000000007; double lat2 = 45.212278; double lont2 = 5.468857; _logger.LogInformation($"Getting location elevation for each dataset (location lat: {lat1:N2}, lon: {lon1:N2})"); Stopwatch sw = new Stopwatch(); Parallel.ForEach(DEMDataSet.RegisteredNonLocalDatasets, (dataSet, loopState) => //foreach (var dataSet in DEMDataSet.RegisteredNonSingleFileDatasets) { sw.Restart(); _elevationService.DownloadMissingFiles(dataSet, lat1, lon1); GeoPoint geoPoint = _elevationService.GetPointElevation(lat1, lon1, dataSet); _logger.LogInformation($"{dataSet.Name} elevation: {geoPoint.Elevation:N2} (time taken: {sw.Elapsed.TotalMilliseconds:N1}ms)"); } ); _logger.LogInformation("Multiple point elevation"); sw.Restart(); GeoPoint pt1 = new GeoPoint(lat1, lon1); GeoPoint pt2 = new GeoPoint(lat2, lont2); GeoPoint[] points = { pt1, pt2 }; Parallel.ForEach(DEMDataSet.RegisteredNonLocalDatasets, (dataSet, loopState) => //foreach (var dataSet in DEMDataSet.RegisteredNonSingleFileDatasets) { sw.Restart(); var geoPoints = _elevationService.GetPointsElevation(points, dataSet); _logger.LogInformation($"{dataSet.Name} elevation: {string.Join(" / ", geoPoints.Select(e => e.Elevation.GetValueOrDefault().ToString("N2")))} (time taken: {sw.Elapsed.TotalMilliseconds:N1}ms)"); } ); _logger.LogInformation("Line elevation"); sw.Restart(); // Line passing by mont ventoux peak [5.144899, 44.078873], [5.351516, 44.225876] var elevationLine = GeometryService.ParseGeoPointAsGeometryLine(new GeoPoint(44.078873, 5.144899), new GeoPoint(44.225876, 5.351516)); Parallel.ForEach(DEMDataSet.RegisteredNonLocalDatasets, (dataSet, loopState) => //foreach (var dataSet in DEMDataSet.RegisteredNonSingleFileDatasets) { _elevationService.DownloadMissingFiles(dataSet, elevationLine.GetBoundingBox()); var geoPoints = _elevationService.GetLineGeometryElevation(elevationLine, dataSet); var metrics = geoPoints.ComputeMetrics(); _logger.LogInformation($"{dataSet.Name} metrics: {metrics.ToString()}"); var simplified = geoPoints.Simplify(50 /* meters */); _logger.LogInformation($"{dataSet.Name} after reduction : {simplified.Count} points"); var geoJson = ConvertLineElevationResultToGeoJson(simplified); } ); _logger.LogInformation($"Done in {sw.Elapsed.TotalMilliseconds:N1}ms"); } catch (Exception ex) { _logger.LogError(ex, ex.Message); } }