| Re: Has anyone worked on location based shipment search? I took a shot and found out it wasn't that bad after all:
Create a Shipment Saved Query and put this in Find All:
select s.shipment_gid from shipment s, location l where s.source_location_gid=l.location_gid and acos(sin(#LAT#/57.29578)*sin(l.lat/57.29578)+cos(#LAT#/57.29578)*cos(l.lat/57.29578)*cos((l.lon-#LON#)/57.29578))*3962<50
Notes:
- Just replace #LAT# (twice!) and #LON# with the lat/long of your location A.
- The 50 at the end represents the maximum distance (crow flight) - change this if needed.
- The 3962 at the end is the radius of the earth in miles
- The 57.29578 stands for 180/pi and is used to convert degrees to radians. A more accurate statement would have been 180/acos(-1), but if I used this I got 'out of range' errors.
Last edited by LourensGlog; July 14th, 2009 at 14:20.
|