Closed alecava58 closed 8 years ago
Normally this should be possible without any issue by using the same RouterDb. Do the two profiles have different names?
The two profiles have the same name (shortest) but different vehicles.
All profiles much have unique names. What does hazmatTruck.Shortest().Name return?
Return Hazmat.Shortest
ok, I'll try and repeat this test and see what I can find...
Attached you can find my Hazmat class along with my MixedProfile class.
Here there is the class Hazmat updated with vehicle dimensions check.
@alecava58 Are you sure the dimension tags are present in the OSM-data?
I selected a short segment where there is the dimension tag but I'm not sure if the dimension tag is still there in the router db. If you are confident that the routing engine takes care of the dimension tag I'll check in debug.
I've created a custom vehicle where I override the IsReleventForProfile fuction as follow:
// Dimensions relevant tags
private static HashSet<string> _relevantProfileKeys = new HashSet<string> { "maxheight", "maxlength", "maxweight", "maxwidth" };
/// <summary>
/// Returns true if the given key is relevant for the given profile.
/// </summary>
public override bool IsRelevantForProfile(string key)
{
if (base.IsRelevantForProfile(key))
{
return true;
}
if (key.StartsWith("hazmat"))
{ // include hazmat tag.
return true;
}
return _relevantProfileKeys.Contains(key);
}
Is this ok?
regards
I made some tests and may be I did not understand how weight restriction works:
I have a custom vehicle that I can set the maxweight.
If I create a routerdb using a vehicle with maxweight = 40000 than the routing engine takes care of the maxweight restriction even if I set the vehicle maxweight property maxweight=0 (it doesn't matter the value of maxweight property of the vehicle)
If I create a routerdb using a vehicle with maxweight = 0 than the routing engine doesn't take care of the maxweight restriction even if I set the vehicle maxweight property maxweight = 40000
So I think that: Changing the vehicle properties (after you have created the routerdb) don't change the routing calculation what is important is how you have created the routingdb.
I'm wrong?
To complete the info I used Rue Pierre de Coubertin - Luxemburg calculating a route from 49.607852, 6.143440 to 49.605363, 6.142153
You also need to make sure that tags normalization is disabled:
https://github.com/itinero/routing/blob/develop/src/Itinero.IO.Osm/Streams/RouterDbStreamTarget.cs#L54 =>set normalizeTags to false.
Disabling tags normalization works very well.
Thanks.
I created a test (see below) for hazmat tag and it works as expected if I create 2 RouterDb, one regarding the new hazmat vehicle and another regarding the BigTruck vehicle (without hazmat restriction).
If I create only one RouterDb using both the vehicles using
var routerDbHaz = Runner.GetTestBuildRouterDb(Download.LuxembourgLocal, false, false, new Vehicle[] { hazmatTruck, Vehicle.BigTruck }).TestPerf("Build Luxemburg router db for Hazmat BigTruck.");
it doesn't work as expected (both route results have the same distance).
Is that ok?