在不使用 Geonames.org 等 Web 服务的情况下根据纬度/经度确定时区 [英] Determine timezone from latitude/longitude without using web services like Geonames.org

查看:30
本文介绍了在不使用 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).

这篇关于在不使用 Geonames.org 等 Web 服务的情况下根据纬度/经度确定时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