itinero / routing

The routing core of itinero.
Apache License 2.0
221 stars 70 forks source link

Tree calculated using max distance from coordinate #230

Closed nsander closed 5 years ago

nsander commented 5 years ago

I am trying to calculate a tree from a point, and a maximum allowed distance from that point, in metres. The way that I am doing this is;

var coordinate = new Coordinate(57, 11);
var profile = routerDb.GetSupportedVehicle("nvdb.car").Shortest();
var maxDistance = 50;
var point = _router.Resolve(profile, coordinate, 200);
var tree = _router.CalculateTree(profile, point, maxDistance);

This code works fine, and it seems as though the maxDistance in this case is the allowed time away from the point, I however want to limit this on distance in metres. If I change the profile to instead use

var profile = routerDb.GetSupportedVehicle("nvdb.car").Fastest();

which has a profile metric of 'distance' rather than 'time'. I get the following error;

"Profile nvdb-reverse.car.shortest not supported, only profiles with metric TimeInSeconds are supported"

Is it possible to use CalculateTree and limit the scope using distance rather than time?

xivk commented 5 years ago

var profile = routerDb.GetSupportedVehicle("nvdb.car").Fastest();

That line is not correct, use the name of the profile you defined in lua:

https://github.com/itinero/routing/blob/develop/src/Itinero/Osm/Vehicles/car.lua#L2

And yes for now only profiles with the time metric are supported:

https://github.com/itinero/routing/blob/develop/src/Itinero/Algorithms/Networks/Analytics/Trees/RouterExtension.cs#L84