Finding Records in a Radius postgresql -


i not sure wrong below query:

select id,  earth_distance(ll_to_earth( 41.273147, -75.896858 ),  ll_to_earth(business_address_latitude, business_address_longitude)) distance_from_current_location events  earth_box( ll_to_earth(41.273147, -75.896858), 20000.00) @> ll_to_earth(business_address_latitude, business_address_longitude); 

as trying search records in radius of 20000 checked result give me records more 20000 mtr distance 24286 meter distance. not sure whats wrong @ above query. suggestion plz.

there nothing wrong, you're using box instead of circle it's normal. the manual states clearly:

some points in box further specified great circle distance location, second check using earth_distance should included in query.

so select points have distance <=20000 in outer query.


Comments