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


C++ tags::const_iterator类代码示例

本文整理汇总了C++中tags::const_iterator的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator类的具体用法?C++ const_iterator怎么用?C++ const_iterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: visit

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);
      }
    }
  }
}
开发者ID:giserh,项目名称:hootenanny,代码行数:25,代码来源:PertyRemoveTagVisitor.cpp

示例2: writeElement

void OgrWriter::writeElement(ElementPtr &element, bool debug)
{
  //Unfortunately, this check also has to happen in addition to checking hasMoreElements.  See
  //explanation in ServicesDbReader::readNextElement.
  if (element.get())
  {
    Tags sourceTags = element->getTags();
    Tags destTags;
    for (Tags::const_iterator it = element->getTags().begin();
         it != element->getTags().end(); ++it)
    {
      if (sourceTags[it.key()] != "")
      {
        destTags.appendValue(it.key(), it.value());
      }
    }
    // Now that all the empties are gone, update our element
    element->setTags(destTags);

    if ( debug == true )
    {
      LOG_DEBUG(element->toString());
    }

    PartialOsmMapWriter::writePartial(element);
  }
}
开发者ID:digideskio,项目名称:hootenanny,代码行数:27,代码来源:OgrWriter.cpp

示例3: isSatisfied

bool LinearCriterion::isSatisfied(const ConstElementPtr& e) const
{
  bool result = false;

  if (e->getElementType() == ElementType::Node)
  {
    return false;
  }

  const Tags& t = e->getTags();

  if (e->getElementType() == ElementType::Relation)
  {
    ConstRelationPtr r = boost::dynamic_pointer_cast<const Relation>(e);
    result |= r->getType() == MetadataTags::RelationMultilineString();
    result |= r->getType() == MetadataTags::RelationRoute();
    result |= r->getType() == MetadataTags::RelationBoundary();
  }

  for (Tags::const_iterator it = t.constBegin(); it != t.constEnd(); ++it)
  {
    const SchemaVertex& tv = OsmSchema::getInstance().getTagVertex(it.key() + "=" + it.value());
    uint16_t g = tv.geometries;
    if (g & (OsmGeometries::LineString | OsmGeometries::ClosedWay) && !(g & OsmGeometries::Area))
    {
      result = true;
      break;
    }
  }

  return result;
}
开发者ID:ngageoint,项目名称:hootenanny,代码行数:32,代码来源:LinearCriterion.cpp

示例4: visit

void TranslatedTagCountVisitor::visit(ElementType type, long id)
{
  shared_ptr<const Element> e = _map->getElement(type, id);

  if (e->getTags().getInformationCount() > 0)
  {
    shared_ptr<Geometry> g = ElementConverter(_map->shared_from_this()).convertToGeometry(e);

    Tags t = e->getTags();
    t["error:circular"] = QString::number(e->getCircularError());
    t["hoot:status"] = e->getStatusString();

    // remove all the empty tags.
    for (Tags::const_iterator it = e->getTags().begin(); it != e->getTags().end(); ++it)
    {
      if (t[it.key()] == "")
      {
        t.remove(it.key());
      }
    }

    QString layerName;
    vector<ScriptToOgrTranslator::TranslatedFeature> f = _translator->translateToOgr(t,
      e->getElementType(), g->getGeometryTypeId());

    // only write the feature if it wasn't filtered by the translation script.
    for (size_t i = 0; i < f.size(); i++)
    {
      _countTags(f[i].feature);
    }
  }
}
开发者ID:mitulvpatel,项目名称:hootenanny,代码行数:32,代码来源:TranslatedTagCountVisitor.cpp

示例5: _writeRelation

