remizovm / geonames

Golang wrapper over the geonames.org website dump
MIT License
23 stars 5 forks source link

geoname_id #22

Closed sundarv85 closed 7 years ago

sundarv85 commented 7 years ago

Hello,

From the answer here - Maxmind returns _geonameid, which can be used to lookup the city in geonames.

Is this possible?

remizovm commented 7 years ago

Hello, @sundarv85! If the geoname ID of the MaxMind service is valid (it does match the same feature of the geonames database), then the task should be pretty simple:

Firstly, you will need to get ISO2 codes of all countries and then - get all features for all ISO2 codes. There are two ways of reaching this - using CountryInfo() and Features() functions or using AllCountries() function. Then save the feature list somewhere (for example, in a MySQL database). Afterwards write a function that will select the feature by the given geoname ID from your storage (ex. SELECT * FROM features_table WHERE geoname_id = 123456). Basically, thats it.

My library does provide the access to geonames data, but I can write a simple example or answer your questions.