I am trying to use the geometry search of apache ignite, applying the example almost as given at https://github.com/dmagda/geospatial/blob/master/src/main/java/org/geospatial/SpatialQueryExample.java
However the search does not look like it is taking into account the polygon but rather the bounding box of the polygon.
I am applying:
SqlQuery<Long, EndDevicePosition> query = new SqlQuery<>(EndDevicePosition.class, "devEUI=? and geoCoordinates && ?");
query.setArgs(devEUI, "POLYGON(("+long1+" "+lat1+", "+long2+" "+lat2+", "+long3+" "+lat3+", "+long4+" "+lat4+", "+long1+" "+lat1+"))");
Collection<Entry<Long, EndDevicePosition>> entries = endDevicePosition.query(query).getAll();
on data:
lat1 48.93677638153757
lat2 48.935514830810355
lat3 48.9355007350914
lat4 48.93569455087813
long1 2.242525877426105
long2 2.2392808748500586
long3 2.240080057302674
long4 2.241281512801883
Though those are WGS84 projection, it should not affect the result.
Am I doing it wrong and is there any way of having an actual polygon ? Thanks.
This is expected behavior: operator &&
means exactly bounding box intersection
. This is the most general spatial operation and it can use spatial index.
You need an additional filter in a query like the following:
geoCoordinates && ? AND my_custom_geo_filter(geoCoordinates, ?)
where in my_custom_geo_filter
function you can use all the capabilities of JTS library.
By default Ignite does not define any geo-related functions in SQL, so you have to do it manually using QuerySqlFunction
[1] annotation. See
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/cache/query/annotations/QuerySqlFunction.html