void PbfWriter::_writeRelation(const shared_ptr<const hoot::Relation>& r)
{
    _elementsWritten++;

    if (_pg == 0)
    {
        _pg = _d->primitiveBlock.add_primitivegroup();
    }

    pb::Relation* pbr = _pg->add_relations();

    pbr->set_id(r->getId() + _relationIdDelta);

    // From http://wiki.openstreetmap.org/wiki/PBF_Format#Ways_and_Relations
    // For ways and relations, which contain the ID's of other nodes, I exploit the tendency of
    // consecutive nodes in a way or relation to have nearby node ID's by using delta compression,
    // resulting in small integers. (I.E., instead of encoding x_1, x_2, x_3, I encode
    // x_1, x_2-x_1, x_3-x_2, ...).
    long lastId = 0;
    const vector<RelationData::Entry>& entries = r->getMembers();
    for (size_t i = 0; i < entries.size(); i++)
    {
        long id = entries[i].getElementId().getId() + _nodeIdDelta;
        pbr->add_memids(id - lastId);
        lastId = id + _nodeIdDelta;
        pbr->add_types((hoot::pb::Relation_MemberType)
                       _toRelationMemberType(entries[i].getElementId().getType()));
        pbr->add_roles_sid(_convertString(entries[i].role));
    }

    // From http://wiki.openstreetmap.org/wiki/PBF_Format#Ways_and_Relations
    // Tags are encoded as two parallel arrays, one array of string-id's of the keys, and the other
    // of string-id's of the values.
    const Tags& tags = r->getTags();
    for (Tags::const_iterator it = tags.constBegin(); it != tags.constEnd(); ++it)
    {
        const QString& key = it.key();
        const QString& value = it.value();
        if (!value.isEmpty())
        {
            pbr->add_keys(_convertString(key));
            pbr->add_vals(_convertString(value));
        }
    }
    int kid = _convertString("error:circular");
    int vid = _convertString(QString::number(r->getCircularError()));
    pbr->add_keys(kid);
    pbr->add_vals(vid);

    if (r->getStatus() != Status::Invalid)
    {
        kid = _convertString("hoot:status");
        vid = _convertString(QString::number(r->getStatus().getEnum()));
        pbr->add_keys(kid);
        pbr->add_vals(vid);
    }

    _dirty = true;
}
开发者ID:giserh,项目名称:hootenanny,代码行数:59,代码来源:PbfWriter.cpp

示例6: _writePartial

void OgrWriter::_writePartial(ElementProviderPtr& provider, const ConstElementPtr& e)
{
  if (_translator.get() == 0)
  {
    throw HootException("You must call open before attempting to write.");
  }

  if (e->getTags().getInformationCount() > 0)
  {
    // There is probably a cleaner way of doing this.
    // convertToGeometry calls  getGeometryType which will throw an exception if it gets a relation
    // that it doesn't know about. E.g. "route", "superroute", " turnlanes:turns" etc

    shared_ptr<Geometry> g;

    try
    {
      g = ElementConverter(provider).convertToGeometry(e);
    }
    catch (IllegalArgumentException& err)
    {
      LOG_WARN("Error converting geometry: " << err.getWhat() << " (" << e->toString() << ")");
      g.reset((GeometryFactory::getDefaultInstance()->createEmptyGeometry()));
    }

    /*
    LOG_DEBUG("After conversion to geometry, element is now a " <<
             g->getGeometryType() );
    */

    Tags t = e->getTags();
    t["error:circular"] = QString::number(e->getCircularError());
    t["hoot:status"] = e->getStatusString();
    for (Tags::const_iterator it = e->getTags().begin(); it != e->getTags().end(); ++it)
    {
      if (t[it.key()] == "")
      {
        t.remove(it.key());
      }
    }

    vector<ScriptToOgrTranslator::TranslatedFeature> tf = _translator->translateToOgr(t,
      e->getElementType(), g->getGeometryTypeId());

    // only write the feature if it wasn't filtered by the translation script.
    for (size_t i = 0; i < tf.size(); i++)
    {
      OGRLayer* layer = _getLayer(tf[i].tableName);
      if (layer != 0)
      {
        _addFeature(layer, tf[i].feature, g);
      }
    }
  }
}
开发者ID:giserh,项目名称:hootenanny,代码行数:55,代码来源:OgrWriter.cpp

示例7: visit

  virtual void visit(const shared_ptr<const Element>& e)
  {
    if (e->getElementType() == _type || _type == ElementType::Unknown)
    {
      const Tags& tags = e->getTags();

      for (Tags::const_iterator it = tags.begin(); it != tags.end(); ++it)
      {
        _keys[it.key()]++;
      }
    }
  }
