void PertyRemoveTagVisitor::visit(const shared_ptr<Element>& e)
{
  boost::uniform_real<> uni(0.0, 1.0);

  Tags t = e->getTags();
  for (Tags::const_iterator it = t.constBegin(); it != t.constEnd(); ++it)
  {
    const QString tagKey = it.key();
    if (uni(*_rng) <= _p && !_exemptTagKeys.contains(tagKey))
    {
      if (!_replacementTagKeys.contains(tagKey))
      {
        LOG_DEBUG("Removing tag with key: " << tagKey << " ...");
        e->getTags().remove(tagKey);
      }
      else
      {
        const int tagIndex = _replacementTagKeys.indexOf(tagKey);
        const QString tagValue = _replacementTagValues.at(tagIndex);
        LOG_DEBUG("Substituting value: " << tagValue << " for tag with key: " << tagKey);
        e->getTags().set(tagKey, tagValue);
      }
    }
  }
}
void TagComparator::_overwriteRemainingTags(Tags& t1, Tags& t2, Tags& result)
{
  // Add t2 tags
  for (Tags::ConstIterator it2 = t2.constBegin(); it2 != t2.constEnd(); ++it2)
  {
    if (it2.value().isEmpty() == false)
    {
      result[it2.key()] = it2.value();
    }
  }

  // Add t1 tags overwriting any t2 tags in the process.
  for (Tags::ConstIterator it1 = t1.constBegin(); it1 != t1.constEnd(); ++it1)
  {
    if (it1.value().isEmpty() == false)
    {
      result[it1.key()] = it1.value();
    }
  }

  t1.clear();
  t2.clear();
}