本文整理汇总了C++中ConstElementPtr::getElementId方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstElementPtr::getElementId方法的具体用法?C++ ConstElementPtr::getElementId怎么用?C++ ConstElementPtr::getElementId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstElementPtr
的用法示例。
在下文中一共展示了ConstElementPtr::getElementId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visit
virtual void visit(const ConstElementPtr& e)
{
const Tags& t = e->getTags();
const QString REV = MetadataTags::TrainingReview();
const QString MAT = MetadataTags::TrainingMatch();
if (t.contains(MetadataTags::TrainingId()) ||
t.contains(MAT) ||
t.contains(REV))
{
if (t.contains(MetadataTags::TrainingId()) == false ||
t.contains(MAT) == false)
{
LOG_WARN(QString("Element %1 doesn't contain %2 and %3.")
.arg(e->getElementId().toString())
.arg(MetadataTags::TrainingId())
.arg(MAT));
}
if (t[MAT] == "todo")
{
LOG_WARN("Element " << e->getElementId().toString() << " (" <<
t[MetadataTags::TrainingId()] << ") is still marked as todo: ");
}
if (!(t[MAT] == "none" || t[MAT] == "") &&
!(t[REV] == "none" || t[REV] == ""))
{
LOG_WARN("Element " << e->getElementId().toString() << " (" <<
t[MetadataTags::TrainingId()] << ") has both match and review populated.");
LOG_WARN(" '" << t[MAT] << "' and '" <<
t[REV] << "'");
}
}
}
示例2: isCorrectOrder
/**
* Returns true if e1, e2 is in the correct ordering for matching. This does a few things:
*
* - Avoid comparing e1 to e2 and e2 to e1
* - The Unknown1/Input1 is always e1. This is a requirement for some of the older code.
* - Gives a consistent ordering to allow backwards compatibility with system tests.
*/
bool isCorrectOrder(const ConstElementPtr& e1, const ConstElementPtr& e2)
{
if (e1->getStatus().getEnum() == e2->getStatus().getEnum())
{
return e1->getElementId() < e2->getElementId();
}
else
{
return e1->getStatus().getEnum() < e2->getStatus().getEnum();
}
}
示例3:
Handle<Value> ElementJs::getElementId(const Arguments& args) {
HandleScope scope;
ConstElementPtr e = ObjectWrap::Unwrap<ElementJs>(args.This())->getConstElement();
return scope.Close(ElementIdJs::New(e->getElementId()));
}
示例4: getSearchRadius
// See the "Calculating Search Radius" section in the user docs for more information.
Meters getSearchRadius(const ConstElementPtr& e)
{
Meters result;
if (_getSearchRadius.IsEmpty())
{
if (_customSearchRadius < 0)
{
//base the radius off of the element itself
result = e->getCircularError() * _candidateDistanceSigma;
}
else
{
//base the radius off some predefined radius
result = _customSearchRadius * _candidateDistanceSigma;
}
}
else
{
if (_searchRadiusCache.contains(e->getElementId()))
{
result = _searchRadiusCache[e->getElementId()];
}
else
{
Isolate* current = v8::Isolate::GetCurrent();
HandleScope handleScope(current);
Context::Scope context_scope(_script->getContext(current));
Handle<Value> jsArgs[1];
int argc = 0;
jsArgs[argc++] = ElementJs::New(e);
LOG_TRACE("Calling getSearchRadius...");
Handle<Value> f = ToLocal(&_getSearchRadius)->Call(getPlugin(), argc, jsArgs);
result = toCpp<Meters>(f) * _candidateDistanceSigma;
_searchRadiusCache[e->getElementId()] = result;
}
}
return result;
}
示例5: findMatch
WaySublineMatchString MaximalSublineStringMatcher::findMatch(const ConstOsmMapPtr& map,
const ConstElementPtr& e1, const ConstElementPtr& e2, Meters maxRelevantDistance) const
{
assert(_maxAngle >= 0);
if (maxRelevantDistance == -1)
{
maxRelevantDistance = e1->getCircularError() + e2->getCircularError();
}
// make sure the inputs are legit. If either element isn't legit then throw a NeedsReviewException
_validateElement(map, e1->getElementId());
_validateElement(map, e2->getElementId());
// extract the ways from the elements. In most cases it will return a vector of 1, but
// multilinestrings may contain multiple ways
vector<ConstWayPtr> ways1 = ExtractWaysVisitor::extractWays(map, e1);
vector<ConstWayPtr> ways2 = ExtractWaysVisitor::extractWays(map, e2);
if ((ways1.size() > 4 && ways2.size() > 4) || (ways1.size() + ways2.size() > 7))
{
throw NeedsReviewException("Elements contain too many ways and the computational complexity "
"is unreasonable.");
}
// Try with all combinations of forward and reversed ways. This is very expensive for
// multilinestrings with lots of ways in them. Though those shouldn't be common.
vector<bool> reversed1(ways1.size(), false), reversed2(ways2.size(), false);
ScoredMatch scoredResult = _findBestMatch(map, maxRelevantDistance, ways1, ways2, reversed1,
reversed2);
// convert the best match into a WaySublineStringMatch and return.
try
{
WaySublineMatchString result = scoredResult.matches;
// this likely shouldn't be necessary. See #4593
result.removeEmptyMatches();
return result;
}
catch(OverlappingMatchesException &e)
{
throw NeedsReviewException("Internal Error: Multiple overlapping way matches were found within "
"one set of ways. Please report this to [email protected]");
}
}
示例6: v
vector<ConstWayPtr> ExtractWaysVisitor::extractWays(const ConstOsmMapPtr& map,
const ConstElementPtr& e)
{
LOG_TRACE("Extracting ways from " << e->getElementId());
vector<ConstWayPtr> result;
ExtractWaysVisitor v(result);
v.setOsmMap(map.get());
e->visitRo(*map, v);
return result;
}
示例7: isMatchCandidate
bool isMatchCandidate(ConstElementPtr e)
{
if (_matchCandidateCache.contains(e->getElementId()))
{
return _matchCandidateCache[e->getElementId()];
}
if (_filter && !_filter->isSatisfied(e))
{
return false;
}
Isolate* current = v8::Isolate::GetCurrent();
HandleScope handleScope(current);
Context::Scope context_scope(_script->getContext(current));
Persistent<Object> plugin(current, getPlugin(_script));
Handle<String> isMatchCandidateStr = String::NewFromUtf8(current, "isMatchCandidate");
if (ToLocal(&plugin)->Has(isMatchCandidateStr) == false)
{
throw HootException("Error finding 'isMatchCandidate' function.");
}
Handle<Value> value = ToLocal(&plugin)->Get(isMatchCandidateStr);
if (value->IsFunction() == false)
{
throw HootException("isMatchCandidate is not a function.");
}
Handle<Function> func = Handle<Function>::Cast(value);
Handle<Value> jsArgs[2];
int argc = 0;
jsArgs[argc++] = getOsmMapJs();
jsArgs[argc++] = ElementJs::New(e);
Handle<Value> f = func->Call(ToLocal(&plugin), argc, jsArgs);
bool result = f->BooleanValue();
_matchCandidateCache[e->getElementId()] = result;
return result;
}
示例8: getScore
MatchClassification MultiaryScoreCache::getScore(ConstElementPtr e1, ConstElementPtr e2)
{
_lastExplainText.clear();
OsmMapPtr tmp(new OsmMap(_map->getProjection()));
tmp->addElement(ElementPtr(e1->clone()));
tmp->addElement(ElementPtr(e2->clone()));
boost::scoped_ptr<Match> m(
_matchCreator->createMatch(tmp, e1->getElementId(), e2->getElementId()));
// default to a hard miss.
MatchClassification result(0, 1, 0);
// if the MatchCreator returns a valid match class, use that as the score.
if (m)
{
result = m->getClassification();
_lastExplainText = m->explain();
}
return result;
}
示例9: visit
void TranslationVisitor::visit(const ConstElementPtr& ce)
{
// this is a hack to get around the visitor interface. The visitor interface should probably be
// redesigned into ConstElementVisitor and ElementVisitor.
ElementPtr e = _map->getElement(ce->getElementId());
Tags& tags = e->getTags();
if (tags.getNonDebugCount() > 0)
{
if (_toOgr)
{
GeometryTypeId gtype = ElementConverter::getGeometryType(e, false);
vector<Tags> allTags = _togr->translateToOgrTags(tags, e->getElementType(), gtype);
if (allTags.size() > 0)
{
if (allTags.size() > 1)
{
LOG_WARN("More than one feature was returned, only keeping the first feature.");
}
e->setTags(allTags[0]);
}
}
else
{
QByteArray layerName;
if (tags.contains(OsmSchema::layerNameKey()))
{
layerName = tags[OsmSchema::layerNameKey()].toUtf8();
}
_t.translateToOsm(tags, layerName.data());
if (tags.contains(_circularErrorKey))
{
e->setCircularError(tags.getDouble(_circularErrorKey));
tags.remove(_circularErrorKey);
tags.remove(_accuracyKey);
}
else if (tags.contains(_accuracyKey))
{
e->setCircularError(tags.getDouble(_accuracyKey));
tags.remove(_circularErrorKey);
tags.remove(_accuracyKey);
}
}
}
}
示例10: visit
virtual void visit(const ConstElementPtr& e)
{
QStringList refs;
if (e->getTags().contains(_ref))
{
e->getTags().readValues(_ref, refs);
}
refs.removeAll("todo");
refs.removeAll("none");
if (refs.size() > 0)
{
for (int i = 0; i < refs.size(); i++)
{
_ref2Eid[refs[i]].insert(e->getElementId());
}
}
}
示例11: _createTags
void OsmApiDbSqlChangesetFileWriter::_createTags(ConstElementPtr element)
{
LOG_TRACE("Creating tags for: " << element->getElementId());
QStringList tableNames = _tagTableNamesForElement(element->getElementId());
Tags tags = element->getTags();
if (_includeDebugTags)
{
tags.set(MetadataTags::HootStatus(), QString::number(element->getStatus().getEnum()));
}
LOG_VART(tags);
if (element->getElementType().getEnum() == ElementType::Relation && !tags.contains("type"))
{
ConstRelationPtr tmp = boost::dynamic_pointer_cast<const Relation>(element);
tags.appendValue("type", tmp->getType());
}
for (Tags::const_iterator it = tags.begin(); it != tags.end(); ++it)
{
QString k = it.key();
QString v = it.value();
if (k != MetadataTags::HootHash())
{
const QString currentTagValues =
QString("(%1_id, k, v) VALUES (%2, '%3', '%4');\n")
.arg(element->getElementId().getType().toString().toLower())
.arg(element->getElementId().getId())
.arg(k.replace('\'', "''"))
.arg(v.replace('\'', "''"));
const QString tagValues =
QString("(%1_id, k, v, version) VALUES (%2, '%3', '%4', %5);\n")
.arg(element->getElementId().getType().toString().toLower())
.arg(element->getElementId().getId())
.arg(k.replace('\'', "''"))
.arg(v.replace('\'', "''"))
.arg(element->getVersion());
_outputSql.write(
(QString("INSERT INTO %1 ").arg(tableNames.at(0)) + currentTagValues).toUtf8());
_outputSql.write((QString("INSERT INTO %1 ").arg(tableNames.at(1)) + tagValues).toUtf8());
}
}
}