-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No longer allow changing profiles between imports and loads #2550
Conversation
* This way we can be sure there is no inconsistency regarding subnetwork encoded values
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") | ||
8000 | ) | |
.setGraphHopperLocation(GH_LOCATION) | ||
.setOSMFile(BAYREUTH); | ||
hopper.importOrLoad(); | ||
int nodes = hopper.getGraphHopperStorage().getNodes(); | ||
hopper.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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#loadExisting
when we try to load. With this PR also changing the profiles yields an error.