Search code examples
javageospatialorientdbspatialorientdb2.2

How to query location "within" in OrientDB 2.2.x Spatial Module in Java?


I'mm trying to implement OrientDB Spatial Module and need some help on coding it in Java.

How do I do the equivalent query in Java:

select *,ST_Distance_Sphere(location,ST_GeomFromText('POINT(12.4696635 41.8894657)')) as distance from Points where ST_Distance_Sphere(location,ST_GeomFromText('POINT(12.4696635 41.8894657)')) < 200 order by distance

Reference

Thanks!


Solution

  • The only way is to use OSQL:

        List<ODocument> execute = db.query(new OSQLSynchQuery<ODocument>(
        "select   *,ST_Distance_Sphere(location,ST_GeomFromText('POINT(12.4696635 41.8894657)')) as distance from Points where ST_Distance_Sphere (location,ST_GeomFromText('POINT(12.4696635 41.8894657)')) < 200 order by distance"));
    

    Does it helps?