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?
Best Answer
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.