Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/RELATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The three main processing functions (`way_function`, `node_function`, `relation_

However, relation hierarchies aren't available in `relation_scan_function`, because not all relations have been read yet.

Instead, you can supply an additional `relation_postscan_function`. This runs immediately after `relation_scan_function`, when all accepted relations are in memory. The concept is that you read the ancestor relations, and then use this to set tags on the child relation. These tags will then be accessible when reading the relation in `way_function` etc.
Instead, you can supply an additional `relation_postscan_function`. This runs immediately after `relation_scan_function`, when all accepted relations are in memory. It is called only for relations that you accepted in `relation_scan_function` and that are themselves a member of another accepted relation - not for every accepted relation. The concept is that you read the ancestor relations, and then use this to set tags on the child relation. These tags will then be accessible when reading the relation in `way_function` etc.

For example, let's say you have a cycle route relation 8590454 (`type=route, route=bicycle, network=ncn, name=Loire à Vélo 3`). This has a parent relation 3199605 (`type=superroute, route=bicycle, network=ncn, name=Loire à Vélo`). You want to use the name from the latter. Write a relation_postscan_function like this:

Expand Down
4 changes: 3 additions & 1 deletion include/osm_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ class RelationScanStore {
if (relationsDone.find(rel) != relationsDone.end()) continue;
relationsDone.insert(rel);
// add all its parents
for (auto rp : relationsForRelations[rel]) {
auto it = relationsForRelations.find(rel);
if (it == relationsForRelations.end()) continue;
for (auto rp : it->second) {
out.emplace_back(rp);
relationsToDo.emplace_back(rp.first);
}
Expand Down
4 changes: 3 additions & 1 deletion src/osm_lua_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,9 +1432,11 @@ void OsmLuaProcessing::postScanRelations() {
if (!supportsPostScanRelations) return;

for (const auto &relp : osmStore.scannedRelations.relationsForRelations) {
RelationID id = relp.first;
// only accepted relations have stored tags; leave the others untouched
if (!osmStore.scannedRelations.has_relation_tags(id)) continue;
reset();
isPostScanRelation = true;
RelationID id = relp.first;
originalOsmID = id;
currentPostScanTags = &(osmStore.scannedRelations.relation_tags(id));
relationList = osmStore.scannedRelations.relations_for_relation_with_parents(id);
Expand Down
Loading