v0.2.52..v0.2.53 changeset NonConflatableCriterion.cpp
Garret Voltz edited this page Feb 12, 2020
·
1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/criterion/NonConflatableCriterion.cpp b/hoot-core/src/main/cpp/hoot/core/criterion/NonConflatableCriterion.cpp
index a6a9822..910246d 100644
--- a/hoot-core/src/main/cpp/hoot/core/criterion/NonConflatableCriterion.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/criterion/NonConflatableCriterion.cpp
@@ -22,7 +22,7 @@
* This will properly maintain the copyright information. DigitalGlobe
* copyrights will be updated automatically.
*
- * @copyright Copyright (C) 2018, 2019 DigitalGlobe (http://www.digitalglobe.com/)
+ * @copyright Copyright (C) 2018, 2019, 2020 DigitalGlobe (http://www.digitalglobe.com/)
*/
#include "NonConflatableCriterion.h"
@@ -36,10 +36,24 @@ namespace hoot
HOOT_FACTORY_REGISTER(ElementCriterion, NonConflatableCriterion)
-NonConflatableCriterion::NonConflatableCriterion()
+NonConflatableCriterion::NonConflatableCriterion() :
+_ignoreChildren(false)
{
}
+NonConflatableCriterion::NonConflatableCriterion(ConstOsmMapPtr map) :
+_map(map),
+_ignoreChildren(false)
+{
+}
+
+void NonConflatableCriterion::setConfiguration(const Settings& conf)
+{
+ ConfigOptions config = ConfigOptions(conf);
+ _ignoreChildren = config.getNonConflatableCriterionIgnoreRelationMembers();
+ LOG_VARD(_ignoreChildren);
+}
+
bool NonConflatableCriterion::isSatisfied(const ConstElementPtr& e) const
{
const QMap<QString, ElementCriterionPtr> conflatableCriteria =
@@ -47,13 +61,55 @@ bool NonConflatableCriterion::isSatisfied(const ConstElementPtr& e) const
for (QMap<QString, ElementCriterionPtr>::const_iterator itr = conflatableCriteria.begin();
itr != conflatableCriteria.end(); ++itr)
{
- if (itr.value()->isSatisfied(e))
+ ElementCriterionPtr crit = itr.value();
+
+ if (_map)
+ {
+ ConstOsmMapConsumer* mapConsumer = dynamic_cast<ConstOsmMapConsumer*>(crit.get());
+ if (mapConsumer != 0)
+ {
+ mapConsumer->setOsmMap(_map.get());
+ }
+ }
+
+ if (crit->isSatisfied(e))
{
// It is something we can conflate.
+ // TODO: change back to trace
+ LOG_DEBUG("Element: " << e->getElementId() << " is conflatable with: " << itr.key());
return false;
}
}
- // It is not something we can conflate
+
+ // Technically, there could also be something like a building way with a POI child and you'd want
+ // to check for ways here as well. Will wait to support that until an actual use case is
+ // encountered.
+ if (!_ignoreChildren && e->getElementType() == ElementType::Relation)
+ {
+ // We need to verify that none of the child relation members are conflatable in order to sign
+ // off on this element not being conflatable.
+
+ ConstRelationPtr relation = std::dynamic_pointer_cast<const Relation>(e);
+ const std::vector<RelationData::Entry>& members = relation->getMembers();
+ for (size_t i = 0; i < members.size(); i++)
+ {
+ const RelationData::Entry& member = members[i];
+ ConstElementPtr memberElement = _map->getElement(member.getElementId());
+ if (memberElement && isSatisfied(memberElement))
+ {
+ // It is something we can conflate.
+ LOG_DEBUG(
+ "Element: " << e->getElementId() << " has a child that is conflatable: " <<
+ memberElement->getElementId() << ", and member children are not being ignored, " <<
+ "therefore it is conflatable.");
+ return false;
+ }
+ }
+ }
+
+ // It is not something we can conflate.
+ LOG_DEBUG("Element: " << e->getElementId() << " is not conflatable.");
+ LOG_VART(e);
return true;
}