Techniques for offline reverse geocoding on a mobile device? - ios

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
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

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.

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

Related

Offline map with routing on iOS

Anybody know good solution for offline routing on iOS?
I read some posts but no solution. I know that ArcGis can do it, but they have an expensive plan.
Another good idea, we have an offline map and when we need routing we will go to internet.
But it should be the same map. If anybody know how to do this tell me please.
Offline Map With Routing - iOS
Offline iPhone Map with offline routing
Offline maps with routing for a particular place
Offline maps on IPhone
In my opinion, Graphhopper is the best choice for offline routing. The project is quite active, relies on OSM data, can be embedded or consumed as a service sharing the same core logic.
I have successfully integrated it in a few projects (mostly foot routing in indoor/urban areas).
Depending on your needs, you might have to adapt a few lines of Java code.
About your second subject, think of map and routing as two different features, even if a few SDK provide both.
You can rely on graphhopper to compute an itinerary then represent it on a Arcgis's AGSMapView.
https://github.com/graphhopper/graphhopper-ios
See http://wiki.openstreetmap.org/wiki/Frameworks and http://wiki.openstreetmap.org/wiki/Routing. The entries for some of the frameworks specify whether they can do off-line routing. These wiki pages refer to systems which use OpenStreetMap data, but some of the frameworks can handle other data (e.g., ESRI shapefiles) as well.
Disclosure: I am the author of one of the mapping SDKs mentioned.

Offline reverse geocoding on iOS

There are lots of existing questions relating to this issue, but I have looked at as many of them as I could find and did not get an answer.
I'm trying to perform an offline reverse geocoding lookup on iOS based on a latitude and longitude. I'd like to be able to provide a latitude and longitude, and be provided with the country in which that point lies. I can do this with Geonames (such as: http://api.geonames.org/countryCode?lat=45.03&lng=8.2&username=demo), but I need a similar ability offline, without Internet functionality on the device.
CLLocation does not provide offline services that work reliably enough for what I'm doing, it relies on caches made while you were previously online, etc. Messy.
I've tried this: https://github.com/drodriguez/reversegeocoding but haven't had any luck, it requires some slightly complex / confusing Terminal installations using something called Thor which I've never heard of, and was throwing up a variety of errors, so I bailed on it.
I've found a few downloadable maps, but these seem to be even more complicated, and worryingly, hundreds of megabytes or even gigabytes in size – much beyond the scope of an iOS app. I only need countries, nothing smaller than that (cities, streets, locations, etc.) so I think I should be able to get a much smaller file.
So my key question is: is there some pre-existing database or tool, preferably with iOS support, that I can feed a latitude/longitude, and get a country? And, if not, what steps should I take to get such functionality working on my own?
Thanks in advance.
ReverseGeocodeCountry is a simple lightweight offline country reverse geocoder for iOS, it has a static JSON file with country polygon data that is used to reverse geocode any lat/lng:
https://github.com/krisrak/ios-offline-reverse-geocode-country
The "Countries of the World" is a .csv text file with countries, coordinates, localised country names, capitals and other information. It seems to be free to use. You just have to import it into an SQLite database.
Edit Just noticed you want reverse geocoding. The database would only be good for forward geocoding.
You can download shapefiles for all countries at http://www.gadm.org/download. If you download a .kmz, you can unpack it to a list of coordinates for the borders. You could probably take every 5th or 10th coordinate to get smaller size (with less accuracy).
Just in case I can suggest another good written offline geocoding library.
https://github.com/Alterplay/APOfflineReverseGeocoding

How do I write a "find nearest" algorithm? e.g. a store / branch locator by address / zip / "my location"

My need is simple and commonly implemented in any location based app today, display to a user a list of all "things" in his/her area (or by a zip code / address)
Using Google Maps API (especially the new "store locator library") sounds like the safest bet, but if I would like to develop something on my own, is there a "standard" way to do so? what are the options? Yahoo geo-location API (and reverse lookup)? (Google Maps API require to use their map, not just API) purchace ZIP code files? other 3rd party services? online? offline? what is the secret?
Hmm. Zip codes can be handled a number of ways, and it helps to get a general background on how they work: http://en.wikipedia.org/wiki/ZIP_code
I'd purchase a USPS database with GPS coordinates, and work from there. A simple SELECT SQL query, with a LIMIT or TOP 10 (or however many search results you'd like) when calculating the magnitude of the vector should work here.
It's been a while, but the algorithm for vector calculation is fairly simple, and should be easy to implemented in SQL: http://www.netcomuk.co.uk/~jenolive/vect5.html

