Vector tile route finding
Asked Answered
T

2

8

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.

Trojan answered 12/9, 2018 at 16:36 Comment(0)
C
3

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.

Coincidental answered 17/9, 2018 at 1:34 Comment(3)
This doesn't really answer the question. There are scenarios were being able to calculate a path using vector tiles is very useful. Especially for powering simulation data where things like turn restrictions, and one-ways may not be of concern.Todhunter
Surely it can be very useful, but is it possible? If you have a practical method, please post it here for everyone.Coincidental
Routing using vector tiles is currently not officially supported: github.com/mapbox/vector-tile-spec/issues/113Anatase
T
3

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.

Todhunter answered 18/3, 2019 at 15:26 Comment(5)
How did you union the tiles together? I have had trouble finding intersections of roads using anything but the most detailed zoom level, and even then I sometimes find intersections that don't exist.Trojan
I used NetTopology suite for the calculations and it worked great. However I used the vector tiles for Azure Maps which have a bit of overlap at the tile edges which likely helped.Todhunter
Is there a way that I could get access to the Azure vector tiles?Trojan
This API can access the vector and raster tiles: learn.microsoft.com/en-us/rest/api/maps/render/getmaptile Be sure to set the format to pbf to get vector tiles.Todhunter
For the record, Mapbox's vector tiles also have a buffer on the edge of each tileAnatase

© 2022 - 2024 — McMap. All rights reserved.