本文整理汇总了C++中ConstOsmMapPtr::getElement方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstOsmMapPtr::getElement方法的具体用法?C++ ConstOsmMapPtr::getElement怎么用?C++ ConstOsmMapPtr::getElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstOsmMapPtr
的用法示例。
在下文中一共展示了ConstOsmMapPtr::getElement方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Match
BuildingMatch::BuildingMatch(const ConstOsmMapPtr& map, shared_ptr<const BuildingRfClassifier> rf,
const ElementId& eid1, const ElementId& eid2, ConstMatchThresholdPtr mt) :
Match(mt),
_eid1(eid1),
_eid2(eid2),
_rf(rf),
_explainText("")
{
//LOG_DEBUG("Classifying building pair: " << eid1 << "; " << eid2);
_p = _rf->classify(map, _eid1, _eid2);
//If the buildings aren't matched and they overlap at all, then make them be reviewed.
if (getType() == MatchType::Miss &&
(OverlapExtractor().extract(*map, map->getElement(eid1), map->getElement(eid2)) > 0.0))
{
//LOG_DEBUG("Building miss overlap:");
//LOG_VARD(eid1);
//LOG_VARD(eid2);
_p.clear();
_p.setReviewP(1.0);
_explainText = "Unmatched buildings are overlapping.";
}
else
{
_explainText = mt->getTypeDetail(_p);
}
//LOG_DEBUG(toString());
}
示例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: handleScope
Handle<Value> ScriptMatch::_callGetMatchFeatureDetails(const ConstOsmMapPtr& map) const
{
Isolate* current = v8::Isolate::GetCurrent();
EscapableHandleScope handleScope(current);
Context::Scope context_scope(_script->getContext(current));
Handle<Object> plugin =
Handle<Object>::Cast(
_script->getContext(current)->Global()->Get(String::NewFromUtf8(current, "plugin")));
Handle<Value> value = plugin->Get(String::NewFromUtf8(current, "getMatchFeatureDetails"));
Handle<Function> func = Handle<Function>::Cast(value);
Handle<Value> jsArgs[3];
if (func.IsEmpty() || func->IsFunction() == false)
{
throw IllegalArgumentException("getMatchFeatureDetails must be a valid function.");
}
Handle<Object> mapObj = OsmMapJs::create(map);
int argc = 0;
jsArgs[argc++] = mapObj;
jsArgs[argc++] = ElementJs::New(map->getElement(_eid1));
jsArgs[argc++] = ElementJs::New(map->getElement(_eid2));
TryCatch trycatch;
Handle<Value> result = func->Call(plugin, argc, jsArgs);
HootExceptionJs::checkV8Exception(result, trycatch);
return handleScope.Escape(result);
}
示例4: context_scope
Handle<Value> ScriptMatch::_call(const ConstOsmMapPtr& map, Handle<Object> plugin)
{
HandleScope handleScope;
Context::Scope context_scope(_script->getContext());
plugin =
Handle<Object>::Cast(_script->getContext()->Global()->Get(String::New("plugin")));
Handle<v8::Value> value = plugin->Get(String::New("matchScore"));
Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(value);
Handle<Value> jsArgs[3];
if (func.IsEmpty() || func->IsFunction() == false)
{
throw IllegalArgumentException("matchScore must be a valid function.");
}
Handle<Object> mapObj = OsmMapJs::create(map);
int argc = 0;
jsArgs[argc++] = mapObj;
jsArgs[argc++] = ElementJs::New(map->getElement(_eid1));
jsArgs[argc++] = ElementJs::New(map->getElement(_eid2));
TryCatch trycatch;
Handle<Value> result = func->Call(plugin, argc, jsArgs);
HootExceptionJs::checkV8Exception(result, trycatch);
return handleScope.Close(result);
}
示例5: _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.");
}
}
}
}
示例6: replace
map<QString, double> RfExtractorClassifier::getFeatures(const ConstOsmMapPtr& m,
ElementId eid1, ElementId eid2) const
{
map<QString, double> result;
const boost::shared_ptr<const Element>& e1 = m->getElement(eid1);
const boost::shared_ptr<const Element> e2 = m->getElement(eid2);
_getExtractors();
for (size_t i = 0; i < _extractors.size(); i++)
{
double v = _extractors[i]->extract(*m, e1, e2);
// if it isn't null then include it.
if (!FeatureExtractor::isNull(v))
{
QString factorName = QString::fromStdString(_extractors[i]->getName()).
replace(QRegExp("[^\\w]"), "_");
result[factorName] = v;
}
}
return result;
}
示例7: checkForMatch
void checkForMatch(const boost::shared_ptr<const Element>& e)
{
Isolate* current = v8::Isolate::GetCurrent();
HandleScope handleScope(current);
Context::Scope context_scope(_script->getContext(current));
Persistent<Object> plugin(current, getPlugin(_script));
Local<Object> mapJs(ToLocal(&_mapJs));
ConstOsmMapPtr map = getMap();
// create an envlope around the e plus the search radius.
boost::shared_ptr<Envelope> env(e->getEnvelope(map));
Meters searchRadius = getSearchRadius(e);
env->expandBy(searchRadius);
// find other nearby candidates
set<ElementId> neighbors =
IndexElementsVisitor::findNeighbors(*env, getIndex(), _indexToEid, getMap());
ElementId from = e->getElementId();
_elementsEvaluated++;
for (set<ElementId>::const_iterator it = neighbors.begin(); it != neighbors.end(); ++it)
{
ConstElementPtr e2 = map->getElement(*it);
if (isCorrectOrder(e, e2) && isMatchCandidate(e2))
{
// score each candidate and push it on the result vector
ScriptMatch* m = new ScriptMatch(_script, plugin, map, mapJs, from, *it, _mt);
// if we're confident this is a miss
if (m->getType() == MatchType::Miss)
{
delete m;
}
else
{
_result.push_back(m);
}
}
}
_neighborCountSum += neighbors.size();
_neighborCountMax = std::max(_neighborCountMax, (int)neighbors.size());
}
示例8: _calculateHilbertValue
int64_t AddHilbertReviewSortOrderOp::_calculateHilbertValue(const ConstOsmMapPtr &map,
const set<ElementId> eids)
{
auto_ptr<Envelope> env;
for (set<ElementId>::const_iterator it = eids.begin(); it != eids.end(); ++it)
{
Envelope::AutoPtr te(map->getElement(*it)->getEnvelope(map));
if (env.get() == 0)
{
env.reset(new Envelope(*te));
}
else
{
env->expandToInclude(te.get());
}
}
if (_mapEnvelope.get() == 0)
{
_mapEnvelope.reset(new Envelope(map->calculateEnvelope()));
}
Coordinate center;
env->centre(center);
Meters cellSize = 10.0;
int xorder = max(1.0, ceil(log(_mapEnvelope->getWidth() / cellSize) / log(2.0)));
int yorder = max(1.0, ceil(log(_mapEnvelope->getHeight() / cellSize) / log(2.0)));
// 31 bits is the most supported for 2 dimensions.
int order = min(31, max(xorder, yorder));
// always 2 dimensions.
Tgs::HilbertCurve c(2, order);
int64_t maxRange = 1 << order;
int point[2];
point[0] = max<int64_t>(0, min<int64_t>(maxRange - 1,
round((center.x - _mapEnvelope->getMinX()) / cellSize)));
point[1] = max<int64_t>(0, min<int64_t>(maxRange - 1,
round((center.y - _mapEnvelope->getMinY()) / cellSize)));
// pad with zeros to make sorting a little easier.
return c.encode(point);
}
示例9: if
PoiPolygonMatch::PoiPolygonMatch(const ConstOsmMapPtr& map, const ElementId& eid1,
const ElementId& eid2, ConstMatchThresholdPtr threshold) :
Match(threshold)
{
ConstElementPtr e1 = map->getElement(eid1);
ConstElementPtr e2 = map->getElement(eid2);
ConstElementPtr poi, poly;
if (isPoiIsh(e1) && isBuildingIsh(e2))
{
_poiEid = eid1;
_polyEid = eid2;
poi = e1;
poly = e2;
}
else if (isPoiIsh(e2) && isBuildingIsh(e1))
{
_poiEid = eid2;
_polyEid = eid1;
poi = e2;
poly = e1;
}
else
{
LOG_WARN(e1->toString());
LOG_WARN(e2->toString());
throw IllegalArgumentException("Expected a POI & polygon, got: " + eid1.toString() + " " +
eid2.toString());
}
shared_ptr<Geometry> gpoly = ElementConverter(map).convertToGeometry(poly);
shared_ptr<Geometry> gpoi = ElementConverter(map).convertToGeometry(poi);
bool typeMatch = _calculateTypeMatch(poi, poly);
double nameScore = _calculateNameScore(poi, poly);
bool nameMatch = nameScore >= ConfigOptions().getPoiPolygonMatchNameThreshold();
double distance = gpoly->distance(gpoi.get());
// calculate the 2 sigma for the distance between the two objects
double sigma1 = e1->getCircularError() / 2.0;
double sigma2 = e1->getCircularError() / 2.0;
double ce = sqrt(sigma1 * sigma1 + sigma2 * sigma2) * 2;
double reviewDistance = ConfigOptions().getPoiPolygonMatchReviewDistance() + ce;
bool closeMatch = distance <= reviewDistance;
int evidence = 0;
evidence += typeMatch ? 1 : 0;
evidence += nameMatch ? 1 : 0;
evidence += distance == 0 ? 2 : 0;
if (!closeMatch)
{
_c.setMiss();
}
else if (evidence >= 3)
{
_c.setMatch();
}
else if (evidence >= 1)
{
_c.setReview();
}
else
{
_c.setMiss();
}
}
示例10: _isOrderedConflicting
bool ScriptMatch::_isOrderedConflicting(const ConstOsmMapPtr& map, ElementId sharedEid,
ElementId other1, ElementId other2) const
{
Isolate* current = v8::Isolate::GetCurrent();
HandleScope handleScope(current);
Context::Scope context_scope(_script->getContext(current));
set<ElementId> eids;
eids.insert(sharedEid);
eids.insert(other1);
eids.insert(other2);
OsmMapPtr copiedMap(new OsmMap(map->getProjection()));
CopyMapSubsetOp(map, eids).apply(copiedMap);
Handle<Object> copiedMapJs = OsmMapJs::create(copiedMap);
// make sure unknown1 is always first
ElementId eid11, eid12, eid21, eid22;
if (map->getElement(sharedEid)->getStatus() == Status::Unknown1)
{
eid11 = sharedEid;
eid21 = sharedEid;
eid12 = other1;
eid22 = other2;
}
else
{
eid11 = other1;
eid21 = other2;
eid12 = sharedEid;
eid22 = sharedEid;
}
boost::shared_ptr<ScriptMatch> m1(
new ScriptMatch(_script, _plugin, copiedMap, copiedMapJs, eid11, eid12, _threshold));
MatchSet ms;
ms.insert(m1.get());
vector<Merger*> mergers;
ScriptMergerCreator creator;
creator.createMergers(ms, mergers);
m1.reset();
bool conflicting = true;
// if we got a merger, then check to see if it conflicts
if (mergers.size() == 1)
{
// apply the merger to our map copy
vector< pair<ElementId, ElementId> > replaced;
mergers[0]->apply(copiedMap, replaced);
// replace the element id in the second merger.
for (size_t i = 0; i < replaced.size(); ++i)
{
if (replaced[i].first == eid21)
{
eid21 = replaced[i].second;
}
if (replaced[i].first == eid22)
{
eid22 = replaced[i].second;
}
}
// if we can still find the second match after the merge was applied then it isn't a conflict
if (copiedMap->containsElement(eid21) &&
copiedMap->containsElement(eid22))
{
ScriptMatch m2(_script, _plugin, copiedMap, copiedMapJs, eid21, eid22, _threshold);
if (m2.getType() == MatchType::Match)
{
conflicting = false;
}
}
}
return conflicting;
}