地理位置和半正矢公式

发布于 2024-09-26 13:11:00 字数 196 浏览 2 评论 0原文

我正在尝试创建一个基本的 Web 应用程序,用于检测用户的地理位置、查询 mySQL 数据库并返回 5 公里内的所有公交车站。

包括经度和纬度的 GTFS 提要已插入到 mySQL 数据库中,我找到了一个示例 HTML 页面,它提供了访问 Web 应用程序的浏览器的经度和纬度。

我正在寻求一些帮助来编写获取此信息并返回结果的 mySQL 查询。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等你爱我 2024-10-03 13:11:00

尽管大圆公式很精确,但在本例中您不需要精度。一分钟的纬度约为 1 英里(1.6 公里)。一分钟的经度约为 cos(LAT)*1 英里。我会考虑选择 LAT +/- 3 分钟和 LONG +/- (3/cos(LAT)) 分钟框。如果你真的需要一个圆,而不是一个盒子,那么就假装它是欧几里得坐标。该尺度上的误差小于总线的长度。

唯一棘手的部分是,一分钟经度的长度根据距赤道的距离而变化。

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.

嘿嘿嘿 2024-10-03 13:11:00

在此链接中,您可以找到:

SELECT id, ( 3959 * acos( cos ( 弧度(37) ) * cos( 弧度( 纬度 ) ) * cos( 弧度( lng ) - 弧度(-122) ) + sin( 弧度(37) ) * sin( 弧度( 纬度 ) ) ) ) AS 与标记的距离距离< 25 按距离限制排序 0 , 20;

In this link you find:

SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文