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.

dooderson
  • 547
  • 1
  • 9
  • 16

2 Answers2

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.

isp-zax
  • 3,833
  • 13
  • 21
  • 2
    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. – rbrundritt Feb 23 '19 at 19:50
  • 1
    Surely it can be very useful, but is it possible? If you have a practical method, please post it here for everyone. – isp-zax Mar 17 '19 at 19:07
  • 1
    Routing using vector tiles is currently not officially supported: https://github.com/mapbox/vector-tile-spec/issues/113 – Kyle Barron Dec 01 '19 at 22:13
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.

rbrundritt
  • 16,570
  • 2
  • 21
  • 46
  • 1
    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. – dooderson Apr 01 '19 at 17:14
  • 1
    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. – rbrundritt Apr 02 '19 at 00:20
  • Is there a way that I could get access to the Azure vector tiles? – dooderson Apr 24 '19 at 15:59
  • 1
    This API can access the vector and raster tiles: https://learn.microsoft.com/en-us/rest/api/maps/render/getmaptile Be sure to set the format to pbf to get vector tiles. – rbrundritt Apr 24 '19 at 23:25
  • For the record, Mapbox's vector tiles also have a buffer on the edge of each tile – Kyle Barron May 24 '20 at 02:49