Repository navigation
Conversation
As long as we do not need it I think it is ok to just throw an error in getMaxValue if defaultIsInfinity=true. /**
* The maximum double value this EncodedValue accepts for setDecimal without throwing an exception.
*/
double getMaxStorableDecimal();and |
Unfortunately we assume it partially in our code (3 tests fail). I.e. we differentiate between the "last real storable decimal" and infinity it seems. E.g. OSMMaxAxleLoadParserTest.testSimpleTags will fail when we set 160 and the "last real storable decimal" is 140, because the following will never be true: but we could internally (silently) round down to the "last real storable decimal"? (we do this rounding when setting other "unfitting" values too) Will try this... |
| enc.init(new EncodedValue.InitializerConfig()); | ||
| assertEquals(12, enc.getNextStorableValue(11.2)); | ||
| assertEquals(45, enc.getNextStorableValue(44.3)); | ||
| assertEquals(45, enc.getNextStorableValue(45)); | ||
| assertEquals(42, enc.getNextStorableValue(41.3)); | ||
| assertEquals(42, enc.getNextStorableValue(42)); | ||
| assertEquals(Double.POSITIVE_INFINITY, enc.getNextStorableValue(42.1)); | ||
| assertEquals(Double.POSITIVE_INFINITY, enc.getNextStorableValue(45)); | ||
| assertEquals(Double.POSITIVE_INFINITY, enc.getNextStorableValue(45.1)); |
There was a problem hiding this comment.
I think this is due to an unrelated bug. See above.
| if (!useMaximumAsInfinity && value > getMaxStorableDecimal()) | ||
| throw new IllegalArgumentException(getName() + ": There is no next storable value for " + value + ". max:" + getMaxStorableDecimal()); | ||
| else if (useMaximumAsInfinity && value > getMaxStorableDecimal()) | ||
| else if (useMaximumAsInfinity && value > (maxStorableValue - 1) * factor) |
| g.getTurnCostStorage().set(turnCostEnc, 0, 4, 7, Double.POSITIVE_INFINITY); | ||
| g.getTurnCostStorage().set(turnCostEnc, 0, 4, 9, Double.POSITIVE_INFINITY); |
There was a problem hiding this comment.
IMO a bug in the test code. But of course this could also happen for production:
only 1 bit was reserved and when the cost=1 was set the (new) behaviour is to use the last possible value below infinity which is 0, which is not the expected outcome here.
|
So this is now cleaner than the workaround with isDefaultIsInfinity before, but introduces a small behaviour change, see CHANGELOG. As this change is a bit delicate would you review again :), @easbar ? |
The maximum value of max_speed is Infinity due to defaultIsInfinity==true.
This special case is a bit ugly but we need this for edges without a (known) speed limit.
Or maybe we should move this information into getMaxValue and getMaxStorableDecimal?