Skip to content

Latest commit

 

History

History
27 lines (14 loc) · 1.76 KB

README.md

File metadata and controls

27 lines (14 loc) · 1.76 KB

geo-util

The project currently offers support for two common geocoding operations without the need to install complicated GIS software.

Getting started

You first need to download and store locally at least two files from Geonames.org:

There are two basic classes that you will want to use: ReverseGeocoder and Countrycoder. Both are initialized giving the two above files as arguments to their constructors. Once initialized, you can use the following two methods:

  • ReverseGeocoder.getCountryByLatLon(lat, lon), which given a pair of coordinates returns the country where these belong,
  • Countrycoder.getCountryByLocationName(locationName), which given a location name returns the country where this belongs.

Considerations

Both of the above methods are not expected to always work correctly. This is due to the following. The first one (getCountryByLatLon) is based on a very simple approximation, i.e. returns the country of the closest geographical object in the index (therefore, you should expect better accuracy by using the allCountries file compared to the cities1000). The second method (getCountryByLocationName) simply indexes the location names (incl. alternate names) found in the geonames files and returns the country through a look-up. It does not perform any approximate text matching, nor does it handle name synonymy.

Contact for further details about the project

Symeon Papadopoulos ([email protected])