开发者ID:Nanonid,项目名称:hootenanny,代码行数:12,代码来源:ShapefileWriter.cpp

示例8: _writeNode

void PbfWriter::_writeNode(const shared_ptr<const hoot::Node>& n)
{
    _elementsWritten++;
    if (_pg == 0)
    {
        _pg = _d->primitiveBlock.add_primitivegroup();
    }

    ::google::protobuf::RepeatedPtrField< ::hoot::pb::Node >* nodes =
        _pg->mutable_nodes();

    _dirty = true;

    pb::Node* newNode = nodes->Add();

    newNode->set_id(n->getId() + _nodeIdDelta);
    newNode->set_lon(_convertLon(n->getX()));
    newNode->set_lat(_convertLat(n->getY()));

    const Tags& tags = n->getTags();
    for (Tags::const_iterator it = tags.constBegin(); it != tags.constEnd(); ++it)
    {
        const QString& key = it.key();
        const QString& value = it.value();
        int kid = _convertString(key);
        int vid = _convertString(value);
        if (!value.isEmpty())
        {
            newNode->add_keys(kid);
            newNode->add_vals(vid);
        }
    }

    // if there are tags on the node then record the CE. CE isn't used as part of a way
    // at this point. Instead the way records the CE for the entire way. No need to waste disk.
    if (n->getTags().getNonDebugCount() > 0)
    {
        int kid = _convertString("error:circular");
        int vid = _convertString(QString::number(n->getCircularError()));
        newNode->add_keys(kid);
        newNode->add_vals(vid);

        if (n->getStatus() != Status::Invalid)
        {
            kid = _convertString("hoot:status");
            vid = _convertString(QString::number(n->getStatus().getEnum()));
            newNode->add_keys(kid);
            newNode->add_vals(vid);
        }
    }

}
开发者ID:giserh,项目名称:hootenanny,代码行数:52,代码来源:PbfWriter.cpp

示例9: visit

