找到在纬度和经度半径内的所有DB中的点。

huangapple go评论71阅读模式
英文:

Find all points in DB which are in the radius of a lat and long

问题

我在DB SQL Server中保存了两个字段的点坐标- 纬度和经度。

我获取了一个点,然后想要找到在我DB中五分钟步行距离内的所有点。

最佳方法是什么?

我了解到可以使用GeoDjango来实现这一点。但我明白它不适用于SQL Server。

还有一些方法,如果您将数据保存为地理数据类型,但这也不相关。

英文:

I have in DB SQL Server saved point in 2 fields- lat and long

I get point, and I want find all the points from my DB in radius of five minutes walking distance.

What's the best way to do it?

I read that there is a way to do it with GeoDanjo. But I understand that it doesn't work with SQL Server.

There also ways to do it if you save the data in geography type but it is not relevant either.

答案1

得分: 0

SELECT your-fields WHERE sqrt ( ( lat - lat1 )^2 + ( long - long1 )^2 ) < your-distance;

其中,lat1 和 long1 是您的参考点数值。

对于短距离的非常粗略估算(正如评论中有人指出的)。

英文:
SELECT your-fields WHERE sqrt ( ( lat - lat1 )^2 + ( long - long1 )^2 ) &lt; your-distance;

Where lat1 and long1 are your reference point values.

Very rough approximation for short distances (as someone noted in the comments).

huangapple
  • 本文由 发表于 2020年1月6日 02:16:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/59602850.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定