2

Is there a function that will return the Time Zone (or an offset from some "fulcrum" such as GMT or UTC) given the coordinates?

IOW, I'd like to (assuming "TimeZoneType" is a class or enum or so):

TimeZoneType timeZone = getTimeZoneForCoordinates(<latitude>, <longitude>);

-or:

int timeZoneDifferential = getTimeZoneOffsetFromUTCForCoordinates(<latitude>, <longitude>);

I was torn between posting this question here an on gis.stackexchange. If advised to, I'll delete this question and post it there...

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
  • I don't see how the language matters, but English is what my GUI is in (at least for now; it may be globalized/localized later) – B. Clay Shannon-B. Crow Raven Oct 30 '12 at 15:58
  • 1
    I meant *programming* language, since your question isn't tagged with any. – LittleBobbyTables - Au Revoir Oct 30 '12 at 16:47
  • 1
    @MiserableVariable It is not as trivial as you think. The actual timezones do not strictly follow longitude. The international date line is a classic example, but there are many exceptions where timezone delineations bend around the lines of longitude for practical reasons. Indeed, there are also timezones which have offsets that are not a whole multiple of 1 hour. – paddy Oct 30 '12 at 22:23
  • To add what @paddy said. Consider that Arizona doesn't do Daylight Saving. And El Paso, Texas is in the Mountain time zone while the rest is in Central. See http://www.timetemperature.com/tzus/time_zone.shtml for a map showing that time zone is only vaguely correlated with longitude. – Jim Mischel Oct 30 '12 at 22:47
  • See http://stackoverflow.com/questions/6247432/timezone-database-with-lat-lng-coordinates. Also http://stackoverflow.com/questions/1855393/algorithm-for-getting-time-zone-from-geo-coordinates – Jim Mischel Oct 30 '12 at 22:48
  • @ paddy and Jim: Yes, I realize it's not a simple function, but it has to be possible that, given a precise location, the time can be deduced. If you can contact a person in Lewiston, Idaho, and get an answer as to their local time, and then a person in Clarkston, Oregon, for the same info, although they may be close to each other, the answer could be different, and yet it can be accomplished. Programming is simply an automated way of doing such things, in a sense. – B. Clay Shannon-B. Crow Raven Oct 31 '12 at 14:17

1 Answers1

1

A simple question, a big answer:

There are few companies that are able to do that. The iphone was the first device that I know that could determine the timeZone from geo position. Even my TomTom Navi cannot do that and I have to manually enter the TimeZone offset.

Here how you would do that.

  1. Buy for some xxx euro navteq "WorldMaps", or go cheaper using OpenStreetMap. Some conversion later you will have the polygons for each country of the world. Such country will typically have 50.000 points or more representing the country border.

  2. Once you have that polygons you have to write a function that gives the countryPolygonId (or countryID) for given (lat/lon).
    (countryId = findCountry(lat, lon); // using a point in polygon method

  3. Once you have the country, you must find the next big city: You need to have a list of cities that are supported by the TimeZone module of your system (I think there is a norm for that, but I am not sure.)

Then you have to translate countryId, cityId to a String like "Austria/Vienna". This is your TimeZone and you cann initialize with TimeZone zt = new TimeZone("Austria/Vienna");

I hope this was interesting, but this is very demanding to implement, and to get the neccessary data for that task.
I have done steps 1, and 2 for a different use case.

AlexWien
  • 28,470
  • 6
  • 53
  • 83
  • The TimeZone class has functions such as GetDateTimeUTC(), GetDateTimeLocal(), GetUTCOffset(), etc., so I reckon if I store the UTC times and the UTCOffset for each user, it will be easy enough to compute given this UTC time, what time was it for the remote user, and what time was it for the local user. BTW, I was in Wien six years ago - beautiful city! – B. Clay Shannon-B. Crow Raven Nov 28 '12 at 23:41
  • Thanks, I like my City, too. Your Question was about coordinates to Timezone. Your comment now is different from your OP – AlexWien Nov 29 '12 at 00:24