From 14f05e5fb2625b6c5912b64c78c5c02677b41812 Mon Sep 17 00:00:00 2001 From: floeschau Date: Sun, 21 Apr 2024 23:07:14 +0200 Subject: [PATCH 1/4] Changes for BlackSky text format --- .../BlackSkyGlobalMetadataExtractor.cs | 37 ++++- .../BlackSkyGlobal/Schemas/Metadata.cs | 143 ++++++++++++++++-- 2 files changed, 161 insertions(+), 19 deletions(-) diff --git a/src/Stars.Data/Model/Metadata/BlackSkyGlobal/BlackSkyGlobalMetadataExtractor.cs b/src/Stars.Data/Model/Metadata/BlackSkyGlobal/BlackSkyGlobalMetadataExtractor.cs index eee292c3..979ec013 100644 --- a/src/Stars.Data/Model/Metadata/BlackSkyGlobal/BlackSkyGlobalMetadataExtractor.cs +++ b/src/Stars.Data/Model/Metadata/BlackSkyGlobal/BlackSkyGlobalMetadataExtractor.cs @@ -21,6 +21,7 @@ using Terradue.Stars.Services.Model.Stac; using Stac.Extensions.Raster; using Newtonsoft.Json; +using Terradue.Stars.Geometry.GeoJson; namespace Terradue.Stars.Data.Model.Metadata.BlackSkyGlobal { @@ -81,6 +82,10 @@ protected virtual IAsset GetMetadataAsset(IItem item) { IAsset metadataAsset = FindFirstAssetFromFileNameRegex(item, @"BSG.*\.json$"); if (metadataAsset == null) + { + metadataAsset = FindFirstAssetFromFileNameRegex(item, @"BS.*\.txt$"); + } + if (metadataAsset == null) { throw new FileNotFoundException(String.Format("Unable to find the metadata file asset")); } @@ -92,14 +97,24 @@ protected virtual IAsset GetMetadataAsset(IItem item) { logger.LogDebug("Opening metadata file {0}", metadataAsset.Uri); + System.Console.WriteLine("METADATA FILE: {0}", metadataAsset.Uri.AbsolutePath); + using (var stream = await resourceServiceProvider.GetAssetStreamAsync(metadataAsset, System.Threading.CancellationToken.None)) { using (StreamReader reader = new StreamReader(stream)) { - logger.LogDebug("Deserializing metadata file {0}", metadataAsset.Uri); - string metadataStr = reader.ReadToEnd(); - Schemas.Metadata metadata = JsonConvert.DeserializeObject(metadataStr); - return metadata; + if (metadataAsset.Uri.AbsolutePath.EndsWith(".json")) + { + logger.LogDebug("Deserializing metadata file {0}", metadataAsset.Uri); + string metadataStr = reader.ReadToEnd(); + Schemas.Metadata metadata = JsonConvert.DeserializeObject(metadataStr); + return metadata; + } + else // .txt file + { + Schemas.Metadata metadata = Schemas.Metadata.FromTextFile(reader); + return metadata; + } } } } @@ -350,9 +365,17 @@ private void AddEoStacExtension(StacItem stacItem, Schemas.Metadata metadata) private GeoJSON.Net.Geometry.IGeometryObject GetGeometry(Schemas.Metadata metadata) { - string s = JsonConvert.SerializeObject(metadata.geometry); - GeoJSON.Net.Geometry.Polygon polygon = JsonConvert.DeserializeObject(s); - return polygon; + GeoJSON.Net.Geometry.Polygon polygon; + if (metadata.geometry is GeoJSON.Net.Geometry.Polygon) + { + polygon = metadata.geometry as GeoJSON.Net.Geometry.Polygon; + } + else + { + string s = JsonConvert.SerializeObject(metadata.geometry); + polygon = JsonConvert.DeserializeObject(s); + } + return polygon.NormalizePolygon(); } diff --git a/src/Stars.Data/Model/Metadata/BlackSkyGlobal/Schemas/Metadata.cs b/src/Stars.Data/Model/Metadata/BlackSkyGlobal/Schemas/Metadata.cs index 5fd335c4..5751a17e 100644 --- a/src/Stars.Data/Model/Metadata/BlackSkyGlobal/Schemas/Metadata.cs +++ b/src/Stars.Data/Model/Metadata/BlackSkyGlobal/Schemas/Metadata.cs @@ -1,8 +1,18 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.RegularExpressions; + namespace Terradue.Stars.Data.Model.Metadata.BlackSkyGlobal.Schemas { - - + + public partial class Metadata { + public static Regex keyValueRegex = new Regex(@"(?'key'[^= ]+) *= *(?'value'.*)"); + public static string[] cornerCoordinateNames = new string[] { + "LL_LONG", "LL_LAT", "LR_LONG", "LR_LAT", "UR_LONG", "UR_LAT", "UL_LONG", "UL_LAT" + }; + public string id { get; set; } public string acquisitionDate { get; set; } public string sensorName { get; set; } @@ -22,21 +32,111 @@ public partial class Metadata { public string targetType { get; set; } public double estimatedCE90 { get; set; } public int bitsPerPixel { get; set; } - + public string imageSpecVersion { get; set; } public double fractionSaturated { get; set; } public object numberRegistrationPoints { get; set; } public GeminiType gemini { get; set; } - -/* - "geometry" : { - "type" : "Polygon", - "coordinates" : [ [ [ -75.12948188832118, 39.951193872769544 ], [ -75.16335070466222, 39.92967968802465 ], [ -75.20606168353703, 39.96975426955367 ], [ -75.17209285763781, 39.99133716421872 ], [ -75.12948188832118, 39.951193872769544 ] ] ] - }, - "registrationPoints" : [ [ [ 5508.0, 4188.0 ], [ 39.98351643268224, -75.16663105733065, -1.0 ] ], [ [ 1776.0, 4032.0 ], [ 39.96019340602546, -75.14387198643686, -17.06084882726229 ] ], [ [ 4914.0, 4020.0 ], [ 39.97907819634284, -75.16410229391467, -0.5235731407156076 ] ], [ [ 4044.0, 4014.0 ], [ 39.9738061605708, -75.15855054780856, -4.549083655777238 ] ], [ [ 2694.0, 3666.0 ], [ 39.963957448533904, -75.15254451308992, -18.75318527794224 ] ], [ [ 5490.0, 3624.0 ], [ 39.98064516391171, -75.1708520480192, 1.0 ] ], [ [ 3750.0, 3576.0 ], [ 39.96989387474083, -75.16001696626596, -6.3587158131358015 ] ], [ [ 912.0, 3498.0 ], [ 39.95236567371066, -75.14238050356576, -19.000000000000004 ] ], [ [ 4344.0, 3408.0 ], [ 39.972652693072334, -75.16515257737989, 1.3023522081983558 ] ], [ [ 5394.0, 3090.0 ], [ 39.977459509898914, -75.1743340733268, 1.3394185907564067 ] ], [ [ 1848.0, 3030.0 ], [ 39.95575022816337, -75.15196431397912, -19.700821388128723 ] ], [ [ 558.0, 3006.0 ], [ 39.947831853482874, -75.14388120642718, -19.0 ] ], [ [ 4008.0, 2928.0 ], [ 39.96828978257286, -75.16665263003831, -2.2073145997432646 ] ], [ [ 1560.0, 2562.0 ], [ 39.9517024780644, -75.15372309484955, -4.742157936342278 ] ], [ [ 4224.0, 2508.0 ], [ 39.96755324604367, -75.17127612598847, -3.0 ] ], [ [ 2106.0, 2484.0 ], [ 39.9546341333115, -75.15786236273613, -6.157818911836694 ] ], [ [ 5262.0, 2340.0 ], [ 39.97301916955755, -75.17925291733495, -3.400819414936417 ] ], [ [ 6048.0, 1962.0 ], [ 39.975952690448274, -75.18728262488706, -12.212236020356219 ] ], [ [ 5010.0, 1830.0 ], [ 39.96902418155413, -75.1815844482777, -10.342892452019393 ] ], [ [ 1074.0, 1434.0 ], [ 39.94329777524861, -75.15927607671765, -20.000000000000004 ] ], [ [ 378.0, 1404.0 ], [ 39.93893372041534, -75.15504056105945, -21.97643335183485 ] ], [ [ 1704.0, 1362.0 ], [ 39.94672408473831, -75.16390790385613, -6.861748824190286 ] ], [ [ 4464.0, 1188.0 ], [ 39.96260698706702, -75.18297251982936, -29.000000000000004 ] ], [ [ 3546.0, 996.0 ], [ 39.956117697961666, -75.17859998713668, -24.976287338009005 ] ], [ [ 5616.0, 942.0 ], [ 39.968358100137635, -75.19235562476945, -13.128662155413142 ] ], [ [ 2448.0, 858.0 ], [ 39.94879282327211, -75.17255215070531, -4.223021851419695 ] ], [ [ 678.0, 792.0 ], [ 39.93776238370972, -75.16167437091262, -21.973801766485288 ] ], [ [ 1224.0, 780.0 ], [ 39.941009893634124, -75.16526376060361, -23.018387427726267 ] ], [ [ 4920.0, 582.0 ], [ 39.96237852804343, -75.19055914592471, 1.4445721386272687 ] ], [ [ 5598.0, 366.0 ], [ 39.965440763421604, -75.19662131300782, -1.7692539152930302 ] ], [ [ 1056.0, 360.0 ], [ 39.93792543201694, -75.16740997433982, -19.531555260982884 ] ], [ [ 222.0, 282.0 ], [ 39.93249021956635, -75.16265677251094, -23.0153379524278 ] ] ], -*/ + // From text file + public string processLevel { get; set; } + + public static Metadata FromTextFile(StreamReader reader) + { + Metadata metadata = new Metadata(); + Dictionary textMetadata = new Dictionary(); + + string line; + while ((line = reader.ReadLine()) != null) + { + Match match = keyValueRegex.Match(line); + if (match.Success) + { + string key = match.Groups["key"].Value; + string value = match.Groups["value"].Value; + textMetadata[key] = value; + } + } + + metadata.id = GetStringValue(textMetadata, "VENDOR_SCENE_ID"); + string acquisitionDate = GetStringValue(textMetadata, "ACQUISITION_DATE"); + if (!String.IsNullOrEmpty(acquisitionDate)) + { + if (acquisitionDate.Length == 8) acquisitionDate = String.Format("{0}-{1}-{2}", acquisitionDate.Substring(0, 4), acquisitionDate.Substring(4, 2), acquisitionDate.Substring(6, 2)); + string acquisitionTime = GetStringValue(textMetadata, "ACQUISITION_TIME"); + if (String.IsNullOrEmpty(acquisitionTime)) + { + acquisitionTime = "00:00:00"; + } + else + { + if (acquisitionTime.Length == 6) acquisitionTime = String.Format("{0}:{1}:{2}", acquisitionTime.Substring(0, 2), acquisitionTime.Substring(2, 2), acquisitionTime.Substring(4, 2)); + } + acquisitionTime = acquisitionTime.Replace("Z", ""); + metadata.acquisitionDate = String.Format("{0}T{1}Z", acquisitionDate, acquisitionTime); + } + metadata.sensorName = GetStringValue(textMetadata, "SENSOR"); + metadata.gsd = 1; // hardcoded + + List coordinates = new List(); + foreach (string name in cornerCoordinateNames) + { + if (Double.TryParse(GetStringValue(textMetadata, name), out double value)) coordinates.Add(value); + } + if (coordinates.Count == 8) + { + GeoJSON.Net.Geometry.Position[] lineStringPositions = new GeoJSON.Net.Geometry.Position[] + { + new GeoJSON.Net.Geometry.Position(coordinates[1], coordinates[0]), + new GeoJSON.Net.Geometry.Position(coordinates[3], coordinates[2]), + new GeoJSON.Net.Geometry.Position(coordinates[5], coordinates[4]), + new GeoJSON.Net.Geometry.Position(coordinates[7], coordinates[6]), + new GeoJSON.Net.Geometry.Position(coordinates[1], coordinates[0]) + }; + GeoJSON.Net.Geometry.LineString lineString = new GeoJSON.Net.Geometry.LineString(lineStringPositions); + metadata.geometry = new GeoJSON.Net.Geometry.Polygon(new GeoJSON.Net.Geometry.LineString[] { lineString }); + } + + metadata.cloudCoverPercent = GetDoubleValue(textMetadata, "CLOUD_COVER"); + metadata.offNadirAngle = GetDoubleValue(textMetadata, "OFF_NADIR"); + metadata.sunElevation = GetDoubleValue(textMetadata, "SUN_ELEVATION"); + metadata.sunAzimuth = GetDoubleValue(textMetadata, "SUN_AZIMUTH"); + metadata.satelliteElevation = GetDoubleValue(textMetadata, "SAT_ELEVATION"); + metadata.satelliteAzimuth= GetDoubleValue(textMetadata, "SAT_AZIMUTH"); + //metadata.georeferenced= ""; + //metadata.orthorectified= ""; + //metadata.width= ""; + //metadata.height= ""; + //metadata.processingVersion= ""; + //metadata.targetType= ""; + //metadata.estimatedCE90= ""; + //metadata.bitsPerPixel= ""; + + //metadata.imageSpecVersion= ""; + //metadata.fractionSaturated= ""; + //metadata.numberRegistrationPoints= ""; + + metadata.processLevel = GetStringValue(textMetadata, "PROCESS_LEVEL"); + + + return metadata; + } + + public static string GetStringValue(Dictionary dict, string key) + { + if (dict.ContainsKey(key)) return dict[key]; + return null; + } + + public static double GetDoubleValue(Dictionary dict, string key) + { + if (dict.ContainsKey(key)) + { + if (Double.TryParse(dict[key], out double value)) return value; + } + return 0; + } } @@ -45,5 +145,24 @@ public partial class GeminiType { public string catalogImageId { get; set; } public string imageId { get; set; } } - + + } + + + +/* +metadata.id +metadata.gsd; +metadata.sensorName.ToLower(); +metadata.sensorName.ToLower() }; +metadata.gsd; +metadata.sensorName.ToUpper(), +metadata.AncillaryDataReference.Tag, "Ellipsoid Designator"); +metadata.offNadirAngle; +metadata.sunAzimuth; +metadata.sunElevation; +metadata.cloudCoverPercent; +metadata.acquisitionDate, null, DateTimeStyles.AssumeUniversal, out DateTime result)) +metadata.geometry); + */ \ No newline at end of file From f1781964e6182062a278806d8261a02e5f657f49 Mon Sep 17 00:00:00 2001 From: floeschau Date: Mon, 29 Apr 2024 13:05:26 +0200 Subject: [PATCH 2/4] Changes for BlackSky (text format) --- .../Harvesters/MetadataExtractorsTests.cs | 2 +- ...2-20240320-024025-217335171_ortho-pan.json | 81 ++++ ...08-20210902-213556-11999279_non-ortho.json | 377 ++++++++++-------- ...SG-108-20210902-213556-11999279_ortho.json | 299 +++++++------- ...2567602024032000000000MS03_BG000000001.jpg | 0 ...2567602024032000000000MS03_DG000000001.txt | 75 ++++ ...2567602024032000000000MS03_GG000000001.tif | 0 src/Stars.Data.Tests/testsettings.json | 2 +- .../BlackSkyGlobalMetadataExtractor.cs | 151 +++++-- .../BlackSkyGlobal/Schemas/Metadata.cs | 60 ++- src/Stars.Data/Terradue.Stars.Data.csproj | 2 +- 11 files changed, 663 insertions(+), 386 deletions(-) create mode 100644 src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-102-20240320-024025-217335171_ortho-pan.json create mode 100644 src/Stars.Data.Tests/Resources/BLACKSKY/Global/data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_BG000000001.jpg create mode 100644 src/Stars.Data.Tests/Resources/BLACKSKY/Global/data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_DG000000001.txt create mode 100644 src/Stars.Data.Tests/Resources/BLACKSKY/Global/data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_GG000000001.tif diff --git a/src/Stars.Data.Tests/Harvesters/MetadataExtractorsTests.cs b/src/Stars.Data.Tests/Harvesters/MetadataExtractorsTests.cs index e61f74fa..b08abcbb 100644 --- a/src/Stars.Data.Tests/Harvesters/MetadataExtractorsTests.cs +++ b/src/Stars.Data.Tests/Harvesters/MetadataExtractorsTests.cs @@ -125,4 +125,4 @@ private static void RemoveAssetUriTmp(StacItemNode stacItemNode) } } } -} \ No newline at end of file +} diff --git a/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-102-20240320-024025-217335171_ortho-pan.json b/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-102-20240320-024025-217335171_ortho-pan.json new file mode 100644 index 00000000..e9cb72eb --- /dev/null +++ b/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-102-20240320-024025-217335171_ortho-pan.json @@ -0,0 +1,81 @@ +{ + "stac_version": "1.0.0", + "stac_extensions": [ + "https://stac-extensions.github.io/processing/v1.0.0/schema.json" + ], + "type": "Feature", + "id": "BSG-102-20240320-024025-217335171_ortho-pan", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + 107.20026032340076, + 47.7408500353907 + ], + [ + 107.31073894793276, + 47.738677702031254 + ], + [ + 107.31338802634312, + 47.79841769410016 + ], + [ + 107.20278300270137, + 47.800594553305935 + ], + [ + 107.20026032340076, + 47.7408500353907 + ] + ] + ] + }, + "properties": { + "datetime": "2024-03-20T00:00:00Z", + "agency": "BlackSky", + "platform": "global-1", + "constellation": "blacksky-global", + "mission": "blacksky-global", + "instruments": [ + "spaceview-24" + ], + "sensor_type": "optical", + "spectral_mode": "MS", + "gsd": 1.0, + "title": "BLACKSY GLOBAL-1 GEO MS", + "processing:level": "GEO", + "providers": [ + { + "name": "BlackSky", + "description": "BlackSky Constellation is a commercially owned and operated constellation of 60 high resolution imaging microsatellites developed by BlackSky Global. The constellation aims to provide higher temporal resolution and lower cost Earth imaging, and currently contains 17 operational microsatellites, each with an expected lifetime of 4 years.", + "roles": [ + "producer", + "processor", + "licensor" + ], + "url": "https://www.blacksky.com" + } + ] + }, + "bbox": [ + 107.20026032340076, + 47.738677702031254, + 107.31338802634312, + 47.800594553305935 + ], + "assets": { + "metadata": { + "type": "application/json", + "roles": [ + "metadata" + ], + "title": "Metadata file", + "href": "data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_DG000000001.txt", + "filename": "BS01N47_769636E107_2567602024032000000000MS03_DG000000001.txt", + "file:size": 1963 + } + }, + "links": [] +} \ No newline at end of file diff --git a/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-108-20210902-213556-11999279_non-ortho.json b/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-108-20210902-213556-11999279_non-ortho.json index f02a1dff..89daa50e 100644 --- a/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-108-20210902-213556-11999279_non-ortho.json +++ b/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-108-20210902-213556-11999279_non-ortho.json @@ -1,70 +1,180 @@ { - "stac_version": "1.0.0", - "stac_extensions": [ - "https://stac-extensions.github.io/eo/v1.0.0/schema.json", - "https://stac-extensions.github.io/processing/v1.0.0/schema.json", - "https://stac-extensions.github.io/view/v1.0.0/schema.json" - ], - "type": "Feature", - "id": "BSG-108-20210902-213556-11999279_non-ortho", - "geometry": { - "type": "Polygon", - "coordinates": [ + "stac_version": "1.0.0", + "stac_extensions": [ + "https://stac-extensions.github.io/eo/v1.0.0/schema.json", + "https://stac-extensions.github.io/processing/v1.0.0/schema.json", + "https://stac-extensions.github.io/raster/v1.0.0/schema.json", + "https://stac-extensions.github.io/view/v1.0.0/schema.json" + ], + "type": "Feature", + "id": "BSG-108-20210902-213556-11999279_non-ortho", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -75.12948188832118, + 39.951193872769544 + ], + [ + -75.17209285763781, + 39.99133716421872 + ], + [ + -75.20606168353703, + 39.96975426955367 + ], + [ + -75.16335070466222, + 39.92967968802465 + ], [ - [ - -75.12948188832118, - 39.951193872769544 - ], - [ - -75.16335070466222, - 39.92967968802465 - ], - [ - -75.20606168353703, - 39.96975426955367 - ], - [ - -75.17209285763781, - 39.99133716421872 - ], - [ - -75.12948188832118, - 39.951193872769544 - ] + -75.12948188832118, + 39.951193872769544 ] ] + ] + }, + "properties": { + "datetime": "2021-09-02T21:35:56.707Z", + "agency": "BlackSky", + "platform": "global-8", + "constellation": "blacksky-global", + "mission": "blacksky-global", + "instruments": [ + "spaceview-24" + ], + "sensor_type": "optical", + "spectral_mode": "PAN/MS", + "gsd": 0.8632106, + "title": "BLACKSY GLOBAL-8 GEO PAN MS", + "view:off_nadir": 13.258979, + "view:sun_azimuth": 262.15057, + "view:sun_elevation": 20.95552, + "processing:level": "GEO", + "eo:cloud_cover": 0.0, + "eo:bands": [ + { + "name": "B1-RED", + "common_name": "red", + "center_wavelength": 0.645, + "full_width_half_max": 0.11 + }, + { + "name": "B2-GREEN", + "common_name": "green", + "center_wavelength": 0.545, + "full_width_half_max": 0.09 + }, + { + "name": "B3-BLUE", + "common_name": "blue", + "center_wavelength": 0.485, + "full_width_half_max": 0.07 + }, + { + "name": "pan", + "common_name": "pan", + "center_wavelength": 0.575, + "full_width_half_max": 0.25 + } + ], + "providers": [ + { + "name": "BlackSky", + "description": "BlackSky Constellation is a commercially owned and operated constellation of 60 high resolution imaging microsatellites developed by BlackSky Global. The constellation aims to provide higher temporal resolution and lower cost Earth imaging, and currently contains 17 operational microsatellites, each with an expected lifetime of 4 years.", + "roles": [ + "producer", + "processor", + "licensor" + ], + "url": "https://www.blacksky.com" + } + ] + }, + "bbox": [ + -75.20606168353703, + 39.92967968802465, + -75.12948188832118, + 39.99133716421872 + ], + "assets": { + "metadata": { + "type": "application/json", + "roles": [ + "metadata" + ], + "title": "Metadata file", + "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_metadata.json", + "filename": "BSG-108-20210902-213556-11999279_metadata.json", + "file:size": 3807 + }, + "overview": { + "type": "image/png", + "roles": [ + "overview" + ], + "title": "Browse image", + "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_browse.png", + "filename": "BSG-108-20210902-213556-11999279_browse.png", + "file:size": 1 }, - "properties": { - "title": "GLOBAL-8 2021-09-02 21:35:56", - "agency": "BlackSky", - "platform": "global-8", - "mission": "Global", - "instruments": [ - "global-8" + "GEO_RGB": { + "type": "image/tiff; application=geotiff", + "roles": [ + "data" ], - "sensor_type": "optical", + "title": "RGB image", + "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_georeferenced.tif", + "filename": "BSG-108-20210902-213556-11999279_georeferenced.tif", + "file:size": 1, "gsd": 0.8632106, - "datetime": "2021-09-02T21:35:56.707Z", - "eo:cloud_cover": 0.0, "eo:bands": [ { - "name": "red", + "name": "B1-RED", "common_name": "red", "center_wavelength": 0.645, "full_width_half_max": 0.11 }, { - "name": "green", + "name": "B2-GREEN", "common_name": "green", "center_wavelength": 0.545, "full_width_half_max": 0.09 }, { - "name": "blue", + "name": "B3-BLUE", "common_name": "blue", "center_wavelength": 0.485, "full_width_half_max": 0.07 + } + ], + "raster:bands": [ + { + "data_type": "uint16", + "bits_per_sample": 12 + }, + { + "data_type": "uint16", + "bits_per_sample": 12 }, + { + "data_type": "uint16", + "bits_per_sample": 12 + } + ] + }, + "GEO_PAN": { + "type": "image/tiff; application=geotiff", + "roles": [ + "data" + ], + "title": "PAN image", + "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_georeferenced-pan.tif", + "filename": "BSG-108-20210902-213556-11999279_georeferenced-pan.tif", + "file:size": 1, + "gsd": 0.8632106, + "eo:bands": [ { "name": "pan", "common_name": "pan", @@ -72,141 +182,54 @@ "full_width_half_max": 0.25 } ], - "view:sun_azimuth": 262.15057, - "view:sun_elevation": 20.95552, - "view:off_nadir": 13.258979, - "processing:level": "ORTHO", - "providers": [ + "raster:bands": [ { - "name": "BlackSky", - "description": "BlackSky Constellation is a commercially owned and operated constellation of 60 high resolution imaging microsatellites developed by BlackSky Global. The constellation aims to provide higher temporal resolution and lower cost Earth imaging, and currently contains 17 operational microsatellites, each with an expected lifetime of 4 years.", - "roles": [ - "producer", - "processor", - "licensor" - ], - "url": "https://www.blacksky.com" + "data_type": "uint16", + "bits_per_sample": 12 } ] }, - "bbox": [ - -75.20606168353703, - 39.92967968802465, - -75.12948188832118, - 39.99133716421872 - ], - "assets": { - "overview": { - "title": "Browse image", - "type": "image/png", - "roles": [ - "overview" - ], - "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_browse.png", - "filename": "BSG-108-20210902-213556-11999279_browse.png", - "file:size": 1 - }, - "metadata": { - "title": "Metadata file", - "type": "application/json", - "roles": [ - "metadata" - ], - "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_metadata.json", - "filename": "BSG-108-20210902-213556-11999279_metadata.json", - "file:size": 3807 - }, - "georeferenced": { - "title": "RGB image file", - "type": "image/tiff; application=geotiff", - "roles": [ - "data" - ], - "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_georeferenced.tif", - "filename": "BSG-108-20210902-213556-11999279_georeferenced.tif", - "file:size": 1, - "gsd": 0.8632106, - "eo:bands": [ - { - "name": "red", - "common_name": "red", - "center_wavelength": 0.645, - "full_width_half_max": 0.11 - }, - { - "name": "green", - "common_name": "green", - "center_wavelength": 0.545, - "full_width_half_max": 0.09 - }, - { - "name": "blue", - "common_name": "blue", - "center_wavelength": 0.485, - "full_width_half_max": 0.07 - } - ] - }, - "georeferenced-pan": { - "type": "image/tiff; application=geotiff", - "roles": [ - "data" - ], - "title": "PAN image file", - "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_georeferenced-pan.tif", - "filename": "BSG-108-20210902-213556-11999279_georeferenced-pan.tif", - "file:size": 1, - "gsd": 0.8632106, - "eo:bands": [ - { - "name": "pan", - "common_name": "pan", - "center_wavelength": 0.575, - "full_width_half_max": 0.25 - } - ] - }, - "mask": { - "type": "image/tiff; application=geotiff", - "roles": [ - "data" - ], - "title": "Pixel mask", - "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_mask.tif", - "filename": "BSG-108-20210902-213556-11999279_mask.tif", - "file:size": 1, - "gsd": 0.8632106 - }, - "georefrenced-rpc": { - "type": "text/plain", - "roles": [ - "metadata" - ], - "title": "RPC (RGB)", - "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_georeferenced_rpc.txt", - "filename": "BSG-108-20210902-213556-11999279_georeferenced_rpc.txt", - "file:size": 1 - }, - "georefrenced-pan-rpc": { - "type": "text/plain", - "roles": [ - "metadata" - ], - "title": "RPC (PAN)", - "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_georeferenced-pan_rpc.txt", - "filename": "BSG-108-20210902-213556-11999279_georeferenced-pan_rpc.txt", - "file:size": 1 - }, - "mask-rpc": { - "type": "text/plain", - "roles": [ - "metadata" - ], - "title": "RPC (mask)", - "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_mask_rpc.txt", - "filename": "BSG-108-20210902-213556-11999279_mask_rpc.txt", - "file:size": 1 - } + "mask": { + "type": "image/tiff; application=geotiff", + "roles": [ + "data" + ], + "title": "Mask file", + "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_mask.tif", + "filename": "BSG-108-20210902-213556-11999279_mask.tif", + "file:size": 1, + "gsd": 0.8632106 + }, + "georefrenced-rgb-rpc": { + "type": "text/plain", + "roles": [ + "metadata" + ], + "title": "RPC (RGB)", + "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_georeferenced_rpc.txt", + "filename": "BSG-108-20210902-213556-11999279_georeferenced_rpc.txt", + "file:size": 1 + }, + "georefrenced-pan-rpc": { + "type": "text/plain", + "roles": [ + "metadata" + ], + "title": "RPC (PAN)", + "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_georeferenced-pan_rpc.txt", + "filename": "BSG-108-20210902-213556-11999279_georeferenced-pan_rpc.txt", + "file:size": 1 }, - "links": [] - } \ No newline at end of file + "mask-rpc": { + "type": "text/plain", + "roles": [ + "metadata" + ], + "title": "RPC (mask)", + "href": "data/BSG-108-20210902-213556-11999279_non-ortho/BSG-108-20210902-213556-11999279_mask_rpc.txt", + "filename": "BSG-108-20210902-213556-11999279_mask_rpc.txt", + "file:size": 1 + } + }, + "links": [] +} \ No newline at end of file diff --git a/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-108-20210902-213556-11999279_ortho.json b/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-108-20210902-213556-11999279_ortho.json index 75aba1fc..82a8d948 100644 --- a/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-108-20210902-213556-11999279_ortho.json +++ b/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-108-20210902-213556-11999279_ortho.json @@ -1,70 +1,180 @@ { - "stac_version": "1.0.0", - "stac_extensions": [ - "https://stac-extensions.github.io/eo/v1.0.0/schema.json", - "https://stac-extensions.github.io/processing/v1.0.0/schema.json", - "https://stac-extensions.github.io/view/v1.0.0/schema.json" - ], - "type": "Feature", - "id": "BSG-108-20210902-213556-11999279_ortho", - "geometry": { - "type": "Polygon", - "coordinates": [ + "stac_version": "1.0.0", + "stac_extensions": [ + "https://stac-extensions.github.io/eo/v1.0.0/schema.json", + "https://stac-extensions.github.io/processing/v1.0.0/schema.json", + "https://stac-extensions.github.io/raster/v1.0.0/schema.json", + "https://stac-extensions.github.io/view/v1.0.0/schema.json" + ], + "type": "Feature", + "id": "BSG-108-20210902-213556-11999279_ortho", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -75.12948188832118, + 39.951193872769544 + ], + [ + -75.17209285763781, + 39.99133716421872 + ], + [ + -75.20606168353703, + 39.96975426955367 + ], [ - [ - -75.12948188832118, - 39.951193872769544 - ], - [ - -75.16335070466222, - 39.92967968802465 - ], - [ - -75.20606168353703, - 39.96975426955367 - ], - [ - -75.17209285763781, - 39.99133716421872 - ], - [ - -75.12948188832118, - 39.951193872769544 - ] + -75.16335070466222, + 39.92967968802465 + ], + [ + -75.12948188832118, + 39.951193872769544 ] ] + ] + }, + "properties": { + "datetime": "2021-09-02T21:35:56.707Z", + "agency": "BlackSky", + "platform": "global-8", + "constellation": "blacksky-global", + "mission": "blacksky-global", + "instruments": [ + "spaceview-24" + ], + "sensor_type": "optical", + "spectral_mode": "PAN/MS", + "gsd": 0.8632106, + "title": "BLACKSY GLOBAL-8 ORTHO PAN MS", + "view:off_nadir": 13.258979, + "view:sun_azimuth": 262.15057, + "view:sun_elevation": 20.95552, + "processing:level": "ORTHO", + "eo:cloud_cover": 0.0, + "eo:bands": [ + { + "name": "B1-RED", + "common_name": "red", + "center_wavelength": 0.645, + "full_width_half_max": 0.11 + }, + { + "name": "B2-GREEN", + "common_name": "green", + "center_wavelength": 0.545, + "full_width_half_max": 0.09 + }, + { + "name": "B3-BLUE", + "common_name": "blue", + "center_wavelength": 0.485, + "full_width_half_max": 0.07 + }, + { + "name": "pan", + "common_name": "pan", + "center_wavelength": 0.575, + "full_width_half_max": 0.25 + } + ], + "providers": [ + { + "name": "BlackSky", + "description": "BlackSky Constellation is a commercially owned and operated constellation of 60 high resolution imaging microsatellites developed by BlackSky Global. The constellation aims to provide higher temporal resolution and lower cost Earth imaging, and currently contains 17 operational microsatellites, each with an expected lifetime of 4 years.", + "roles": [ + "producer", + "processor", + "licensor" + ], + "url": "https://www.blacksky.com" + } + ] + }, + "bbox": [ + -75.20606168353703, + 39.92967968802465, + -75.12948188832118, + 39.99133716421872 + ], + "assets": { + "metadata": { + "type": "application/json", + "roles": [ + "metadata" + ], + "title": "Metadata file", + "href": "data/BSG-108-20210902-213556-11999279_ortho/BSG-108-20210902-213556-11999279_metadata.json", + "filename": "BSG-108-20210902-213556-11999279_metadata.json", + "file:size": 3807 }, - "properties": { - "title": "GLOBAL-8 2021-09-02 21:35:56", - "agency": "BlackSky", - "platform": "global-8", - "mission": "Global", - "instruments": [ - "global-8" + "overview": { + "type": "image/png", + "roles": [ + "overview" ], - "sensor_type": "optical", + "title": "Browse image", + "href": "data/BSG-108-20210902-213556-11999279_ortho/BSG-108-20210902-213556-11999279_browse.png", + "filename": "BSG-108-20210902-213556-11999279_browse.png", + "file:size": 1 + }, + "ORTHO_RGB": { + "type": "image/tiff; application=geotiff", + "roles": [ + "data" + ], + "title": "RGB image", + "href": "data/BSG-108-20210902-213556-11999279_ortho/BSG-108-20210902-213556-11999279_ortho.tif", + "filename": "BSG-108-20210902-213556-11999279_ortho.tif", + "file:size": 1, "gsd": 0.8632106, - "datetime": "2021-09-02T21:35:56.707Z", - "eo:cloud_cover": 0.0, "eo:bands": [ { - "name": "red", + "name": "B1-RED", "common_name": "red", "center_wavelength": 0.645, "full_width_half_max": 0.11 }, { - "name": "green", + "name": "B2-GREEN", "common_name": "green", "center_wavelength": 0.545, "full_width_half_max": 0.09 }, { - "name": "blue", + "name": "B3-BLUE", "common_name": "blue", "center_wavelength": 0.485, "full_width_half_max": 0.07 + } + ], + "raster:bands": [ + { + "data_type": "uint16", + "bits_per_sample": 12 + }, + { + "data_type": "uint16", + "bits_per_sample": 12 }, + { + "data_type": "uint16", + "bits_per_sample": 12 + } + ] + }, + "ORTHO_PAN": { + "type": "image/tiff; application=geotiff", + "roles": [ + "data" + ], + "title": "PAN image", + "href": "data/BSG-108-20210902-213556-11999279_ortho/BSG-108-20210902-213556-11999279_ortho-pan.tif", + "filename": "BSG-108-20210902-213556-11999279_ortho-pan.tif", + "file:size": 1, + "gsd": 0.8632106, + "eo:bands": [ { "name": "pan", "common_name": "pan", @@ -72,100 +182,13 @@ "full_width_half_max": 0.25 } ], - "view:sun_azimuth": 262.15057, - "view:sun_elevation": 20.95552, - "view:off_nadir": 13.258979, - "processing:level": "ORTHO", - "providers": [ + "raster:bands": [ { - "name": "BlackSky", - "description": "BlackSky Constellation is a commercially owned and operated constellation of 60 high resolution imaging microsatellites developed by BlackSky Global. The constellation aims to provide higher temporal resolution and lower cost Earth imaging, and currently contains 17 operational microsatellites, each with an expected lifetime of 4 years.", - "roles": [ - "producer", - "processor", - "licensor" - ], - "url": "https://www.blacksky.com" + "data_type": "uint16", + "bits_per_sample": 12 } ] - }, - "bbox": [ - -75.20606168353703, - 39.92967968802465, - -75.12948188832118, - 39.99133716421872 - ], - "assets": { - "overview": { - "title": "Browse image", - "type": "image/png", - "roles": [ - "overview" - ], - "href": "data/BSG-108-20210902-213556-11999279_ortho/BSG-108-20210902-213556-11999279_browse.png", - "filename": "BSG-108-20210902-213556-11999279_browse.png", - "file:size": 1 - }, - "metadata": { - "title": "Metadata file", - "type": "application/json", - "roles": [ - "metadata" - ], - "href": "data/BSG-108-20210902-213556-11999279_ortho/BSG-108-20210902-213556-11999279_metadata.json", - "filename": "BSG-108-20210902-213556-11999279_metadata.json", - "file:size": 3807 - }, - "ortho": { - "title": "RGB image file", - "type": "image/tiff; application=geotiff", - "roles": [ - "data" - ], - "href": "data/BSG-108-20210902-213556-11999279_ortho/BSG-108-20210902-213556-11999279_ortho.tif", - "filename": "BSG-108-20210902-213556-11999279_ortho.tif", - "file:size": 1, - "gsd": 0.8632106, - "eo:bands": [ - { - "name": "red", - "common_name": "red", - "center_wavelength": 0.645, - "full_width_half_max": 0.11 - }, - { - "name": "green", - "common_name": "green", - "center_wavelength": 0.545, - "full_width_half_max": 0.09 - }, - { - "name": "blue", - "common_name": "blue", - "center_wavelength": 0.485, - "full_width_half_max": 0.07 - } - ] - }, - "ortho-pan": { - "type": "image/tiff; application=geotiff", - "roles": [ - "data" - ], - "title": "PAN image file", - "href": "data/BSG-108-20210902-213556-11999279_ortho/BSG-108-20210902-213556-11999279_ortho-pan.tif", - "filename": "BSG-108-20210902-213556-11999279_ortho-pan.tif", - "file:size": 1, - "gsd": 0.8632106, - "eo:bands": [ - { - "name": "pan", - "common_name": "pan", - "center_wavelength": 0.575, - "full_width_half_max": 0.25 - } - ] - } - }, - "links": [] - } \ No newline at end of file + } + }, + "links": [] +} \ No newline at end of file diff --git a/src/Stars.Data.Tests/Resources/BLACKSKY/Global/data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_BG000000001.jpg b/src/Stars.Data.Tests/Resources/BLACKSKY/Global/data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_BG000000001.jpg new file mode 100644 index 00000000..e69de29b diff --git a/src/Stars.Data.Tests/Resources/BLACKSKY/Global/data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_DG000000001.txt b/src/Stars.Data.Tests/Resources/BLACKSKY/Global/data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_DG000000001.txt new file mode 100644 index 00000000..fbe5f6e9 --- /dev/null +++ b/src/Stars.Data.Tests/Resources/BLACKSKY/Global/data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_DG000000001.txt @@ -0,0 +1,75 @@ +EVENT=202403_Flood_MNG +ENTITY_ID=BS01N47_769636E107_2567602024032000000000MS03 +AGENCY=BlackSky +PLATFORM=BLACKSKY +PLATFORM_NUMBER=1 +SENSOR=MSI +SENSOR_TYPE=MS +OBLIQUE_FLAG=N +RESTRICTED_FLAG=Y +LICENSE_TYPE=BLACKSKY_GLOBAL_LLC +MOSAIC_FLAG=N +ACQUISITION_DATE=20240320 +ACQUISITION_TIME= +END_ACQUISITION_DATE= +CENTER_LAT=47.7696361276686 +CENTER_LONG=107.256760975317 +UL_LAT=47.800594553305935 +UL_LONG=107.20278300270137 +UR_LAT=47.79841769410016 +UR_LONG=107.31338802634312 +LR_LAT=47.738677702031254 +LR_LONG=107.31073894793276 +LL_LAT=47.7408500353907 +LL_LONG=107.20026032340076 +PROCESS_LEVEL=G +VENDOR_PROCESS_LEVEL= +MAP_PROJECTION=UTM +PROJECTION_PARAMETERS= +DATUM=WGS84 +LINESPERBAND=6645 +PIXELSPERLINE=8289 +BROWSE_HEIGHT= +BROWSE_WIDTH= +PROJECTION_ZONE= +PIXEL_SIZE_X=1.000000 +PIXEL_SIZE_Y=1.000000 +PIX_SIZE_UNITS=M +NUM_BANDS=1 +BAND_NUMBERS=000000001 +INCIDENCE_ANGLE= +SUN_AZIMUTH= +SUN_ELEVATION= +CLOUD_COVER= +WRS_PATH= +WRS_ROW= +FILE_FORMAT=GEOTIFF +FULL_RES_LOC=https://hddsexplorer.usgs.gov/order/process?ordered=2563258&node=HDDS&dataset_name=EVENT3340 +FULL_RES_SIZE=54183440 +BROWSE_LOC=https://ims.cr.usgs.gov/browse/eo/disaster/202403_Flood_MNG/BLACKSKY_BlackSky/BS01N47_769636E107_2567602024032000000000MS03.png +METADATA_LOC=https://hddsexplorer.usgs.gov/order/process?ordered=2563258&node=HDDS&dataset_name=EVENT3340 +METADATA_SIZE=9000 +MED_QUAL_LOC=https://hddsexplorer.usgs.gov/order/process?ordered=2563258&node=HDDS&dataset_name=EVENT3340 +MED_QUAL_SIZE=12484653 +LOW_QUAL_LOC=https://hddsexplorer.usgs.gov/order/process?ordered=2563258&node=HDDS&dataset_name=EVENT3340 +LOW_QUAL_SIZE=5828206 +LICENSE_LOC= +VENDOR=BlackSky +VENDOR_SCENE_ID=BSG-102-20240320-024025-217335171_ortho-pan +CATALOG_ID= +SOFTWARE_VERSION=4.2.12 +CONTACT_INFORMATION=eocustserv@usgs.gov +DATE_ENTERED=2024-03-21 +DATE_UPDATED= +IMAGE_INDEX= +DISPLAY_INDEX= +SAT_AZIMUTH= +SAT_ELEVATION= +EVENT_TYPE= +DATA_SOURCE=SATELLITE +VERSION= +PRODUCT_TYPE= +POLARIZATION= +ORBIT_DIRECTION= +SENSOR_MODE=default +CIDR_ID= diff --git a/src/Stars.Data.Tests/Resources/BLACKSKY/Global/data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_GG000000001.tif b/src/Stars.Data.Tests/Resources/BLACKSKY/Global/data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_GG000000001.tif new file mode 100644 index 00000000..e69de29b diff --git a/src/Stars.Data.Tests/testsettings.json b/src/Stars.Data.Tests/testsettings.json index fa092696..b650b40b 100644 --- a/src/Stars.Data.Tests/testsettings.json +++ b/src/Stars.Data.Tests/testsettings.json @@ -96,4 +96,4 @@ ] } } -} \ No newline at end of file +} diff --git a/src/Stars.Data/Model/Metadata/BlackSkyGlobal/BlackSkyGlobalMetadataExtractor.cs b/src/Stars.Data/Model/Metadata/BlackSkyGlobal/BlackSkyGlobalMetadataExtractor.cs index 979ec013..504bd848 100644 --- a/src/Stars.Data/Model/Metadata/BlackSkyGlobal/BlackSkyGlobalMetadataExtractor.cs +++ b/src/Stars.Data/Model/Metadata/BlackSkyGlobal/BlackSkyGlobalMetadataExtractor.cs @@ -27,11 +27,27 @@ namespace Terradue.Stars.Data.Model.Metadata.BlackSkyGlobal { public class BlackSkyGlobalMetadataExtractor : MetadataExtraction { + public static Dictionary platformDesignators = new Dictionary { + { 1, "2018-096M" }, + { 2, "2018-099BG" }, + { 3, "2019-037C" }, + { 4, "2019-054E" }, + { 7, "2020-055BP" }, + { 8, "2020-055BQ" }, + { 9, "2021-023G" }, + { 12, "2021-115BA" }, + { 13, "2021-115BB" }, + { 14, "2021-106A" }, + { 15, "2021-106B" }, + { 16, "2021-120B" }, + }; + // Possible identifiers: // CSKS4_SCS_B_HI_16_HH_RA_FF_20211016045150_20211016045156 private Regex identifierRegex = new Regex(@"(?'id'CSKS(?'i'\d)_(?'pt'RAW_B|SCS_B|SCS_U|DGM_B|GEC_B|GTC_B)_(?'mode'HI|PP|WR|HR|S2)_(?'swath'..)_(?'pol'HH|VV|HV|VH|CO|CH|CV)_(?'look'L|R)(?'dir'A|D)_.._\d{14}_\d{14})"); private Regex coordinateRegex = new Regex(@"(?'lat'[^ ]+) (?'lon'[^ ]+)"); private static Regex h5dumpValueRegex = new Regex(@".*\(0\): *(?'value'.*)"); + private static Regex satNumberRegex = new Regex(@".+?(?'n'\d+)$"); public static XmlSerializer metadataSerializer = new XmlSerializer(typeof(Schemas.Metadata)); @@ -70,7 +86,7 @@ protected override async Task ExtractMetadata(IItem item, string suffi AddSatStacExtension(stacItem, metadata); AddProjStacExtension(stacItem, metadata); AddViewStacExtension(stacItem, metadata); - AddProcessingStacExtension(stacItem, metadata); + AddProcessingStacExtension(stacItem, metadata, item); AddEoStacExtension(stacItem, metadata); AddOtherProperties(stacItem, metadata); @@ -97,8 +113,6 @@ protected virtual IAsset GetMetadataAsset(IItem item) { logger.LogDebug("Opening metadata file {0}", metadataAsset.Uri); - System.Console.WriteLine("METADATA FILE: {0}", metadataAsset.Uri.AbsolutePath); - using (var stream = await resourceServiceProvider.GetAssetStreamAsync(metadataAsset, System.Threading.CancellationToken.None)) { using (StreamReader reader = new StreamReader(stream)) @@ -123,15 +137,19 @@ protected virtual IAsset GetMetadataAsset(IItem item) internal virtual StacItem CreateStacItem(Schemas.Metadata metadata, IItem item) { string suffix = String.Empty; - if (FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_ortho\.tif$", metadata.id)) != null) suffix = "_ortho"; - else if (FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_georeferenced\.tif$", metadata.id)) != null) suffix = "_non-ortho"; + if (!metadata.id.Contains("ortho")) + { + suffix = GetProcessingLevel(metadata, item); + if (suffix == "ORTHO") suffix = "_ortho"; + else suffix = "_non-ortho"; + } string identifier = String.Format("{0}{1}", metadata.id, suffix); Dictionary properties = new Dictionary(); FillDateTimeProperties(properties, metadata); - FillInstrument(properties, metadata); - FillBasicsProperties(properties, metadata); + FillInstrument(properties, metadata, item); + FillBasicsProperties(properties, metadata, item); StacItem stacItem = new StacItem(identifier, GetGeometry(metadata), properties); @@ -159,14 +177,19 @@ protected void AddAssets(StacItem stacItem, IItem item, Schemas.Metadata metadat IAsset imageAsset = FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_ortho\.tif$", metadata.id)); if (imageAsset != null) { - StacAsset stacAsset = StacAsset.CreateDataAsset(stacItem, imageAsset.Uri, new ContentType("image/tiff; application=geotiff"), "RGB image file"); - stacItem.Assets.Add("ortho", stacAsset); + StacAsset stacAsset = StacAsset.CreateDataAsset(stacItem, imageAsset.Uri, new ContentType("image/tiff; application=geotiff"), "RGB image"); + stacItem.Assets.Add("ORTHO_RGB", stacAsset); stacAsset.Properties.AddRange(imageAsset.Properties); stacAsset.Properties["gsd"] = metadata.gsd; stacAsset.EoExtension().Bands = new EoBandObject[] { - new EoBandObject("red", EoBandCommonName.red) { CenterWavelength = 0.645, FullWidthHalfMax = 0.11 }, - new EoBandObject("green", EoBandCommonName.green) { CenterWavelength = 0.545, FullWidthHalfMax = 0.09 }, - new EoBandObject("blue", EoBandCommonName.blue) { CenterWavelength = 0.485, FullWidthHalfMax = 0.07 }, + new EoBandObject("B1-RED", EoBandCommonName.red) { CenterWavelength = 0.645, FullWidthHalfMax = 0.11 }, + new EoBandObject("B2-GREEN", EoBandCommonName.green) { CenterWavelength = 0.545, FullWidthHalfMax = 0.09 }, + new EoBandObject("B3-BLUE", EoBandCommonName.blue) { CenterWavelength = 0.485, FullWidthHalfMax = 0.07 }, + }; + stacAsset.RasterExtension().Bands = new RasterBand[] { + new RasterBand() { DataType = Stac.Common.DataType.uint16, BitsPerSample = 12 }, + new RasterBand() { DataType = Stac.Common.DataType.uint16, BitsPerSample = 12 }, + new RasterBand() { DataType = Stac.Common.DataType.uint16, BitsPerSample = 12 }, }; } @@ -174,27 +197,35 @@ protected void AddAssets(StacItem stacItem, IItem item, Schemas.Metadata metadat IAsset imageAssetPan = FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_ortho-pan\.tif$", metadata.id)); if (imageAssetPan != null) { - StacAsset stacAssetPan = StacAsset.CreateDataAsset(stacItem, imageAssetPan.Uri, new ContentType("image/tiff; application=geotiff"), "PAN image file"); - stacItem.Assets.Add("ortho-pan", stacAssetPan); + StacAsset stacAssetPan = StacAsset.CreateDataAsset(stacItem, imageAssetPan.Uri, new ContentType("image/tiff; application=geotiff"), "PAN image"); + stacItem.Assets.Add("ORTHO_PAN", stacAssetPan); stacAssetPan.Properties.AddRange(imageAssetPan.Properties); stacAssetPan.Properties["gsd"] = metadata.gsd; stacAssetPan.EoExtension().Bands = new EoBandObject[] { new EoBandObject("pan", EoBandCommonName.pan) { CenterWavelength = 0.575, FullWidthHalfMax = 0.25 }, }; + stacAssetPan.RasterExtension().Bands = new RasterBand[] { + new RasterBand() { DataType = Stac.Common.DataType.uint16, BitsPerSample = 12 }, + }; } // RGB TIFF (non-ortho) imageAsset = FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_georeferenced\.tif$", metadata.id)); if (imageAsset != null) { - StacAsset stacAsset = StacAsset.CreateDataAsset(stacItem, imageAsset.Uri, new ContentType("image/tiff; application=geotiff"), "RGB image file"); - stacItem.Assets.Add("georeferenced", stacAsset); + StacAsset stacAsset = StacAsset.CreateDataAsset(stacItem, imageAsset.Uri, new ContentType("image/tiff; application=geotiff"), "RGB image"); + stacItem.Assets.Add("GEO_RGB", stacAsset); stacAsset.Properties.AddRange(imageAsset.Properties); stacAsset.Properties["gsd"] = metadata.gsd; stacAsset.EoExtension().Bands = new EoBandObject[] { - new EoBandObject("red", EoBandCommonName.red) { CenterWavelength = 0.645, FullWidthHalfMax = 0.11 }, - new EoBandObject("green", EoBandCommonName.green) { CenterWavelength = 0.545, FullWidthHalfMax = 0.09 }, - new EoBandObject("blue", EoBandCommonName.blue) { CenterWavelength = 0.485, FullWidthHalfMax = 0.07 }, + new EoBandObject("B1-RED", EoBandCommonName.red) { CenterWavelength = 0.645, FullWidthHalfMax = 0.11 }, + new EoBandObject("B2-GREEN", EoBandCommonName.green) { CenterWavelength = 0.545, FullWidthHalfMax = 0.09 }, + new EoBandObject("B3-BLUE", EoBandCommonName.blue) { CenterWavelength = 0.485, FullWidthHalfMax = 0.07 }, + }; + stacAsset.RasterExtension().Bands = new RasterBand[] { + new RasterBand() { DataType = Stac.Common.DataType.uint16, BitsPerSample = 12 }, + new RasterBand() { DataType = Stac.Common.DataType.uint16, BitsPerSample = 12 }, + new RasterBand() { DataType = Stac.Common.DataType.uint16, BitsPerSample = 12 }, }; } @@ -202,20 +233,23 @@ protected void AddAssets(StacItem stacItem, IItem item, Schemas.Metadata metadat imageAssetPan = FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_georeferenced-pan\.tif$", metadata.id)); if (imageAssetPan != null) { - StacAsset stacAssetPan = StacAsset.CreateDataAsset(stacItem, imageAssetPan.Uri, new ContentType("image/tiff; application=geotiff"), "PAN image file"); - stacItem.Assets.Add("georeferenced-pan", stacAssetPan); + StacAsset stacAssetPan = StacAsset.CreateDataAsset(stacItem, imageAssetPan.Uri, new ContentType("image/tiff; application=geotiff"), "PAN image"); + stacItem.Assets.Add("GEO_PAN", stacAssetPan); stacAssetPan.Properties.AddRange(imageAssetPan.Properties); stacAssetPan.Properties["gsd"] = metadata.gsd; stacAssetPan.EoExtension().Bands = new EoBandObject[] { new EoBandObject("pan", EoBandCommonName.pan) { CenterWavelength = 0.575, FullWidthHalfMax = 0.25 }, }; + stacAssetPan.RasterExtension().Bands = new RasterBand[] { + new RasterBand() { DataType = Stac.Common.DataType.uint16, BitsPerSample = 12 }, + }; } // Mask TIFF (non-ortho) IAsset imageAssetMask = FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_mask\.tif$", metadata.id)); if (imageAssetMask != null) { - StacAsset stacAssetMask = StacAsset.CreateDataAsset(stacItem, imageAssetMask.Uri, new ContentType("image/tiff; application=geotiff"), "Pixel mask"); + StacAsset stacAssetMask = StacAsset.CreateDataAsset(stacItem, imageAssetMask.Uri, new ContentType("image/tiff; application=geotiff"), "Mask file"); stacItem.Assets.Add("mask", stacAssetMask); stacAssetMask.Properties.AddRange(imageAssetMask.Properties); stacAssetMask.Properties["gsd"] = metadata.gsd; @@ -226,7 +260,7 @@ protected void AddAssets(StacItem stacItem, IItem item, Schemas.Metadata metadat if (rpcAsset != null) { StacAsset stacAssetRpc = StacAsset.CreateMetadataAsset(stacItem, rpcAsset.Uri, new ContentType("text/plain"), "RPC (RGB)"); - stacItem.Assets.Add("georefrenced-rpc", stacAssetRpc); + stacItem.Assets.Add("georefrenced-rgb-rpc", stacAssetRpc); stacAssetRpc.Properties.AddRange(rpcAsset.Properties); } @@ -261,26 +295,53 @@ private void FillDateTimeProperties(Dictionary properties, Schem } - private void FillInstrument(Dictionary properties, Schemas.Metadata metadata) + private void FillInstrument(Dictionary properties, Schemas.Metadata metadata, IItem item) { // platform & constellation properties["agency"] = "BlackSky"; properties["platform"] = metadata.sensorName.ToLower(); - properties["mission"] = "Global"; - properties["instruments"] = new string[] { metadata.sensorName.ToLower() }; + properties["constellation"] = "blacksky-global"; + properties["mission"] = "blacksky-global"; + properties["instruments"] = new string[] { "spaceview-24" }; properties["sensor_type"] = "optical"; + properties["spectral_mode"] = GetSpectralMode(metadata, item); + properties["gsd"] = metadata.gsd; } - private void FillBasicsProperties(IDictionary properties, Schemas.Metadata metadata) + private string GetSpectralMode(Schemas.Metadata metadata, IItem item) + { + if (metadata.spectralMode != null) + { + if (metadata.spectralMode == "PN") return "PAN"; + if (metadata.spectralMode == "MS") return "MS"; + if (metadata.spectralMode.Contains("MS") && metadata.spectralMode.Contains("MS")) return "PAN/MS"; + } + + bool pan = FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_ortho-pan\.tif$", metadata.id)) != null || FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_georeferenced-pan\.tif$", metadata.id)) != null; + bool ms = FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_ortho\.tif$", metadata.id)) != null || FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_georeferenced\.tif$", metadata.id)) != null; + + return String.Format("{0}{1}{2}", pan ? "PAN" : String.Empty, pan && ms ? "/": String.Empty, ms ? "MS" : String.Empty); + + } + + private void FillBasicsProperties(IDictionary properties, Schemas.Metadata metadata, IItem item) { DateTime? acquisitionDate = GetAcquisitionDateTime(metadata); string dateStr = (acquisitionDate != null ? String.Format(" {0:yyyy-MM-dd HH:mm:ss}", acquisitionDate.Value.ToUniversalTime()) : String.Empty); CultureInfo culture = new CultureInfo("fr-FR"); - properties["title"] = String.Format("{0}{1}", + string processingLevel = GetProcessingLevel(metadata, item); + if (processingLevel == null) processingLevel = String.Empty; + else processingLevel = String.Format(" {0}", processingLevel); + string spectralMode = GetSpectralMode(metadata, item); + if (spectralMode == null) spectralMode = String.Empty; + else spectralMode = String.Format(" {0}", spectralMode.Replace("/", " ")); + properties["title"] = String.Format("BLACKSY {0}{1}{2}", metadata.sensorName.ToUpper(), + processingLevel, + spectralMode, dateStr ); } @@ -302,6 +363,16 @@ private void AddOtherProperties(StacItem stacItem, Schemas.Metadata metadata) private void AddSatStacExtension(StacItem stacItem, Schemas.Metadata metadata) { + var sat = new SatStacExtension(stacItem); + if (!String.IsNullOrEmpty("")) + { + Match match = satNumberRegex.Match(""); + if (match != null && Int32.TryParse(match.Groups["n"].Value, out int n) && platformDesignators.ContainsKey(n)) + { + sat.PlatformInternationalDesignator = platformDesignators[n]; + } + } + } @@ -320,16 +391,16 @@ private void AddProjStacExtension(StacItem stacItem, Schemas.Metadata metadata) private void AddViewStacExtension(StacItem stacItem, Schemas.Metadata metadata) { var view = new ViewStacExtension(stacItem); - view.OffNadir = metadata.offNadirAngle; - view.SunAzimuth = metadata.sunAzimuth; - view.SunElevation = metadata.sunElevation; + if (metadata.offNadirAngle.HasValue) view.OffNadir = metadata.offNadirAngle.Value; + if (metadata.sunAzimuth.HasValue) view.SunAzimuth = metadata.sunAzimuth.Value; + if (metadata.sunElevation.HasValue) view.SunElevation = metadata.sunElevation.Value; } - private void AddProcessingStacExtension(StacItem stacItem, Schemas.Metadata metadata) + private void AddProcessingStacExtension(StacItem stacItem, Schemas.Metadata metadata, IItem item) { var proc = stacItem.ProcessingExtension(); - proc.Level = "ORTHO"; + proc.Level = GetProcessingLevel(metadata, item); } @@ -378,6 +449,20 @@ private GeoJSON.Net.Geometry.IGeometryObject GetGeometry(Schemas.Metadata metada return polygon.NormalizePolygon(); } + private string GetProcessingLevel(Schemas.Metadata metadata, IItem item) + { + if (metadata.processLevel != null) + { + if (metadata.orthorectified.HasValue && metadata.orthorectified.Value) return "ORTHO"; + if (metadata.georeferenced.HasValue && metadata.georeferenced.Value) return "GEO"; + if (metadata.processLevel == "O") return "ORTHO"; + if (metadata.processLevel == "G") return "GEO"; + } + if (FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_ortho\.tif$", metadata.id)) != null) return "ORTHO"; + if (FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_georeferenced\.tif$", metadata.id)) != null) return "GEO"; + return null; + } + } diff --git a/src/Stars.Data/Model/Metadata/BlackSkyGlobal/Schemas/Metadata.cs b/src/Stars.Data/Model/Metadata/BlackSkyGlobal/Schemas/Metadata.cs index 5751a17e..97ce2823 100644 --- a/src/Stars.Data/Model/Metadata/BlackSkyGlobal/Schemas/Metadata.cs +++ b/src/Stars.Data/Model/Metadata/BlackSkyGlobal/Schemas/Metadata.cs @@ -16,25 +16,26 @@ public partial class Metadata { public string id { get; set; } public string acquisitionDate { get; set; } public string sensorName { get; set; } - public double gsd { get; set; } + public string spectralMode { get; set; } + public double? gsd { get; set; } public object geometry { get; set; } - public double cloudCoverPercent { get; set; } - public double offNadirAngle { get; set; } - public double sunElevation { get; set; } - public double sunAzimuth { get; set; } - public double satelliteElevation { get; set; } - public double satelliteAzimuth { get; set; } - public bool georeferenced { get; set; } - public bool orthorectified { get; set; } - public int width { get; set; } - public int height { get; set; } + public double? cloudCoverPercent { get; set; } + public double? offNadirAngle { get; set; } + public double? sunElevation { get; set; } + public double? sunAzimuth { get; set; } + public double? satelliteElevation { get; set; } + public double? satelliteAzimuth { get; set; } + public bool? georeferenced { get; set; } + public bool? orthorectified { get; set; } + public int? width { get; set; } + public int? height { get; set; } public string processingVersion { get; set; } public string targetType { get; set; } - public double estimatedCE90 { get; set; } - public int bitsPerPixel { get; set; } + public double? estimatedCE90 { get; set; } + public int? bitsPerPixel { get; set; } public string imageSpecVersion { get; set; } - public double fractionSaturated { get; set; } + public double? fractionSaturated { get; set; } public object numberRegistrationPoints { get; set; } public GeminiType gemini { get; set; } @@ -60,6 +61,14 @@ public static Metadata FromTextFile(StreamReader reader) } metadata.id = GetStringValue(textMetadata, "VENDOR_SCENE_ID"); + string platformNumber = GetStringValue(textMetadata, "PLATFORM_NUMBER"); + if (platformNumber == null) + { + string fileName = GetStringValue(textMetadata, "ENTITY_ID"); + if (fileName != null && fileName.StartsWith("BS")) platformNumber = fileName.Substring(2, 2).TrimStart('0'); + } + metadata.sensorName = String.Format("Global-{0}", platformNumber); + metadata.spectralMode = GetStringValue(textMetadata, "SENSOR_TYPE"); string acquisitionDate = GetStringValue(textMetadata, "ACQUISITION_DATE"); if (!String.IsNullOrEmpty(acquisitionDate)) { @@ -76,7 +85,6 @@ public static Metadata FromTextFile(StreamReader reader) acquisitionTime = acquisitionTime.Replace("Z", ""); metadata.acquisitionDate = String.Format("{0}T{1}Z", acquisitionDate, acquisitionTime); } - metadata.sensorName = GetStringValue(textMetadata, "SENSOR"); metadata.gsd = 1; // hardcoded List coordinates = new List(); @@ -129,13 +137,13 @@ public static string GetStringValue(Dictionary dict, string key) return null; } - public static double GetDoubleValue(Dictionary dict, string key) + public static double? GetDoubleValue(Dictionary dict, string key) { if (dict.ContainsKey(key)) { if (Double.TryParse(dict[key], out double value)) return value; } - return 0; + return null; } @@ -148,21 +156,3 @@ public partial class GeminiType { } - - - -/* -metadata.id -metadata.gsd; -metadata.sensorName.ToLower(); -metadata.sensorName.ToLower() }; -metadata.gsd; -metadata.sensorName.ToUpper(), -metadata.AncillaryDataReference.Tag, "Ellipsoid Designator"); -metadata.offNadirAngle; -metadata.sunAzimuth; -metadata.sunElevation; -metadata.cloudCoverPercent; -metadata.acquisitionDate, null, DateTimeStyles.AssumeUniversal, out DateTime result)) -metadata.geometry); - */ \ No newline at end of file diff --git a/src/Stars.Data/Terradue.Stars.Data.csproj b/src/Stars.Data/Terradue.Stars.Data.csproj index b412c83d..5eae3e1f 100644 --- a/src/Stars.Data/Terradue.Stars.Data.csproj +++ b/src/Stars.Data/Terradue.Stars.Data.csproj @@ -31,7 +31,7 @@ - + From 09d28afee6c0578310ab7f13bef8de8326d1b12b Mon Sep 17 00:00:00 2001 From: floeschau Date: Fri, 3 May 2024 18:34:35 +0200 Subject: [PATCH 3/4] Fix for missing asset in case of text metadata --- .../BlackSkyGlobalMetadataExtractor.cs | 9 +++++---- .../Metadata/BlackSkyGlobal/Schemas/Metadata.cs | 13 ++++++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Stars.Data/Model/Metadata/BlackSkyGlobal/BlackSkyGlobalMetadataExtractor.cs b/src/Stars.Data/Model/Metadata/BlackSkyGlobal/BlackSkyGlobalMetadataExtractor.cs index 504bd848..18901233 100644 --- a/src/Stars.Data/Model/Metadata/BlackSkyGlobal/BlackSkyGlobalMetadataExtractor.cs +++ b/src/Stars.Data/Model/Metadata/BlackSkyGlobal/BlackSkyGlobalMetadataExtractor.cs @@ -174,7 +174,8 @@ protected void AddAssets(StacItem stacItem, IItem item, Schemas.Metadata metadat } // RGB TIFF (ortho) - IAsset imageAsset = FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_ortho\.tif$", metadata.id)); + IAsset imageAsset = metadata.IsFromText && metadata.id.EndsWith("_ortho") ? FindFirstAssetFromFileNameRegex(item, @".*\.tif") : FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_ortho\.tif$", metadata.id)); + if (imageAsset != null) { StacAsset stacAsset = StacAsset.CreateDataAsset(stacItem, imageAsset.Uri, new ContentType("image/tiff; application=geotiff"), "RGB image"); @@ -194,7 +195,7 @@ protected void AddAssets(StacItem stacItem, IItem item, Schemas.Metadata metadat } // PAN TIFF (ortho) - IAsset imageAssetPan = FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_ortho-pan\.tif$", metadata.id)); + IAsset imageAssetPan = metadata.IsFromText && metadata.id.EndsWith("_ortho-pan") ? FindFirstAssetFromFileNameRegex(item, @".*\.tif") : FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_ortho-pan\.tif$", metadata.id)); if (imageAssetPan != null) { StacAsset stacAssetPan = StacAsset.CreateDataAsset(stacItem, imageAssetPan.Uri, new ContentType("image/tiff; application=geotiff"), "PAN image"); @@ -210,7 +211,7 @@ protected void AddAssets(StacItem stacItem, IItem item, Schemas.Metadata metadat } // RGB TIFF (non-ortho) - imageAsset = FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_georeferenced\.tif$", metadata.id)); + imageAsset = metadata.IsFromText && metadata.id.EndsWith("_georeferenced") ? FindFirstAssetFromFileNameRegex(item, @".*\.tif") : FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_georeferenced\.tif$", metadata.id)); if (imageAsset != null) { StacAsset stacAsset = StacAsset.CreateDataAsset(stacItem, imageAsset.Uri, new ContentType("image/tiff; application=geotiff"), "RGB image"); @@ -230,7 +231,7 @@ protected void AddAssets(StacItem stacItem, IItem item, Schemas.Metadata metadat } // PAN TIFF (non-ortho) - imageAssetPan = FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_georeferenced-pan\.tif$", metadata.id)); + imageAssetPan = metadata.IsFromText && metadata.id.EndsWith("_georeferenced-pan") ? FindFirstAssetFromFileNameRegex(item, @".*\.tif") : FindFirstAssetFromFileNameRegex(item, String.Format(@"{0}_georeferenced-pan\.tif$", metadata.id)); if (imageAssetPan != null) { StacAsset stacAssetPan = StacAsset.CreateDataAsset(stacItem, imageAssetPan.Uri, new ContentType("image/tiff; application=geotiff"), "PAN image"); diff --git a/src/Stars.Data/Model/Metadata/BlackSkyGlobal/Schemas/Metadata.cs b/src/Stars.Data/Model/Metadata/BlackSkyGlobal/Schemas/Metadata.cs index 97ce2823..ed2f150d 100644 --- a/src/Stars.Data/Model/Metadata/BlackSkyGlobal/Schemas/Metadata.cs +++ b/src/Stars.Data/Model/Metadata/BlackSkyGlobal/Schemas/Metadata.cs @@ -8,11 +8,18 @@ namespace Terradue.Stars.Data.Model.Metadata.BlackSkyGlobal.Schemas { public partial class Metadata { + private bool isFromText = false; + public static Regex keyValueRegex = new Regex(@"(?'key'[^= ]+) *= *(?'value'.*)"); public static string[] cornerCoordinateNames = new string[] { "LL_LONG", "LL_LAT", "LR_LONG", "LR_LAT", "UR_LONG", "UR_LAT", "UL_LONG", "UL_LAT" }; + public bool IsFromText { + get { return isFromText; } + set { isFromText = value; } + } + public string id { get; set; } public string acquisitionDate { get; set; } public string sensorName { get; set; } @@ -45,7 +52,11 @@ public partial class Metadata { public static Metadata FromTextFile(StreamReader reader) { - Metadata metadata = new Metadata(); + Metadata metadata = new Metadata + { + IsFromText = true + }; + Dictionary textMetadata = new Dictionary(); string line; From b74831acb463e71c70056b89a57443cbe61979ef Mon Sep 17 00:00:00 2001 From: floeschau Date: Sun, 5 May 2024 23:11:27 +0200 Subject: [PATCH 4/4] Corrected test case expected output for text metadata --- ...2-20240320-024025-217335171_ortho-pan.json | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-102-20240320-024025-217335171_ortho-pan.json b/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-102-20240320-024025-217335171_ortho-pan.json index e9cb72eb..d6ea599b 100644 --- a/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-102-20240320-024025-217335171_ortho-pan.json +++ b/src/Stars.Data.Tests/Resources/BLACKSKY/Global/MetadataExtractorsTests_BSG-102-20240320-024025-217335171_ortho-pan.json @@ -1,7 +1,9 @@ { "stac_version": "1.0.0", "stac_extensions": [ - "https://stac-extensions.github.io/processing/v1.0.0/schema.json" + "https://stac-extensions.github.io/eo/v1.0.0/schema.json", + "https://stac-extensions.github.io/processing/v1.0.0/schema.json", + "https://stac-extensions.github.io/raster/v1.0.0/schema.json" ], "type": "Feature", "id": "BSG-102-20240320-024025-217335171_ortho-pan", @@ -46,6 +48,14 @@ "gsd": 1.0, "title": "BLACKSY GLOBAL-1 GEO MS", "processing:level": "GEO", + "eo:bands": [ + { + "name": "pan", + "common_name": "pan", + "center_wavelength": 0.575, + "full_width_half_max": 0.25 + } + ], "providers": [ { "name": "BlackSky", @@ -75,6 +85,31 @@ "href": "data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_DG000000001.txt", "filename": "BS01N47_769636E107_2567602024032000000000MS03_DG000000001.txt", "file:size": 1963 + }, + "ORTHO_PAN": { + "type": "image/tiff; application=geotiff", + "roles": [ + "data" + ], + "title": "PAN image", + "href": "data/BSG-102-20240320-024025-217335171_ortho-pan/BS01N47_769636E107_2567602024032000000000MS03_GG000000001.tif", + "filename": "BS01N47_769636E107_2567602024032000000000MS03_GG000000001.tif", + "file:size": 0, + "gsd": 1.0, + "eo:bands": [ + { + "name": "pan", + "common_name": "pan", + "center_wavelength": 0.575, + "full_width_half_max": 0.25 + } + ], + "raster:bands": [ + { + "data_type": "uint16", + "bits_per_sample": 12 + } + ] } }, "links": []