Beispiel #1
0
        private static Dictionary <string, string> BuildMap(AzurePlateTilePyramidOptions options, BlobServiceClient service, ILogger <AzureKnownPlateFile> logger)
        {
            var result = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            try
            {
                var blob = service.GetBlobContainerClient(options.Container).GetBlobClient(options.KnownPlateFile);

                using var stream = blob.OpenRead();
                using var reader = new StreamReader(stream);

                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine().Trim();

                    if (!string.IsNullOrEmpty(line) && !line.StartsWith("#"))
                    {
                        result.Add(line, line);
                    }
                }
            }
            catch (Exception e)
            {
                logger.LogError(e, "Unexpected error while loading known plate files");
            }

            logger.LogInformation("Loaded {Count} known plate files", result.Count);

            return(result);
        }
 public MarsMolaAwareSeekableAzurePlateTilePyramid(
     AzurePlateTilePyramidOptions options,
     AzureServiceAccessor services,
     ILogger <SeekableAzurePlateTilePyramid> logger)
     : base(options, services, logger)
 {
     _container = services.WwtFiles.GetBlobContainerClient("marsmola");
 }
Beispiel #3
0
 public MarsAwareSeekableAzurePlateTilePyramid(
     AzurePlateTilePyramidOptions options,
     AzureServiceAccessor services,
     ILogger <SeekableAzurePlateTilePyramid> logger)
     : base(options, services.WwtFiles, logger)
 {
     _blobRetriever = BuildLookup(services.Mars);
 }
Beispiel #4
0
        public SeekableAzurePlateTilePyramid(AzurePlateTilePyramidOptions options, BlobServiceClient service, ILogger <SeekableAzurePlateTilePyramid> logger)
        {
            _container = service.GetBlobContainerClient(options.Container);
            _logger    = logger;

            var cache = new ConcurrentDictionary <string, BlobClient>();

            _blobRetriever = plateName => cache.GetOrAdd(plateName, _container.GetBlobClient);
        }
Beispiel #5
0
        public static AzureServiceBuilder AddPlateFiles(this AzureServiceBuilder services, Action <AzurePlateTilePyramidOptions> configure)
        {
            var options = new AzurePlateTilePyramidOptions();

            configure(options);

            services.Services.AddSingleton(options);
            services.Services.AddSingleton <IPlateTilePyramid, MarsMolaAwareSeekableAzurePlateTilePyramid>();
            services.Services.AddSingleton <IKnownPlateFiles, AzureKnownPlateFile>();
            services.Services.AddSingleton <IPlateTileDownloader, AzurePlateFileDownloader>();

            return(services);
        }
Beispiel #6
0
 public AzureKnownPlateFile(AzurePlateTilePyramidOptions options, BlobServiceClient service, ILogger <AzureKnownPlateFile> logger)
 {
     _map = BuildMap(options, service, logger);
 }