地理位置和Haversine公式 [英] Geolocation and Haversine formula
问题描述
我试图创建一个基本的Web应用程序来检测用户的地理位置,查询一个mySQL数据库,并返回所说的5公里内的所有公共汽车站。
GTFS包括经度和纬度的提要已被插入到mySQL数据库中,并且我找到了一个示例HTML页面,它提供了访问Web应用程序的浏览器的Longitude和Latitude。
我正在寻求一些帮助来编写mySQL查询,并获取这些信息并返回结果。
虽然大圆公式是精确的,在这种情况下你不需要精确度。纬度约1英里(1.6公里)。一分钟的经度约为cos(LAT)* 1英里。我会考虑选择LAT +/- 3分钟和LONG +/-(3 / cos(LAT))分钟。如果你真的需要一个圆圈,而不是一个盒子,那么就假装它是欧几里德坐标。这种规模的误差小于公交车的长度。
唯一棘手的部分是经度的长短取决于距离赤道有多远。
I am trying to create a basic web application that detects the users geolocation, queries a mySQL database, and returns all bus stops within say 5 kilometers.
The GTFS feed including the Longitude and Latitude have been inserted into a mySQL database, and I found a example HTML page that provides the Longitude and Latitude of the browser accessing the web application.
I am seeking some help writing the mySQL query that takes this information and returns the results.
Although the great circle formula is precise, you don't need the precision in this case. A minute of latitude is about 1 mile (1.6 km). A minute of longitude is about cos(LAT)*1 mile. I would consider selecting for the box of LAT +/- 3 minutes, and LONG +/- (3/cos(LAT)) minutes. If you really need a circle, not a box, then just pretend it's Euclidean coordinates. The error on this scale is less than the length of the bus.
The only tricky part is that the length of a minute of longitude varies depending on how far from the equator you are.
这篇关于地理位置和Haversine公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!