Repository navigation
Remove acceptWay optimization - #2471
Conversation
This reverts commit fa7c84b.
easbar
left a comment
There was a problem hiding this comment.
This was pretty straight-forward with the exception of a few tests that test the priority calculation under the assumption that there is access for ways that do not have access, something that never happens in the production code currently. However, in the future this is what we actually might do: Calculate priorities regardless of the access flags as the access flags might change depending on the custom model.
| // important: UNCHANGED should not get 0 priority! | ||
| osmWay = new ReaderWay(1); | ||
| osmWay.setTag("highway", "somethingelse"); | ||
| flags = encodingManager.handleWayTags(osmWay, accessMap, encodingManager.createRelationFlags()); | ||
| osmWay.setTag("highway", "track"); | ||
| flags = encodingManager.handleWayTags(osmWay, encodingManager.createRelationFlags()); | ||
| assertEquals(PriorityCode.getValue(UNCHANGED.getValue()), priorityEnc.getDecimal(false, flags), .1); |
There was a problem hiding this comment.
@karussell do you remember what this comment
// important: UNCHANGED should not get 0 priority!
is supposed to say? The issue with this test is that previously we called AbstractFlagEncoder#getAccess before handleWayTags and passed the AcceptWay into handleWayTags. This allowed us in this test to pass Access=WAY and test the priority even for ways that aren't even accessible. This is why the test used to work even for highway=somethingelse. I now changed it to track because then we also get priority==UNCHANGED. But I don't understand why the comment says the priority should not be 0, but then we do not even test whether the priority is not 0...
There was a problem hiding this comment.
I think I meant that the default value is 0. And the default meaning should be "unchanged priority" but we do not have an option for this (anymore) and we need to set this UNCHANGED explicitly. But not sure.
Should we ensure that priority is UNCHANGED for unknown highway values (?)
There was a problem hiding this comment.
I think I meant that the default value is 0.
Ok, this makes sense. It does get the default value 0 as long as the access is false though.
Should we ensure that priority is UNCHANGED for unknown highway values (?)
Probably, but maybe this is not needed yet (at least for this PR), because for unknown highway values the access will be false anyway. The test only works in master because we pass Access.WAY even though in reality it would be CAN_SKIP.
| EncodingManager.AcceptWay map = new EncodingManager.AcceptWay(); | ||
| assertTrue(em.acceptWay(way, map)); | ||
| IntsRef edgeFlags = em.handleWayTags(way, map, em.createRelationFlags()); | ||
| assertEquals(EncodingManager.Access.CAN_SKIP, encoder.getAccess(way)); | ||
| assertNotEquals(EncodingManager.Access.CAN_SKIP, ((AbstractFlagEncoder) em.getEncoder("bike")).getAccess(way)); | ||
| IntsRef edgeFlags = em.handleWayTags(way, em.createRelationFlags()); |
There was a problem hiding this comment.
Not sure why we use a bike encoder for this car encoder test, but I just kept the logic the same.
There was a problem hiding this comment.
Likely because initially there were a couple of bit handling bugs in EncodingManager (and/or EncodedValue) when using multiple flag encoders like overlapping ranges or similar and we needed the test against that somewhere I guess but yes those tests do not belong here.
There was a problem hiding this comment.
Ok, I'll leave it as it is then
| public void testPriority_avoidanceOfHighMaxSpeed() { | ||
| // here we test the priority that would be calculated if the way was accessible (even when it is not) | ||
| // therefore we need a modified encoder that always yields access=WAY | ||
| BikeCommonFlagEncoder encoder = new RacingBikeFlagEncoder(new PMap("block_fords=true")) { | ||
| @Override | ||
| public EncodingManager.Access getAccess(ReaderWay way) { | ||
| return WAY; | ||
| } | ||
| }; |
There was a problem hiding this comment.
This is the same problem I described in the other comment: We used to be able to test the priority by ignoring access by just passing in Access.WAY. Since this is no longer possible I worked around this by using a modified encoder here. The much better approach would of course be testing the priority calculation in isolation, but this is not possible yet, because handleWayTags does a bit of everything.
Fixes #2462