【发布时间】:2014-02-19 05:53:47
【问题描述】:
数据库中有一个表location:
id | latitude | longitude
---| -------- | --------
1 | 45.0000 | 90.0000
...
所以我可以使用 SQL 来查询我想要的位置:
SELECT id FROM location
WHERE latitude BETWEEN min_latitude AND max_latitude
AND longitude BETWEEN min_longitude AND max_longitude;
其中min_latitude,max_latitude,min_longitude,max_longitude表示current_location附近1KM的4个边界。
现在我想知道,如何使用 current_location 获取 min_latitude、max_latitude、min_longitude、max_longitude?p>
我看过这个问题的答案:How to get the nearest area from a list of locations?,如果allLocations太多,我觉得不是很好的解决方案。
【问题讨论】: