Skip to content

Use geo ref to identify copied edges - #2985

Merged
easbar merged 9 commits into
masterfrom
georef_copy_edge
May 5, 2024
Merged

easbar merged 9 commits into
masterfrom
georef_copy_edge

Conversation

@easbar

@easbar easbar commented Apr 22, 2024 •

Copy link
Copy Markdown
Member

For e.g. #2914 we need to be able to tell which edges are copies of which. One possible solution is to assign a common identifier to each original edge and the corresponding copied edges, because then we can find the copies by iterating the edges at one of the nodes of an edge.

I added a new method forEdgeAndCopiedEdges() to BaseGraph that can be used to modify edges and their corresponding copied edges. We mainly use these copied edges for via-way turn restrictions so far. So basically whenever one needs to modify an edge after the via-way turn restriction handling went through it should be done using this method!

A memory efficient way to do this is using the geometry ref since the geometry for copied edges should be identical to the geometry of the original edge anyway. But unfortunately, not every edge has a geometry (and thus no geo ref). This makes it a bit more tricky but it is still doable by using a dedicated (negative) value for the geo ref for each copied edge (that has no geometry).

The other tricky bit is that by setting the geometry of an edge (using setWayGeometry which changes the inner geometry of an edge, i.e. the positions of the pillar nodes) a second time or by setting the geometry after copying an edge the possibility to identify the copied edges gets lost. Therefore, with this PR we now get an error when we try to set the geometry when it was set already or the edge was copied before. The only exception that still works is when the new geometry has a smaller or equal number of pillar nodes than before, because in this case the geo ref stays the same. Otherwise the current edge elevation interpolation wouldn't work for example.

@easbar
easbar requested a review from karussell April 22, 2024 18:26
# Conflicts:
#	core/src/main/java/com/graphhopper/storage/BaseGraph.java
easbar added 2 commits May 4, 2024 12:56
# Conflicts:
#	core/src/test/java/com/graphhopper/storage/BaseGraphTest.java
@easbar easbar added this to the 10.0 milestone May 4, 2024
// 0 stands for no separate geoRef
maxGeoRef = 4;
// 0 stands for no separate geoRef, <0 stands for no separate geoRef but existing edge copies
maxGeoRef = 1;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really related to this PR but there did not seem to be a good reason this was set to 4.

# Conflicts:
#	core/src/main/java/com/graphhopper/storage/BaseGraph.java
#	core/src/test/java/com/graphhopper/storage/AbstractGraphStorageTester.java
@easbar
easbar merged commit 7ddf6cc into master May 5, 2024
@easbar
easbar deleted the georef_copy_edge branch May 5, 2024 07:55

This branch was previously deployed

1 inactive deployment
benchmarks — 6ac9b9de Deployed May 5, 2024 by easbar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant