mysql - Find 25 nearest addresses for table with Latitude and Longitude -
i'm trying create new table list of each address in table , it's 10 nearest addreses. each record has latitude , longitude. running against much more work needed (several 1000000 records).
however occurred me if resorted/indexed table using latitude, longitude sort distance automatically , step through each record doing id+/- 25.
however still leaves me question; query find distance between 2 records each having latitude/longitude like?
if you, i'd have indexes on latitude , longitude. i'd select count(*) table (table.latitude between (query_lat - x) , (query_lat + x)) , (table.longitude between (query_long - y) , (query_long + y));, refining x , y each time until count got downwards around 100 or records. (maybe i'd store final x , y values record query address don't have many queries next time.) i'd run query columns, not count(*), actual latitude , longitude , maybe utilize heap queue 25 shortest distances.
the real hard thing here relationship between longitude , distance depends on latitude well; they're not independent. i'm not sure putting spherical coordinate transformation query great idea.
your use-latitude/longitude-for-id trick isn't going work because won't sort right. example, sort tell houston closer san antonio austin is.
mysql gis latitude-longitude distance
No comments:
Post a Comment