当前位置:网站首页>mysql 计算经纬度范围内的数据
mysql 计算经纬度范围内的数据
2022-07-02 12:32:00 【请告诉他】
利用谷歌方案
The SQL statement that will find the closest 20 locations that are within a radius of 30 miles to the 78.3232, 65.3234 coordinate. It calculates the distance based on the latitude/longitude of that row and the target latitude/longitude, and then asks for only rows where the distance value is less than 30 miles, orders the whole query by distance, and limits it to 20 results. To search by kilometers instead of miles, replace 3959 with 6371.
示例:(谷歌)
SELECT
id, (
3959 * acos (
cos ( radians(78.3232) )
* cos( radians( lat ) )
* cos( radians( lng ) - radians(65.3234) )
+ sin ( radians(78.3232) )
* sin( radians( lat ) )
)
) AS distance
FROM markers
HAVING distance < 30
ORDER BY distance
LIMIT 0 , 20;以上是谷歌说明,下面是用谷歌翻译的哈
根据以上说明,有以下应用实例
其中
3959是地球半径的英里,6371是地球半径的千米,LATITUDE是数据库字段的经度,LONGITUDE是数据库的纬度 ,18.7777是查找的经度,55.3774是查找的纬度即是有(18.7777,55.3774)这个位置点 搜索附近3.7KM的位置数据
SELECT
id, (
3959 * acos (
cos ( radians(18.7777) )
* cos( radians( LATITUDE) )
* cos( radians( LONGITUDE) - radians(55.3774) )
+ sin ( radians(18.7777) )
* sin( radians( LATITUDE) )
)
) AS distance
FROM markers
HAVING distance < 3700
ORDER BY distance
LIMIT 0 , 20;边栏推荐
猜你喜欢

愛可可AI前沿推介(7.2)

又是一年毕业季

Experiment collection of University "Fundamentals of circuit analysis". Experiment 6 - observation and measurement of typical signals

动态规划入门二(5.647.62)

XPT2046 四线电阻式触摸屏

全是精华的模电专题复习资料:基本放大电路知识点

数仓中的维度表与事实表

HMS core machine learning service helps zaful users to shop conveniently

Why does the system convert the temp environment variable to a short file name?

PHP static members
随机推荐
Why does the system convert the temp environment variable to a short file name?
SQL FOREIGN KEY
6091. Divide the array so that the maximum difference is K
Traversal before, during and after binary tree
中科大脑知识图谱平台建设及业务实践
《大学“电路分析基础”课程实验合集.实验七》丨正弦稳态电路的研究
6096. Success logarithm of spells and potions
(万字精华知识总结)Shell脚本编程基础知识
fastjson List转JSONArray以及JSONArray转List「建议收藏」
matlab中wavedec2,说说wavedec2函数[通俗易懂]
Song of cactus - throwing stones to ask the way (3)
Digital collection system development (program development) - Digital Collection 3D modeling economic model system development source code
[experience cloud] how to get the metadata of experience cloud in vscode
【idea】推荐一个idea翻译插件:Translation「建议收藏」
制作p12证书[通俗易懂]
全是精华的模电专题复习资料:基本放大电路知识点
/Bin/ld: cannot find -lcrypto
Introduction to dynamic planning I, BFS of queue (70.121.279.200)
Aiko ai Frontier promotion (7.2)
Flink real-time data warehouse (7): Flink realizes the full pull module to extract data in MySQL