Skip to content

Commit 1b6a4c6

Browse files
committed
updated intersects filter builder to look for a geojson geom vs feature
1 parent 3813287 commit 1b6a4c6

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

staccato-application/src/main/java/com/planet/staccato/exceptions/ErrorResponseComposer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public Optional<StacException> compose(T ex) {
4040
// find a handler for the exception
4141
// if no handler is found,
4242
// loop into for its cause (ex.getCause())
43+
T originalEx = ex;
4344
while (ex != null) {
4445
handler = handlers.get(ex.getClass().getSimpleName());
4546

@@ -54,6 +55,12 @@ public Optional<StacException> compose(T ex) {
5455
return Optional.of(handler.getErrorResponse(ex));
5556
}
5657

58+
if (ex == null) {
59+
ex = originalEx;
60+
}
61+
5762
return Optional.of(new StacException(String.valueOf(HttpStatus.BAD_REQUEST.value()), ex.getMessage()));
63+
64+
5865
}
5966
}

staccato-elasticsearch/src/main/java/com/planet/staccato/es/QueryBuilderHelper.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,15 @@ public static Optional<QueryBuilder> intersectsBuilder(Object intersects) {
159159
return Optional.empty();
160160
}
161161
Map<String, Object> intersectsMap = (Map<String, Object>) intersects;
162-
Map<String, Object> geometryMap = (Map<String, Object>) intersectsMap.get("geometry");
163-
String type = (String) geometryMap.get("type");
162+
String type = (String) intersectsMap.get("type");
163+
if (type == null || type.isBlank()) {
164+
throw new FilterException("Unable to determine geometry type from intersects parameter");
165+
}
164166

165-
List coords = (List) geometryMap.get("coordinates");
167+
List coords = (List) intersectsMap.get("coordinates");
168+
if (coords == null) {
169+
throw new FilterException("Unable to determine coordinates from intersects parameter");
170+
}
166171
if (coords.isEmpty()) {
167172
return Optional.empty();
168173
}

0 commit comments

Comments
 (0)