示例#1
0
MatchClassification MultiaryScoreCache::getScore(MultiaryClusterPtr c1, MultiaryClusterPtr c2)
{
  // make sure all the elements in c1 can possibly (regardless of how remotely) be merged with
  // any of the elements in c2.
  foreach (const ConstElementPtr& e1, *c1)
  {
    foreach (const ConstElementPtr& e2, *c2)
    {
      MatchClassification mc = getScore(e1, e2);
      if (mc.getMissP() == 1)
      {
        return mc;
      }
    }
  }

  return getScore(c1->mergedElement, c2->mergedElement);
}
MatchClassification RfExtractorClassifier::classify(const ConstOsmMapPtr& map,
  ElementId eid1, ElementId eid2) const
{
  MatchClassification result;

  std::map<QString, double> features = getFeatures(map, eid1, eid2);
  vector<double> row;
  row.reserve(features.size());
  for (std::map<QString, double>::const_iterator it = features.begin(); it != features.end(); it++)
  {
    row.push_back(it->second);
  }
  std::map<string, double> scores;
  _rf->classifyVector(row, scores);

  result.setMissP(scores["miss"]);
  result.setMatchP(scores["match"]);
  result.setReviewP(scores["review"]);

  return result;
}
示例#3
0
double NetworkDetails::getPartialEdgeMatchScore(ConstNetworkEdgePtr e1, ConstNetworkEdgePtr e2)
{
  assert(e1->getMembers().size() == 1);
  assert(e2->getMembers().size() == 1);

  ConstWayPtr w1 = dynamic_pointer_cast<const Way>(e1->getMembers()[0]);
  ConstWayPtr w2 = dynamic_pointer_cast<const Way>(e2->getMembers()[0]);

  //LOG_VAR(ElementConverter(_map).convertToGeometry(w1)->toString());
  //LOG_VAR(ElementConverter(_map).convertToGeometry(w2)->toString());

  // calculated the shared sublines
  WaySublineMatchString sublineMatch = _sublineMatcher->findMatch(_map, w1, w2,
    ConfigOptions().getSearchRadiusHighway());

  MatchClassification c;
  if (sublineMatch.isValid())
  {
    // calculate the match score
    c = _classifier->classify(_map, w1->getElementId(), w2->getElementId(), sublineMatch);
  }

  return c.getMatchP();
}
MatchClassification HighwayExpertClassifier::classify(const ConstOsmMapPtr& map,
  const WaySublineMatch& match)
{
  MatchClassification result;

  vector<long> wids;
  wids.push_back(match.getSubline1().getElementId().getId());
  wids.push_back(match.getSubline2().getElementId().getId());
  shared_ptr<OsmMap> theMap = map->copyWays(wids);

  if (match.isValid() == false)
  {
    result.setMissP(1.0);
    result.setMatchP(0.0);
    result.setReviewP(0.0);
    return result;
  }

  WayPtr sl1 = match.getSubline1().toWay(theMap);
  WayPtr sl2 = match.getSubline2().toWay(theMap);

  ElementConverter ec(theMap);
  Meters l1 = ec.convertToLineString(match.getSubline1().getWay())->getLength();
  Meters l2 = ec.convertToLineString(match.getSubline2().getWay())->getLength();

  // what portion of the original lines is the MNS
  double po1 = ec.convertToLineString(sl1)->getLength() / l1;
  double po2 = ec.convertToLineString(sl2)->getLength() / l2;

  // give it a score
  double ps = std::min(po1, po2) / 2.0 + 0.5;

  double p;

  // if either of the lines are zero in length.
  if (po1 == 0 || po2 == 0)
  {
    p = 0.0;
  }
  else
  {
    p = ps * ProbabilityOfMatch::getInstance().expertProbability(theMap, sl1, sl2);
  }

  result.setMatchP(p);
  result.setMissP(1.0 - p);

  return result;
}
MatchClassification HighwayExpertClassifier::classify(const ConstOsmMapPtr& map,
  ElementId /*eid1*/, ElementId /*eid2*/, const WaySublineMatchString &match)
{
  // calculate the average classification. Is there a better approach? Max, min, mean? Dunno.
  MatchClassification result;

  for (size_t i = 0; i < match.getMatches().size(); i++)
  {
    MatchClassification m = classify(map, match.getMatches()[i]);

    result.setMatchP(m.getMatchP() + result.getMatchP());
    result.setMissP(m.getMissP() + result.getMissP());
    result.setReviewP(m.getReviewP() + result.getReviewP());
  }

  result.normalize();

  return result;
}