1

I am working on a mobile mapping application (currently iOS, eventually Android) - and I am struggling with how to best support reverse geocoding from lat/long to Country/State without using an online service.

Apple's reverse geocoding API depends on Google as the backend, and works great while connected. I could achieve similar functionality using the Open Street Maps project too, or any number of other web services.

What I really want however is to create a C library that I can call even when offline from within my application, passing in the GPS coordinates, and having it return the country and/or state at those coordinates. I do not need finer granularity than state-level, so the dataset is not huge.

I've seen examples of how to do this on a server, but never anything appropriate for a mobile device.

I've heard Spatialite might be a solution, but I am not sure how to get it working on iOS, and I wonder if it may be overkill for the problem.

What are some recommended techniques to accomplish this?

radven
  • 2,296
  • 1
  • 22
  • 39
  • 1
    possible duplicate of [Reverse Geocoding Without Web Access](http://stackoverflow.com/questions/1425149/reverse-geocoding-without-web-access) – Darius Bacon Jan 04 '11 at 00:31

3 Answers3

4

Radven

You will need to get the Shapefiles (lat/lng outline) of all the administrative entities (US states, countries, etc). There are a lot of public domain sources for these. For example, the NOAA has shapefiles for US states and territories you can download:

http://www.nws.noaa.gov/geodata/catalog/national/html/us_state.htm

Once you got the shapefiles, you can use a shapefile reader to test if a lat/lng is within a shape. There are open source readers in C, just google. I seen stuff at sourceforge for shapefiles, but have not used these myself.

The Team at OpenGeoCode.Org

Andrew - OpenGeoCode
  • 2,299
  • 18
  • 15
0

If you're looking for an approach based on a quadtree, try Yggdrasil. It generates a quadtree based on country polygon data. A Ruby example script can be found here.

leo
  • 7,518
  • 1
  • 24
  • 25
0

I can suggest good written offline geocoding 3rd party library. https://github.com/Alterplay/APOfflineReverseGeocoding

Krivoblotsky
  • 1,492
  • 11
  • 17