Project Description
GeonamesDotOrgDotNet is a libaray to access the webservice of GeoNames (www.geonames.org) from a dotnet application. It provides easy to use methods to call the webservice functions and returns dotnet classes. There is no need to parse xml or anything similar.

Currently only the following webservice calls are supported:
  • findNearby
  • findNearbyPlaceName
  • findNearByWeather
  • findNearbyWikipedia
  • get
  • hierarchy
  • children
  • gtopo30
  • srtm3

For more information see http://www.geonames.org/export/ws-overview.html.

Example
Starting point is the class GeoNamesOrgWebservice that provides static methods. Most methods are returning a single object or a list of the following classes:
  • Geoname
  • WeatherObservation
  • WikipediaArticle

// finding some place in Berlin, Germany
// (using prefix m for decimal literals)
Geoname Place = GeoNamesOrgWebservice.FindNearbyPlaceName(52.51m, 13.4m);

// getting all parents
IEnumerable<Geoname> ParentPlaces = Place.Hierarchy();

// display the partents
// (will print out something like: "Globe > Europe > Germany > Land Berlin > Berlin >")
foreach (Geoname x in ParentPlaces)
    Console.Write(x.Name + " > ");


Classes
classes.png

Testing
A little WinForms applications allows you to call these methods and visualize the data:

testapp.png

Fell free to take a look on the sourcecode.

Remarks
  • Since a webservice is involved every method call can throw exceptions on network errors (e.g. timeouts). You should catch the WebException to handle these situations.
  • Not all Methods provided by the Geonames.org team are implemented yet. Please feel free to contact me or help me with the programming.
  • If you need asynchronous access to the webservice you have to handle the threading part yourself. All methods are blocking at the moment.
  • You need .NET Framework 3.5 to use GeonamesDotOrgDotNet

Last edited Nov 2, 2008 at 1:02 PM by BenjaminSchroeter, version 10