8000 No longer allow changing profiles between imports and loads by easbar · Pull Request #2550 · graphhopper/graphhopper · GitHub
[go: up one dir, main page]

Skip to content
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

Merged
merged 1 commit into from
Apr 5, 2022

Conversation

easbar
Copy link
Member
@easbar easbar commented Apr 5, 2022

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.

* This way we can be sure there is no inconsistency regarding subnetwork encoded values
@easbar easbar added this to the 6.0 milestone Apr 5, 2022
Comment on lines -2480 to +2489
8000
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();
Copy link
Member Author

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.

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();
Copy link
Member Author

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.

@easbar easbar merged commit 5e60241 into master Apr 5, 2022
@easbar easbar deleted the do_not_modify_profiles branch April 5, 2022 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0