GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Hierarchy query with exported dump  XML
Forum Index -> General
Author Message
qqilihq



Joined: 28/01/2013 13:17:21
Messages: 5
Offline

Hi everybody,

I just found out about GeoNames recently and I'm using it very successfully for some information extraction tasks. I'm using the dump files with a local DB. Now I want to access hierarchies, e.g. get the state, country, continent, … of a given city (like the "hierarchy" query offered by the web service [1]).

Currently I do not understand how to retrieve this hierarchy from the given database scheme. As far as I can see, the hierarchy.zip file does not provide this data. Can somebody give me a hint on how to achieve this?

Best regards,
qqilihq

[1] http://api.geonames.org/hierarchy?geonameId=2825297&username=demo
marc



Joined: 08/12/2005 07:39:47
Messages: 4501
Offline

hierarchy.zip : parentId, childId, type. The type 'ADM' stands for the admin hierarchy modeled by the admin1-4 codes. The other entries are entered with the user interface. The relation toponym-adm hierarchy is not included in the file, it can instead be built from the admincodes of the toponym.


Hope this helps.

Marc

[WWW]
qqilihq



Joined: 28/01/2013 13:17:21
Messages: 5
Offline

Hi Marc,

this helps. Just to make clear, I understood correctly:

Four levels of political hierarchies are modeled directly by the four columns. Hierarchies below those levels are in the dedicated hierarchy.zip. From my findings, this hierarchy also contains relations of POIs like hotels assigned to cities.

Thank you!
marc



Joined: 08/12/2005 07:39:47
Messages: 4501
Offline

The hierarchy file contains relations not covered by the admin relations, such as the hotel to city relation you mention.

Best Regards

Marc

[WWW]
qqilihq



Joined: 28/01/2013 13:17:21
Messages: 5
Offline

Unfortunately, I'm still having issues with understanding the hierarchy mechanisms. I currently try to replicate the functionality of the hierarchy web service with my local database dump.

If I understood correctly, there are two potential ways of retrieving a "parent":

1) Using the countryCode, admin1Code, ... admin4Code and checking in the locations data for entities with ADM1, ... ADM4 feature code and matching codes.

2) Using the data from hierarchy.txt file. Now:
a) If the hierarchy contains an entry, which one has priority? The hierarchy entry or the one I get via 1)?
b) Is there a difference in priorities, based on the type given in the hierarchy? (mostly it is "ADM" or empty/null, but there is also a minor number of other types).

Is there an explanation somewhere how to correctly perform hierarchical queries? I have searched through the forums and read the readme files several times but I cannot find any proper documentation how the hierarchy mechanism works.
marc



Joined: 08/12/2005 07:39:47
Messages: 4501
Offline

It depends on what you want to achieve. Normally the info in 1) is sufficient.

Best

Marc

[WWW]
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team