当前位置:网站首页>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;边栏推荐
- Use ffmpeg command line to push UDP and RTP streams (H264 and TS), and ffplay receives
- 数据湖(十一):Iceberg表数据组织与查询
- C # get PLC information (kepserver) II
- Traversal before, during and after binary tree
- 奥比中光 astra: Could not open “2bc5/[email protected]/6“: Failed to set USB interface
- /bin/ld: 找不到 -lxml2
- Solve the problem of base64encoder error
- What are the necessary functions of short video app development?
- Xpt2046 four wire resistive touch screen
- Target detection - make your own deep learning target detection data set with labelimg
猜你喜欢
随机推荐
beforeEach
Flink real-time data warehouse (7): Flink realizes the full pull module to extract data in MySQL
奥比中光 astra: Could not open “2bc5/[email protected]/6“: Failed to set USB interface
数组和链表的区别浅析
Experiment collection of University "Fundamentals of circuit analysis". Experiment 7 - Research on sinusoidal steady-state circuit
Use ffmpeg command line to push UDP and RTP streams (H264 and TS), and ffplay receives
Analysis of the difference between array and linked list
Nebula Graph & 数仓血缘关系数据的存储与读写
lseek 出错
2020.4.12 byte written test questions B DP D monotone stack
纪念成为首个 DAYU200 三方 demo 贡献者
Solve the problem of base64encoder error
Boot connection to impala database
Demo of converting point cloud coordinates to world coordinates
手机app通达信添加自定义公式(分时T+0)为例子讲解
SQL FOREIGN KEY
《大学“电路分析基础”课程实验合集.实验七》丨正弦稳态电路的研究
6095. Strong password checker II
Golang MD5 encryption and MD5 salt value encryption
[5g NR] RRC connection release








