From fe53809184d7058504ecd7900209d59e644a3613 Mon Sep 17 00:00:00 2001 From: Colin Dellow Date: Sat, 30 Dec 2023 00:14:43 -0500 Subject: [PATCH] fix multipolygon handling D'oh, I thought this could be handled with fewer cases, but I don't think that's the case. If it's a multipolygon: whether to accept or not is a function of wayKeys filtering. If it's not a multipolygon: whether to accept or not is the result of relation_scan_function. --- src/pbf_processor.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/pbf_processor.cpp b/src/pbf_processor.cpp index caa5cb29..b9e33905 100644 --- a/src/pbf_processor.cpp +++ b/src/pbf_processor.cpp @@ -200,26 +200,24 @@ bool PbfProcessor::ScanRelations(OsmLuaProcessing& output, PbfReader::PrimitiveG tags.reset(); readTags(pbfRelation, pb, tags); - bool isAccepted = wayKeys.filter(tags); + bool isAccepted = false; if (!isMultiPolygon) { if (output.canReadRelations()) { - // NB: even if the relation is already accepted due to matching the wayKeys - // filter, we still need to call scanRelation, as other side effects can - // happen if the relation is Accept()ed. - isAccepted = output.scanRelation(relid, tags) || isAccepted; + isAccepted = output.scanRelation(relid, tags); } - } - - if (!isAccepted) - continue; + if (!isAccepted) continue; + } else { + if (!wayKeys.filter(tags)) + continue; + } osmStore.usedRelations.set(relid); for (int n=0; n < pbfRelation.memids.size(); n++) { uint64_t lastID = pbfRelation.memids[n]; if (pbfRelation.types[n] != PbfReader::Relation::MemberType::WAY) { continue; } if (lastID >= pow(2,42)) throw std::runtime_error("Way ID in relation "+std::to_string(relid)+" negative or too large: "+std::to_string(lastID)); osmStore.mark_way_used(static_cast(lastID)); - osmStore.relation_contains_way(relid, lastID); + if (isAccepted) { osmStore.relation_contains_way(relid, lastID); } } } return true;