当前位置: 首页>>代码示例>>C++>>正文


C++ Tags::contains方法代码示例

本文整理汇总了C++中Tags::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ Tags::contains方法的具体用法?C++ Tags::contains怎么用?C++ Tags::contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tags的用法示例。


在下文中一共展示了Tags::contains方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _addAsDefault

void TagComparator::_addAsDefault(Tags& t, const QString& key, const QString& value)
{
  if (t.contains(key) == false || t[key].isEmpty() == true)
  {
    t[key] = value;
  }
}
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:7,代码来源:TagComparator.cpp

示例2: _overwriteUnrecognizedTags

void TagComparator::_overwriteUnrecognizedTags(Tags& t1, Tags& t2, Tags& result)
{
  OsmSchema& schema = OsmSchema::getInstance();

  const Tags t1Copy = t1;
  for (Tags::ConstIterator it1 = t1Copy.begin(); it1 != t1Copy.end(); ++it1)
  {
    // if this is an unknown type
    if (schema.getTagVertex(it1.key() + "=" + it1.value()).isEmpty() &&
        schema.getTagVertex(it1.key()).isEmpty())
    {
      // if this is also in t2.
      if (t2.contains(it1.key()))
      {
        result[it1.key()] = it1.value();
        t1.remove(it1.key());
        t2.remove(it1.key());
      }
    }
  }

  // go through any remaining tags in t2
  const Tags t2Copy = t2;
  for (Tags::ConstIterator it2 = t2Copy.begin(); it2 != t2Copy.end(); ++it2)
  {
    // if this is an unknown type
    if (schema.getTagVertex(it2.key() + "=" + it2.value()).isEmpty())
    {
      // we know it isn't in t1, or it would have been handled in the above loop so just deal with
      // t2
      t2.remove(it2.key());
      result[it2.key()] = it2.value();
    }
  }
}
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:35,代码来源:TagComparator.cpp

示例3: getMostEnglishName

QString MostEnglishName::getMostEnglishName(const Tags& tags)
{
  if (tags.contains("name:en") && tags.get("name:en").isEmpty() == false)
  {
    return tags.get("name:en");
  }

  QStringList names = tags.getNames();

  double bestScore = -numeric_limits<double>::max();
  QString bestName;

  for (int i = 0; i < names.size(); i++)
  {
    double score = scoreName(names[i]);

    if (score > bestScore)
    {
      bestScore = score;
      bestName = names[i];
    }
  }

  return bestName;
}
开发者ID:ngageoint,项目名称:hootenanny,代码行数:25,代码来源:MostEnglishName.cpp

示例4: _mergeText

void TagComparator::_mergeText(Tags& t1, Tags& t2, Tags& result)
{
  OsmSchema& schema = OsmSchema::getInstance();

  const Tags t1Copy = t1;
  for (Tags::ConstIterator it1 = t1Copy.begin(); it1 != t1Copy.end(); ++it1)
  {
    const SchemaVertex& tv = schema.getTagVertex(it1.key());

    // if this is a text field and it exists in both tag sets.
    if (tv.valueType == Text && t2.contains(it1.key()))
    {
      // only keep the unique text fields
      QStringList values = t1.getList(it1.key());
      values.append(t2.getList(it1.key()));

      // append all unique values in the existing order.
      for (int i = 0; i < values.size(); i++)
      {
        if (values[i].isEmpty() == false)
        {
          result.appendValueIfUnique(it1.key(), values[i]);
        }
      }

      t1.remove(it1.key());
      t2.remove(it1.key());
    }
  }
}
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:30,代码来源:TagComparator.cpp

示例5: _addDefaults

void TagComparator::_addDefaults(Tags& t)
{
  if (t.contains("highway"))
  {
    _addAsDefault(t, "bridge", "no");
    _addAsDefault(t, "tunnel", "no");
    _addAsDefault(t, "oneway", "no");
  }
}
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:9,代码来源:TagComparator.cpp

示例6: _getNextNameId

int SplitNameVisitor::_getNextNameId(const Tags& t, int lastId)
{
    for (int i = lastId + 1; i < lastId + 100; i++)
    {
        QString k = QString("name:%1").arg(i);

        if (t.contains(k) == false)
        {
            return i;
        }
    }

    throw InternalErrorException("Unable to find a valid key for a new extra name.");
}
开发者ID:mitulvpatel,项目名称:hootenanny,代码行数:14,代码来源:SplitNameVisitor.cpp

示例7: _mergeUnrecognizedTags

void TagComparator::_mergeUnrecognizedTags(Tags& t1, Tags& t2, Tags& result)
{
  OsmSchema& schema = OsmSchema::getInstance();

  const Tags t1Copy = t1;
  for (Tags::ConstIterator it1 = t1Copy.begin(); it1 != t1Copy.end(); ++it1)
  {
    // if this is an unknown type
    if (schema.getTagVertex(it1.key() + "=" + it1.value()).isEmpty() &&
        schema.getTagVertex(it1.key()).isEmpty())
    {
      // if this is also in t2.
      if (t2.contains(it1.key()))
      {
        // get the set of all values.
        QSet<QString> values = _toSet(t1, it1.key());
        values.unite(_toSet(t2, it1.key()));
        QList<QString> sortEm = values.toList();
        qSort(sortEm);

        // remove it from the inputs
        t1.remove(it1.key());
        t2.remove(it1.key());
        // set the united set in the output
        result.set(it1.key(), sortEm.begin(), sortEm.end());
      }
      else
      {
        result[it1.key()] = it1.value();
      }
    }
  }

  // go through any remaining tags in t2
  const Tags t2Copy = t2;
  for (Tags::ConstIterator it2 = t2Copy.begin(); it2 != t2Copy.end(); ++it2)
  {
    // if this is an unknown type
    if (schema.getTagVertex(it2.key() + "=" + it2.value()).isEmpty())
    {
      // we know it isn't in t1, or it would have been handled in the above loop so just deal with
      // t2
      t2.remove(it2.key());
      result[it2.key()] = it2.value();
    }
  }
}
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:47,代码来源:TagComparator.cpp

