[GIS] method to create offline geocoder using OSM xml data

androidgeocodingopenstreetmap

I am trying to develop an offline android map that makes use of OSM map tiles of 15 zoom level, For this purpose i used an open source library : Osmdroid

Now, i m looking into the possibility of creating an offline geocoding/ reverse geocoding that can be integrated with my application,

can i use Osm xml data for that purpose? if so , then can anyone suggest/explain how to use it to create SQlite db.. to be used wit my app

While doing this, i hope i m not violating any data usage terms or conditions?

Thanks

Best Answer

Yes, you can use the OSM XML data. Unfortunately it's a 250GB XML file. Trying to get all that data onto a mobile device is very challenging.

I don't think SQLite is the right way to store the map data, you're going to need something more efficient (in terms of disk space efficiency). There is a format under development called OSM Mobile Binary Format, which may be suitable:

Essentially it breaks the world up into smallish chunks, and has some simple math to figure out which one you need for a given position in the world. You should be able to fit at least most of the world on a typical smartphone in this format.

That will cover reverse geocoding. But for geocoding you will need your data the other way around, perhaps an SQLite database containing street/city names with a single lat/long coordinate for each one. Once you have a lat/long, you can quickly search the OSM Mobile Binary files to find the rest of the metadata related to that entry.

You are required to provide your own mirror of the data for all the users of your app. You cannot write an app which downloads data directly from the openstreetmap servers. You will be blacklisted. This might mean you will need to sell your app for a nominal fee, to cover server costs.

In terms of licensing, it's creative commons/share alike. You need to give clear attribution to openstreetmap.org somewhere in your app, and any modifications to the map data must be released under the same or equivalent license (your actual app can be any license). See the OSM wiki for more specific details.