获取整条路线、谷歌地图或 OpenStreetMap 的准确地理坐标 [英] Get exact geo coordinates along an entire route, Google Maps or OpenStreetMap
问题描述
假设我有一条从一个城镇到另一个城镇的路线.从 Google Maps API 我可以恢复两者之间的路线.但是,从 Google 返回的路线是一条包含地理坐标的驾驶路线,仅在一条腿还有另一步的地方(例如,我必须从一条高速公路转向另一条高速公路).
Suppose I have a route defined from one town to another. From the Google Maps API I can recover a route between the two. However, the route returned from Google is a driving route that includes geo-coordinates only at places where there is another step in a leg (for example, where I have to turn from one highway to another).
我需要的是整个路线上的地理位置(纬度/经度),以特定的间隔(例如,每 1/4 英里或 100m).
What I need is geo-locations (lat/long) along the entire route, at specific intervals (for example, every 1/4 mile or 100m).
有没有办法通过 Google Maps API/网络服务来实现这一点?
Is there a way to accomplish this via the Google Maps API / web services?
或者 OpenStreetMap 数据库会是这样做的方式吗?
Or would the OpenStreetMap database be the way to do it?
亲切的问候,玛德琳.
推荐答案
OSRM 为您提供具有道路几何形状的路线,就像它们在 OpenStreetMap 数据库中一样.例如,您可以将路由作为 GPX 获取(如果需要,可以对该文件进行后处理).如下所示:
OSRM gives you routes with road geometries as they are in the OpenStreetMap database. For example, you can get the route as GPX (and post-process this file if you want). This would look like the following:
GET http://router.project-osrm.org/viaroute?hl=en&loc=47.064970,15.458470&loc=47.071100,15.476760&output=gpx
阅读更多:OSRM API 文档.
这篇关于获取整条路线、谷歌地图或 OpenStreetMap 的准确地理坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!