Пример #1
0
        private void DownloadMissingFiles_FromReport(IEnumerable <DemFileReport> report, DEMDataSet dataSet)
        {
            // Generate metadata files if missing
            foreach (var file in report.Where(r => r.IsMetadataGenerated == false && r.IsExistingLocally == true))
            {
                _IRasterService.GenerateFileMetadata(file.LocalName, dataSet.FileFormat, false);
            }
            List <DemFileReport> filesToDownload = new List <DemFileReport>(report.Where(kvp => kvp.IsExistingLocally == false));

            if (filesToDownload.Count == 0)
            {
                _logger?.LogTrace("No missing file(s).");
            }
            else
            {
                _logger?.LogInformation($"Downloading {filesToDownload.Count} missing file(s).");

                try
                {
                    Parallel.ForEach(filesToDownload, file =>
                    {
                        _IRasterService.DownloadRasterFile(file, dataSet);
                    }
                                     );

                    _IRasterService.GenerateDirectoryMetadata(dataSet, false, false);
                    _IRasterService.LoadManifestMetadata(dataSet, true);
                }
                catch (AggregateException ex)
                {
                    _logger?.LogError(ex, $"Error downloading missing files. Check internet connection or retry later. {ex.GetInnerMostException().Message}");
                    throw;
                }
            }
        }
Пример #2
0
        public IEnumerable <DEMFileSource> GetFileSources(DEMDataSet dataset)
        {
            foreach (var file in Directory.GetFiles(dataset.DataSource.IndexFilePath, "*" + dataset.FileFormat.FileExtension, SearchOption.AllDirectories))
            {
                var metadataPath = Path.Combine(Path.GetDirectoryName(file), RasterService.MANIFEST_DIR, Path.ChangeExtension(Path.GetFileName(file), ".json"));
                if (!File.Exists(metadataPath))
                {
                    _rasterService.GenerateFileMetadata(file, dataset.FileFormat, false);
                }


                FileMetadata metadata = JsonConvert.DeserializeObject <FileMetadata>(File.ReadAllText(metadataPath));
                yield return(new DEMFileSource()
                {
                    BBox = metadata.BoundingBox
                    ,
                    LocalFileName = file
                });
            }
        }