本文整理汇总了C++中tags::const_iterator::key方法的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator::key方法的具体用法?C++ const_iterator::key怎么用?C++ const_iterator::key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tags::const_iterator
的用法示例。
在下文中一共展示了const_iterator::key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
示例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);
}
}
示例3: _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);
}
}
}
}
示例4: 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);
}
示例5: 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;
}
示例6: 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);
}
}
}
}
示例7: 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);
}
*/
}
示例8: _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;
}
示例9: 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());
}
}
}
示例10: 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);
}
示例11: 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()]++;
}
}
}
示例12: _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);
}
}
}
示例13: _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;
}
示例14: 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;
}
}
示例15: _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(",");
}