示例#1
0
        public List <DemFileReport> GenerateReportForLocation(DEMDataSet dataSet, double lat, double lon)
        {
            var indexService = this._rasterIndexServiceResolver(dataSet.DataSource.DataSourceType);

            indexService.Setup(dataSet, GetLocalDEMPath(dataSet));

            if (dataSet.FileFormat.Registration == DEMFileRegistrationMode.Cell)
            {
                var size    = 1d / dataSet.PointsPerDegree;
                var bbox    = BoundingBox.AroundPoint(lat, lon, size);
                var sources = indexService.GetFileSources(dataSet).Where(source => source.BBox.Intersects(bbox))
                              .Select(source => new DemFileReport()
                {
                    IsExistingLocally   = File.Exists(source.LocalFileName),
                    IsMetadataGenerated = File.Exists(GetMetadataFileName(source.LocalFileName, ".json")),
                    LocalName           = source.LocalFileName,
                    URL    = source.SourceFileNameAbsolute,
                    Source = source
                })
                              .ToList();
                return(sources);
            }
            else
            {
                var sources = indexService.GetFileSources(dataSet)
                              .Where(source => source.BBox.Intersects(lat, lon))
                              .Select(source => new DemFileReport()
                {
                    IsExistingLocally   = File.Exists(source.LocalFileName),
                    IsMetadataGenerated = File.Exists(GetMetadataFileName(source.LocalFileName, ".json")),
                    LocalName           = source.LocalFileName,
                    URL    = source.SourceFileNameAbsolute,
                    Source = source
                })
                              .ToList();
                return(sources);
            }
        }
示例#2
0
        public GeoPoint GetPointElevation(double lat, double lon, DEMDataSet dataSet, InterpolationMode interpolationMode = InterpolationMode.Bilinear)
        {
            GeoPoint     geoPoint = new GeoPoint(lat, lon);
            FileMetadata tile     = this.GetCoveringFile(lat, lon, dataSet);

            if (tile == null)
            {
                _logger?.LogWarning($"No coverage found matching provided point {geoPoint} for dataset {dataSet.Name}");
                return(null);
            }
            else
            {
                IEnumerable <FileMetadata> adjacentRasters = null;
                // for cell registered rasters, we need adjacent tiles for edge locations
                if (dataSet.FileFormat.Registration == DEMFileRegistrationMode.Cell)
                {
                    // construct a bbox around the location
                    adjacentRasters = this.GetCoveringFiles(BoundingBox.AroundPoint(lat, lon, Math.Abs(tile.PixelScaleX)), dataSet);
                }
                // Init interpolator
                IInterpolator interpolator = GetInterpolator(interpolationMode);

                // TODO : grab adjacent tiles for cell registrered datasets to allow correct interpolation when close to edges
                using (RasterFileDictionary tileCache = new RasterFileDictionary())
                {
                    PopulateRasterFileDictionary(tileCache, tile, _IRasterService, adjacentRasters);

                    geoPoint.Elevation = GetElevationAtPoint(tileCache, tile, lat, lon, 0, interpolator);


                    //Debug.WriteLine(adjacentRasters.Count);
                }  // Ensures all geotifs are properly closed
            }

            return(geoPoint);
        }