From 259fcc9c5c1279cb7e44538c0c2416966174d0da Mon Sep 17 00:00:00 2001 From: floeschau Date: Wed, 6 Dec 2023 17:21:09 +0000 Subject: [PATCH] Fixed (unrelated) NewSat extractor bug --- ...ctorsTests_20231030_200817_SN29_L1_SR.json | 544 ++++++++++++++++++ .../NewSat/NewSatMetadataExtractor.cs | 14 +- 2 files changed, 554 insertions(+), 4 deletions(-) create mode 100644 src/Stars.Data.Tests/Resources/SATELLOGIC/NEWSAT/MetadataExtractorsTests_20231030_200817_SN29_L1_SR.json diff --git a/src/Stars.Data.Tests/Resources/SATELLOGIC/NEWSAT/MetadataExtractorsTests_20231030_200817_SN29_L1_SR.json b/src/Stars.Data.Tests/Resources/SATELLOGIC/NEWSAT/MetadataExtractorsTests_20231030_200817_SN29_L1_SR.json new file mode 100644 index 00000000..f3c63340 --- /dev/null +++ b/src/Stars.Data.Tests/Resources/SATELLOGIC/NEWSAT/MetadataExtractorsTests_20231030_200817_SN29_L1_SR.json @@ -0,0 +1,544 @@ +{ + "stac_version": "1.0.0", + "stac_extensions": [ + "https://stac-extensions.github.io/eo/v1.0.0/schema.json", + "https://stac-extensions.github.io/eo/v1.1.0/schema.json", + "https://stac-extensions.github.io/projection/v1.1.0/schema.json", + "https://stac-extensions.github.io/view/v1.0.0/schema.json" + ], + "type": "Feature", + "id": "20231030_200817_SN29_L1_SR", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -99.93470881082585, + 16.811541443165122 + ], + [ + -99.9347272336818, + 16.811542232809916 + ], + [ + -99.93474548715189, + 16.811544760031037 + ], + [ + -99.93476339501291, + 16.811549000430055 + ], + [ + -99.93478078437825, + 16.81155491306919 + ], + [ + -99.9347974873669, + 16.811562440866417 + ], + [ + -99.93481334272427, + 16.81157151114662 + ], + [ + -99.93482819737895, + 16.81158203634319 + ], + [ + -99.93484190792044, + 16.81159391484338 + ], + [ + -99.93485434198374, + 16.81160703196934 + ], + [ + -99.93486537952718, + 16.811621261085218 + ], + [ + -99.93487491399138, + 16.8116364648197 + ], + [ + -99.93488285332796, + 16.811652496392245 + ], + [ + -99.93488912088823, + 16.81166920103015 + ], + [ + -99.93489365616317, + 16.81168641746272 + ], + [ + -99.93489641536765, + 16.81170397947823 + ], + [ + -99.93489737186313, + 16.81172171752856 + ], + [ + -99.93489651641485, + 16.811739460366073 + ], + [ + -99.93489385728104, + 16.811757036696864 + ], + [ + -99.91644692200495, + 16.902224832024498 + ], + [ + -99.916442496803, + 16.902242022769297 + ], + [ + -99.9164363454607, + 16.90225871412815 + ], + [ + -99.91642852702275, + 16.902274745884792 + ], + [ + -99.91641911653608, + 16.9022899641543 + ], + [ + -99.91640820432927, + 16.902304222860167 + ], + [ + -99.91639589514568, + 16.90231738513646 + ], + [ + -99.91638230713794, + 16.902329324641606 + ], + [ + -99.9163675707339, + 16.902339926771074 + ], + [ + -99.91635182738473, + 16.902349089757465 + ], + [ + -99.91633522820702, + 16.90235672564741 + ], + [ + -99.91631793253237, + 16.902362761145707 + ], + [ + -99.91630010637796, + 16.90236713831897 + ], + [ + -99.91628192085295, + 16.902369815151694 + ], + [ + -99.91626355051605, + 16.902370765949538 + ], + [ + -99.86406795878128, + 16.902600501277348 + ], + [ + -99.86404946112604, + 16.90259970144793 + ], + [ + -99.86403113522755, + 16.902597151655996 + ], + [ + -99.86401315927831, + 16.902592876694502 + ], + [ + -99.86399570806809, + 16.90258691813117 + ], + [ + -99.8639789512843, + 16.902579333904285 + ], + [ + -99.86396305186204, + 16.902570197759307 + ], + [ + -99.86394816439976, + 16.902559598531834 + ], + [ + -99.86393443365597, + 16.902547639283767 + ], + [ + -99.86392199314177, + 16.902534436301213 + ], + [ + -99.86391096382262, + 16.902520117963725 + ], + [ + -99.86390145294205, + 16.902504823496034 + ], + [ + -99.86389355297895, + 16.902488701614246 + ], + [ + -99.86388734074843, + 16.902471909079843 + ], + [ + -99.86388287665476, + 16.902454609175344 + ], + [ + -99.86388020410413, + 16.902436970116664 + ], + [ + -99.86387934908267, + 16.902419163417438 + ], + [ + -99.86388031990363, + 16.902401362221323 + ], + [ + -99.86388310712678, + 16.90238373961839 + ], + [ + -99.88296660715089, + 16.811911991825397 + ], + [ + -99.88297112086238, + 16.81189490440982 + ], + [ + -99.88297734138811, + 16.81187832179625 + ], + [ + -99.88298520955168, + 16.811862401735482 + ], + [ + -99.88299465050264, + 16.811847295675356 + ], + [ + -99.88300557442872, + 16.811833147320105 + ], + [ + -99.88301787741007, + 16.811820091263233 + ], + [ + -99.88303144240801, + 16.811808251707184 + ], + [ + -99.88304614037834, + 16.811797741281772 + ], + [ + -99.88306183149889, + 16.81178865997278 + ], + [ + -99.88307836649982, + 16.811781094170744 + ], + [ + -99.88309558808342, + 16.811775115849183 + ], + [ + -99.88311333242062, + 16.81177078187988 + ], + [ + -99.88313143070941, + 16.811768133491885 + ], + [ + -99.88314971078071, + 16.811767195879312 + ], + [ + -99.93470881082585, + 16.811541443165122 + ] + ] + ] + }, + "properties": { + "title": "NEWSAT MS L1 2023-10-30 20:08:17", + "description": "scene_set_id: 27b30afd-1c9a-4580-846c-7fe1ab55b46a--179598", + "datetime": "2023-10-30T20:08:17.595251Z", + "processing:level": "l1", + "mission": "NewSat", + "providers": [ + { + "name": "Satellogic", + "description": "High-resolution geospatial imagery and analytics", + "roles": [ + "producer", + "processor" + ], + "url": "https://satellogic.com/" + } + ], + "platform": "NewSat", + "instruments": [ + "MS" + ], + "constellation": "Aleph1", + "gsd": 0.7, + "eo:cloud_cover": 0.08, + "proj:epsg": 32614, + "proj:centroid": { + "lat": 0.0, + "lon": 0.0 + }, + "view:sun_elevation": 48.598335413432935, + "view:off_nadir": 4.411399791891043, + "satl:exposure_sec": 0.0015876999999999998, + "satl:type": "stripes", + "satl:sat_id": "SN29", + "satl:product_level": "L1 TOA Reflectance SR" + }, + "bbox": [ + -99.93489737186313, + 16.811541443165122, + -99.86387934908267, + 16.902600501277348 + ], + "assets": { + "analytic": { + "type": "application/xml", + "roles": [ + "data", + "reflectance" + ], + "title": "4-Band Analytic", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/rasters/20231030_200817_SN29_L1_SR_MS_0.tif", + "eo:bands": [ + { + "name": "band1", + "common_name": "blue", + "center_wavelength": 0.48, + "full_width_half_max": 0.06 + }, + { + "name": "band2", + "common_name": "green", + "center_wavelength": 0.545, + "full_width_half_max": 0.07 + }, + { + "name": "band3", + "common_name": "red", + "center_wavelength": 0.64, + "full_width_half_max": 0.1 + }, + { + "name": "band4", + "common_name": "nir", + "center_wavelength": 0.825, + "full_width_half_max": 0.15 + } + ], + "filename": "20231030_200817_SN29_L1_SR_MS_0.tif" + }, + "visual": { + "roles": [ + "data" + ], + "title": "3-Band Visual", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/rasters/20231030_200817_SN29_L3_SR_MS_0.tif", + "eo:bands": [ + { + "name": "band1", + "common_name": "blue", + "center_wavelength": 0.48, + "full_width_half_max": 0.06 + }, + { + "name": "band2", + "common_name": "green", + "center_wavelength": 0.545, + "full_width_half_max": 0.07 + }, + { + "name": "band3", + "common_name": "red", + "center_wavelength": 0.64, + "full_width_half_max": 0.1 + } + ], + "filename": "20231030_200817_SN29_L3_SR_MS_0.tif" + }, + "thumbnail": { + "type": "image/png", + "roles": [ + "thumbnail" + ], + "title": "Thumbnail", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/20231030_200817_SN29_L3_SR_MS_thumbnail.png", + "filename": "20231030_200817_SN29_L3_SR_MS_thumbnail.png" + }, + "preview": { + "type": "image/png", + "roles": [ + "preview" + ], + "title": "Preview", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/20231030_200817_SN29_L3_SR_MS_preview.png", + "filename": "20231030_200817_SN29_L3_SR_MS_preview.png" + }, + "cloud_mask": { + "type": "image/tif", + "roles": [ + "cloud_mask" + ], + "title": "Cloud Mask", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/rasters/20231030_200817_SN29_L1_SR_MS_cloud_mask_0.tif", + "filename": "20231030_200817_SN29_L1_SR_MS_cloud_mask_0.tif" + }, + "geojson-metadata": { + "type": "application/geojson", + "roles": [ + "metadata" + ], + "title": "Extended STAC Metadata", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/20231030_200817_SN29_L1_SR_MS_metadata_stac.geojson", + "filename": "20231030_200817_SN29_L1_SR_MS_metadata_stac.geojson" + }, + "xml-metadata": { + "type": "application/xml", + "roles": [ + "metadata" + ], + "title": "Extended ISO Metadata", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/20231030_200817_SN29_L1_SR_MS_metadata_iso.xml", + "filename": "20231030_200817_SN29_L1_SR_MS_metadata_iso.xml" + }, + "footprint": { + "type": "footprint/kml", + "roles": [ + "footprint" + ], + "title": "Footprint", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/20231030_200817_SN29_L1_SR_MS_footprint.kml", + "filename": "20231030_200817_SN29_L1_SR_MS_footprint.kml" + }, + "toa-factors": { + "type": "application/geojson", + "roles": [ + "metadata" + ], + "title": "TOA factors", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/20231030_200817_SN29_L1_SR_MS_toa_factors.json", + "filename": "20231030_200817_SN29_L1_SR_MS_toa_factors.json" + }, + "solar-and-viewing-angles": { + "type": "application/geojson", + "roles": [ + "metadata" + ], + "title": "Solar and viewing angles", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/20231030_200817_SN29_L1_SR_MS_solar_and_viewing_angles.geojson", + "filename": "20231030_200817_SN29_L1_SR_MS_solar_and_viewing_angles.geojson" + }, + "analytic_0": { + "type": "image/tiff", + "roles": [], + "title": "4-Band Analytic chunk 0", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/rasters/20231030_200817_SN29_L1_SR_MS_0.tif", + "eo:bands": [ + { + "name": "band1", + "common_name": "blue", + "center_wavelength": 480, + "full_width_half_max": 60 + }, + { + "name": "band2", + "common_name": "green", + "center_wavelength": 545, + "full_width_half_max": 70 + }, + { + "name": "band3", + "common_name": "red", + "center_wavelength": 640, + "full_width_half_max": 100 + }, + { + "name": "band4", + "common_name": "nir", + "center_wavelength": 825, + "full_width_half_max": 150 + } + ], + "filename": "20231030_200817_SN29_L1_SR_MS_0.tif" + }, + "quicklook_0": { + "type": "image/tiff", + "roles": [], + "title": "3-Band RGB chunk 0", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/rasters/20231030_200817_SN29_L3_SR_MS_0.tif", + "eo:bands": [ + { + "name": "band1", + "common_name": "red" + }, + { + "name": "band2", + "common_name": "green" + }, + { + "name": "band3", + "common_name": "blue" + } + ], + "filename": "20231030_200817_SN29_L3_SR_MS_0.tif" + }, + "cloud_mask_0": { + "type": "image/tiff", + "roles": [ + "cloud_mask" + ], + "title": "Cloud Mask chunk 0", + "href": "data/Landslide_Storm_Hurricane_in_Mexico_6-product/rasters/20231030_200817_SN29_L1_SR_MS_cloud_mask_0.tif", + "filename": "20231030_200817_SN29_L1_SR_MS_cloud_mask_0.tif" + } + }, + "links": [ + { + "type": "text/html", + "rel": "license", + "href": "https://satellogic.com/license-agreement/" + } + ] +} \ No newline at end of file diff --git a/src/Stars.Data/Model/Metadata/NewSat/NewSatMetadataExtractor.cs b/src/Stars.Data/Model/Metadata/NewSat/NewSatMetadataExtractor.cs index 8d382cbb..90ea126e 100644 --- a/src/Stars.Data/Model/Metadata/NewSat/NewSatMetadataExtractor.cs +++ b/src/Stars.Data/Model/Metadata/NewSat/NewSatMetadataExtractor.cs @@ -113,9 +113,15 @@ private static async Task DeserializeProductMetadata(IStreamResource g // before deserializing we modify the instruments type from string to array of strings dynamic featureCollection = JsonConvert.DeserializeObject(json); - string instruments = featureCollection.features[0].properties.instruments; - featureCollection.features[0].properties.instruments = new JArray() as dynamic; - featureCollection.features[0].properties.instruments.Add(instruments.ToLower()); + + // Transform instrument into array if it is a string + if (featureCollection.features[0].properties.instruments is JValue) + { + string instruments = featureCollection.features[0].properties.instruments; + + featureCollection.features[0].properties.instruments = new JArray() as dynamic; + featureCollection.features[0].properties.instruments.Add(instruments.ToLower()); + } // retrieving first statItem of the collection string featureJson = featureCollection.features[0].ToString(); @@ -165,7 +171,7 @@ private void FillGsdProperty(StacItem stacItem) { string itemId = stacItem.Id; string resolution = itemId.Split('_')[4].ToLower(); if (resolution.Equals("sr")) { - stacItem.Gsd = 0.7; + stacItem.Gsd = 0.7; } else { stacItem.Gsd = 1; }