itinero / routing

The routing core of itinero.
Apache License 2.0
221 stars 69 forks source link

What is Shortcut and use shortcut has redouble performance ? #189

Closed NguyenSen closed 6 years ago

NguyenSen commented 6 years ago

Hello Itinero Team.

I try to build routing data (shapefile) with lib itinero. My network has 1,2 million edges and 800.000 junctions(nodes) but routing between 2 points with distance 1000km only take 1 second (I has use function addContract ), so how to increase performance in 0.5s with above points.

I saw "shortcut" in your source code, but i don't clear about that, please help me explain about it.

Thanks you very much.

xivk commented 6 years ago

When using the contracted graph most of the time is spend rebuilding the route. You could try using an route-builder that only reconstructs the route geometry without all the streetnames and other details along the route.

This one should improve performance:

https://github.com/itinero/routing/blob/develop/src/Itinero/Algorithms/Routes/FastRouteBuilder.cs

You can override the default routebuilder by setting this property on the router:

https://github.com/itinero/routing/blob/18c01646babed19d2ceb0438902126432b26a12a/src/Itinero/Router.cs#L62

You can do this by implementing the interface IRouteBuilder and then using the FastRouteBuilder inside. This obviously can be made easier, sorry about that.

This is the code that runs after the route was found and that's probably where most time is spent:

https://github.com/itinero/routing/blob/develop/src/Itinero/Router.cs#L1250

Additionally if your frontend where your displaying the route has difficulties displaying routes that are too long you may want to consider simplification of the route geometry.

NguyenSen commented 6 years ago

thanks @xivk