【发布时间】:2016-03-28 06:04:30
【问题描述】:
我正在开发一个 android 应用程序,其中我每 5 分钟记录一次设备的点数。现在我希望使用这些点计算道路覆盖的总距离。有没有办法做到这一点。在google apis中,我看到有一个起点和终点,它使用它计算距离,但可能有多个相同的路线。我需要找到这条特定路线的距离。我该怎么做?
谢谢
编辑:
谷歌距离矩阵 api 具有多个起点和多个目的地的选项。我不确定这是否有帮助:
origins — One or more locations to use as the starting point for calculating travel distance and time.
You can supply one or more locations separated by the pipe (|) character, in the form of an address or latitude/longitude coordinates. If you pass an address as a string, the service will geocode the string and convert it to a latitude/longitude coordinate to calculate distances. If you pass coordinates, ensure that no space exists between the latitude and longitude values.
origins=Bobcaygeon+ON|41.43206,-81.38992
Alternatively, you can supply an encoded set of coordinates using the Encoded Polyline Algorithm. This is particularly useful if you have a large number of origin points, because the URL is significantly shorter when using an encoded polyline. Encoded polylines must be prefixed with enc: and followed by a colon (:). For example: origins=enc:gfo}EtohhU:
destinations — One or more locations to use as the finishing point for calculating travel distance and time.
You can supply one or more locations separated by the pipe (|) character, in the form of an address or latitude/longitude coordinates. If you pass an address as a string, the service will geocode the string and convert it to a latitude/longitude coordinate to calculate distances. If you pass coordinates, ensure that no space exists between the latitude and longitude values.
destinations=Darling+Harbour+NSW+Australia|24+Sussex+Drive+Ottawa+ON|Capitola+CA
Alternatively, you can supply an encoded set of coordinates using the Encoded Polyline Algorithm. This is particularly useful if you have a large number of destination points, because the URL is significantly shorter when using an encoded polyline. Encoded polylines must be prefixed with enc: and followed by a colon (:). For example: destinations=enc:gfo}EtohhU:
【问题讨论】:
-
您可以使用航路点以及起点和终点,或者您可以使用“距离 = 速度 * 时间”来计算总距离。您必须找到记录的每 2 个点的平均速度,并将其乘以所用时间
-
@NakulSudhakar “您可以使用一些航路点以及起点和终点”您能告诉我怎么做吗?
-
@NakulSudhakar 感谢您的链接,我浏览了它。但它再次要求起点和终点,然后根据“谷歌推荐的”路线计算距离。我需要找到我的特定路线的距离,这可能与谷歌的建议不同。
-
您可以指定起点和终点之间的航点。这样你的实际路径将与谷歌建议的非常相似。
标签: android google-maps geolocation google-distancematrix-api