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 fe53809
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 @@ -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<WayID>(lastID));
osmStore.relation_contains_way(relid, lastID);
if (isAccepted) { osmStore.relation_contains_way(relid, lastID); }
}
}
return true;
Expand Down

0 comments on commit fe53809

Please sign in to comment.