routing
routing copied to clipboard
routing fail with exception Itinero.Exceptions.RouteNotFoundException
Hello All,
The router fail with this coordinates origine : 43.48291899 5.38124321 Dest : 43.51054304 5.42063052 Here my code:
public Route GetDistance(Coordinate p_PointA, Coordinate p_PointB, Profile p_profile, RouterDb routerDB)
{
Route route = new Route();
RouterPoint start, end;
const float DistanceMaxProj = 50.0F;
// create a router.
Router router = new Router(routerDB);
// create a routerpoint from a location.
// snaps the given location to the nearest routable edge.
try
{
start = router.Resolve(p_profile, p_PointA, DistanceMaxProj);
}
catch (Exception exc)
{
route.TotalDistance = -1;
route.TotalTime = -1;
return route;
}
try
{
end = router.Resolve(p_profile, p_PointB, DistanceMaxProj);
}
catch (Exception exc)
{
route.TotalDistance = -1;
route.TotalTime = -1;
return route;
}
// calculate a route.
route = router.Calculate(p_profile, start, end);
return route;
I call it with Profile v_profile = Vehicle.Car.Fastest(); The routerDB was made from france-latest.osm.pbf (29/01/2019) that I found here: https://download.geofabrik.de/europe/france.html
Here my code to gerate the routerDB:
public void OsmRouterDBToDisk(string p_pathToOsmFile, string p_PathToDisk)
{
PrintTimeToConsole("load OSM .pbf");
// load some routing data and build a routing network.
RouterDb v_routerDb = new RouterDb();
using (FileStream v_stream = new FileInfo(p_pathToOsmFile).OpenRead())
{
// create the network for cars only.
v_routerDb.LoadOsmData(v_stream, VehicleOSM.Car);
}
//!\\
// todo : verify that routerDB is not empty
PrintTimeToConsole("Write routerDB to disk");
// write the routerdb to disk.
using (FileStream v_stream = new FileInfo(p_PathToDisk).Open(FileMode.Create))
{
v_routerDb.Serialize(v_stream);
}
}
So Is there something wrong in my code or is it a bug?
Emmanuel, from France.
I just speak with Algorithm Man ;-) , and perhaps we have an idea about why it fail: The destination point is between a way and an highway, but more near the highway. So the projection on graph will be on the highway but ... the router fail because the constraint : you could take the highway only on in highway entrance !
To test this idea, I change a little the destination coordinate like the point is more near the way than the highway, and the router work fine!
So, what you think about that?
There is an option somewhere to allow resolving on segments that are marked as 'canstop=false' but I'm not sure anymore where. If I have time today, I'll try and search for it, feel free to ping me if I forget.
You can also search the code and try to figure it out. It's probably somewhere in the Router class itself.
I try a search in the code for canstop. I found some references in some .lua files, one of them is: ...\src\Itinero\Osm\Vehicles\car.lua
As I am newbies on Itinero, could you explain the relation between the problem I got and canstop ?
I assumed you want to resolve only to location where a vehicle is allowed to stop but you are correct, this issue is not related. I think this route should work.
What version of Itinero do you have installed when testing this?