GPS Software for PC

I will start on a private project that will require some GPS software on my computer, so far I have been contacting Garmin and Destinator to ask if they have some sort of SDK kit for theire map services. however they could not offer me this in Norway.
I am therefore asking here if anyone here know any kind of map software, capable of GPS and have some decent updates on maps every year, that also can provide me with some ActiveX component which I can embed in my application.
I really only need the most basic functions to setup a destination address and drive.. maybe turn on or off some various switches.
You should be able to get some stuff done with Google Maps.
It's slow, and you'll have to interact with a browser. I'm putting up an open source project to wrap all of it into an easy-to-use component, but until that time, using Google Maps from Delphi is just painful.
Alternatively, you could embed Google Earth into your application. Read here how to do that.
Or generate KML files in Delphi and serve it Google Earth either via a webserver via your local machine. You can have the KML refresh itself, and you can have users click links in the KML that's shown in GE. It's basically a stateless approach like normal webbrowsers. I've done that, and it works ok for simple stuff.
As Francois suggested, MapPoint is quite easy to use from Delphi, but it's not free, and it's slooooooooooow. I remember that adding pins took half a second or so. I'm talking about 5 or 6 years ago, so maybe nowadays things are better. The cool thing about MapPoint is that it renders the map for you in realtime, so it places labels intelligently so that they never clip at the borders of your map.
I've used MapWindow GIS from Delphi too. That was also slow and not very stable, but it's quite easy to use. If you don't know the application, just check it out, it's free.
For all of the tools that are mentioned here, there are ways to import GPS data, and all of them (except for Google Maps) will let you connect a GPS receiver, either directly (GE), or via a plugin (MapPoint, MapWindow).
Last but not least, you could always roll your own mapping solution, which is the route that I decided to take a long time ago.
You have the big names like MS Mappoint, ArcGIS from ESRI...
I remember using Mappoint from Delphi was very easy. Not free though!

Is the Map Rails Kit worth the money?

http://railskits.com/map/
Would you like to launch your own
google map mashup? Need a way to
easily get data onto a map, but don’t
want to have to dig through piles of
poorly documented Google Maps
javascript code?
The Map Rails Kit allows you to deploy
a map mashup instantly. It extracts
all the Google Maps implementation
details, organizes all the
customizations into an easy to use
config file, and reimplements the map
controls, bubbles, and markers so your
app looks unique.
Populating your map with markers
consists of working with a few simple
ActiveRecord models so it’s amazingly
easy to get started. Create marker
records with titles, bubble content,
and location. If you specify just an
address to your markers, your markers
will be automatically geocoded for
you. You can even add tens of
thousands of markers to your maps
easily, and they’ll dynamically load
onto the map only when they are
currently in view as your users
navigate the map.
The Kit includes all the usability
polish that your users would expect in
a commercial map mashup. Their current
map settings are always saved via
session so when they come back to the
page later on, they’re right where
they left off before. For new
visitors, we support hooking into an
ip2location service in order to
initialize their current position. So
they immediately see their current
spot on the map, and can begin
interacting with it.
This Kit was authored by Jacques
Crocker.
This is kind of subjective, but I don't find the Google Maps API nearly as daunting as the blurb makes it out to be. I don't think I'd pay half a grand for an API to the Maps API — especially since you can buy a whole book on the topic for like $15 even if you find Google's docs lacking.
This guy doesn't even make it clear what it is he's selling. He makes the features of using the google maps API with Rails sound more difficult than entire feature set of Google maps itself.
There are plenty of other plugins and/or gems available that do more or less the same thing with slightly more effort involved and the book of course (possibly more than one at this point).
If you want a turnkey solution for stacks of money, .NET or some more commercial platform will have more options. I would avoid using this guys solutions out of selfishness, if he does well they'll be others with more colorful marketing making such grand solutions. After which Google will be clogged with them and we'll have to wade through dozens of such spectacular offerings to find the better, albeit less polished (less advertised) open source versions.
Are there any good googlemaps plugins for rails?

Resources