Skip to content

Commit

Permalink
fix multipolygon handling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cldellow committed Dec 30, 2023
1 parent 3c1740a commit 2a0abf0
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/pbf_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,30 +196,28 @@ bool PbfProcessor::ScanRelations(OsmLuaProcessing& output, PbfReader::PrimitiveG

for (PbfReader::Relation pbfRelation : pg.relations()) {
bool isMultiPolygon = relationIsType(pbfRelation, typeKey, mpKey);
bool isAccepted = false;
WayID relid = static_cast<WayID>(pbfRelation.id);
tags.reset();
readTags(pbfRelation, pb, tags);

bool isAccepted = wayKeys.filter(tags);
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<WayID>(lastID));
osmStore.relation_contains_way(relid, lastID);
if (isAccepted) { osmStore.relation_contains_way(relid, lastID); }
}
}
return true;
Expand Down

0 comments on commit 2a0abf0

Please sign in to comment.