示例#1
0
        public void Run()
        {
            try
            {
                // Sample testing bad calculation on tile edges with tile registration modes (cell/grid)

                double amountx = .00000000000004;
                double amounty = .000000000000007;

                double lat = 46;
                double lon = 10;

                LineSample(DEMDataSet.ASTER_GDEMV3, latStart: 45.9993826389, lonStart: 9.9997211693, latEnd: 46.00002905, lonEnd: 10.00063093);

                TestEdges(DEMDataSet.ASTER_GDEMV3, lat, lon, "ASTGTMV003_N45E009_dem.tif", "ASTGTMV003_N45E010_dem.tif", "ASTGTMV003_N46E009_dem.tif", "ASTGTMV003_N46E010_dem.tif");
                TestEdges(DEMDataSet.SRTM_GL3, lat, lon, "N45E009.hgt", "N45E010.hgt", "N46E009.hgt", "N46E010.hgt");
                TestEdges(DEMDataSet.SRTM_GL1, lat, lon, "N45E009.hgt", "N45E010.hgt", "N46E009.hgt", "N46E010.hgt");
                TestEdges(DEMDataSet.AW3D30, lat, lon, "N045E009_AVE_DSM.tif", "N045E010_AVE_DSM.tif", "N046E009_AVE_DSM.tif", "N046E010_AVE_DSM.tif");


                DEMDataSet dataSet = DEMDataSet.SRTM_GL1;
                //_rasterService.GenerateDirectoryMetadata(dataSet, true, false, 1);
                _elevationService.DownloadMissingFiles(dataSet, lat, lon);
                var tiles = _rasterService.GenerateReportForLocation(dataSet, lat, lon);
                Debug.Assert(tiles.Count == 4);
                //_rasterService.GenerateFileMetadata(tile.LocalName, dataSet.FileFormat, true);
                GeoPoint pt = null;


                pt = _elevationService.GetPointElevation(lat + amounty, lon + amountx, dataSet);
                pt = _elevationService.GetPointElevation(lat - amounty, lon + amountx, dataSet);
                pt = _elevationService.GetPointElevation(lat + amounty, lon - amountx, dataSet);
                pt = _elevationService.GetPointElevation(lat - amounty, lon - amountx, dataSet);
                pt = _elevationService.GetPointElevation(lat + (1 / 3600d) / 2d, lon + (1 / 3600d) / 2, dataSet);

                pt = _elevationService.GetPointElevation(lat + 0.5, lon + 0.5, dataSet);
                pt = _elevationService.GetPointElevation(lat, lon, dataSet);


                foreach (var dataset in DEMDataSet.RegisteredNonLocalDatasets)
                {
                    _elevationService.DownloadMissingFiles(dataset, lat, lon);
                    //foreach (var file in _rasterService.GenerateReportForLocation(dataset, lat, lon))
                    //{
                    //    _rasterService.GenerateFileMetadata(file.LocalName, dataset.FileFormat, true);
                    //}
                    GeoPoint geoPoint = _elevationService.GetPointElevation(lat, lon, dataset);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
            }
        }
示例#2
0
        public void DownloadTile_Location()
        {
            double lat = 43.537854;
            double lon = 5.429993;

            DEMDataSet dataset = DEMDataSet.SRTM_GL3;

            _elevationService.DownloadMissingFiles(dataset, lat, lon);

            var report = _rasterService.GenerateReportForLocation(dataset, lat, lon);

            Assert.NotNull(report);
            Assert.True(report.IsExistingLocally);
        }
示例#3
0
        public void DownloadMissingFiles(DEMDataSet dataSet, double lat, double lon)
        {
            var report = _IRasterService.GenerateReportForLocation(dataSet, lat, lon);

            if (report == null)
            {
                _logger?.LogWarning($"No coverage for lat/lon {lat}/{lon} in {dataSet.Name} dataset.");
                return;
            }

            DownloadMissingFiles_FromReport(Enumerable.Repeat(report, 1), dataSet);
        }
示例#4
0
        public void SourceBboxCheck(string dataSetName, double lat, double lon, string expectedFileName)
        {
            DEMDataSet dataSet = DEMDataSet.RegisteredDatasets.FirstOrDefault(d => d.Name == dataSetName);

            Assert.NotNull(dataSet);

            var indexService = _rasterResolver(dataSet.DataSource.DataSourceType);

            Assert.NotNull(dataSet);

            indexService.Setup(dataSet, _rasterService.LocalDirectory);
            var intersectingTiles = indexService.GetFileSources(dataSet).Where(tile => tile.BBox.Intersects(lat, lon)).ToList();

            var report = _rasterService.GenerateReportForLocation(dataSet, lat, lon);

            Assert.NotNull(report);
            Assert.True(report.Count == 1);


            Assert.Equal(expectedFileName, Path.GetFileName(report.First().LocalName));
        }
示例#5
0
        public void Run()
        {
            try
            {
                _logger.LogInformation("GenerateReportAsString() will generate a report of all local datasets.");
                _logger.LogInformation($"Local data directory : {_rasterService.LocalDirectory}");
                Stopwatch sw = new Stopwatch();

                sw.Restart();

                _logger.LogInformation($"Generating report...");
                _logger.LogInformation(_rasterService.GenerateReportAsString());

                _logger.LogInformation($"time taken: {sw.Elapsed:g}");


                GeoPoint geoPoint = new GeoPoint(45.179337, 5.721421);
                _logger.LogInformation($"Getting raster file for dataset at location {geoPoint}");

                foreach (var dataset in DEMDataSet.RegisteredNonLocalDatasets)
                {
                    _logger.LogInformation($"{dataset.Name}:");

                    var report = _rasterService.GenerateReportForLocation(dataset, geoPoint.Latitude, geoPoint.Longitude);
                    if (!report.Any())
                    {
                        _logger.LogInformation($"> Location is not covered by dataset");
                    }
                    else
                    {
                        foreach (var reportFile in report)
                        {
                            _logger.LogInformation($"> Remote file URL: {reportFile.URL}");

                            if (reportFile.IsExistingLocally)
                            {
                                _logger.LogInformation($"> Local file: {reportFile.LocalName}");
                            }
                            else
                            {
                                _logger.LogInformation($"> Local file: <not dowloaded>");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
            }
        }