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; }