问题
Has anyone used either Mapbox or OpenMapTiles vector tiles to find routes from one place to another?
It seems to me like those tiles are made for display and don't contain intersection information the way that say Open Street Map does.
回答1:
Mapbox has directions API which uses Open Street Map:
Mapbox’s directions services use a network of roads and paths, or ways, derived from OpenStreetMap, a collaborative project to create a free and editable map of the world.
Contributors to OpenStreetMap have built a vast, routeable network that includes properties like speed limits, turn lane restrictions, and accessibility for bikes and pedestrians. These details provide the framework that the Open Source Routing Machine (OSRM) needs to calculate the fastest path for your mode of transportation (driving, cycling, walking).
So the answer is yes - the tiles don't contain routing graph and meant to display. Waypoints retrieved via API allow to display route on top. Here is an example of how to use it with mapbox-gl.
OpenMapTiles at this time (15-09-2018) don't offer routing as far as I know.
回答2:
I've done this recently as I needed a method to calculate a million random routes at low cost for simulation purposes. What I did was download all the vector tiles in the area in which the route was relevant (bounding box or all tiles that intersect a buffered straight line path between the start/end). Then extracted the roads from the vector tiles and merged (union) them together to create a large MultiLineString. From there I used nettopology suite and shortest path algorithm to calculate a route. Note that this does not take into consideration turn and other road restrictions as that data typically is not in the tiles, but this would depend on the source of your vector tiles. You can avoid toll roads simply by excluding them from the MultiLineString. One way streets can be honored since the vector tiles need this information for rendering.
来源:https://stackoverflow.com/questions/52299872/vector-tile-route-finding