当前位置:网站首页>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;
边栏推荐
- 6090. Minimax games
- /bin/ld: 找不到 -lcrypto
- Pattern matching extraction of specific subgraphs in graphx graph Computing Practice
- C # get PLC information (kepserver) II
- 【题解】Educational Codeforces Round 82
- Idea jar package conflict troubleshooting
- PyObject 转 char* (string)
- 动态规划入门二(5.647.62)
- Experiment collection of University "Fundamentals of circuit analysis". Experiment 4 - Research on linear circuit characteristics
- 隐藏在 Nebula Graph 背后的星辰大海
猜你喜欢
Idea public method extraction shortcut key
HMS core machine learning service helps zaful users to shop conveniently
[experience cloud] how to get the metadata of experience cloud in vscode
Two traversal sequences are known to construct binary trees
Boot 事务使用
Pattern matching extraction of specific subgraphs in graphx graph Computing Practice
PostgresSQL 流复制 主备切换 主库无读写宕机场景
中科大脑知识图谱平台建设及业务实践
智联招聘的基于 Nebula Graph 的推荐实践分享
全是精华的模电专题复习资料:基本放大电路知识点
随机推荐
解决BASE64Encoder报错的问题
Soul torture, what is AQS???
【idea】推荐一个idea翻译插件:Translation「建议收藏」
Boot 连接 Impala数据库
Experiment collection of University "Fundamentals of circuit analysis". Experiment 7 - Research on sinusoidal steady-state circuit
Ant group's large-scale map computing system tugraph passed the national evaluation
XPT2046 四线电阻式触摸屏
Moveit 避障路径规划 demo
Flink real-time data warehouse (7): Flink realizes the full pull module to extract data in MySQL
Crawl the information of national colleges and universities in 1 minute and make it into a large screen for visualization!
【小白聊云】中小企业容器化改造建议
Why does the system convert the temp environment variable to a short file name?
Add an empty column to spark dataframe - add an empty column to spark dataframe
【Salesforce】如何确认你的Salesforce版本?
2303. Calculate the total tax payable
SQL FOREIGN KEY
Astra: could not open "2bc5/ [email protected] /6“: Failed to set USB interface
使用 percona 工具给 MySQL 表加字段中断后该如何操作
Boot 中bean配置覆盖
idea jar包冲突排查