当前位置:网站首页>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;边栏推荐
- The sea of stars hidden behind the nebula graph
- Two traversal sequences are known to construct binary trees
- 二叉树前,中,后序遍历
- 数据湖(十一):Iceberg表数据组织与查询
- Pyobject to char* (string)
- Teach you how to build virtual machines locally and deploy microservices
- beforeEach
- Song of cactus - throwing stones to ask the way (3)
- 2278. Percentage of letters in string
- 图数据库|Nebula Graph v3.1.0 性能报告
猜你喜欢

《大学“电路分析基础”课程实验合集.实验七》丨正弦稳态电路的研究

爱可可AI前沿推介(7.2)

Two traversal sequences are known to construct binary trees

Deux séquences ergodiques connues pour construire des arbres binaires

《大学“电路分析基础”课程实验合集.实验五》丨线性有源二端网络等效电路的研究
![[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)](/img/26/3f19d36c048e669c736e27384e0fa7.jpg)
[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)

Aiko ai Frontier promotion (7.2)
![[experience cloud] how to get the metadata of experience cloud in vscode](/img/45/012c2265402ba1b44f4497f468bc61.png)
[experience cloud] how to get the metadata of experience cloud in vscode

《大学“电路分析基础”课程实验合集.实验六》丨典型信号的观察与测量

PHP static members
随机推荐
Fiddler realizes mobile packet capturing - getting started
可视化技术在 Nebula Graph 中的应用
树-二叉搜索树
Idea public method extraction shortcut key
lseek 出错
Jsp+mysql006 community management system
Crawl the information of national colleges and universities in 1 minute and make it into a large screen for visualization!
Tree binary search tree
The sea of stars hidden behind the nebula graph
/bin/ld: 找不到 -lpam
【Salesforce】如何确认你的Salesforce版本?
floyed「建议收藏」
Review materials for the special topic of analog electronics with all essence: basic amplification circuit knowledge points
Wavedec2 in MATLAB, talk about the wavedec2 function [easy to understand]
构建多架构镜像的最佳实践
【idea】推荐一个idea翻译插件:Translation「建议收藏」
QVariant与Json的各种纠葛——Qt
[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)
【5G NR】RRC连接释放
Add an empty column to spark dataframe - add an empty column to spark dataframe