[OSM-dev] Questions on Nominatim and administrative boundaries + osm2pgsql

David MENTRE dmentre at linux-france.org
Sun Dec 20 10:55:55 GMT 2009


Dear fellow OSM hackers,

We are working on improving MapOSMatic, especially for international support.

We are using http://nominatim.openstreetmap.org to query OSM in a
human-friendly way, which, indeed, is a wonderful tool!

Now we would like to use its results to query our own copy of the DB
(created with osm2pgsql). We found a way to do this, but we are not
quite sure it's the "right way" (tm) to do it...

For example, we query Nominatim for "Paris". One of the results is an
administrative boundary limit (the one with osm_id 7444). For that
entry, we would like to query our OSM DB to determine its
administrative level.

If we do:
  select * from planet_osm_line where osm_id=7444;
then we don't get anything.

However, when we do:
  select * from planet_osm_line where osm_id=-7444;
then we get exactly what we need.

Is this the right way to do it? Can we assume that, when nominatim
returns an entry with class="boundary" type="administrative" and
osm_type="relation", then we can safely query the planet_osm_line
table with the _opposite_ of osm_id?

Now, we already know that it does not always work like this... For
example, if we try this with the entry for "Paris, Kentucky, United
States of America" (osm_id 130722), then it simply does not work at
all. In fact, it doesn't seem to work at all with none of the other
administrative boundary query results that nominatim returns us for
"Paris".

Should we instead query the planet_osm_rels table? Can we assume this
table is always present in the database? If yes, how do we parse its
fields to get the IDs to the other tables?

Are there any documentation on the DB tables produced by osm2pgsql?

Thanks a lot in advance!
Regards,

david -- for MapOSMatic dev team




More information about the dev mailing list