void KeepTagsVisitor::visit(const shared_ptr<Element>& e)
{
  //get a copy of the tags for modifying
  Tags tags;
  tags.addTags(e->getTags());
  for (Tags::const_iterator it = e->getTags().begin(); it != e->getTags().end(); ++it)
  {
    if (!_keys.contains(it.key()))
    {
      tags.remove(it.key());
    }
  }
  e->setTags(tags);
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:14,代码来源:KeepTagsVisitor.cpp

示例10: writeElement

void OgrWriter::writeElement(ElementInputStream& inputStream, bool debug)
{
  // Make sure incoming element is in WGS84
  assert( inputStream.getProjection()->IsSame(&_wgs84) == true );
  ElementPtr nextElement = inputStream.readNextElement();

  // TERRY TESTING COULD BE CATASTROPHIC
  Tags sourceTags = nextElement->getTags();
  Tags destTags;
  for (Tags::const_iterator it = nextElement->getTags().begin();
       it != nextElement->getTags().end(); ++it)
  {
    if (sourceTags[it.key()] != "")
    {
      destTags.appendValue(it.key(), it.value());
    }
  }
  // Now that all the empties are gone, update our element
  nextElement->setTags(destTags);

  if ( debug == true )
  {
    LOG_DEBUG(nextElement->toString());
  }

  PartialOsmMapWriter::writePartial(nextElement);
  /*
  if ( nextElement->getElementType().getEnum() == ElementType::Node )
  {
    //LOG_DEBUG("\n" << nextElement->toString());

    const long nodeID = nextElement->getId();
    if ( (nodeID >= -265198) && (nodeID <= -265167) )
    {
      LOG_DEBUG("\n" << nextElement->toString());
      PartialOsmMapWriter::writePartial(nextElement);
    }
  }
  else if ((nextElement->getElementType().getEnum() == ElementType::Way) &&
           (nextElement->getId() == -23189) )
  {
    LOG_DEBUG("Writing Little Mill Creek -23189");
    LOG_DEBUG("\n" << nextElement->toString());
    PartialOsmMapWriter::writePartial(nextElement);
  }
  */
}
开发者ID:giserh,项目名称:hootenanny,代码行数:47,代码来源:OgrWriter.cpp

示例11: _escapeTags

QString ServicesDb::_escapeTags(const Tags& tags) const
{
  QStringList l;
  static QChar f1('\\'), f2('"'), f3('\'');
  static QChar to('_');

  for (Tags::const_iterator it = tags.begin(); it != tags.end(); ++it)
  {
    // this doesn't appear to be working, but I think it is implementing the spec as described here:
    // http://www.postgresql.org/docs/9.0/static/hstore.html
    // The spec described above does seem to work on the psql command line. Curious.
    QString k = QString(it.key()).replace(f1, "\\\\").replace(f2, "\\\"");
    QString v = QString(it.value()).replace(f1, "\\\\").replace(f2, "\\\"");

    l << QString("\"%1\"=>\"%2\"").arg(k).arg(v);
  }
  return l.join(",");
}
开发者ID:msorenson,项目名称:hootenanny,代码行数:18,代码来源:ServicesDb.cpp

示例12: compareTags

  void compareTags(const Tags& t1, const Tags& t2)
  {
    if (t1.size() != t2.size())
    {
      LOG_WARN("t1: " << t1.toString());
      LOG_WARN("t2: " << t2.toString());
      CPPUNIT_ASSERT_EQUAL(t1.size(), t2.size());
    }

    for (Tags::const_iterator it = t1.begin(); it != t1.end(); it++)
    {
      if (t1[it.key()] != t2[it.key()])
      {
        LOG_WARN("t1: " << t1.toString());
        LOG_WARN("t2: " << t2.toString());
        CPPUNIT_ASSERT_EQUAL(t1[it.key()].toStdString(), t2[it.key()].toStdString());
      }
    }
  }
开发者ID:drew-bower,项目名称:hootenanny,代码行数:19,代码来源:TagComparatorTest.cpp

示例13: visit

void SplitNameVisitor::visit(const shared_ptr<Element>& e)
{
    Tags& t = e->getTags();

    QStringList extraNames;

    Tags copy = t;
    for (Tags::const_iterator it = copy.begin(); it != copy.end(); ++it)
    {
        const QString& k = it.key();
        const QString& v = it.value();
        if (v.size() > _maxSize &&
                OsmSchema::getInstance().getCategories(it.key()).intersects(OsmSchemaCategory::name()))
        {
            QStringList l = _splitNames(v, extraNames);
            t.setList(k, l);
        }
    }

    _addExtraNames(t, extraNames);
}
开发者ID:mitulvpatel,项目名称:hootenanny,代码行数:21,代码来源:SplitNameVisitor.cpp

示例14: _calculateTypeMatch

bool PoiPolygonMatch::_calculateTypeMatch(ConstElementPtr e1, ConstElementPtr e2) const
{
  bool result = false;

  const Tags& t1 = e1->getTags();
  const Tags& t2 = e2->getTags();
  for (Tags::const_iterator it = t1.begin(); it != t1.end(); it++)
  {
    // if it is a use or POI category
    if ((OsmSchema::getInstance().getCategories(it.key(), it.value()) &
         (OsmSchemaCategory::building() | OsmSchemaCategory::use() | OsmSchemaCategory::poi()))
          != OsmSchemaCategory::Empty)
    {
      result = t2.get(it.key()) == it.value();
      if (result)
      {
        return result;
      }
    }
  }

  return result;
}
开发者ID:BSteine,项目名称:hootenanny,代码行数:23,代码来源:PoiPolygonMatch.cpp

示例15: isSatisfied

bool RoundaboutCriterion::isSatisfied(const ConstElementPtr& e) const
{
  // If it's not a highway, it's not a roundabout
  if (!HighwayCriterion().isSatisfied(e))
  {
    return false;
  }

  // Now check some details...
  bool result = false;
  Tags::const_iterator tagIt = e->getTags().find("junction");

  if (tagIt != e->getTags().end() && tagIt.value().toLower() == "roundabout")
  {
    result = true;
  }

  if (result)
  {
    LOG_TRACE("isRoundabout; key: " << tagIt.key());
  }

  return result;
}
开发者ID:ngageoint,项目名称:hootenanny,代码行数:24,代码来源:RoundaboutCriterion.cpp


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