void checkForMatch(const shared_ptr<const Element>& e) { HandleScope handleScope; Context::Scope context_scope(_script->getContext()); auto_ptr<Envelope> env(e->getEnvelope(_map)); //if _searchRadius is unchanged, don't use it as an auto-calculated search radius value and //expand the search envelope based on the element's circular error and map worst circular error //instead if (_searchRadius == -1.0) { env->expandBy(_candidateDistanceSigma * _worstCircularError + getSearchRadius(e)); } else { env->expandBy(_candidateDistanceSigma * _searchRadius); } // find other nearby candidates set<ElementId> neighbors = _map->findElements(*env); ElementId from(e->getElementType(), e->getId()); _elementsEvaluated++; int neighborCount = 0; for (set<ElementId>::const_iterator it = neighbors.begin(); it != neighbors.end(); ++it) { ConstElementPtr e2 = _map->getElement(*it); if ((e->getStatus() != e2->getStatus() || from < *it) && isMatchCandidate(e2)) { // score each candidate and push it on the result vector ScriptMatch* m = new ScriptMatch(_script, getPlugin(), _map, from, *it, _mt); // if we're confident this is a miss if (m->getType() == MatchType::Miss) { delete m; } else { _result.push_back(m); neighborCount++; } } } _neighborCountSum += neighborCount; _neighborCountMax = std::max(_neighborCountMax, neighborCount); }
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()); }