View Full Version : CoreLocation City Name
Jul 25, 2008, 10:45 AM
In my application i want to use the CoreLocation framework to append a the users current location to a string (which will be sent out as a POST to php, but thats not imporant). When using CoreLocation im noticing that you really only get Lat and Long co-ordinates back. In the twitteriffic app, and some others i notice it will give you city names and not lat and long lines, how would i ask CoreLocation to give me back a city name, or how do i take my lat long co-ordinates and translate them into a city name.
Jul 25, 2008, 01:32 PM
If another application is doing a city lookup, it's going to be a function that that app is performing, or one of its services. I don't seem any ability in CoreLocation to get the city name, which is to be expected.
If you want to perform it yourself, you're going to have to dive into Geographic Information Systems (GIS for short), where you compare the Lat/Lon you get from CoreLocation to a set of polygons loaded from a file, seeing which polygons the point is inside of. Then comes a myrid of questions: how will the information about the city polygon be stored and how will you load it? How are you going to do the search (there are pre-prepared algorithms you could use)? How expansive of a city search are you going to be doing?
There's no quick-and-easy way to do it, really, at least from the app perspective. You may be able to find a web service that would do the search for you, and return the city name. If you can find that, then you'd be golden. Short of that, you'd have to put infrastructure in place.
Hope this helps.
Jul 25, 2008, 02:49 PM
Last time I looked for city data, I found these data sets - you could put them in a database (on a server) and query them to find a list of nearest cities. (There's no "city limits" data here, just a single point for each city center.)
files for each country, plus "all"
Data pulled from Wikipedia
Geocoordinates from Wikipedia for Google Earth
found on http://www.downloadsquad.com/2006/10/26/google-earth-coordinates-for-all-of-wikipedia/