Skip to content

Commit

Permalink
ESACPE-1695 PNEO: include all spectral processings in the title
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrauzzi committed Sep 27, 2023
1 parent b7c79a1 commit ebe2ef8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
],
"sensor_type": "optical",
"gsd": 1.34,
"title": "PNEO4 MS-FS ORTHO 2021-11-15 13:58:30",
"title": "PNEO4 PAN MS-FS ORTHO 2021-11-15 13:58:30",
"sat:platform_international_designator": "2021-073E",
"proj:epsg": 32622,
"proj:shape": [
Expand Down
33 changes: 32 additions & 1 deletion src/Stars.Data/Model/Metadata/Airbus/AirbusMetadataExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ protected override async Task<StacNode> ExtractMetadata(IItem item, string suffi
{
var metadataAssets = GetMetadataAssets(item);
List<StacItemNode> stacItemNodes = new List<StacItemNode>();

List<AirbusProfiler> dimapProfilers = new List<AirbusProfiler>();

foreach (var metadataAsset in metadataAssets)
{
Dimap_Document metadata = await ReadMetadata(metadataAsset.Value);
AirbusProfiler dimapProfiler = GetProfiler(metadata);
dimapProfilers.Add(dimapProfiler);

if (dimapProfiler is VolumeDimapProfiler)
{
Expand All @@ -104,6 +106,14 @@ protected override async Task<StacNode> ExtractMetadata(IItem item, string suffi
{
baseNode.StacItem.Assets.AddRange(n.StacItem.Assets);
}

// Custom title for PNEO with multiple spectral processings
// the second element of the title must contain all spectral processings
// eg. PNEO4 MS-FS PAN ORTHO 2021-11-15 13:58:30
if( dimapProfilers.Count > 1 && dimapProfilers[0].GetPlatform().Contains("PNEO")) {
string title = GetPNEOTitle(dimapProfilers, baseNode);
baseNode.StacItem.Title = title;
}

return baseNode;

Expand Down Expand Up @@ -136,6 +146,27 @@ protected override async Task<StacNode> ExtractMetadata(IItem item, string suffi
return StacCatalogNode.Create(catalog, item.Uri);*/
}

private string GetPNEOTitle(List<AirbusProfiler> profilers, StacItemNode baseNode)
{
// from each item, get the spectral processing and put it in a list
var spectralProcesses = profilers.Select(profiler => profiler.Dimap.Processing_Information.Product_Settings.SPECTRAL_PROCESSING.ToUpper())
.ToList();

// check if PAN is present and move it to the first position
spectralProcesses.Remove("PAN");
spectralProcesses.Insert(0, "PAN");

// join the list into a string
string spectralProcessesString = string.Join(" ", spectralProcesses);

CultureInfo culture = new CultureInfo("fr-FR");
return string.Format("{0} {1} {2} {3}",
profilers[0].GetPlatform().ToUpper(),
spectralProcessesString,
profilers[0].GetProcessingLevel(),
baseNode.StacItem.Properties.GetProperty<DateTime>("datetime").ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss", culture));
}

internal StacItemNode ExtractMetadata(IItem item,
AirbusProfiler dimapProfiler,
IAsset metadataAsset,
Expand Down

0 comments on commit ebe2ef8

Please sign in to comment.