本文整理汇总了C++中OsmMapPtr::addRelation方法的典型用法代码示例。如果您正苦于以下问题:C++ OsmMapPtr::addRelation方法的具体用法?C++ OsmMapPtr::addRelation怎么用?C++ OsmMapPtr::addRelation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsmMapPtr
的用法示例。
在下文中一共展示了OsmMapPtr::addRelation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
shared_ptr<Relation> BuildingPartMergeOp::combineParts(const OsmMapPtr& map,
const vector< shared_ptr<Element> >& parts)
{
assert(parts.size() > 0);
shared_ptr<Relation> building(new Relation(parts[0]->getStatus(),
map->createNextRelationId(), -1, "building"));
OsmSchema& schema = OsmSchema::getInstance();
Tags& t = building->getTags();
for (size_t i = 0; i < parts.size(); i++)
{
building->addElement("part", parts[i]);
Tags pt = parts[i]->getTags();
Tags tCopy = t;
Tags names;
TagComparator::getInstance().mergeNames(tCopy, pt, names);
t.set(names);
// go through all the tags.
for (Tags::const_iterator it = pt.begin(); it != pt.end(); it++)
{
// ignore all keys that are building:part specific.
if (_buildingPartTagNames.find(it.key()) == _buildingPartTagNames.end())
{
// if the tag isn't already in the relation
if (t.contains(it.key()) == false)
{
t[it.key()] = it.value();
}
// if this is an arbitrary text value, then concatenate the values.
else if (schema.isTextTag(it.key()))
{
t.appendValueIfUnique(it.key(), it.value());
}
// if the tag is in the relation and the tags differ.
else if (t[it.key()] != it.value())
{
t[it.key()] = "";
}
}
}
}
// go through all the keys that were consistent for each of the parts and move them into the
// relation.
Tags tCopy = t;
for (Tags::const_iterator it = tCopy.begin(); it != tCopy.end(); it++)
{
// if the value is empty, then the tag isn't needed, or it wasn't consistent between multiple
// parts.
if (it.value() == "")
{
t.remove(it.key());
}
// if the tag isn't empty, remove it from each of the parts.
else
{
for (size_t i = 0; i < parts.size(); i++)
{
parts[i]->getTags().remove(it.key());
}
}
}
if (t.contains("building") == false)
{
t["building"] = "yes";
}
// replace the building tag with building:part tags.
for (size_t i = 0; i < parts.size(); i++)
{
parts[i]->getTags().remove("building");
parts[i]->getTags()["building:part"] = "yes";
}
map->addRelation(building);
return building;
}