Skip to content

Commit

Permalink
support GLOBAL-MOSAICS/Sentinel 1 collection
Browse files Browse the repository at this point in the history
  • Loading branch information
bossie authored Aug 23, 2024
1 parent 49af490 commit 2db5786
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.openeo</groupId>
<artifactId>openeo-opensearch-client</artifactId>
<version>1.3.1_2.12-SNAPSHOT</version>
<version>1.4.0_2.12-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
12 changes: 12 additions & 0 deletions src/main/scala/org/openeo/opensearch/OpenSearchResponses.scala
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,16 @@ object OpenSearchResponses {
suffixes.map(s=>Link(URI.create(s"${getGDALPrefix(path)}$path/${prefix}_$s.tif"),Some(s)))
}

private def getGlobalMosaicsSentinel1FilePaths(path: String): Seq[Link] = {
val bandNames =
if (path contains "_IW_") Seq("VH", "VV")
else if (path contains "_DH_") Seq("HH", "HV")
else throw new IllegalArgumentException(path)

bandNames
.map(bandName => Link(URI.create(s"${getGDALPrefix(path)}$path/$bandName.tif"), title = Some(bandName)))
}

private def ensureValidGeometry(geometry: Json): Json = {
// TODO: This is required because the old Creodias API can return incorrect MultiPolygon geometries.
// This can be removed once the API is fixed.
Expand Down Expand Up @@ -834,6 +844,8 @@ object OpenSearchResponses {
getLandsat8FilePaths(path = f.id).toArray
} else if (f.id.startsWith("/eodata/Sentinel-1-RTC")) {
getSentinel1RTCFilePaths(path = f.id).toArray
} else if (f.id.startsWith("/eodata/Global-Mosaics/Sentinel-1")) {
getGlobalMosaicsSentinel1FilePaths(path = f.id).toArray
} else {
f.links
}
Expand Down
137 changes: 137 additions & 0 deletions src/test/resources/org/openeo/creodiasGlobalMosaicsSentinel1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"type": "FeatureCollection",
"properties": {
"id": "4126eeb8-956b-5bd0-b6d8-99cf088365fb",
"totalResults": null,
"exactCount": 0,
"startIndex": 1,
"itemsPerPage": 1000,
"query": {
"originalFilters": {
"box": "116.56784977351838,33.818177847881614,116.67755861181377,33.88958185515551",
"status": "ONLINE",
"dataset": "ESA-DATASET",
"platform": "SENTINEL-1",
"startDate": "2023-09-01T00:00:00Z",
"completionDate": "2024-10-01T00:00:00Z",
"collection": "GLOBAL-MOSAICS"
},
"appliedFilters": {
"box": "116.56784977351838,33.818177847881614,116.67755861181377,33.88958185515551",
"status": "ONLINE",
"dataset": "ESA-DATASET",
"platform": "SENTINEL-1",
"startDate": "2023-09-01T00:00:00Z",
"completionDate": "2024-10-01T00:00:00Z",
"collection": "GLOBAL-MOSAICS"
},
"processingTime": 0.812684961
},
"links": [
{
"rel": "self",
"type": "application/json",
"title": "self",
"href": "https://catalogue.dataspace.copernicus.eu/resto/api/collections/GLOBAL-MOSAICS/search.json?box=116.56784977351838%2C33.818177847881614%2C116.67755861181377%2C33.88958185515551&page=1&maxRecords=1000&status=ONLINE&dataset=ESA-DATASET&platform=SENTINEL-1&startDate=2023-09-01T00%3A00%3A00Z&completionDate=2024-10-01T00%3A00%3A00Z"
},
{
"rel": "search",
"type": "application/opensearchdescription+xml",
"title": "OpenSearch Description Document",
"href": "https://catalogue.dataspace.copernicus.eu/resto/api/collections/GLOBAL-MOSAICS/describe.xml"
}
]
},
"features": [
{
"type": "Feature",
"id": "e605002a-63a5-49ca-9abf-7e65c6d94f6a",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
115.923810175081,
33.4343643656752
],
[
115.912416716213,
34.3368332245052
],
[
117.000434893879,
34.3416634578714
],
[
117.000430336879,
33.4390338814186
],
[
115.923810175081,
33.4343643656752
]
]
]
},
"properties": {
"collection": "GLOBAL-MOSAICS",
"status": "ONLINE",
"license": {
"licenseId": "unlicensed",
"hasToBeSigned": "never",
"grantedCountries": null,
"grantedOrganizationCountries": null,
"grantedFlags": null,
"viewService": "public",
"signatureQuota": -1,
"description": {
"shortName": "No license"
}
},
"parentIdentifier": null,
"title": "Sentinel-1_IW_mosaic_2023_M12_50SMC_0_0",
"description": null,
"organisationName": null,
"startDate": "2023-12-01T00:00:00.000Z",
"completionDate": "2023-12-31T23:59:59.000Z",
"productType": "S1SAR_L3_IW_MCM",
"processingLevel": null,
"platform": "SENTINEL-1",
"instrument": null,
"resolution": 0,
"sensorMode": null,
"orbitNumber": 0,
"quicklook": null,
"thumbnail": null,
"updated": "2024-06-19T03:28:32.729Z",
"published": "2024-06-19T03:28:32.729Z",
"snowCover": 0,
"cloudCover": 0,
"gmlgeometry": "<gml:Polygon srsName=\"EPSG:4326\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>115.923810175081,33.4343643656752 115.912416716213,34.3368332245052 117.000434893879,34.3416634578714 117.000430336879,33.4390338814186 115.923810175081,33.4343643656752</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>",
"centroid": {
"type": "Point",
"coordinates": [
116.459279094554,
33.8887658994282
]
},
"productIdentifier": "/eodata/Global-Mosaics/Sentinel-1/S1SAR_L3_IW_MCM/2023/12/01/Sentinel-1_IW_mosaic_2023_M12_50SMC_0_0",
"services": {
"download": {
"url": "https://catalogue.dataspace.copernicus.eu/download/e605002a-63a5-49ca-9abf-7e65c6d94f6a",
"mimeType": "application/octet-stream",
"size": -1
}
},
"links": [
{
"rel": "self",
"type": "application/json",
"title": "GeoJSON link for e605002a-63a5-49ca-9abf-7e65c6d94f6a",
"href": "https://catalogue.dataspace.copernicus.eu/resto/collections/GLOBAL-MOSAICS/e605002a-63a5-49ca-9abf-7e65c6d94f6a.json"
}
]
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,23 @@ class CreoFeatureCollectionTest {
assertTrue(featureIds.forall(_.startsWith("/eodata/Sentinel-2")), "unexpected product identifiers")
assertFalse(featureIds contains corruptTileProductIdentifier, "corrupt tile is still present")
}

@Test
def globalMosaicsSentinel1Response(): Unit = {
val productsResponse = loadJsonResource("creodiasGlobalMosaicsSentinel1.json")

val FeatureCollection(_, features) = CreoFeatureCollection.parse(productsResponse, dedup = true)

val titledHrefs = for {
feature <- features
link <- feature.links
} yield (link.title, link.href.toString)

val expected = Set(
(Some("VV"), "/eodata/Global-Mosaics/Sentinel-1/S1SAR_L3_IW_MCM/2023/12/01/Sentinel-1_IW_mosaic_2023_M12_50SMC_0_0/VV.tif"),
(Some("VH"), "/eodata/Global-Mosaics/Sentinel-1/S1SAR_L3_IW_MCM/2023/12/01/Sentinel-1_IW_mosaic_2023_M12_50SMC_0_0/VH.tif"),
)

assertEquals(expected, titledHrefs.toSet)
}
}

0 comments on commit 2db5786

Please sign in to comment.