本文整理汇总了C++中ConstElementPtr::getElementType方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstElementPtr::getElementType方法的具体用法?C++ ConstElementPtr::getElementType怎么用?C++ ConstElementPtr::getElementType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstElementPtr
的用法示例。
在下文中一共展示了ConstElementPtr::getElementType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: _validateElement
void MaximalSublineStringMatcher::_validateElement(const ConstOsmMapPtr& map, ElementId eid) const
{
ConstElementPtr e = map->getElement(eid);
if (e->getElementType() == ElementType::Relation)
{
ConstRelationPtr r = dynamic_pointer_cast<const Relation>(e);
if (OsmSchema::getInstance().isMultiLineString(*r) == false)
{
throw NeedsReviewException("Internal Error: When matching sublines expected a multilinestring "
"relation not a " + r->getType() + ". A non-multilinestring should never be found here. "
"Please report this to [email protected]");
}
const vector<RelationData::Entry>& entries = r->getMembers();
for (size_t i = 0; i < entries.size(); i++)
{
if (entries[i].getElementId().getType() != ElementType::Way)
{
throw NeedsReviewException("MultiLineString relations can only contain ways when matching "
"sublines.");
}
}
}
if (e->getElementType() == ElementType::Way)
{
ConstWayPtr w = dynamic_pointer_cast<const Way>(e);
if (w->getNodeCount() <= 1)
{
throw NeedsReviewException("Internal Error: Attempting to match against a zero length way.");
}
}
}
示例3: _createNewElement
void OsmApiDbSqlChangesetFileWriter::_createNewElement(ConstElementPtr element)
{
const QString elementTypeStr = element->getElementType().toString().toLower();
ElementPtr changeElement = _getChangeElement(element);
//we only grab and assign a new id if we have a new element with a negative id, since we'll be
//writing this directly to the database and negative ids aren't allowed
LOG_TRACE("ID before: " << changeElement->getElementId());
long id;
if (changeElement->getId() < 0)
{
id = _db.getNextId(element->getElementType().getEnum());
}
else
{
id = changeElement->getId();
}
LOG_TRACE("ID after: " << ElementId(changeElement->getElementType(), id));
changeElement->setId(id);
changeElement->setVersion(1);
changeElement->setVisible(true);
changeElement->setChangeset(_changesetId);
LOG_TRACE("Creating: " << changeElement->getElementId());
QString note = "";
LOG_VART(changeElement->getId());
LOG_VART(note);
LOG_VART(changeElement->getVersion());
QString commentStr = "/* create " + elementTypeStr + " " + QString::number(changeElement->getId());
commentStr += "*/\n";
_outputSql.write((commentStr).toUtf8());
const QString values = _getInsertValuesStr(changeElement);
_outputSql.write(
("INSERT INTO " + elementTypeStr + "s (" + elementTypeStr + "_id, " + values).toUtf8());
_outputSql.write(("INSERT INTO current_" + elementTypeStr + "s (id, " + values).toUtf8());
_createTags(changeElement);
switch (changeElement->getElementType().getEnum())
{
case ElementType::Way:
_createWayNodes(boost::dynamic_pointer_cast<const Way>(changeElement));
break;
case ElementType::Relation:
_createRelationMembers(boost::dynamic_pointer_cast<const Relation>(changeElement));
break;
default:
//node
break;
}
}
示例4: isRelated
static bool isRelated(ConstElementPtr e1, ConstElementPtr e2)
{
if (e1->getStatus() != e2->getStatus() &&
e1->isUnknown() && e2->isUnknown() &&
OsmSchema::getInstance().isBuilding(e1->getTags(), e1->getElementType()) &&
OsmSchema::getInstance().isBuilding(e2->getTags(), e2->getElementType()))
{
return true;
}
else
{
return false;
}
}
示例5: visit
void TranslatedTagCountVisitor::visit(const ConstElementPtr& e)
{
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);
}
}
}
示例6: isPoiIsh
bool PoiPolygonMatch::isPoiIsh(ConstElementPtr e)
{
return e->getElementType() == ElementType::Node &&
(OsmSchema::getInstance().getCategories(e->getTags()).intersects(
OsmSchemaCategory::building() | OsmSchemaCategory::poi()) ||
e->getTags().getNames().size() > 0);
}
示例7: IllegalArgumentException
Handle<Object> ElementJs::New(ConstElementPtr e)
{
HandleScope scope;
Handle<Object> result;
switch (e->getElementType().getEnum())
{
case ElementType::Node:
{
ConstNodePtr n = dynamic_pointer_cast<const Node>(e);
result = NodeJs::New(n);
break;
}
case ElementType::Way:
{
ConstWayPtr w = dynamic_pointer_cast<const Way>(e);
result = WayJs::New(w);
break;
}
case ElementType::Relation:
{
ConstRelationPtr r = dynamic_pointer_cast<const Relation>(e);
result = RelationJs::New(r);
break;
}
default:
throw IllegalArgumentException("Unexpected element type.");
}
return scope.Close(result);
}
示例8: _validateElement
void MaximalSublineStringMatcher::_validateElement(const ConstOsmMapPtr& map, ElementId eid) const
{
ConstElementPtr e = map->getElement(eid);
if (e->getElementType() == ElementType::Relation)
{
ConstRelationPtr r = dynamic_pointer_cast<const Relation>(e);
if (OsmSchema::getInstance().isMultiLineString(*r) == false)
{
throw NeedsReviewException("When matching sublines expected a multilinestring relation not"
" a " + r->getType());
}
const vector<RelationData::Entry>& entries = r->getMembers();
for (size_t i = 0; i < entries.size(); i++)
{
if (entries[i].getElementId().getType() != ElementType::Way)
{
throw NeedsReviewException("MultiLineString relations can only contain ways when matching "
"sublines.");
}
}
}
}
示例9: visit
void PertyRemoveRandomElementVisitor::visit(const ConstElementPtr& e)
{
boost::uniform_real<> uni(0.0, 1.0);
if (uni(*_rng) <= _p)
{
RecursiveElementRemover(ElementId(e->getElementType(), e->getId())).apply(_map->shared_from_this());
}
}
示例10: visit
virtual void visit(const ConstElementPtr& e)
{
if (e->getElementType() == ElementType::Way)
{
WayDiscretizer wd(_map->shared_from_this(), dynamic_pointer_cast<const Way>(e));
wd.discretize(_spacing, _result);
}
}
示例11: isSatisfied
bool ContainsNodeCriterion::isSatisfied(const ConstElementPtr& e) const
{
if (e->getElementType() == ElementType::Way)
{
ConstWayPtr w = boost::dynamic_pointer_cast<const Way>(e);
return w->hasNode(_nodeId);
}
else if (e->getElementType() == ElementType::Relation)
{
ConstRelationPtr r = boost::dynamic_pointer_cast<const Relation>(e);
return r->contains(ElementId(ElementType::Node, _nodeId));
}
else if (e->getElementType() == ElementType::Node)
{
ConstNodePtr n = boost::dynamic_pointer_cast<const Node>(e);
return (n->getId() == _nodeId);
}
return false;
}
示例12: _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);
}
}
}
}
示例13: visit
void DecomposeBuildingRelationsVisitor::visit(const ConstElementPtr& e)
{
if (e->getElementType() == ElementType::Relation)
{
const shared_ptr<Relation>& r = _map->getRelation(e->getId());
if (r->getType() == "building")
{
_decomposeBuilding(r);
}
}
}
示例14: isSatisfied
bool HgisPoiCriterion::isSatisfied(const ConstElementPtr& e) const
{
bool result = false;
// See ticket #6853 for a definition of a "HGIS POI"
if (e->getElementType() == ElementType::Node)
{
result =
OsmSchema::getInstance().hasCategory(e->getTags(), OsmSchemaCategory::hgisPoi().toString());
}
return result;
}
示例15: _updateExistingElement
void OsmApiDbSqlChangesetFileWriter::_updateExistingElement(ConstElementPtr element)
{
const QString elementTypeStr = element->getElementType().toString().toLower();
ElementPtr changeElement = _getChangeElement(element);
//if another parsed change previously modified the element with this id, we want to get the
//modified version
const long currentVersion = changeElement->getVersion();
const long newVersion = currentVersion + 1;
changeElement->setVersion(newVersion);
changeElement->setChangeset(_changesetId);
changeElement->setVisible(true);
LOG_TRACE("Updating: " << changeElement->getElementId());
QString note = "";
LOG_VART(changeElement->getId());
LOG_VART(note);
LOG_VART(changeElement->getVersion());
QString commentStr = "/* modify " + elementTypeStr + " " + QString::number(changeElement->getId());
commentStr += "*/\n";
_outputSql.write((commentStr).toUtf8());
//<element-name> table contains all version of all elements of that type in a history, so insert
//into that table.
_outputSql.write(
("INSERT INTO " + elementTypeStr + "s (" + elementTypeStr + "_id, " +
_getInsertValuesStr(changeElement)).toUtf8());
//current_<element-name> contains the single latest version of the element, so update that record
_outputSql.write(
("UPDATE current_" + elementTypeStr + "s SET " + _getUpdateValuesStr(changeElement)).toUtf8());
_deleteCurrentTags(changeElement->getElementId());
_createTags(changeElement);
switch (changeElement->getElementType().getEnum())
{
case ElementType::Way:
_deleteAll(ApiDb::getCurrentWayNodesTableName(), "way_id", changeElement->getId());
_deleteAll(ApiDb::getWayNodesTableName(), "way_id", changeElement->getId());
_createWayNodes(boost::dynamic_pointer_cast<const Way>(changeElement));
break;
case ElementType::Relation:
_deleteAll(ApiDb::getCurrentRelationMembersTableName(), "relation_id", changeElement->getId());
_deleteAll(ApiDb::getRelationMembersTableName(), "relation_id", changeElement->getId());
_createRelationMembers(boost::dynamic_pointer_cast<const Relation>(changeElement));
break;
default:
//node
break;
}
}