@@ -56,14 +56,22 @@ class SpatialService {
56
56
if (geoJson. type != ' GeometryCollection' ) {
57
57
int length = geoJson?. toString(). size()
58
58
if (length > threshold) {
59
+ geo = GeometryUtils . geoJsonMapToGeometry (geoJson)
59
60
geoJson = GeometryUtils . geometryToGeoJsonMap(geo. getEnvelope())
60
61
}
61
62
62
63
geo = GeometryUtils . geoJsonMapToGeometry (geoJson)
64
+ if (! geo. isValid()) {
65
+ geo = geo. buffer(0 )
66
+ }
63
67
wkt = geo. toText()
64
68
} else {
65
69
geo = GeometryUtils . geoJsonMapToGeometry (geoJson)
66
70
GeometryCollection geometryCollection = (GeometryCollection )geo
71
+ if (! geometryCollection. isValid()) {
72
+ geometryCollection = geometryCollection. buffer(0 )
73
+ }
74
+
67
75
Geometry convexHullGeometry = geometryCollection. union(). convexHull()
68
76
wkt = convexHullGeometry. toText()
69
77
}
@@ -308,13 +316,13 @@ class SpatialService {
308
316
309
317
@Cacheable (value = " spatialSearchObject" , key = { query.toUpperCase() + fids.toUpperCase() })
310
318
Map searchObject(String query, String fids = " " ) {
311
- query = URLEncoder . encode(query, ' UTF-8' ). replaceAll(' \\ +' , ' %20' )
312
- String url = grailsApplication. config. getProperty(' spatial.baseUrl' )+ " /ws/search?q=$q uery &include=$fids "
319
+ String urlquery = URLEncoder . encode(query, ' UTF-8' ). replaceAll(' \\ +' , ' %20' )
320
+ String url = grailsApplication. config. getProperty(' spatial.baseUrl' )+ " /ws/search?q=$u rlquery &include=$fids "
313
321
def resp = webService. getJson(url)
314
322
if ((resp instanceof Map ) || ! resp)
315
- return
323
+ return [:]
316
324
317
- def result = resp?. find { it. name?. toUpperCase() == query?. toUpperCase() }
325
+ def result = resp?. find { it. name?. toUpperCase() == query?. toUpperCase() } ?: [:]
318
326
deepCopy(result)
319
327
}
320
328
0 commit comments