选择落在中心点半径范围内的坐标? [英] Select coordinates which fall within a radius of a central point?
本文介绍了选择落在中心点半径范围内的坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ID:Latitude:Longitude:name:desc
<我已经设置了我的谷歌地图应用程序,以便在屏幕上有效地显示标记。但是我需要添加另一个功能,用户可以从中心点查看所有位于半径范围内的指针。
如何编写这种类型的sql语句:
选择X& 10英里半径范围内的所有指针。 Y
解决方案
以下SQL应该可以工作:
SELECT * FROM Table1 a
WHERE(
acos(sin(a.Latitude * 0.0175)* sin(YOUR_LATITUDE_X * 0.0175)
+ cos(a.Latitude * 0.0175)* cos(YOUR_LATITUDE_X * 0.0175)*
cos((YOUR_LONGITUDE_Y * 0.0175) - (a.Litude * 0.0175))
)* 3959 < = YOUR_RADIUS_INMILES
)
这是基于余弦的球形定律,更多有关该主题的详细信息,请查看本文 - http://www.movable- type.co.uk/scripts/latlong.html
I have a database of coordinates in the schema:
ID:Latitude:Longitude:name:desc
I've set up my google maps application to show the markers effectively on the screen. However I need to add another feature whereby the user can view all pointers that fall within the radius from a central point.
How would I write up a sql statement of the kind:
Select all pointers that fall within a 10 mile radius of X & Y
解决方案
The SQL below should work:
SELECT * FROM Table1 a
WHERE (
acos(sin(a.Latitude * 0.0175) * sin(YOUR_LATITUDE_X * 0.0175)
+ cos(a.Latitude * 0.0175) * cos(YOUR_LATITUDE_X * 0.0175) *
cos((YOUR_LONGITUDE_Y * 0.0175) - (a.Longitude * 0.0175))
) * 3959 <= YOUR_RADIUS_INMILES
)
This is based on the spherical law of cosines, for more detailed information on the topic, check out this article - http://www.movable-type.co.uk/scripts/latlong.html
这篇关于选择落在中心点半径范围内的坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文