Skip to content

Commit

Permalink
Find(...) in relation_function uses new tags
Browse files Browse the repository at this point in the history
If the user has called SetTag(...) on a relation, surface that new tag
inside of relation_function.
  • Loading branch information
cldellow committed Jan 14, 2024
1 parent 7344945 commit e9951bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/osm_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ class RelationScanStore {
const std::vector<std::pair<RelationID, uint16_t>>& relations_for_relation(RelationID relId) {
return relationsForRelations[relId];
}
bool has_relation_tags(RelationID relId) {
const size_t shard = relId % mutex.size();
return relationTags[shard].find(relId) != relationTags[shard].end();
}

const tag_map_t& relation_tags(RelationID relId) {
const size_t shard = relId % mutex.size();
return relationTags[shard][relId];
Expand Down
15 changes: 14 additions & 1 deletion src/pbf_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,20 @@ bool PbfProcessor::ReadRelations(

try {
tags.reset();
readTags(pbfRelation, pb, tags);
std::deque<protozero::data_view> dataviews;
if (osmStore.scannedRelations.has_relation_tags(pbfRelation.id)) {
const auto& scannedTags = osmStore.scannedRelations.relation_tags(pbfRelation.id);
for (const auto& entry : scannedTags) {
dataviews.push_back({entry.first.data(), entry.first.size()});
const auto& key = dataviews.back();
dataviews.push_back({entry.second.data(), entry.second.size()});
const auto& value = dataviews.back();
tags.addTag(key, value);
}
} else {
readTags(pbfRelation, pb, tags);
}

if (osmStore.usedRelations.test(pbfRelation.id) || wayKeys.filter(tags))
output.setRelation(pb.stringTable, pbfRelation, outerWayVec, innerWayVec, tags, isMultiPolygon, isInnerOuter);

Expand Down

0 comments on commit e9951bc

Please sign in to comment.