Repository navigation
No longer allow changing profiles between imports and loads - #2550
Merged
Merged
Conversation
* This way we can be sure there is no inconsistency regarding subnetwork encoded values
easbar
commented
Apr 5, 2022
Comment on lines
-2480
to
+2489
| FlagEncoder carEncoder = FlagEncoders.createCar(); | ||
| EncodingManager encodingManager = new EncodingManager.Builder().add(carEncoder).add(FlagEncoders.createBike()).build(); | ||
| GraphHopperStorage graph = new GraphBuilder(encodingManager).setDir(new RAMDirectory(GH_LOCATION, true)).create(); | ||
| NodeAccess na = graph.getNodeAccess(); | ||
| na.setNode(0, 12, 23); | ||
| na.setNode(1, 8, 13); | ||
| na.setNode(2, 2, 10); | ||
| na.setNode(3, 5, 9); | ||
| GHUtility.setSpeed(60, true, true, carEncoder, graph.edge(1, 2).setDistance(10)); | ||
| GHUtility.setSpeed(60, true, true, carEncoder, graph.edge(1, 3).setDistance(10)); | ||
| int nodes = graph.getNodes(); | ||
| int edges = graph.getAllEdges().length(); | ||
| graph.flush(); | ||
| Helper.close(graph); | ||
| GraphHopper hopper = new GraphHopper() | ||
| .setProfiles( | ||
| new Profile("p_car").setVehicle("car").setWeighting("fastest"), | ||
| new Profile("p_bike").setVehicle("bike").setWeighting("fastest") | ||
| ) | ||
| .setGraphHopperLocation(GH_LOCATION) | ||
| .setOSMFile(BAYREUTH); | ||
| hopper.importOrLoad(); | ||
| int nodes = hopper.getGraphHopperStorage().getNodes(); | ||
| hopper.close(); |
Member
Author
There was a problem hiding this comment.
This test was testing an API I do not even think we should support: Creating a graph using a low-level API, but then loading it using the high-level GraphHopper class. For example this way we do not even create subnetwork encoded values. I now use the GraphHopper class to create the graph.
Comment on lines
-22
to
-27
| public void testLoad() { | ||
| String defaultGraphLoc = "./target/ghstorage_lm"; | ||
| Helper.removeDir(new File(defaultGraphLoc)); | ||
| CarFlagEncoder carFlagEncoder = new CarFlagEncoder(); | ||
| EncodingManager encodingManager = new EncodingManager.Builder().add(carFlagEncoder).add(Subnetwork.create("my_profile")).build(); | ||
| GraphHopperStorage graph = GraphBuilder.start(encodingManager).setRAM(defaultGraphLoc, true).create(); |
Member
Author
There was a problem hiding this comment.
Also here we use a combination of low- and high-level API. This test does no longer test anything useful so I deleted the entire class.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We do not allow changing profiles for which there are CH or LM preparations, because this would invalidate the index data we stored for these preparations. However, changing profiles without preparations is also potentially wrong, because of the subnetwork encoded values we calculate for each profile during the import. See: #2025 (comment)
Adding or removing profiles is not possible already in master, because this changes the (subnetwork) encoded value setup and we get an error in
GraphHopperStorage#loadExistingwhen we try to load. With this PR also changing the profiles yields an error.