Repository navigation
OSMReader: Keep node tags until we create edges - #2430
Conversation
|
Very interesting approach and this could improve barrier handling a lot if we had all the information of the node when we create the edge 👍 |
Yes this is the idea. 👍 There is also this OSMReader rewrite where we already get the full node+way+relation information for each edge: Not sure about this though, because it currently still performs a bit worse and requires more memory (even though memory can be reduced using MMAP). For now I think we should continue with this PR and focus on removing some of the FlagEncoder stuff. |
* we just add barrier edges at all barrier nodes no matter whether the road is accessible or not
# Conflicts: # core/src/main/java/com/graphhopper/reader/osm/OSMReader.java
# Conflicts: # core/src/main/java/com/graphhopper/reader/osm/OSMReader.java # core/src/main/java/com/graphhopper/routing/util/EncodingManager.java # core/src/test/java/com/graphhopper/reader/osm/OSMReaderTest.java
|
I am now confident that this is the way we should proceed. So far we just keep the I'm still working on a rewrite of the This PR is a bit slower (<10%) than current master, but I think this is very reasonable considering that it also opens a lot of opportunities. The memory usage is increased as well and currently the biggest contribution is due to the relations. This is because there are a lot more route relations than barrier nodes. If we kept other node tags than Here is the memory footprint for the node and relation data for Germany (foot,bike+car): The biggest contribution is due to the |
|
Regarding the increased memory usage I think we have at least five options:
I would prefer 1) or 2) now so we can go on. Later we could try 3) or 4), and maybe try 5) as well. |
|
I reverted the changes related to the relation flags here: df998e6 (approach number 2 above). I then ran a base graph only import for germany-210101.osm.pbf from Geofabrik with a single profile (car) and
So maybe we should just merge the changes related to the node flags for now and deal with relations later? |
|
I just added the commit that reverts the relation flag changes to this PR (option 2). It seems like this is the easiest way for now and we can deal with relations later. |
|
Thanks for this nice work. It will make the handling downstream in the TagParsers easier. |
| } | ||
|
|
||
| public void setMembers(List<Member> members) { | ||
| this.members = members; |
There was a problem hiding this comment.
we do not need this yet (due to the revert)?
| public List<BooleanEncodedValue> getAccessEncFromNodeFlags(long importNodeFlags) { | ||
| List<BooleanEncodedValue> list = new ArrayList<>(edgeEncoders.size()); | ||
| for (int i = 0; i < edgeEncoders.size(); i++) { | ||
| FlagEncoder encoder = edgeEncoders.get(i); | ||
| if (((1L << i) & importNodeFlags) != 0) | ||
| list.add(encoder.getAccessEnc()); | ||
| } | ||
| return list; | ||
| } |
| flags |= (encoder.isBarrier(node) ? 1L << i : 0); | ||
| public IntsRef handleNodeTags(Map<String, Object> nodeTags, IntsRef edgeFlags) { | ||
| for (AbstractFlagEncoder encoder : edgeEncoders) { | ||
| // todo: not sure yet: should we pass the reader node (because it includes the coordinates), or just the tag? |
There was a problem hiding this comment.
For now I would keep this? As the method might change soonish as we reconsider how handleWayTags+handleNodeTags+applyWayTags work and which method signature they should have?
| return properties; | ||
| } | ||
|
|
||
| public void _setTags(Map<String, Object> properties) { |
There was a problem hiding this comment.
We could create a new constructor and allow directly assigning the properties Map.
| DIJKSTRA + ",false,505", | ||
| ASTAR + ",false,438", | ||
| DIJKSTRA_BI + ",false,224", | ||
| ASTAR_BI + ",false,180", | ||
| ASTAR_BI + ",true,41", | ||
| DIJKSTRA_BI + ",true,41" | ||
| DIJKSTRA + ",false,511", | ||
| ASTAR + ",false,444", | ||
| DIJKSTRA_BI + ",false,228", | ||
| ASTAR_BI + ",false,184", | ||
| ASTAR_BI + ",true,36", | ||
| DIJKSTRA_BI + ",true,30" |
There was a problem hiding this comment.
These changes are due to the fact that we now add barrier edges for all barrier nodes, even those that do not block access. This way we have better control over which barriers should block access in the tag parsers.
Instead of compressing the node and relation tags into node/relation'flags' early with this PR we keep the full node and relation tag data until we parse the ways in the second pass (but only for 'barrier' nodes and 'route' relations). This requires more memory, but it is actually not that bad, because there aren't so many barrier nodes and route relations. I did a little test and both master and this branch failed to run the import with
Xmx=1100m, but succeeded forXmx=1200m.I keep the node tags in a
List<Map<String, Object>>and use a separateLongIntMapto associate OSM node IDs with the indices into this list. The relations are grouped by the member way IDsLongMap<List<ReaderRelation>>. There is still room for improvement memory-wise, for example we could remove some of the tags like 'created' etc.The goal here is to make the relation and node tag handling more flexible. With this PR we should be able to delay the creation of edge flags until we actually create the edges and get rid of
EncodingManager#handleNodeTagsand some others. Ultimately, this should help us in getting rid ofFlagEncoderaltogether.Putting this as a Draft here, because maybe we should continue in this direction until we actually can remove e.g.
handleNodeTagsbefore merging.Update:
We reverted the changes to relation flags for now as this increased memory usage during import in some cases.