Improved Instructions, different behavior for different loaded vehicles


something I just realized about the improved instructions is that they might behave different, when a different set of encoders is enabled. The reason for this that we compare flags as a heuristic approach as we cannot access the highway type.

Not sure if this is a problem? Maybe we should mention that somewhere?

A possible fix might be to extend the encoder with a method like long getEncoderFlags(long flags). This method returns only the flags that are relevant for the encoder. Maybe by simply applying a bit mask?


Isn’t the reason here that with one encoder street A is not considered and with the second street A is considered and a new instruction at the new junction could be created? (btw: moved to Developers)

Indeed my tests so far show that behavior, or @boldtrn means something else?

No, the junction check only considers streets that are accessible for the encoder. The reason for this are definitely the flags.

For this route we show a continue instructions if only car is loaded. If we load car,bike,foot, no continue instruction is created. If you debug it you find the reason for this is that the flags are different.

The flags are surely not identical:
E.g. bits for car is 0111 for just car and the flags then read like 000000000000|0111 and if foot (1011) and car is used it will be 00000000|1011|0111

but for car we use just a certain bit range and this should be the same even if other encoders are loaded! So I’m pretty sure the bits in this bit range are identical also if other encoders are used. If this is not the case then it is a bug.

Yes exactly. But I currently check the all the flags, using edge.getFlags(). That’s why I proposed to only check the encoder specific flags. I think this should be done in the encoder, using for example the above mentioned long getEncoderFlags(long flags). But, from my first tests it looks like that the quality of the instructions is better with more encoders, as the flags are more likely to change if the OSM tagging of the edge is different. So I am not sure if we should change the current behavior.

Now I understand what you mean, you are comparing the full flags like ìf edge.getFlags == edge2.getFlags. That is indeed suboptimal, but we should also not introduce yet another FlagEncoder method. Maybe we should introduce a customizable method for the Weighting like boolean shouldCreateInstruction, but that is also not entire clear at this moment to me.

So I am not sure if we should change the current behavior.

Ok, so let us keep this for now and think about a ‘weighting-based’ instruction creation approach as well as moving this part out of the Path class.