开发者

Find nearby postcode with a base postcode

开发者 https://www.devze.com 2023-02-25 13:15 出处:网络
This is with reference to this question: Find UK PostCodes closest to other UK Post Codes by matching the Post Code String

This is with reference to this question: Find UK PostCodes closest to other UK Post Codes by matching the Post Code String

--User wants to get all postcodes nearby B193SH
-- Postcode  = 'B193SH开发者_如何学C'
-- Latitude  = 52.488460
-- Longitude = -1.895690

SELECT [HouseNumber],
             [Street],
             [Area],
             [PostCode],
             [Latitude],
             [Longitude],
FROM   [dbo].[Address]
WHERE  ([Latitude]  BETWEEN ( 52.488460 - 0.100000 ) AND ( 52.488460 + 0.100000 )) AND 
             ([Longitude] BETWEEN ( -1.895690 - 0.100000 ) AND ( -1.895690 + 0.100000 ))
ORDER  BY [PostCode]
GO 

Executing this query, i get a couple of results. But the question stands that what difference (meters/miles) does a +/- 0.100000 to Lat/Lon makes?

Should I try to find close postcodes by using the first three letter of the base postcode, i.e., 'B19'?

Please see the reference question for a full detail of my scenerio.

Thanks!


Given the approximate radius of the Earth being 6378.1 km.

Latitude (and longitude, when along equator)

2 * pi * 6378.1 * 0.1 / 360 = 11.1319 km (4 d.p.)

Longitude when along x degrees north or south

For example, when at 50 degrees north:

2 * pi * 6378.1 * cos(50) * 0.1 / 360 = 7.1554 km (4 d.p.)
0

精彩评论

暂无评论...
验证码 换一张
取 消