Skip to content

Commit

Permalink
fix Attribute Conflation dropped multipoly building relations bug (#3038
Browse files Browse the repository at this point in the history
)

Changes were previously made to Attribute Conflation to remove building relations after conflation when they had already had a corresponding unioned multipoly relation created for them after conflation.  However, BuildingOutlineUpdateOp was incorrectly removing all multipoly relations, regardless of whether they had been conflated and then unioned with anything.  So, multipoly building relations were disappearing from the output.  These changes fix that.
  • Loading branch information
bwitham authored Mar 7, 2019
1 parent 6c7d9ce commit 668d9b4
Show file tree
Hide file tree
Showing 6 changed files with 1,154 additions and 6 deletions.
9 changes: 7 additions & 2 deletions hoot-core/src/main/cpp/hoot/core/cmd/ConflateCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,13 @@ void ConflateCmd::_updateConfigOptionsForAttributeConflation()
// are involved in reviews.

QStringList postConflateOps = ConfigOptions().getConflatePostOps();
LOG_DEBUG("Post conflate ops before Attribute Conflation adjustment: " << postConflateOps);
// Currently, all these things will be true if we're running Attribute Conflation, but I'm
// specifying them anyway to harden this a bit.
if (ConfigOptions().getBuildingOutlineUpdateOpRemoveBuildingRelations() &&
postConflateOps.contains("hoot::RemoveElementsVisitor") &&
ConfigOptions().getRemoveElementsVisitorElementCriterion() == "hoot::ReviewRelationCriterion" &&
ConfigOptions().getRemoveElementsVisitorElementCriterion() ==
"hoot::ReviewRelationCriterion" &&
postConflateOps.contains("hoot::BuildingOutlineUpdateOp"))
{
const int removeElementsVisIndex = postConflateOps.indexOf("hoot::RemoveElementsVisitor");
Expand All @@ -388,7 +390,10 @@ void ConflateCmd::_updateConfigOptionsForAttributeConflation()
conf().set(
ConfigOptions::getRemoveElementsVisitorElementCriterionKey(), "hoot::ReviewScoreCriterion");
}
LOG_VARD(conf().get(ConfigOptions::getRemoveElementsVisitorElementCriterionKey()));

LOG_DEBUG(
"Post conflate ops after Attribute Conflation adjustment: " <<
conf().get("conflate.post.ops").toStringList());
}
}

Expand Down
18 changes: 14 additions & 4 deletions hoot-core/src/main/cpp/hoot/core/ops/BuildingOutlineUpdateOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ void BuildingOutlineUpdateOp::apply(boost::shared_ptr<OsmMap> &map)
if (BuildingCriterion().isSatisfied(r))
{
_createOutline(r);
_buildingRelationIds.insert(r->getElementId());
}
}

Expand All @@ -169,13 +168,14 @@ void BuildingOutlineUpdateOp::_deleteBuildingRelations()

void BuildingOutlineUpdateOp::_createOutline(const RelationPtr& building)
{
LOG_VART(building->toString());
LOG_TRACE("Input building: " << building->toString());

boost::shared_ptr<Geometry> outline(GeometryFactory::getDefaultInstance()->createEmptyGeometry());

const vector<RelationData::Entry> entries = building->getMembers();
for (size_t i = 0; i < entries.size(); i++)
{
LOG_VART(entries[i].role);
if (entries[i].role == MetadataTags::RoleOutline())
{
LOG_TRACE("Removing outline role from: " << entries[i] << "...");
Expand Down Expand Up @@ -228,6 +228,7 @@ void BuildingOutlineUpdateOp::_createOutline(const RelationPtr& building)
else if (entries[i].getElementId().getType() == ElementType::Relation)
{
RelationPtr relation = _map->getRelation(entries[i].getElementId().getId());
LOG_VART(relation);
if (relation->isMultiPolygon())
{
LOG_TRACE("Unioning multipoly relation: " << relation << "...");
Expand Down Expand Up @@ -296,13 +297,22 @@ void BuildingOutlineUpdateOp::_createOutline(const RelationPtr& building)
// We don't need the relation "type" tag.
outlineElement->getTags().remove("type");
LOG_VART(outlineElement);
if (!_removeBuildingRelations)
if (_removeBuildingRelations)
{
LOG_TRACE("Marking building: " << building->getElementId() << " for deletion...");
_buildingRelationIds.insert(building->getElementId());
}
else
{
building->addElement(MetadataTags::RoleOutline(), outlineElement);
}
}
else
{
LOG_TRACE("Building outline is empty. Skipping creation of multipoly relation.");
}

LOG_VART(building);
LOG_DEBUG("Output building: " << building);
}

void BuildingOutlineUpdateOp::_mergeNodes(const boost::shared_ptr<Element>& changed,
Expand Down
Loading

0 comments on commit 668d9b4

Please sign in to comment.