From: Mathieu Baudier Date: Fri, 3 Nov 2023 07:00:51 +0000 (+0100) Subject: Fix bbox query for box overlap X-Git-Tag: v2.3.19~1 X-Git-Url: http://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=commitdiff_plain;h=12b80cad8670765da2cc8316c2c5d537cfbcbcd2 Fix bbox query for box overlap --- diff --git a/org.argeo.app.geo/src/org/argeo/app/geo/http/WfsHttpHandler.java b/org.argeo.app.geo/src/org/argeo/app/geo/http/WfsHttpHandler.java index 59cb97a..c12a77b 100644 --- a/org.argeo.app.geo/src/org/argeo/app/geo/http/WfsHttpHandler.java +++ b/org.argeo.app.geo/src/org/argeo/app/geo/http/WfsHttpHandler.java @@ -216,11 +216,14 @@ public class WfsHttpHandler implements HttpHandler { if (bbox != null) { search.getWhere().any((or) -> { + // box overlap, see https://stackoverflow.com/questions/20925818/algorithm-to-check-if-two-boxes-overlap + // isOverlapping = (x1min < x2max AND x2min < x1max AND y1min < y2max AND y2min < y1max) + // x1 = entity, x2 = bbox or.all((and) -> { - and.gte(EntityName.minLat, bbox.getMinX()); - and.gte(EntityName.minLon, bbox.getMinY()); - and.lte(EntityName.maxLat, bbox.getMaxX()); - and.lte(EntityName.maxLon, bbox.getMaxY()); + and.lte(EntityName.minLat, bbox.getMaxX()); + and.gte(EntityName.maxLat, bbox.getMinX()); + and.lte(EntityName.minLon, bbox.getMaxY()); + and.gte(EntityName.maxLon, bbox.getMinY()); }); or.all((and) -> { and.gte(WGS84PosName.lat, bbox.getMinX());