foursquare 如何确定签到的时区?
查看他们的 checkin api 当您添加签入时,它不需要传递任何日期时间或时区信息,但当您查询用户签入历史记录时,它返回时区字段 表示签到发生地的时区。我想他们会以某种方式通过纬度/经度或其他方式查找它。有谁知道具体是怎么做的吗?
Looking at their checkin api when you add a checkin it does not require passing in any datetime or timezone information, but when you query a users checkin history it returns a timezone field indicating the timezone of where the checkin took place. I imagine somehow they're looking it up by lat/lng or something. Does anyone know specifically how they're doing it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这肯定是针对登记位置进行基于位置的查找。
我的猜测是,他们在创建场地时计算并缓存该场地的时区。我会将这些信息存储为元组到字符串的映射,这些字符串以城市、[州]、国家等数据为关键字,存储在分布式哈希表数据库(如 memcached)中。我会保留每个时区可用的边界多边形(以及许多其他地理数据),并提供基于纬度/经度查询它的服务。这通常称为地理编码服务。根据内存限制和使用变化,我会延迟地填充来自该服务的元组映射(即,仅当用户请求时)。
对于无场地签到,他们可能会根据纬度/经度计算一次,并将此信息缓存较短的时间,以防其他人在同一位置签到。我敢打赌,他们通常也会利用时区字段是可选的这一事实,并且如果地理编码服务过载,则不会填充它。
如果您正在寻找可以处理此类查询的服务,请查看 http://www.geonames.com(文档)。
It's most certainly a location-based look up against the check-in location.
My guess is that they compute and cache the timezone for a venue when it is created. I'd store this information as a map of tuples to strings keyed on data like city,[state],country in a distributed hash table database like memcached. I'd keep bounding polygons available for each timezone (as well as many other geographic data) and provide a service for querying it based on lat/lon. This is typically called a geocoding service. Depending on memory constraints and usage variability, I'd populate the tuple mapping from this service lazily (ie, only as users request it).
For venueless check-ins they probably compute it once based on the lat/lon and cache this information for a shorter period of time in case others perform check-ins to the same location. I'd bet that they also routinely take advantage of the fact that the timezone field is optional and don't populate it if the geocoding service is overloaded.
If you're looking for a service which can handle these kinds of queries, check out http://www.geonames.com (documentation).