Finding nearest postal code

0
Hi all, I want to search between the postcodes in my database with any potcode or address and select the 5 closest to this address. Q: How can I calculate the addresses that are close to this address? Anyone have experience with this? Are there any modules?  
asked
1 answers
0

You’ll need latitude en longitude values for your locations. If you have addresses and cities you could get them via a Google api (paid) or Open Streetmap api (fair use policy) or otherwise.

Then, you can retrieve addresses from your database where compared to your address longitude difference < x and latitude difference < y to get around 10 results. The results are within an imaginary box around your location on the map.

Then you could loop through the results and use a java action to check which 5 are closest, calculating the distance between geo locations like suggested here. Closest means “as the bird flies” btw, not driving distance or anything like that. The results now are within the smallest possible circle around your location on the map.

answered