public
Description: Offline reverse geocoding library and scripts for the iPhone.
Homepage:
Clone URL: git://github.com/drodriguez/reversegeocoding.git
name age message
file .gitignore Fri Mar 27 15:39:11 -0700 2009 Adding .gitignore. [Daniel Rodríguez Troitiño]
directory Classes/ Mon Mar 30 16:18:43 -0700 2009 Copyright notices. [Daniel Rodríguez Troitiño]
file Info.plist Tue Mar 31 06:42:06 -0700 2009 AdHoc profile to do some testing on the device. [Daniel Rodríguez Troitiño]
file LICENSE Mon Mar 30 16:47:09 -0700 2009 README and external LICENSE file. [Daniel Rodríguez Troitiño]
file MainWindow.xib Sat Mar 28 15:04:21 -0700 2009 Implemented a simple application based on Locat... [Daniel Rodríguez Troitiño]
file README.markdown Tue Mar 31 23:22:32 -0700 2009 Remove <> around email. [drodriguez]
file RGConfig.h Mon Mar 30 15:04:12 -0700 2009 Modified to use the values from the RGConfig.h ... [Daniel Rodríguez Troitiño]
file RGReverseGeocoder.h Tue Mar 31 01:45:16 -0700 2009 Adding placeForLatitude:longitude: message. [Daniel Rodríguez Troitiño]
file RGReverseGeocoder.m Tue Mar 31 07:05:45 -0700 2009 There is no Application Support directory on th... [Daniel Rodríguez Troitiño]
directory ReverseGeocoding.xcodeproj/ Tue Mar 31 06:42:06 -0700 2009 AdHoc profile to do some testing on the device. [Daniel Rodríguez Troitiño]
file ReverseGeocoding_Prefix.pch Fri Mar 27 13:46:32 -0700 2009 Starting Xcode project. [Daniel Rodríguez Troitiño]
file dist.plist Tue Mar 31 06:42:06 -0700 2009 AdHoc profile to do some testing on the device. [Daniel Rodríguez Troitiño]
file geocoder.thor Tue Mar 31 01:35:52 -0700 2009 Add option to compress harder the database. [Daniel Rodríguez Troitiño]
file main.m Mon Mar 30 16:19:35 -0700 2009 Copyright notice. [Daniel Rodríguez Troitiño]
README.markdown

Reverse Geocoding

This project a Objective-C class (aim to be used on the iPhone) to include in your application a reverse geocoding system. Included in the project there is also a Thor http://github.com/wycats/thor script for downloading the cities database and transforming it into a suitable format for the iPhone.

What's a “reverse geocoding” system?

As Wikipedia says http://en.wikipedia.org/wiki/Geocoding:

Geocoding is the process of finding associated geographic coordinates … from other geographic data, such as street addresses, or zip codes. …

Reverse Geocoding is the opposite: finding an associated textual location such a street address, from geographic coordinates.

How do I use it

The project includes a script for Thor http://github.com/wycats/thor that tries to make the use of the project classes and the needed resources as easy as I can.

This project tries to leverage the tools include in Mac OS X 10.5, but there are some steps you have to do before using this script. So open your Terminal and type the following (except the dollar sign):

    $ gem install thor sqlite3-ruby fastercsv

After Thor installation you have to install this project Thor script into your system:

    $ thor install http://github.com/drodriguez/reversegeocoding/blob/master/geocoder.thor?raw=true

When asked, you should say “y” to the question “Do you wish to continue?” and provide “geocoder” as name for the script in your system.

Once installed you can use Thor anywhere in your system to access the geocoder tasks. You can get a list of the task typing the following:

    $ thor list geocoder

And you can update the Thor script easily by:

    $ thor update geocoder

The easiest way to use the reverse geocoding system is to use the defaults, download all (code and databases), and create the SQLite database and the auxiliary files.

    $ thor geocoder:download all
    $ thor geocoder:database

Then in your application include the following files:

  • RGReverseGeocoder.h
  • RGReverseGeocoder.m
  • RGConfig.h
  • geodata.sqlite.gz
  • geodata.sqlite.plist

And also add libsqlite3.dylib, libz.dylib and CoreLocation.framework to your application.

Then at the start of your application call to:

    [RGReverseGeocoder setupDatabase];

And when you need to get a place from a location:

    [[RGReverseGeocoder sharedGeocoder] placeForLocation:myLocation];

If you need more help look at help from the Thor script, the documentation of the source code and the example project included in this Git repository.

Credits

Author: Daniel Rodríguez Troitiño (drodrigueztroitino thAT yahoo thOT es)

This project could not have been done without the free data provided by GeoNames http://geonames.org. GeoNames data is licensed under a Creative Commons Attribution 3.0 License http://creativecommons.org/licenses/by/3.0/. The data is provided "as is" without warranty or any representation of accuracy, timeliness or completeness.

There is a small “inspiration” on some parts of SQLite Persistent Objects for Cocoa and Cocoa Touch http://code.google.com/p/sqlitepersistentobjects.

There is also a method adapted from Figure 14-10 of Hacker's Delight by Henry S. Warren http://www.hackersdelight.org/.