在不使用 Geonames.org 等 Web 服务的情况下根据纬度/经度确定时区
是否有可能在不使用网络服务的情况下确定点的时区(纬度/经度)?Geonames.org 不够稳定,我无法使用 :( 我需要它才能在 PHP 中工作.
is there any possibility to determine the timezone of point (lat/lon) without using webservices? Geonames.org is not stable enough for me to use :( I need this to work in PHP.
谢谢
推荐答案
前段时间我遇到了这个问题,完全按照亚当的建议做了:
I had this problem a while back and did exactly what adam suggested:
- 从 geonames.org 下载 城市数据库
- 将其转换为紧凑的纬度/经度 -> 时区列表
- 使用 R-Tree 实现来有效地查找最近的城市(或者更确切地说,它的时区)到给定的坐标
- Download the database of cities from geonames.org
- convert it to a compact lat/lon -> timezone list
- use an R-Tree implementation to efficiently lookup the nearest city (or rather, its timezone) to a given coordinate
IIRC 用不到 1 秒的时间填充 R-Tree,然后每秒可以执行数千次查找(均在 5 年的旧 PC 上).
IIRC it took less than 1 second to populate the R-Tree, and it could then perform thousands of lookups per second (both on a 5 year old PC).
相关文章