与Google Places/Geocoding API相交 [英] Getting an intersection with Google Places/Geocoding API

查看:72
本文介绍了与Google Places/Geocoding API相交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google Places API查找到一条点的两条最接近的街道(基本上是指示最接近的十字路口).但是,任何结果(如果有的话)都只会返回一条路线".

I'm trying to find the two closest streets to a point with the Google Places API (basically to indicate the closest intersection). However, any result will only ever return one "route", if at all.

我认为我可以用+或X模式进行5个查询,但这很笨拙,不可靠,当然会更快地达到查询限制.

I figure I could do 5 queries in a + or X pattern, but that's hacky, unreliable, and of course will hit the query limit a lot sooner.

我很想说这是一个有意的举动,因为该API并不是要用于导航系统之类的(我不打算这样做),但我仍然希望有一种符合TOS的方式得到交点.

I am tempted to say that this is a deliberate move because the API is not meant to be used for something like navigation systems (which I'm not trying to do), but I still hope there's a TOS-compliant way to get the intersection.

旁注-似乎指定"types = route"从不返回任何结果,这进一步使我怀疑,Places仅真正用于实际的POI,而不是用于导航,尽管

Side note - it seems like specifying "types=route" never returns any results, which further nolsters my suspicion that Places is only really meant to be used for actual POIs, not for navigation, although the terms of service don't mention any explicit restrictions in that regard.

正如Chris所指出的那样,有一个专门为地理编码而设计的地理编码API,但是除了通过多次查询外,我仍然看不到获得最接近的十字路口的方法.

As Chris pointed out, there's the Geocoding API that is specifically designed for geocoding, but I still don't see a way to get the closest cross street other than through multiple queries.

推荐答案

共识是Google的反向地理编码器不够复杂,无法在一个查询中报告交叉点.也就是说,没有参数可用于告诉他们您只希望使用"types" : [ "intersection" ]获得结果.谷歌在这里吃自己的狗食.如果您在maps.google搜索框中输入纬度/经度,则总是会返回一条街道(以Google的说法是路线").

The consensus is that Google's reverse geocoder is not sophisticated enough to report intersections in one query. That is, there isn't a parameter that you can use to tell them you just want the results with "types" : [ "intersection" ]. Google is eating its own dogfood here; if you enter a lat/lon in a maps.google search box, you always get a street (in Google parlance, a 'route') back.

正如您所指出的那样,您可以应用许多启发式方法来获得令人垂涎的["intersection"]类型.

As you point out, there are plenty of heuristics you could apply to get the coveted ["intersection"] type.

例如第一世界城市中的几个主要"十字路口都有描述该十字路口的公交站点.如果任何结果包含"types" : [ "bus_station", "transit_station" ]元素,则可以尝试使用"long_name"元素作为搜索词,并希望得到一个交集.斯米尔金曼还提到了一个可行的解决方案.这两个都需要2个以上的查询,

e.g. Several 'major' intersections in 1st-world cities have transit stops that describe the intersection. If any results have a "types" : [ "bus_station", "transit_station" ] element, you can try the "long_name" element as a search term and hope you get an intersection. smirkingman also mentioned a viable solution. Both of these required 2+ queries, alas.

最后,Google Geocoding API中没有latelngToIntersection(lat,lng)这种功能.证据在Google自己的maps.google页面中.我会以不同的方式解决您的问题.如果要在给定GPS位置的情况下获得最近的主要十字路口,可能会有助于获得用户的帮助.众所周知,地理编码散布着邪恶的人类.

In conclusion, there is no latelngToIntersection(lat,lng) kind of function in the Google Geocoding API. Evidence of this exists in Google's own maps.google page. I would attack your problem differently. If you want to get the nearest major intersection given a GPS location, it may help to get the user to help. Geocoding is notoriously littered with icky humanity.

这篇关于与Google Places/Geocoding API相交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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