算法从地理坐标获取时区 [英] algorithm for getting time zone from geo coordinates
问题描述
我想要写的应用程序,其中用户可以在地图上(不仅是城市)指向任何地方,并得到时区在那个地方。
I want to write app where user can point any place on map (not only cities) and get timezone in that place.
什么数据结构(应用程序不会有互联网连接)和算法,我应该使用?我在哪里可以获取所需的数据(我不会更准确,然后占卜映射到24矩形)?
What data structure (app will not have Internet connectivity) and algorithm should I use? Where I can obtain needed data (I wont more accuracy then divining map into 24 rectangles)?
我会写在Java ME的我的应用程序。
I will write my app in Java ME.
推荐答案
由于时区的基础上的政治实体,而不是简单的物理纬度/经度计算,我会创建一个映射的多边形上的纬度/经度坐标的数据结构为政治实体(国家和省/州),然后有一个映射的政治实体和当前日期到时区偏移一个独立的结构。
Given that time zones are based on political entities rather than simply a physical lat/lon computation, I would create a data structure that mapped polygons over lat/lon coordinates into political entities (country and province/state) and then have a separate structure that mapped political entities and current date into timezone offset.
这样的话你不但避免冗余,同时也:
That way you not only avoid redundancy, but also:
- 您可以独立显示一组特定的坐标的DST的参考信息,以及
- 在当前一些国家改变了夏令时开始和结束的规则,你有一个地方来进行更新。
然而,由于一些边界的高度不规则的形状,你需要一个相当大的数据结构的准确性,取决于您的输入和/或显示器的分辨率。
However, given the highly irregular shape of some borders, you'll need a fairly large data structure for accuracy, depending on the resolution of your input and/or display.
这篇关于算法从地理坐标获取时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!