Tue Apr 05, 2016 6:07 pm
I would like to compute route between two points and after that get its' length and points it goes through (like all points that are in GPX file when the route is exported ).
I started with example file basic-routing.cpp. After line
and it outputs zero, although I would expect size of calculated route. The state of Routingmanager never changes to Retrieved (although the route shows on map).
Could you please tell me, how to get all points of computed route and its' length and ideally find route using open route service?
I would also like to display two independent routes in one map, is it possible?
Sat Apr 16, 2016 9:53 am
The route is retrieved asynchronously once app.exec() is called. You have to wait for the stateChanged() signal of RoutingManager to tell when its done. Note that even when that has happened, the route is not immediately available in routingModel(). This is because retrieved routes are first stored in a list of alternative routes in AlternativeRoutesModel. RoutingWidget then chooses the "best" among them and this becomes the one that will be available in routingModel(). Once that has happened you can query the route length using manager->routingModel()->route().distance(). The size() method returns the number of waypoints (route segments).
The display of a route is done in RoutingLayer. It supports to display one main and several alternative routes currently, but there is no support for displaying multiple routes. At least not multiple routes you can interact with. You can always display the GeoDataDocument that is retrieved by routing backends if you don't want interaction with the route.
Can you elaborate on your use-case a bit? There might be a simpler way to achieve what you want to do.