Skip to content

Commit

Permalink
Changing to wkt due to issues parsing Features #929
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Jun 13, 2024
1 parent 1bb8ee8 commit e6665b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions grails-app/services/au/org/ala/ecodata/SpatialService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.geotools.geojson.geom.GeometryJSON
import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.geom.Geometry
import org.locationtech.jts.geom.GeometryFactory
import org.locationtech.jts.io.WKTReader

import static ParatooService.deepCopy
/**
Expand Down Expand Up @@ -244,12 +245,12 @@ class SpatialService {
Geometry getGeoJsonForPidToGeometry(String pid) {
log.debug("Cache miss for getGeoJsonForPidToMap($pid)")
log.debug("Cache miss for getGeoJsonForPid($pid)")
String url = grailsApplication.config.getProperty('spatial.baseUrl')+"/ws/shapes/geojson/$pid"
String jsonText = webService.get(url)
String url = grailsApplication.config.getProperty('spatial.baseUrl')+"/ws/shapes/wkt/$pid"
String wkt = webService.get(url)

Geometry geometry = null
try {
geometry = new GeometryJSON().read(jsonText)
geometry = new WKTReader().read(wkt)
log.info("*************************************Successfully created geometry for pid $pid")
}
catch (Exception e) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/groovy/au/org/ala/ecodata/SpatialServiceSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SpatialServiceSpec extends Specification implements ServiceUnitTest<Spatia
then:
response["cl22"].size() == 1
response["cl22"][0].name == "ACT"
1 * webService.get("/ws/shapes/geojson/123") >> ([type: "Polygon", coordinates: [[[5, 0], [5, 5], [0, 5], [0, 0], [5, 0]]]] as JSON).toString()
1 * webService.get("/ws/shapes/geojson/456") >> ([type: "Polygon", coordinates: [[[11.5, 9.5], [11.5, 11.5], [9.5, 11.5], [9.5, 9.5], [11.5, 9.5]]]] as JSON).toString()
1 * webService.get("/ws/shapes/wkt/123") >> ([type: "Polygon", coordinates: [[[5, 0], [5, 5], [0, 5], [0, 0], [5, 0]]]] as JSON).toString()
1 * webService.get("/ws/shapes/wkt/456") >> ([type: "Polygon", coordinates: [[[11.5, 9.5], [11.5, 11.5], [9.5, 11.5], [9.5, 9.5], [11.5, 9.5]]]] as JSON).toString()
}
}

0 comments on commit e6665b9

Please sign in to comment.