Example #1
0
bool CustomPoiMatch::_isDistanceMatch(const ConstNodePtr &n1, const ConstNodePtr &n2) const
{
  double d = n1->toCoordinate().distance(n2->toCoordinate());

  double s1 = n1->getCircularError() / 2.0;
  double s2 = n2->getCircularError() / 2.0;
  // calculated the expected sigma for the distance value.
  double sigma = sqrt(s1 * s1 + s2 * s2);

  // if the distance is within 2 sigma of the expected distance, then call it a match.
  return d < sigma * 2.0;
}
Example #2
0
void PertyWaySplitVisitor::_updateNewNodeProperties(NodePtr newNode,
                                                   ConstNodePtr firstSplitBetweenNode,
                                                   ConstNodePtr lastSplitBetweenNode)
{
  //arbitrarily copy the status from one split between node to the new node
  newNode->setStatus(firstSplitBetweenNode->getStatus());
  //add a circular error to the new node that's a weighted average of the circular error on the
  //two split between nodes
  newNode->setCircularError(
    (firstSplitBetweenNode->getCircularError() + lastSplitBetweenNode->getCircularError()) / 2);
  LOG_TRACE(
    "Updated the properties of a node created as a result of a way split: " << newNode->toString());
}
  set<long> _findNeighbors(const ConstNodePtr& n)
  {
    set<long> result;

    set<QString> allNames = _getNamePermutations(n->getTags().getNames());

    double minSimilarity = conf().getDouble(PlacesPoiMatch::minimumEditSimilarityKey(),
                                            PlacesPoiMatch::minimumEditSimilarityDefault());

    for (set<QString>::const_iterator it = allNames.begin(); it != allNames.end(); ++it)
    {
      const QString& s = *it;
      // if the string we're comparing against is longer then D may be bigger than
      // (1 - minSimilarity) * string length. Account for that below.
      int D = (int)round((double)s.size() / minSimilarity) - s.size();
      set<long> r = _index->find(n->toCoordinate(), n->getCircularError(), s, D);
      result.insert(r.begin(), r.end());
    }

    return result;
  }