Exemplo n.º 1
0
bool WaySublineMatch::overlaps(const WaySublineMatch& ws) const
{
  return (ws.getSubline1().getWay() == getSubline1().getWay() &&
          ws.getSubline1().overlaps(getSubline1())) ||
         (ws.getSubline2().getWay() == getSubline2().getWay() &&
          ws.getSubline2().overlaps(getSubline2()));
}
bool WaySublineMatchString::contains(const WaySublineMatch &other) const
{
  bool result = false;

  for (size_t i = 0; i < _matches.size(); i++)
  {
    if (_matches[i].getSubline1().contains(other.getSubline1()) ||
        _matches[i].getSubline2().contains(other.getSubline2()))
    {
      result = true;
    }
  }

  return result;
}
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;
}
Exemplo n.º 4
0
bool lessThan(const WaySublineMatch& ws1, const WaySublineMatch& ws2)
{
    return ws1.getSubline1().getStart() < ws2.getSubline1().getStart();
}
Exemplo n.º 5
0
WaySublineMatch::WaySublineMatch(const WaySublineMatch& other, const ConstOsmMapPtr& newMap)
{
  _ws1 = WaySubline(other.getSubline1(), newMap);
  _ws2 = WaySubline(other.getSubline2(), newMap);
  _reversed = other.isReverseMatch();
}