英文:
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 ) < your-distance;
Where lat1 and long1 are your reference point values.
Very rough approximation for short distances (as someone noted in the comments).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论