7

I am using hibernate spatial and postgis and i want to find the points that fall within a certain radius. Using this SQL:

SELECT name FROM institution WHERE ST_DWithin(geom,ST_GeographyFromText('SRID=4326;POINT(36.9881 0)'), 5000)

I get the points within 5KM.

Using Hibernate Spatial i am doing

Criteria criteria = getCurrentSession().createCriteria(Institution.class, "i");
Geometry geometry = ....

criteria.add(SpatialRestrictions.distanceWithin("i.geom", geometry, distance)); 

But it does not return distance in Metres. What do I need to do?

1

You have to provide geographic data to evaluate distance but you are passing geometry.

see https://stackoverflow.com/a/20577961/6490042

SRID 4326 geometry is in degrees not meters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.