检测距离给定位置最近的公交站
我需要获取距离给定位置一定距离内的所有附近公共交通信息。公共交通类型可以是公交车、火车等。
我的意思是:
如果我使用 Google 地图查询 "某个位置附近的公交站(例如新加坡武吉士街)",然后它将返回给我们我想要的所有附近的公交站。就像图中所示的那样。但我需要它的 API 来获取这些详细信息。 (如公交服务号、公交站ID等如图所示)。但我找不到任何。
这是我尝试过的
我尝试过使用Google 地图附近地点 API 用于搜索类型为 < 的地点一个href="http://code.google.com/apis/maps/documentation/places/supported_types.html" rel="nofollow noreferrer">公交站、公交车站、火车站等。。但它们都返回零结果。我只能使用这个API来搜索附近的景点,但不能搜索附近的公交。
我还检查了 Google Transit API,但我只找到API将交通数据插入Google,但没有将其提取出来。我认为 Google 还没有公开过境 API。
其他信息
我已经查看了网站 Gothere.sg。又迷茫如何?因为他们能够检测到附近的交通。难道只是因为他们指定了“从-到”方向。
我读过一个关于检测附近的非常类似的问题过境。如果我们使用 Google API,也许还不可能。
但对我来说没有什么是不可能的
最后的手段
作为最后的手段,我还咨询了提供商 publictransport.sg。我用 API 进行修改。并发现它可以为我提供一个带有一些坐标的交通站点。但它缺少在 Google 地图上找到的附近 API。
因此,我目前能想到的一种解决方法是在这种情况下使用提供者 publictransport.sg ,它给了我停靠站 ID 及其坐标。为此,首先,我必须使用 Google GeoCoding API 将位置名称转换为坐标,然后我必须创建自己的附近计算,通过将搜索到的坐标与提供商拥有的所有站点坐标进行比较来查找附近的站点。
现在,这对我来说是可能的,但非常痛苦:-)
回到问题:
有没有办法从给定位置检索所有公交站点数据(使用 Google Maps API 或任何其他 API)?你是怎么做到的?
谢谢
至少感谢您阅读我的冗长问题。我很感激你的任何帮助。
I need to get all the nearby public transit information within certain distance from a given location. The type of public transit can be either bus, train, etc..
Here is what I meant:
If I use Google Map to query "Transit Stop near a Location (e.g. Bugis Street Singapore)", then it will return us all the nearby Transit Stop that I want. Like the one shown in the picture. But I need its API to get those details out. (such as bus service No, bus stop ID, etc. as shown in the picture). But I couldn't found any.
Here is what I've tried
I have tried using the Google Map Nearby Place API to search for a place with the type of transit_station, bus_station, train_station,etc... But they all return Zero Result. I could only use this API to search for Nearby Place of Interest, but not nearby transit.
I've also check Google Transit API, but I only found API to insert transit data to Google but Not to extract it out. I think Google didn't publicize the transit API yet.
Additional Information
I have check the site Gothere.sg. And confused How? because they able to detect the nearby transit. Is it only because they specify the direction "From-To".
I have read a pretty similar question on Detecting nearby transit. Perhaps It is not yet possible if we use Google APIs.
But nothing is impossible for me
Last Resort
As Last resort, I also check with the provider, publictransport.sg. I hack around with the API. And found out that it can provide me with a transit stop with some coordinate. But it lack a nearby API which found on Google Map.
So one workaround I could think of at the moment, is to use the provider in this case was publictransport.sg which give me the Stop ID and its coordinate. To do this, First, I have to translate the location name using the Google GeoCoding API into Coordinate then I have to create my own nearby calculation to find the nearby station by comparing the searched Coordinate against all the station coordinate that the provider have.
Now, it is possible for me, but very painful :-)
Back to the Question:
Is there a way to retrieve all transit stop data from a given location (either using Google Maps API or Any other API)? and How did u do that?
Thanks
At least thanks for reading my lengthy question. I appreciate any help from you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好吧,您可以使用地方 API 来查找最近的公交站,对于给定的位置,它对我来说效果很好。
只需使用以下参数进行请求:
latlng
-给定位置的对象)['bus_station', 'subway_station']
)检查小提琴:http://jsfiddle.net/doktormolle/aZrvs/
用于检索更多详细信息(巴士服务编号、巴士站 ID)我现在没有什么好的主意。
应该有办法,maps.google.com上的那些数据将通过使用AJAX来检索,所以有一个资源。但只要没有公共 API 来获取这些结果,使用该资源就不合法。
Well, you could use the places-API to find the nearest transit-stops, it works fine for me for the given location.
Just do a request with the parameters:
latlng
-object of the given location)['bus_station','subway_station']
)Checkout the fiddle: http://jsfiddle.net/doktormolle/aZrvs/
For retrieving further details(bus service No, bus stop ID) I don't have any good idea right now.
There should be a way, those data on maps.google.com will be retrieved by using AJAX, so there is a ressource. But as long as there is no public API to fetch those results it would not be legal to use this ressource.
将 &output=json 添加到您的初始查询 (http://maps.google.com/maps?q=transit%20stop%20near%20New%20Bugis%20Street%20Singapore&output=json) 不是合法的方法得到这个信息吗?
Adding &output=json to your initial query (http://maps.google.com/maps?q=transit%20stop%20near%20New%20Bugis%20Street%20Singapore&output=json), is not a legal way to get this information?
在获取 google-places-api 详细信息后,您仍然可以枚举所有公交车服务号码、公交车站 ID(车站名称),如 @Dr.Molle 所说。
打开detail['result']['url']的网页,然后XPath总线ID列表的字符串。
以下是获取某个位置(纬度、经度)周围台北巴士信息的示例。更详细的实现请参见 https://github.com/MikimotoH/gisTools/blob/master /google_place.py
You can still enumerate all of Bus Service Number, Bus Stop ID (Station Names) after getting the google-places-api details, as @Dr.Molle: said.
Open the webpage of detail['result']['url'], and then XPath the string of bus ID list.
Below is an example to get Taipei's bus Info around a location (latitude, longitude). More detail implementation see https://github.com/MikimotoH/gisTools/blob/master/google_place.py
Transitland API 可以回答您的问题。例如,尝试使用 Transitland v2 REST API 停止端点,如下所示:
有关端点参数和响应的更多信息,请访问 https://www.transit.land/documentation/rest-api/stops
The Transitland APIs can answer your question. For example, try using the Transitland v2 REST API stops endpoint like this:
More information on the endpoint parameters and response at https://www.transit.land/documentation/rest-api/stops