-
Notifications
You must be signed in to change notification settings - Fork 74
v0.2.48..v0.2.49 changeset RemoveElementsVisitor.cpp
Garret Voltz edited this page Oct 2, 2019
·
1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/visitors/RemoveElementsVisitor.cpp b/hoot-core/src/main/cpp/hoot/core/visitors/RemoveElementsVisitor.cpp
index 5e96cd8..6ec6c3e 100644
--- a/hoot-core/src/main/cpp/hoot/core/visitors/RemoveElementsVisitor.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/visitors/RemoveElementsVisitor.cpp
@@ -33,7 +33,6 @@
#include <hoot/core/ops/RecursiveElementRemover.h>
#include <hoot/core/ops/RemoveElementByEid.h>
#include <hoot/core/util/ConfigOptions.h>
-#include <hoot/core/criterion/NotCriterion.h>
#include <hoot/core/util/Log.h>
namespace hoot
@@ -44,10 +43,10 @@ HOOT_FACTORY_REGISTER(ElementVisitor, RemoveElementsVisitor)
RemoveElementsVisitor::RemoveElementsVisitor(bool negateCriteria) :
_recursive(false),
_count(0),
-_negateCriteria(negateCriteria),
-_chainCriteria(false),
_startElementCount(0)
{
+ _negateCriteria = negateCriteria;
+ _chainCriteria = false;
}
void RemoveElementsVisitor::setConfiguration(const Settings& conf)
@@ -55,34 +54,29 @@ void RemoveElementsVisitor::setConfiguration(const Settings& conf)
ConfigOptions configOptions(conf);
_negateCriteria = configOptions.getElementCriterionNegate();
-
+ _chainCriteria = configOptions.getRemoveElementsVisitorChainElementCriteria();
+ LOG_VARD(_chainCriteria);
const QStringList critNames = configOptions.getRemoveElementsVisitorElementCriteria();
LOG_VART(critNames);
- if (critNames.size() > 0)
+ _addCriteria(critNames);
+ // TODO: Maybe we should just make MultipleCriterionConsumerVisitor configurable and move this up?
+ LOG_VARD(_criteria.size());
+ LOG_VARD(_configureChildren);
+ if (_configureChildren)
{
- _criteria.clear();
- for (int i = 0; i < critNames.size(); i++)
+ for (std::vector<ElementCriterionPtr>::const_iterator it = _criteria.begin();
+ it != _criteria.end(); ++it)
{
- const QString critName = critNames.at(i);
- if (!critName.trimmed().isEmpty())
+ ElementCriterionPtr crit = *it;
+ Configurable* c = dynamic_cast<Configurable*>(crit.get());
+ if (c != 0)
{
- LOG_VARD(critName);
- ElementCriterionPtr crit =
- std::shared_ptr<ElementCriterion>(
- Factory::getInstance().constructObject<ElementCriterion>(critName.trimmed()));
- addCriterion(crit);
- Configurable* c = dynamic_cast<Configurable*>(crit.get());
- if (c != 0)
- {
- c->setConfiguration(conf);
- }
+ c->setConfiguration(conf);
}
}
}
_recursive = configOptions.getRemoveElementsVisitorRecursive();
- _chainCriteria = configOptions.getRemoveElementsVisitorChainElementCriteria();
- LOG_VARD(_chainCriteria);
}
void RemoveElementsVisitor::setOsmMap(OsmMap* map)
@@ -100,55 +94,6 @@ void RemoveElementsVisitor::setOsmMap(OsmMap* map)
}
}
-void RemoveElementsVisitor::addCriterion(const ElementCriterionPtr& crit)
-{
- LOG_VART(_negateCriteria);
- LOG_VART(crit.get());
- if (_negateCriteria)
- {
- _criteria.push_back(ElementCriterionPtr(new NotCriterion(crit)));
- }
- else
- {
- _criteria.push_back(ElementCriterionPtr(crit));
- }
- LOG_VART(_criteria.size());
-}
-
-bool RemoveElementsVisitor::_criteriaSatisfied(const ConstElementPtr& e) const
-{
- bool criteriaSatisfied;
- if (!_chainCriteria)
- {
- criteriaSatisfied = false;
- for (std::vector<ElementCriterionPtr>::const_iterator it = _criteria.begin();
- it != _criteria.end(); ++it)
- {
- ElementCriterionPtr crit = *it;
- if (crit->isSatisfied(e))
- {
- criteriaSatisfied = true;
- break;
- }
- }
- }
- else
- {
- criteriaSatisfied = true;
- for (std::vector<ElementCriterionPtr>::const_iterator it = _criteria.begin();
- it != _criteria.end(); ++it)
- {
- ElementCriterionPtr crit = *it;
- if (!crit->isSatisfied(e))
- {
- criteriaSatisfied = false;
- break;
- }
- }
- }
- return criteriaSatisfied;
-}
-
void RemoveElementsVisitor::visit(const ElementPtr& e)
{
if (_criteria.size() == 0)
@@ -169,6 +114,10 @@ void RemoveElementsVisitor::visit(const ElementPtr& e)
RemoveElementByEid::removeElement(_map->shared_from_this(), e->getElementId());
}
}
+ else
+ {
+ LOG_TRACE("Not removing element: " << e);
+ }
}
void RemoveElementsVisitor::removeWays(const std::shared_ptr<OsmMap>& pMap,