Skip to content

Commit

Permalink
load_stac: support withGeometryFromWkt
Browse files Browse the repository at this point in the history
  • Loading branch information
bossie committed May 28, 2024
1 parent 6e6de2c commit 755e7d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ object OpenSearchResponses {
}

def withTileId(tileId:String): FeatureBuilder = copy(tileID=Some(tileId))
def withGeometry(geometry:Geometry): FeatureBuilder = copy(geometry=Some(geometry))

def withGeometry(geometry: Geometry): FeatureBuilder = copy(geometry = Some(geometry))
def withGeometryFromWkt(geometryWkt: String): FeatureBuilder = withGeometry(geometryWkt.parseWKT())

def withCRS(crs:String): FeatureBuilder = copy(crs=Some(CRS.fromName(crs)))

Expand Down
13 changes: 11 additions & 2 deletions src/test/scala/org/openeo/OpenSearchResponsesTest.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.openeo

import geotrellis.proj4.{CRS, LatLng}
import geotrellis.vector.Extent
import geotrellis.vector.{Extent, Polygon}
import org.junit.Assert._
import org.junit.Test
import org.openeo.TestHelpers.loadJsonResource
Expand All @@ -16,7 +16,15 @@ class OpenSearchResponsesTest {

@Test
def testFeatureBuilder():Unit = {
val f = OpenSearchResponses.FeatureBuilder().withBBox(0,0,10,10).withId("id").withNominalDate("2021-01-01T00:00:00Z").addLink("url","title",0.0,java.util.Arrays.asList("B01","B02")).withCRS("EPSG:32631").build()
val f = OpenSearchResponses.FeatureBuilder()
.withBBox(0, 0, 10, 10)
.withId("id")
.withNominalDate("2021-01-01T00:00:00Z")
.addLink("url", "title", 0.0, java.util.Arrays.asList("B01","B02"))
.withCRS("EPSG:32631")
.withGeometryFromWkt("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))")
.build()

assertEquals("id",f.id)
assertEquals(Extent(0,0,10,10),f.bbox)
assertEquals(ZonedDateTime.parse("2021-01-01T00:00:00Z"),f.nominalDate)
Expand All @@ -25,6 +33,7 @@ class OpenSearchResponsesTest {
assertEquals("title",f.links(0).title.get)
assertEquals(0.0,f.links(0).pixelValueOffset.get,0.0)
assertEquals("EPSG:32631",f.crs.get.toString())
assertEquals(Some(Extent(0, 0, 10, 10).toPolygon()), f.geometry)
}

@Test
Expand Down

0 comments on commit 755e7d1

Please sign in to comment.