确定一个坐标是否在另一个半径内 [英] Determine if one coordinate is in radius of another

查看:65
本文介绍了确定一个坐标是否在另一个半径内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个包含坐标的行表.

Let's say I have a Table of rows that contain coordinates.

仅拉出位于另一个坐标半径内的坐标行的最佳方法是什么?

What would be the best way to pull only the rows of coordinates which are in the radius of another coordinate?

为简化我的问题,我给出以下示例:

To simplify my question, I'm giving the following example:

Table like:
Columns: Latitude, Longitude.
Row1:    23.44444  24.55555
Row2:    32.44444  28.22222
Row3:    35.11111  32.12345

在SQL语句中,如何获取例如在Row3半径内的坐标行?

In an SQL statement, how do I get the rows of coordinates that are in the radius of Row3 for example?

推荐答案

This post shows how to do this in SQL Server.

这是在MySQL中的操作方法:

And here is how to do it in MySQL:

SELECT ((ACOS(SIN($lat * PI() / 180) * SIN(lat * PI() / 180) + 
         COS($lat * PI() / 180) * COS(lat * PI() / 180) * COS(($lon - lon) * 
         PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance 
FROM members 
HAVING distance<='10' ORDER BY distance ASC

这篇关于确定一个坐标是否在另一个半径内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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