How to get a complete address from database

I’d like to implement reverse geocoding from OSM database.

  1. From lat,lon → node
  2. Node → way (Current_way_nodes table)
  3. From Way Id, I can get some tags from current_way_tags.

My questions is how can I composite these tags into a complete address.
May be the format are like ‘door number, street, city, state(province), country’.

The current_way_nodes have ‘name’ tag, some time the name is a street name, other time it will be a city name. How do I know them exactly.

Thanks a lot!

First of all Openstreetmap lacks data, it’s especially sparse on:

  1. house numbers
  2. postal codes
  3. postal addresses
  4. even countries

Just so you know, you can stil build this in areas where you have good OSM coverage, but you will still have problems like wether something is in the US or Mexico.

I would suggest you have a look at

What do you mean? Many objects in OSM have names, nodes as well as ways, usually nodes are places like cities and musuems, and the ways represents streets…

Streets are usually ways tagged highway=“somthing”
Places nodes tagged with place=“something”.
House numbers,postal code have no good standard that I know of.