Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

DSchwartz88

macrumors 6502
Original poster
May 18, 2006
419
0
Hey All,

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.

Thanks,
Daniel
 

Flyncode

macrumors newbie
Sep 5, 2007
6
0
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.
 

xsmasher

macrumors regular
Jul 18, 2008
140
0
How to find city name

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

Geonames data
http://www.geonames.org/export/
files for each country, plus "all"
http://download.geonames.org/export/dump/

Data pulled from Wikipedia
Geocoordinates from Wikipedia for Google Earth
http://www.webkuehn.de/hobbys/wikipedia/geokoordinaten/index_en.htm
found on http://www.downloadsquad.com/2006/10/26/google-earth-coordinates-for-all-of-wikipedia/
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.