使用经纬度40公里的半径 [英] Radius of 40 kilometers using latitude and longitude

查看:100
本文介绍了使用经纬度40公里的半径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:

多个纬度/经度点的半径

在MySQL查询中的距离计算

根据纬度/经度在20公里内选择

Possible Duplicate:
Radius of multiple latitude/longitude points
distance calculations in mysql queries
select within 20 kilometers based on latitude/longitude

我有一个MyISAM表格,数据存储在其中。数据包括Google Maps的纬度和经度。我试图达到的目标是选取样本纬度和经度40公里范围内的所有物体。

I have a MyISAM table, which the data is stored in. The data includes latitude and longitude for Google Maps. What I am trying to achieve is to select all objects within the radius of 40 kilometers of the sample latitude and longitude.

谢谢!

推荐答案

我使用这个查询来得到 $ lat周围的 $ radius 中的所有点 / $ lng

I use this query to get all points within a $radius around $lat/$lng:

SELECT
    *,
    ( 6371 * acos( cos( radians({$lat}) ) * cos( radians( `lat` ) ) * cos( radians( `lng` ) - radians({$lng}) ) + sin( radians({$lat}) ) * sin( radians( `lat` ) ) ) ) AS distance
FROM `positions`
HAVING distance <= {$radius}
ORDER BY distance ASC



<63>是地球半径im km。我还没有发明它:
http://代码。 google.com/intl/zh_CN/apis/maps/articles/phpsqlsearch.html
https://developers.google.com/maps/articles/phpsqlsearch_v3#findnearsql (编辑:URL已更改)

6371 is the earth radius im km. And I have not invented it: http://code.google.com/intl/en/apis/maps/articles/phpsqlsearch.html https://developers.google.com/maps/articles/phpsqlsearch_v3#findnearsql (edit: URL changed)

这篇关于使用经纬度40公里的半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