开发者

Geocoding with Timezone information

Is there a good way to get Timezone information with DST information from a lat/lo开发者_如何学Pythonng coordinate or a physical address?

I've found some web services that seem to offer this service, but I can't tell how reliable they might be, or if they might disappear at some point. I need something for my application that will be around long term.

  • http://www.earthtools.org/webservices.htm#timezone
  • http://www.geonames.org/export/web-services.html#timezone

Are these services reliable and long-term? Are there other, better options?


The answer in this other question is a great solution to this question - Determine timezone from latitude/longitude without using web services like Geonames.org


I searched for a long time to find a database I could host locally to map lat+lon coordinates to a timezone (i.e. no dependency on a remote service). This is the best I was able to come up with.

A vectorized timezone map is available here: http://georezo.net/jparis/Data/wrldtz_tab.htm . This is a database of almost 2000 "regions". Each region is defined by a set of polygons on the surface of the Earth, and it tells you what timezone you are in if you are inside that region.

There are major drawbacks:

  • It hasn't been updated since 2002.
  • It only defines polygons over land (if you are over water, you are not considered to be in any time zone).
  • It does not give you the Olson identifiers for the timezones, only the name of the country and the (standard time) UTC offset.

The last limitation might not be a big problem for you: there are not that many timezones and maybe you are able to invest the time to manually assign each one to its Olson name (especially if you are interested in only a small number of timezones).

In order to read the data files which you can download from the web site given above, you will need to use this library. I would be able to come up with some sample code if you are interested.

You also mention using a physical (postal) address. Translating those to lat+lon coordinates is a whole separate question, and my guess is that you can't do a good job of that without using some kind of online/remote service.

-Phil


Tauren. I would propose using GeoIP by MaxMind.

I have written a post on how to use Geolocation with time zone support in Django but the same approach can be applied to other languages also.

http://www.konstruktor.ee/blog/geolocation-with-time-zone-support-in-django

GeoIP has many bindings for different languages.

http://www.maxmind.com/app/api

I think in the long run this is the most reliable solution to use.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