示例8: _decomposeBuilding

void DecomposeBuildingRelationsVisitor::_decomposeBuilding(const shared_ptr<Relation>& r)
{
  Tags baseTags = r->getTags();

  const vector<RelationData::Entry> members = r->getMembers();

  for (size_t i = 0; i < members.size(); ++i)
  {
    ElementId eid = members[i].getElementId();
    r->removeElement(eid);
    if (eid.getType() == ElementType::Node)
    {
      LOG_WARN("Unexpected node encountered in building relation. " << r->getElementId());
      continue;
    }
    // we're dropping the outline. We only care about the parts.
    else if (members[i].getRole() == "outline")
    {
      continue;
    }
    else if (members[i].getRole() != "part")
    {
      LOG_WARN("Encountered an unexpected role in a building relation. " << r->getElementId());
    }

    // ok, we've got a building part. Recompose it as a building.
    shared_ptr<Element> e = _map->getElement(members[i].getElementId());

    Tags t = baseTags;
    t.addTags(e->getTags());
    // don't need the building:part tag anymore.
    t.remove("building:part");

    if (!t.contains("building"))
    {
      t["building"] = "yes";
    }

    e->setTags(t);
  }

  // remove the building relation
  RecursiveElementRemover(r->getElementId()).apply(_map->shared_from_this());
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:44,代码来源:DecomposeBuildingRelationsVisitor.cpp

示例9: compareTextTags

void TagComparator::compareTextTags(const Tags& t1, const Tags& t2, double& score, double& weight)
{
  OsmSchema& schema = OsmSchema::getInstance();

  score = 1.0;
  weight = 0.0;

  for (Tags::const_iterator it = t1.begin(); it != t1.end(); it++)
  {
    const SchemaVertex& tv = schema.getTagVertex(it.key());
    if (schema.isAncestor(it.key(), "abstract_name") == false &&
        tv.valueType == Text && t2.contains(it.key()))
    {
      score *= LevenshteinDistance::score(it.value(), t2[it.key()]);
      weight += tv.influence;
    }
  }

  // if the weight is zero don't confuse things with a low score.
  if (weight == 0.0)
  {
    score = 1;
  }
}
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:24,代码来源:TagComparator.cpp

示例10: mergeNames

void TagComparator::mergeNames(Tags& t1, Tags& t2, Tags& result)
{
  set<QString> altNames, nonAltNames;
  set<QString> toRemove;

  toRemove.insert("alt_name");

  for (Tags::const_iterator it1 = t1.begin(); it1 != t1.end(); it1++)
  {
    if (it1.key() == "alt_name")
    {
      QStringList sl = Tags::split(it1.value());
      altNames.insert(sl.begin(), sl.end());
    }
    else
    {
      if (OsmSchema::getInstance().isAncestor(it1.key(), "abstract_name"))
      {
        result[it1.key()] = it1.value();
        QStringList sl = Tags::split(it1.value());
        // keep track of all the names we've used
        nonAltNames.insert(sl.begin(), sl.end());
        toRemove.insert(it1.key());
      }
    }
  }

  for (Tags::const_iterator it2 = t2.begin(); it2 != t2.end(); it2++)
  {
    if (it2.key() == "alt_name")
    {
      QStringList sl = Tags::split(it2.value());
      altNames.insert(sl.begin(), sl.end());
    }
    else if (result.contains(it2.key()))
    {
      const Qt::CaseSensitivity caseSensitivity =
        _caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
      if (result[it2.key()].compare(it2.value(), caseSensitivity) != 0)
      {
        QStringList sl = Tags::split(it2.value());
        altNames.insert(sl.begin(), sl.end());
      }
    }
    else
    {
      if (OsmSchema::getInstance().isAncestor(it2.key(), "abstract_name"))
      {
        result[it2.key()] = it2.value();
        QStringList sl = Tags::split(it2.value());
        nonAltNames.insert(sl.begin(), sl.end());
        toRemove.insert(it2.key());
      }
    }
  }

  for (set<QString>::const_iterator it = toRemove.begin(); it != toRemove.end(); it++)
  {
    t1.remove(*it);
    t2.remove(*it);
  }

  // add all the altNames that don't exist in nonAltNames
  QStringList l;
  for (set<QString>::const_iterator it = altNames.begin(); it != altNames.end(); it++)
  {
    if (nonAltNames.find(*it) == nonAltNames.end())
    {
      l.append(*it);
    }
  }

  if (l.size() > 0)
  {
    result.setList("alt_name", l);
  }
}
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:77,代码来源:TagComparator.cpp


注:本文中的Tags::contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。