开发者

Matching GPS locations in my database against current location

I have the GPS locations for a particular business stored in my android applicatio开发者_JAVA技巧n database. The android application will give me location information for current location.

How can I find the addresses of business premises closer to the current location? Please note: The GPS locations for this business is not present in Google Maps/Places.


You probably want a nicely crafted SELECT statement, along the lines of

SELECT long-<current_long> AS dLong,lat-<current_lat> AS dLat,name,(dLong*dLong)+(dLat*dLat) AS r2 FROM table WHERE r2<<threshold> ORDER BY r2 ASC;

<current_long>,<current_lat>, and are placeholders you should replace when building the query. Note that threshold is the square of the distance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