这是参考这个问题: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'
-- 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
执行此查询,我得到了几个结果。但问题是,Lat / Lon的差异(米/英里)是+/- 0.100000吗?
我是否应该尝试使用基本邮政编码的前三个字母来查找密切的邮政编码,即'B19'?
请参阅参考问题以获取我的场景的完整细节。
谢谢!
答案 0 :(得分:1)
鉴于地球的近似半径为6378.1 km。
纬度(和经度,沿赤道时)
2 * pi * 6378.1 * 0.1 / 360 = 11.1319 km (4 d.p.)
沿 x 度北或南的经度
例如,在北纬50度时:
2 * pi * 6378.1 * cos(50) * 0.1 / 360 = 7.1554 km (4 d.p.)