UK Post Code Geocoding Help


I am working on rewriting my system to use OSM instead of Bing Maps.

I need to be able to geocode a UK post code.

When I use Bing Maps I can throw the post code at the geocoding function in any format I like and it works no problem. For example, it has no problem geocoding “TW61QG” or “TW61 QG” or “TW6 1QG”

But, the OSM geocoding function appears to insist that the post code is in the exact correct format. For example…

this works:,uk&format=xml

but this doesn’t work:,uk&format=xml

Is there a way around this please?




I appear to have found an answer.

Below is a link to a function which checks and cleans a post code and returns it in the correct format so I can use it with OSM.

Hopefully this will help others…