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

Router.Resolve crashes - not sure what to do #21

Open
gfmoore opened this issue Aug 3, 2022 · 1 comment
Open

Router.Resolve crashes - not sure what to do #21

gfmoore opened this issue Aug 3, 2022 · 1 comment

Comments

@gfmoore
Copy link

gfmoore commented Aug 3, 2022

My routing program has been running well, many thanks for a superb package.

However today I came across a crash. I am using .net Maui

Here is my code

  public double ItineroDistance(PostcodePosition pp1, PostcodePosition pp2)
  {
    // calculate a route.

    // snaps the given location to the nearest routable edge.
    var start = router.Resolve(profile, (float) pp1.Latitude, (float) pp1.Longitude);
    var end = router.Resolve(profile, (float) pp2.Latitude, (float) pp2.Longitude);

    var route = router.Calculate(profile, start, end);

    return route.TotalDistance; //(in meters)
  }

pp1.Latitude was 53.033809 pp1.Longitude was -2.151793
pp2.Latitude was 52.807553 pp2.Longitude was -1.740858
The profile is "car"
I obtain these from UK Postcodes ST1 6SS and DE13 9RD
https://api.postcodes.io/postcodes/

The exception
Itinero.Exceptions.ResolveFailedException: 'Could not resolve point at [52.807552, -1.740858]. Probably too far from closest road or outside of the loaded network.'

On OpenStreetMap (which I'm using)
image

On Google
image

What would be the best way to handle this? Use a try catch? Then what would I do in the catch? I could just do a CrowFlies calc (I have some code for that) I suppose. Or is it a bug?

Thanks for any suggestions, advice, help.
Gordon :)

@gfmoore
Copy link
Author

gfmoore commented Aug 3, 2022

Doing a try catch meant that the exception could be ignored (ok handled). Any other thoughts. I suspect something about the farm track/lane is not being recognised?

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