Skip to content

Commit

Permalink
Merge branch 'release/2.16.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Sep 22, 2023
2 parents 356813c + db0ed43 commit d26682b
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@
// "--nocopy-cog",
"--output",
"/tmp/stars",
"https://earth-search.aws.element84.com/v0/collections/sentinel-s2-l2a-cogs/items/S2B_36RTT_20191205_0_L2A"
"https://earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2A_17UNQ_20230511_0_L2A"
],
"cwd": "${workspaceFolder}/src",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

## [2.15.5](https://github.com/Terradue/Stars/compare/2.15.4...2.15.5)
## [2.16.0](https://github.com/Terradue/Stars/compare/2.15.5...2.16.0)

Image overlay offering for collection atom publication

### Merged

- Image overlay offering for collection atom publication [`#29`](https://github.com/Terradue/Stars/pull/29)

### Commits

- offering link mapper support [`d6ed64d`](https://github.com/Terradue/Stars/commit/d6ed64db2e450031b3c0f542881b9d03897dd275)

## [2.15.5](https://github.com/Terradue/Stars/compare/2.15.4...2.15.5) - 2023-09-01

### Commits

Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Console/Terradue.Stars.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<Version>2.15.5</Version>
<Version>2.16.0</Version>
<!-- <VersionSuffix>beta.8</VersionSuffix> -->
<Description>Stars is a CLI for working with Spatio Temporal Catalog such as STAC but not only</Description>
<Version Condition=" '$(VersionSuffix)' != '' ">$(Version)-$(VersionSuffix)</Version>
Expand Down
45 changes: 45 additions & 0 deletions src/Stars.Data/Model/Atom/StarsAtomItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,35 @@ public bool AddImageOverlayOffering(StacItemNode stacItemNode)
return false;
}

public bool AddImageOverlayOffering(StacCollectionNode stacCollectionNode)
{
var imageOverview = SelectOverlayOverviewAssets(stacCollectionNode.StacCollection).FirstOrDefault();
if (imageOverview.Key != null)
{
Uri assetUri = imageOverview.Value.Uri;
try
{
// if relative
if (!assetUri.IsAbsoluteUri)
// then make absolute from item
assetUri = new Uri(stacCollectionNode.Uri, assetUri);
}
catch { return false; }
ElementExtensions.Add(new OwcOffering()
{

Contents = new OwcContent[]{new OwcContent()
{
Url = assetUri,
Type = imageOverview.Value.MediaType.ToString()
}},
Code = "http://www.opengis.net/spec/owc-atom/1.0/req/img"
}.CreateReader());
return true;
}
return false;
}

public bool TryAddEGMSOffering(StacCollectionNode stacCollectionNode, EgmsService egmsService)
{
var egmsServiceUri = stacCollectionNode.StacCollection.Links.FirstOrDefault(l => l.RelationshipType == "self").Uri;
Expand Down Expand Up @@ -508,6 +537,22 @@ private static Dictionary<string, StacAsset> SelectOverlayOverviewAssets(StacIte
return new Dictionary<string, StacAsset>();
}

private static Dictionary<string, StacAsset> SelectOverlayOverviewAssets(StacCollection stacCollection)
{

Dictionary<string, StacAsset> overviewAssets = stacCollection.Assets
.Where(a => a.Value.Roles.Contains("overview") ||
a.Value.Roles.Contains("visual"))
.OrderBy(a => a.Value.GetProperty<long>("size"))
.Where(a => a.Value.MediaType.MediaType.StartsWith("image/") &&
a.Value.FileExtension().Size < 20971520)
.Take(1)
.ToDictionary(a => a.Key, a => a.Value);
if (overviewAssets.Count == 1) return overviewAssets;

return new Dictionary<string, StacAsset>();
}

SyndicationElementExtension earthObservationExtension = null;

public SyndicationElementExtension EarthObservationExtension
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Data/Terradue.Stars.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ProjectName>Terradue.Stars.Data</ProjectName>
<Title>Terradue.Stars.Data</Title>
<Description>Collection of data Plugins for Terradue.Stars</Description>
<Version>2.15.5</Version>
<Version>2.16.0</Version>
<!-- <VersionSuffix>beta.8</VersionSuffix> -->
<Version Condition=" '$(VersionSuffix)' != '' ">$(Version)-$(VersionSuffix)</Version>
<NoWarn>NU1603</NoWarn>
Expand Down
20 changes: 20 additions & 0 deletions src/Stars.Data/ThirdParty/Publication/GeosquareService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Terradue.Stars.Services.Model;
using System.Collections.Specialized;
using System.Web;
using Terradue.ServiceModel.Ogc.Owc.AtomEncoding;

namespace Terradue.Stars.Data.ThirdParty.Geosquare
{
Expand Down Expand Up @@ -207,6 +208,25 @@ public async Task PrepareAtomItem(AtomItem atomItem, GeosquarePublicationState g
link.Uri = geosquareConfiguration.MapUri(link.Uri);
geosquarePublicationState.GeosquarePublicationModel.UpdateLink(link, atomItem, assetsContainer);
}
foreach (var extension in atomItem.ElementExtensions.ToArray())
{
if (extension.OuterName == "offering" && extension.OuterNamespace == OwcNamespaces.Owc)
{
var xml = extension.GetReader().ReadOuterXml();
var offering = OwcContextHelper.OwcOfferingSerializer.Deserialize(new System.IO.StringReader(xml)) as OwcOffering;
atomItem.ElementExtensions.Remove(extension);
foreach (var content in offering.Contents)
{
SyndicationLink link = new SyndicationLink(content.Url, "enclosure", "", content.Type, 0);
geosquarePublicationState.GeosquarePublicationModel.UpdateLink(link, atomItem, assetsContainer);
content.Url = geosquareConfiguration.MapUri(link.Uri);
}
atomItem.ElementExtensions.Add(offering.CreateReader());
}
}

atomItem.ElementExtensions.ReadElementExtensions<OwcOffering>("offering", OwcNamespaces.Owc, new System.Xml.Serialization.XmlSerializer(typeof(OwcOffering)));


// create eventual opensearch link
if (atomItem is StarsAtomItem)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using Terradue.Stars.Interface.Router.Translator;
using Terradue.Stars.Services.Model.Atom;
using Stac;
Expand Down Expand Up @@ -71,10 +71,15 @@ private StarsAtomItem CreateAtomItem(StacCollectionNode stacCollectionNode)
if (link.RelationshipType == "wms" && link.Uri != null)
{
atomItem.AddWMSOffering(link);
imageOfferingSet = true;
}
}
}

// if no previous image offering set, then let's try a simple overlay offering
if (!imageOfferingSet)
atomItem.AddImageOverlayOffering(stacCollectionNode);

return atomItem;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Data/Translators/StacItemToAtomItemTranslator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using Terradue.Stars.Interface.Router.Translator;
using Terradue.Stars.Services.Model.Atom;
using Stac;
Expand Down
7 changes: 6 additions & 1 deletion src/Stars.Services/Model/Stac/StacRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ private async Task<IResource> AffineRouteAsync(IResource route, CancellationToke
public async Task<IResource> RouteAsync(IResource route, CancellationToken ct)
{
var routeFound = await AffineRouteAsync(route, ct);
if (routeFound is StacCollectionNode)
return routeFound as StacCollectionNode;
if (routeFound is StacCatalogNode)
return routeFound as StacCatalogNode;
if (routeFound is StacItemNode)
Expand All @@ -106,8 +108,11 @@ public async Task<IResource> RouteAsync(IResource route, CancellationToken ct)
{
var json = await (routeFound as IStreamResource).ReadAsStringAsync(ct);
IStacObject stacObject = StacConvert.Deserialize<IStacObject>(json);
if (stacObject is IStacCatalog)
if (stacObject is IStacCatalog){
if (stacObject is StacCollection)
return new StacCollectionNode(stacObject as StacCollection, routeFound.Uri);
return new StacCatalogNode(stacObject as IStacCatalog, routeFound.Uri);
}
else
return new StacItemNode(stacObject as StacItem, routeFound.Uri);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Services/Terradue.Stars.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Title>Terradue.Stars</Title>
<Description>Stars is a set of services for working with Spatio Temporal Catalog such as STAC but not only</Description>
<Version>2.15.5</Version>
<Version>2.16.0</Version>
<!-- <VersionSuffix>beta.8</VersionSuffix> -->
<Version Condition=" '$(VersionSuffix)' != '' ">$(Version)-$(VersionSuffix)</Version>
<AssemblyName>Terradue.Stars.Services</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Tests/S3Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public async Task ImportHttpStreamabletoS3()
S3Resource s3Route = await s3ClientFactory.CreateAsync(S3Url.Parse("s3://local-http/S2B_MSIL2A_20211022T045839_N0301_R119_T44NLN_20211022T071547.jpg"));
BlockingStream stream = new BlockingStream(0, 100);
S3StreamingCarrier s3StreamingCarrier = serviceProvider.GetRequiredService<S3StreamingCarrier>();
var httpRoute = await resourceServiceProvider.CreateStreamResourceAsync(new GenericResource(new Uri("https://store.terradue.com/api/scihub/sentinel2/S2MSI2A/2021/10/22/quicklooks/v1/S2B_MSIL2A_20211022T045839_N0301_R119_T44NLN_20211022T071547.jpg")), CancellationToken.None);
var httpRoute = await resourceServiceProvider.CreateStreamResourceAsync(new GenericResource(new Uri("https://store.terradue.com/scihub/sentinel2/S2MSI2A/2023/09/17/quicklooks/v1/S2A_MSIL2A_20230917T100031_N0509_R122_T32TQM_20230917T143103.jpg")), CancellationToken.None);
var newRoute = await s3StreamingCarrier.StreamToS3Object(httpRoute, s3Route, CancellationToken.None);
var metadata = await s3Route.Client.GetObjectMetadataAsync(s3Route.S3Uri.Bucket, s3Route.S3Uri.Key);
Assert.Equal(httpRoute.ContentLength, Convert.ToUInt64(metadata.ContentLength));
Expand Down

0 comments on commit d26682b

Please sign in to comment.