Greetings everyone,
I am very new to libosmscout and would like to know how to display
calculated routes and current location marker (using latitude and longitude
coordinates).
The libosmscout tutorial page (here
<http://libosmscout.sourceforge.net/tutorials/renderonmap/>) says that it
is possible to show the current route and current position on top of the
map. However, I can't seem to find any example code to achieve this.
There are previous discussions present on this topic, here
<https://sourceforge.net/p/libosmscout/mailman/message/30205963/>. The
discussion however seems to be old and there have been some API changes
now. So, have the steps for displaying routes changed in any way?
This <https://www.toptal.com/developers/hastebin/tefiqitece.php> is the
code I have currently. It is the DrawMapCairo demo with the routing code
copied from the Routing demo. The relevant code for adding the route to the
MapData class is present in the calculate_route function:
osmscout::TypeInfoRef route_type_info =
std::make_shared<osmscout::TypeInfo>("_route");
route_type_info->SetInternal().CanBeWay(true);
typeConfig->RegisterType( route_type_info );
osmscout::RouteWayResult routing_way = router->TransformRouteDataToWay(
result.GetRoute() );
if ( !routing_way.Success() ){
std::cerr << "Unable to convert route data to way!" << std::endl;
} else {
std::cout << "Converted route data to way!" << std::endl;
auto way_ref = routing_way.GetWay();
way_ref->SetType(route_type_info);
data.poiWays.push_back(way_ref);
}
It would be very helpful if you could provide some helpful pointers or
example code to display the calculated routes.
Thank you very much!
Regards,
Asim Maharjan
|