本文介绍了大圆距离公式:T-SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个表,里面有一堆不同的地址.我需要一个proc,它将选择该表中的地址,该地址与传递的经度/纬度值相距指定距离(以英里为单位)内.

So I have a table with a bunch of different addresses in it. I need a proc that will select the addresses in that table that are within a specified distance in miles from the passed in lat/long values.

我的桌子的例子:

- messageId
- lat (float)
- long (float)

Proc正在传递另一对纬度/经度对(也都是float)和int(英里)

Proc is passing in another lat/long pair (both floats as well) as well as an int (miles)

我找到了这个 http://www.sqlteam.com/forums/topic .asp?TOPIC_ID = 81360 来计算实际公式,但是我不知道要以proc形式对其进行修改,以便能够浏览整个地址列表,而只给我Id从我经过的经纬度开始,< =的地址(我经过的英里).

I found this http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81360 to calculate the actual formula but I can't figure out to modify it in proc form to be able to go through an entire list of addresses and only give me the Id's of the addresses that are <= the miles (that I pass in), from the lat/long I pass in.

我可以在这里得到任何帮助吗?

Can I get any help here?

谢谢!

推荐答案

SQL Server 2008

SQL Server 2008

使用空间函数STDistance返回距离(以米为单位)

Using the spacial function STDistance return distance in meters

geography :: Point(@ lat1,@ lon1,4326).STDistance(geography :: Point(@ lat2,@ lon2,4326))

geography::Point(@lat1, @lon1, 4326).STDistance(geography::Point(@lat2, @lon2, 4326))

这篇关于大圆距离公式:T-SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 06:50