OPolygon search from Java ( 3.0.12 )

I’m trying to do geo searching from Java, like this:

SELECT from Polygon where ST_DWithin(geometry, ST_GeomFromText('POLYGON((12 0, 14 0, 14 6, 12 6, 12 0))'), 2.0) = true

currently I’m trying this…:

            ODocument polygon = new ODocument("OPolygon");
            polygon.field("coordinates", coordinates);

            String statement = "select * from Location where ST_WITHIN(geometry,?) = true";
            rs = db.query(statement, polygon);
            while(rs.hasNext()){
                      ...

which blows up with null ptr exception, tho nothing is null as far as I can see.

Is there a resource which explains how to do this?

Hi,

did you already took a look at this https://orientdb.com/docs/last/Spatial-Index.html ?

Hope it helps
Regards,
Michela

Yes, that is where I first looked. On that page, there is an example of how to do a query using a ‘POLYGON’ string and an example of using an OPoint java class, but not an example of how to use an OPolygon java class to do a query. I’m am looking for details on the last: How to do a query using an OPolygon.