From 1e5e26e4d5b66eeb3200fad135030598dfcfc610 Mon Sep 17 00:00:00 2001 From: Jan Van den bosch Date: Thu, 25 May 2023 14:16:59 +0200 Subject: [PATCH] support collections that return root catalog with trailing slash Otherwise you get a 404 on e.g. https://landsatlook.usgs.gov/stac-server//search?collections=landsat-c2l2-sr&limit=100&bbox=-87.83488652056919%2C42.57816424833807%2C-87.80864005698832%2C42.59122817379843&page=1&datetime=2022-05-20T00%3A00%3A00Z%2F2022-05-20T23%3A59%3A59.999999999Z https://github.com/Open-EO/openeo-geopyspark-driver/issues/402 --- .../scala/org/openeo/opensearch/backends/STACClient.scala | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/scala/org/openeo/opensearch/backends/STACClient.scala b/src/main/scala/org/openeo/opensearch/backends/STACClient.scala index dfac9c3a..28df093a 100644 --- a/src/main/scala/org/openeo/opensearch/backends/STACClient.scala +++ b/src/main/scala/org/openeo/opensearch/backends/STACClient.scala @@ -5,7 +5,7 @@ import org.openeo.opensearch.OpenSearchResponses.{Feature, FeatureCollection, ST import geotrellis.proj4.LatLng import geotrellis.vector.{Extent, ProjectedExtent} -import java.net.URL +import java.net.{URI, URL} import java.time.ZonedDateTime import java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME import scala.collection.Map @@ -22,7 +22,6 @@ import scala.collection.Map */ class STACClient(private val endpoint: URL = new URL("https://earth-search.aws.element84.com/v0"), private val s3URLS: Boolean = true) extends OpenSearchClient { - override def getProducts(collectionId: String, dateRange: Option[(ZonedDateTime, ZonedDateTime)], bbox: ProjectedExtent, @@ -53,7 +52,7 @@ class STACClient(private val endpoint: URL = new URL("https://earth-search.aws.e (collectionId, Array(xMin, yMin, xMax, yMax) mkString ",") // fixed path according to https://github.com/radiantearth/stac-api-spec/tree/main/item-search - val getProducts = http(s"$endpoint/search") + val getProducts = http(URI.create(s"$endpoint/search").normalize().toString) .param("collections", collectionsParam) .param("limit", "100") .param("bbox", bboxParam) @@ -74,7 +73,7 @@ class STACClient(private val endpoint: URL = new URL("https://earth-search.aws.e override def getCollections(correlationId: String = ""): Seq[Feature] = { // fixed path according to https://github.com/radiantearth/stac-api-spec/tree/main/ogcapi-features - val getCollections = http(s"$endpoint/collections") + val getCollections = http(URI.create(s"$endpoint/collections").normalize().toString) val json = withRetries { execute(getCollections)