Library to calculate distances between postcodes in the UK

这一生的挚爱 提交于 2019-12-02 10:21:56

First, you need to translate the postcode into useful coordinates. For example, the Easting and Northing values from a Postcode lookup table, like the one from here: http://www.doogal.co.uk/UKPostcodes.php

These Easting and Northing are UK Ordnance Survey grid coordinates in metres from the OS map origin.

Convert them into Kilometres by dividing by 1000

Then use a simple Pythagoros triangle formula. Say the two points have Easting and Northing values (in kilometres) of E1, N1 and E2, N2

Distance between them in Kilometres = Square root of ( abs(E1-E2)^2 + abs(N1-M2)^2 )

Dave

The following question answers the exact same question only in PHP specifically:

Using PHP and google Maps Api to work out distance between 2 post codes (UK)

It leverages a web service API though, so you should be able to use any basic rest api to leverage it (I'm sure there are well documented options in Java, C# and C++).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!