Repository navigation
move relation and turn relation parsing out of FlagEncoder - #1775
Conversation
# Conflicts: # core/src/main/java/com/graphhopper/routing/util/AbstractFlagEncoder.java # core/src/main/java/com/graphhopper/routing/util/BikeCommonFlagEncoder.java # core/src/main/java/com/graphhopper/routing/util/MotorcycleFlagEncoder.java # core/src/main/java/com/graphhopper/routing/util/MountainBikeFlagEncoder.java # core/src/main/java/com/graphhopper/routing/util/parsers/OSMMaxAxleLoadParser.java # core/src/main/java/com/graphhopper/routing/util/parsers/OSMMaxLengthParser.java # core/src/main/java/com/graphhopper/routing/util/parsers/OSMTollParser.java # core/src/main/java/com/graphhopper/routing/util/parsers/OSMTrackTypeParser.java # core/src/test/java/com/graphhopper/reader/dem/BridgeElevationInterpolatorTest.java # core/src/test/java/com/graphhopper/reader/dem/EdgeElevationInterpolatorTest.java # core/src/test/java/com/graphhopper/routing/PathTest.java # core/src/test/java/com/graphhopper/routing/util/AbstractBikeFlagEncoderTester.java # core/src/test/java/com/graphhopper/routing/util/BikeFlagEncoderTest.java # core/src/test/java/com/graphhopper/routing/util/CarFlagEncoderTest.java # core/src/test/java/com/graphhopper/routing/util/DataFlagEncoderTest.java # core/src/test/java/com/graphhopper/routing/util/EncodingManagerTest.java # core/src/test/java/com/graphhopper/routing/util/MountainBikeFlagEncoderTest.java # core/src/test/java/com/graphhopper/routing/util/parsers/OSMMaxAxleLoadParserTest.java # core/src/test/java/com/graphhopper/routing/util/parsers/OSMRoadClassParserTest.java # core/src/test/java/com/graphhopper/routing/util/parsers/OSMTollParserTest.java # core/src/test/java/com/graphhopper/routing/util/parsers/OSMTrackTypeParserTest.java # core/src/test/java/com/graphhopper/util/PathSimplificationTest.java # reader-osm/src/main/java/com/graphhopper/reader/osm/OSMReader.java # reader-osm/src/test/java/com/graphhopper/reader/osm/OSMReaderTest.java
|
Copied from now closed #1772:
|
# Conflicts: # core/src/main/java/com/graphhopper/storage/TurnCostExtension.java # core/src/test/java/com/graphhopper/routing/BidirPathExtractorTest.java # core/src/test/java/com/graphhopper/routing/CHQueryWithTurnCostsTest.java # core/src/test/java/com/graphhopper/routing/RandomCHRoutingTest.java # core/src/test/java/com/graphhopper/routing/ch/EdgeBasedNodeContractorTest.java # core/src/test/java/com/graphhopper/routing/ch/Path4CHTest.java # core/src/test/java/com/graphhopper/routing/querygraph/QueryGraphTest.java # core/src/test/java/com/graphhopper/storage/GraphHopperStorageWithTurnCostsTest.java # core/src/test/java/com/graphhopper/storage/ShortcutUnpackerTest.java # core/src/test/java/com/graphhopper/storage/TurnCostExtensionTest.java # reader-osm/src/main/java/com/graphhopper/reader/osm/OSMReader.java
# Conflicts: # core/src/main/java/com/graphhopper/storage/TurnCostExtension.java
# Conflicts: # core/src/main/java/com/graphhopper/routing/ch/PrepareContractionHierarchies.java # core/src/main/java/com/graphhopper/routing/querygraph/QueryGraph.java # core/src/main/java/com/graphhopper/routing/querygraph/QueryGraphTurnExt.java # core/src/main/java/com/graphhopper/routing/weighting/TurnWeighting.java # core/src/main/java/com/graphhopper/util/GHUtility.java # core/src/test/java/com/graphhopper/routing/BidirPathExtractorTest.java # core/src/test/java/com/graphhopper/routing/CHQueryWithTurnCostsTest.java # core/src/test/java/com/graphhopper/routing/DirectedBidirectionalDijkstraTest.java # core/src/test/java/com/graphhopper/routing/RandomCHRoutingTest.java # core/src/test/java/com/graphhopper/routing/ch/CHTurnCostTest.java # core/src/test/java/com/graphhopper/routing/ch/EdgeBasedNodeContractorTest.java # core/src/test/java/com/graphhopper/routing/ch/Path4CHTest.java # core/src/test/java/com/graphhopper/routing/querygraph/QueryGraphTest.java # core/src/test/java/com/graphhopper/routing/weighting/DirectedRoutingTest.java # core/src/test/java/com/graphhopper/storage/GraphHopperStorageWithTurnCostsTest.java # core/src/test/java/com/graphhopper/storage/ShortcutUnpackerTest.java # core/src/test/java/com/graphhopper/storage/TurnCostStorageTest.java # reader-osm/src/main/java/com/graphhopper/reader/osm/OSMReader.java
# Conflicts: # core/src/test/java/com/graphhopper/routing/CHQueryWithTurnCostsTest.java # core/src/test/java/com/graphhopper/routing/DirectedBidirectionalDijkstraTest.java # core/src/test/java/com/graphhopper/routing/EdgeBasedRoutingAlgorithmTest.java # core/src/test/java/com/graphhopper/routing/ch/CHTurnCostTest.java # core/src/test/java/com/graphhopper/routing/ch/EdgeBasedNodeContractorTest.java # core/src/test/java/com/graphhopper/routing/ch/Path4CHTest.java # core/src/test/java/com/graphhopper/routing/weighting/TurnWeightingTest.java # core/src/test/java/com/graphhopper/storage/ShortcutUnpackerTest.java
| // todo: | ||
| // also this does not allow TurnCostEncoder to set the u-turn costs to zero explicitly, like FootFlagEncoder! | ||
| // this problem is a bit hidden, because if you do not apply any turn restrictions (like FootFlagEncoder) | ||
| // you never do a u-turn anyway. |
There was a problem hiding this comment.
the comment (or at least the line before 'todo' still applies, no ? setting u-turn costs on turnCostExt has no effect, because the uTurnCosts take a higher priority here.
There was a problem hiding this comment.
Ah, ok. This is what was meant with the comment before the todo. I'll revert the removal of that.
Regarding the TODO: the FootFlagEncoder does not have any turn restriction stuff but still overwriting/overruling is not possible.
BTW: could we make isUTurn dependent on turnCostEnc and then remove this comment?
| * This creates an EncodedValue specifically for the turn costs | ||
| */ | ||
| public static DecimalEncodedValue create(String name, int maxTurnCosts) { | ||
| int turnBits = Helper.countBitValue(maxTurnCosts); |
There was a problem hiding this comment.
Not sure if this is relevant here, but IntelliJ complains about return counter++ in Helper#countBitValue (counter is incremented "after" it is returned)
| IntsRef tcFlags = new IntsRef(turnCostFlags.length); | ||
| getTurnCostEnc().setDecimal(false, tcFlags, Double.POSITIVE_INFINITY); | ||
| entries.add(entry); | ||
| tcs.setTurnCost(tcFlags, edgeIdFrom, viaNode, iter.getEdge()); |
There was a problem hiding this comment.
Why can we not use tcs.set(...) here and why do we (need to) create a new IntsRef everytime we are here ?
There was a problem hiding this comment.
Ah, yes. It is indeed no longer required to create a new IntsRef now that we do no collect the TurnCostEntry. And will also try to use tcs.set...
|
LGTM |
|
Thanks a lot for the review - I finally could get rid of a bit more code :) |
This pull request removes several methods of FlagEncoders and TurnCostEncoder.java and is one of the many tasks to remove this class like #1625. Especially in FlagEncoders that do not use turn costs like FootFlagEncoder you see the effects of this change. Also OSMReader.TurnCostTableEntry is no longer part of the public API.
Initially I wanted to create two PRs, one for the 'pure' relation and one for the turn restriction part, but I think this belongs together.
So this PR is based on the branch: https://github.com/graphhopper/graphhopper/commits/move_rel_out_of_flag_encoder where the first two commits move the relation handling out of FlagEncoder into a new RelationTagParser (plus some clean up commits). It also fixes a bug here that calling the super method here has no side effects: https://github.com/graphhopper/graphhopper/blob/master/core/src/main/java/com/graphhopper/routing/util/MountainBikeFlagEncoder.java#L150 Additionally there was code reduction possible in some FlagEncoders.
From commit 22b1483 it cleans up the turn relation parsing and moves it into OSMTurnRelationParser. The OSMReader shows its age here and needs some later rewrite maybe using mapdb or similar so that several workarounds can be avoided (this is tricky as it needs to be very fast). At the moment there are 2 phases: preprocessing and processing that both have 3 subprocedures:
The RelationTagParser fetches the ReaderRelation tags in step 1.3 and compacts them into relationFlags (IntsRef) to convert them in step 2.2 into edgeFlags: see the new EncodedValues for RouteNetwork (
bike.networkandfoot.network). These EncodedValues can be used in other TagParsers.The TurnCostParser is more involved and different to the RelationTagParser as it needs a traversable Graph and e.g. for
car.turn_costit requires a ready-to-usecar.access. So this work is done at step 2.3. Also the method TurnCostParser.handleTurnRelationTags requires several parameters like the graph and an interface to convert between OSM and internal GraphHopper IDs.TODOs:
GraphExtensioninterface #1772 (comment) and remove TurnCostAccess