当前位置: 首页>>代码示例>>C++>>正文


C++ ConstOsmMapPtr::copyWays方法代码示例

本文整理汇总了C++中ConstOsmMapPtr::copyWays方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstOsmMapPtr::copyWays方法的具体用法?C++ ConstOsmMapPtr::copyWays怎么用?C++ ConstOsmMapPtr::copyWays使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConstOsmMapPtr的用法示例。


在下文中一共展示了ConstOsmMapPtr::copyWays方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: findMatch

WaySublineMatchString MaximalNearestSublineMatcher::findMatch(const ConstOsmMapPtr &map,
  const ConstWayPtr& way1, const ConstWayPtr &way2, double &score, Meters maxRelevantDistance) const
{
  score = 0;
  Meters mrd = maxRelevantDistance == -1 ? way1->getCircularError() + way2->getCircularError() :
    maxRelevantDistance;

  vector<long> wayIds;
  wayIds.push_back(way1->getId());
  wayIds.push_back(way2->getId());
  OsmMapPtr mapCopy(map->copyWays(wayIds));

  WayPtr way1NonConst = mapCopy->getWay(way1->getId());
  WayPtr way2NonConst = mapCopy->getWay(way2->getId());

  MaximalNearestSubline mns1(
    mapCopy, way1NonConst, way2NonConst, _minSplitSize, mrd, _maxRelevantAngle, _headingDelta);

  // use the maximal nearest subline code to find the best subline
  std::vector<WayLocation> interval1 = mns1.getInterval();
  if (!interval1[0].isValid() || !interval1[1].isValid() ||
      interval1[0] == interval1[1])
  {
    // if the interval isn't valid then return an invalid result.
    return WaySublineMatchString();
  }
  _snapToEnds(map, interval1);
  WayPtr subline1 = WaySubline(interval1[0], interval1[1]).toWay(mapCopy);

  MaximalNearestSubline mns2(mapCopy, way2NonConst, subline1, _minSplitSize, -1, -1, _headingDelta);
  std::vector<WayLocation> interval2 = mns2.getInterval();
  if (!interval2[0].isValid() || !interval2[1].isValid() ||
      interval2[0] == interval2[1])
  {
    return WaySublineMatchString();
  }
  _snapToEnds(map, interval2);

  WaySublineMatch match = WaySublineMatch(WaySubline(interval1[0], interval1[1]),
                           WaySubline(interval2[0], interval2[1]));

  if (subline1->getNodeCount() > 1)
  {
    shared_ptr<LineString> ls = ElementConverter(mapCopy).convertToLineString(subline1);
    if (ls->isValid())
    {
      score = ls->getLength();
    }
  }

  vector<WaySublineMatch> v;
  // switch the subline match to reference a different map.
  v.push_back(WaySublineMatch(match, map));

  return WaySublineMatchString(v);
}
开发者ID:drew-bower,项目名称:hootenanny,代码行数:56,代码来源:MaximalNearestSublineMatcher.cpp

示例2: classify

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;
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:49,代码来源:HighwayExpertClassifier.cpp


注:本文中的ConstOsmMapPtr::copyWays方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。