Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route IsError #357

Open
goroggy opened this issue Jul 18, 2022 · 0 comments
Open

Route IsError #357

goroggy opened this issue Jul 18, 2022 · 0 comments

Comments

@goroggy
Copy link

goroggy commented Jul 18, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant