Route IsError
goroggy opened this issue · 0 comments
goroggy commented
Hi there, I resolve my start and end points and check their connectivity, but sometimes this fails (can it fail?).
Also when connectivity is OK, calculate() sometimes fails. I only need the total length of the route. _profile is Vehicle.Car.Fastest().
db is _routerDb.LoadOsmData(inStream, Itinero.Osm.Vehicles.Vehicle.Car);
_routerDb.AddContracted(_profile);
Either I misunderstand these concepts or something is wrong.
int distance = 0;
Result<RouterPoint> start = new Result<RouterPoint>("start");
while( start.IsError && distance ++ < 10 )
start = _router.TryResolve( _profile, origin.Lat, origin.Lng, distance * 10);
if (start.IsError) return 0;
distance = 1;
Result<RouterPoint> end = new Result<RouterPoint>("end");
while (end.IsError && distance ++ < 10)
end = _router.TryResolve(_profile, destination.Lat, destination.Lng, distance * 10);
if (end.IsError) return 0;
if (!_router.CheckConnectivity(_profile, start.Value)
|| !_router.CheckConnectivity(_profile, end.Value)) return 0;
Result <Route> route = _router.TryCalculate( _profile, start.Value, end.Value );
return route.IsError ? 0 : route.Value.TotalDistance;
Thanks!