从经纬度查找时区 [英] Timezone lookup from latitude longitude

查看:86
本文介绍了从经纬度查找时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何可以将纬度/经度转换为时区的库(或者更好的网络服务)?

Is there any library (or even better, web service) available which can convert from a latitude/longitude into a time zone?

推荐答案

对于我正在从事的项目,我相当深入地研究了这个问题.GeoNames.org 和 EarthTools.com 在许多情况下都是不错的选择,但存在以下严重缺陷:

I looked fairly deeply into this question for a project I am working on. GeoNames.org and EarthTools.com are both good options for many situations but with the following serious flaws:

  • GeoNames.org 通过在其数据库中搜索包含时区字段的最近点来查找时区.这通常会导致靠近边界的错误结果.它也非常缓慢,导致每个请求的查询时间大约为几秒钟.如果查询点附近的数据库中没有项目,它也不会返回有效的时区.GeoNames 还限制了每天可以进行的查询数量,从而使批量操作变得困难.
  • EarthTools.org 使用地图并能够快速返回查询,但它没有考虑大多数位置的夏令时,它返回原始偏移量而不是时区 ID(即,它们返回"GMT-7"而不是美国/芝加哥").此外,我在准备这篇文章时只是查看了他们的页面,谷歌浏览器警告了他们网站上的恶意软件.这对我来说是新的,它可能会改变,但显然令人担忧.

这些缺陷意味着这些现有工具不适合我的需求,因此我推出了自己的解决方案并将其发布以供一般使用.你可以在这里找到它:

These flaws meant that these existing tools were not suitable for my needs so I rolled my own solution and have published it for general use. You can find it here:

http://www.askgeo.com/

AskGeo 基于世界时区地图,因此它返回每个有效纬度和经度的有效时区.它返回在 Linux 和大多数其他操作系统和编程框架上使用的标准时区 ID(例如,America/Los_Angeles").它还返回当前偏移量,充分考虑夏令时.

AskGeo is based on a time zone map of the world, so it returns a valid time zone for every valid latitude and longitude. It returns the standard time zone ID (e.g., "America/Los_Angeles") used on Linux and most other operating systems and programming frameworks. It also returns the current offset, taking full account of daylight savings time.

它非常易于使用,网站主页上记录了使用情况.API 支持批量查询,因此如果您需要进行大量查找,请使用批处理接口,而不是通过串行请求使我们的服务器陷入困境.批量查询也更快,所以每个人都赢了.

It is extremely easy to use and usage is documented on the main page of the site. The API supports batch queries, so if you need to do a lot of look-ups, please use the batch interface rather than bog down our servers with serial requests. The bulk queries are also much faster, so everybody wins.

当我们第一次推出它时,我们是在 Google App Engine (GAE) 上构建的,并免费提供给所有用户.这是可能的,因为当时 GAE 的价格非常低.从那时起,我们的服务器负载大幅增加,GAE 的价格也随之上涨.这两个因素的结合使我们转向使用 Amazon Web Services 进行托管并开始对商业用途收费,同时为非营利、非商业开源项目和研究人员提供免费服务.对于商业用户,我们提供 1000 个免费查询,让潜在客户评估 API 以确保它满足他们的需求.有关定价和条款,请参阅网站.

When we first launched this, we built it on Google App Engine (GAE) and made it free to all users. This was possible because GAE's prices were so low at that time. Since then, our server load has increased substantially and GAE's prices went way up. Both factors combined led us to switch to Amazon Web Services for hosting and to start charging for commercial use, while keeping the service free for non-profit, non-commercial open source projects, and researchers. For commercial users, we provide 1000 free queries to let potential customers evaluate the API to make sure it meets their needs. See the web site for pricing and terms.

底层库是用 Java 编写的,由于大众需求,我们还在商业许可下发布了该库.网站上提供了图书馆的完整文档和定价详情.

The underlying library was written in Java and due to popular demand, we also released the library under a commercial license. Full documentation of the library and pricing details are on the web site.

我希望这是有用的.这对我正在从事的项目当然很有用.

I hope this is useful. It certainly was useful for the project I was working on.

这篇关于从经纬度查找时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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