Skip to content

Connecting to GeoNames

Jeremy Friesen edited this page Feb 2, 2021 · 3 revisions

Overview

The GeoNames geographical database covers all countries and contains over eleven million placenames that are available for download free of charge.

More Information

Prerequisites

Step 1: Signup with GeoNames

You need to signup for a GeoNames user name on the GeoNames login page. You will need to update your account to allow for public API calls. Test your ability to connect to GeoNames with...

http://api.geonames.org/searchJSON?q=port&&maxRows=10&username=YOUR_ACCOUNT_NAME

You should see about 10 results for this URL.

Step 2: Register your GeoNames account name in QA

Put the following statement in an initializer and restart the rails server.

Qa::Authorities::Geonames.username = 'YOUR_ACCOUNT_NAME'

Accessing via QA

Authority: geonames

Subauthorities:

None supported

NOTE: The linked data module for QA also provides access to this authority. It returns additional data including the URI for terms. See Using-the-Linked-Data-module-to-access-authorities for more information.


Example search queries

Example search:

/qa/search/geonames?q=port

Result:

[
  {"id":"http://sws.geonames.org/2088122/","label":"Port Moresby, National Capital, Papua New Guinea"},
  {"id":"http://sws.geonames.org/934154/","label":"Port Louis, Port Louis, Mauritius"},
  etc.
]

NOTE: The qa request is converted to the following GeoNames request. This is for information only. You do not need to know this to use QA.

http://api.geonames.org/searchJSON?q=port&username=YOUR_ACCOUNT_NAME&maxRows=10

Example term fetch request

Example fetch:

/qa/show/geonames/2088122

Result:

{"timezone":{
   "gmtOffset":10,
   "timeZoneId":"Pacific/Port_Moresby",
   "dstOffset":10},
 "bbox":{
   "east":147.2209134174236,
   "south":-9.546311526867365,
   "north":-9.408148473132636,
   "west":147.08086658257642,
   "accuracyLevel":0},
 etc.
}

NOTE: The qa request is converted to the following GeoNames request. This is for information only. You do not need to know this to use QA.

http://www.geonames.org/getJSON?geonameId=2088122&username=YOUR_ACCOUNT_NAME

Example list all terms

Not supported


Documentation

GeoNames documents their API at... https://www.geonames.org/export/web-services.html

Clone this wiki locally