Open Oyekunle86 opened 1 year ago
Hi,
Don't know if you have figured this out already but I'll put this here for anyone else having issues with GPS coordinates.
Those GPS coordinates seem to show they are in the middle of the ocean, you might have your GPS coordinates reversed. I also recommend parsing the GPS points into router points. I find this gives better results when routing as it will snap the GPS point to the closest edge.
Here is a code snippet I like to use to convert, you could adapt it to process an array of coordinates if needed. This method will try different search distances incase the GPS point is pretty far away from the road / edge.
private static RouterPoint? BuildRouterPoints(RouterBase router, Coordinate coordinate, IProfileInstance profile)
{
var routerPoint = router.TryResolve(profile, coordinate, 200);
if (!routerPoint.IsError) return routerPoint.Value;
Console.WriteLine($"{DateTime.Now} - [WARNING]: {routerPoint.ErrorMessage}");
routerPoint = router.TryResolve(profile, coordinate, 2000);
if (!routerPoint.IsError) return routerPoint.Value;
Console.WriteLine($"{DateTime.Now} - [ERROR]: {routerPoint.ErrorMessage}");
return null;
}
Another thing to be keep in mind is if you are getting errors with points not routing, make sure you're not on an island. I found this out when doing some routing in New Zealand the North Island roads only get added if you load island data were the South Island gets loaded without island data.
Here is how you can load island data
routerDb.AddIslandData(profile);
Hope this helps anyone that stumbles into the same issue
Hello,
Please I get this error when I calculate route for multiple points/locations e.g.
var route = router.Calculate(bus, locations); var routeGeoJson = route.ToGeoJson();
I get this error:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index') at System.Collections.Generic.List
1.get_Item(Int32 index) at Itinero.RouterBaseExtensions.TryCalculate(RouterBase router, IProfileInstance profile, IMassResolvingAlgorithm resolvingAlgorithm, Single turnPenalty, Tuple
2[] preferredTurns, CancellationToken cancellationToken)Please help out