Change zip codes to three-word addresses using reverse geocoding

    what3words is great for indicating the exact location. This coordinate system helps you find any 3 x 3 meter square on the planet. If you have not heard about the coordinates of three words before, you can find out more about the service from our welcome post . However, with all the positive qualities of what3words, we can not use this technology in all cases. For example, to work with mail, we have to indicate the mailing address, even though the courier can easily deliver the shipment directly to the door using what3words addresses. It would be convenient if what3words address could be converted to a mailing address directly on the website page, and of course, this is possible.

    Very often at the moment when you want to order a product on the site, you are required to have a zip code. Behind each such index lies a huge number of streets. For example, in the UK there are 1.7 million postal codes and about 29 million delivery points. It is worth recognizing that it is quite convenient to specify a zip code for further street searches, but this approach has its drawbacks. Maintaining up-to-date information on indexes is rather laborious, and new indexes are often created. Many difficulties arise with the fact that in different countries they use a different approach to postal codes, and while the index in Russia can cover about 100 streets, in Belgium thousands of streets can be assigned to one index.

    what3words works anywhere in the world and gives benefits not only to residents of densely populated cities, but also to those who are in rural areas or settlements with an imperfect addressing system. This is a great replacement for a zip code, what3words is just as simple and concise, and at the same time, unlike an index, it can contain information about the exact location of the delivery point. In order to embed what3words on a website, it is enough to resort to a fairly simple reverse geocoding procedure - this is the process of converting coordinates into a mailing address. This will require street information and APIs, such as the free Google API , which is well suited for reverse geocoding.

    Google API Example

    And so, we need to take a three-word address, and convert it to a mailing address. The mailing address looks like this: 111397, Russia, Moscow, 3rd Vladimirskaya ulitsa 26, building 2, building 3. The address of this place in the what3words coordinate system is: earth.field . Twin . As an example of using the Google API, we will take the work of Steve Caldwell of Crosstek. It uses the free what3words API to convert three-word addresses to latitude and longitude, and then converts the received values ​​to a mailing address using the Google API. Steve built his converter on Meteor, you can check out his demo and find out more on GitHub . He also described the entire process on his blog .

    OpenStreetMap example

    Despite all the positive qualities of the API from Google, it has limitations on use. As a more free and open solution, you can use the data of the wonderful OpenStreetMap project. One of the contributors to this project, David Earle, uses the open source OSM geocoder that we know as Nominatim . The quality of his work is different for different countries, but Nominatim does an excellent job with our example. David has kindly provided about 150 lines of his PHP code , which you can test on your server under the GPL v2 license. You can also check out his demo .

    Geocoding and routing

    In addition, I would like to say that what3words addresses are also great for couriers to use. Using three-word addresses eliminates the possibility of error, thanks to protection against typos and a special algorithm for working with dictionaries, which you can learn about from our previous publication . Unlike email addresses, the w3w address can lead you directly to the front door, and you will always understand if the address was entered incorrectly, or there was an error in voice recognition. However, this is a topic for a separate publication.

    Thank you for your attention! If you have ideas for using what3words coordinates in other areas, and you are ready to share them, we will be glad to hear your comments. You can always contact us !

    Also popular now: