GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Offline CountryCode  XML
Forum Index -> General
Author Message
hc98br



Joined: 24/02/2011 16:42:15
Messages: 2
Offline

Hi,

I'm producing an iPhone app that needs to know which country the user is in. As the use is probably roaming, online services are not really an option.

I need no more information that is provided by the countryCode service.

I've download the allCountries file - but it's massive, and has far too much information - I'm a little lost where to start.....

Any ideas most welcome

Thanks

Ben.
dik_voormekaar



Joined: 23/12/2009 09:40:39
Messages: 22
Offline

Is the countryInfo file something you can use?
http://download.geonames.org/export/dump/countryInfo.txt
Silent3



Joined: 15/02/2011 03:51:23
Messages: 8
Offline

Shall I take it that you want to use GPS coordinates to figure out what country someone is in?

What I think you'd need is a collection shapefile (or similar) boundaries, which are essentially sets of very complex polygons that define the borders of a geographic area. You would test if a latitude/longitude point is contained within a given polygon (or multi-polygon, for places that consist of multiple disjoint regions), and then you'd know whether or not that point in or out of the corresponding country.

I've recently been playing around with timezone shapefiles. The total data is about 34 MB. I suspect a set of national boundaries would be similar in size, perhaps a bit smaller.

How well locations on tiny islands would be handled, or near undulating coastlines, or at sea but within territorial waters, that's hard to say. The devil is always in the details.
marc



Joined: 08/12/2005 07:39:47
Messages: 4416
Offline

The country info xml has a bounding box. You could fetch them and use it as a rough indication of the country. For fine grained control you would need polygons as Silent3 suggests.

http://api.geonames.org/countryInfo?lang=it&country=FM&username=demo&style=full

[WWW]
hc98br



Joined: 24/02/2011 16:42:15
Messages: 2
Offline

Thanks for your help, just got time to get back to this project!

I'd missed the bounding box data, that's the closest I've got so far!

I guess I would look which bounding box the phone was in and if more than one I'd see which centre I was nearest to; In terms of population do you think that would really be good enough?? It's a balance between ease and number of people who would be given bad information!

So, Silent3 - any idea where I might get this polygon data from?

Ben.
Silent3



Joined: 15/02/2011 03:51:23
Messages: 8
Offline

I got timezone shapefiles from here:

http://efele.net/maps/tz/world/

I can't vouch for their accuracy. They seem to work pretty well, but I've already found one odd situation were Louisville, Kentucky itself wasn't in the polygon-defined borders for the America/Kentucky/Louisville timezone. A fair amount of stuff at sea, even a little bit offshore, appears to get missed too, not matched to any timezone.

I'm trying to use country/admin1/admin2 info to determine timezones first, then using the shapefiles when that isn't enough (some US counties are split, for example), but there's a little feedback in the process because I've used the shapefiles to correct some of my country/admin1/admin2 associations built from data provided here, where geonames data looks a little flaky (like places all over Florida reported as being in the America/Kentucky/Louisville, which makes no sense).

I wish I could find something definitive and authoritative about what places are in what Olson timezones, but so far I'm just doing the best I can with a little logic and a little guesswork, and simply having to accept my final results may only be 99-99.9% accurate.
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team