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


C++ ConstWayPtr::getCircularError方法代码示例

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


在下文中一共展示了ConstWayPtr::getCircularError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: toWay

WayPtr WaySubline::toWay(const OsmMapPtr& map, GeometryConverter::NodeFactory* nf) const
{
  ConstWayPtr way = _start.getWay();

  auto_ptr<GeometryConverter::NodeFactory> nfPtr;
  if (nf == 0)
  {
    nf = new FindNodesInWayFactory(way);
    // delete it automatically.
    nfPtr.reset(nf);
  }

  WayPtr result(new Way(way->getStatus(), map->createNextWayId(), way->getCircularError()));
  result->setTags(way->getTags());

  int includedStartIndex = _start.getSegmentIndex();
  if (_start.getSegmentFraction() > 0.0)
  {
    includedStartIndex += 1;
  }
  int includedEndIndex = _end.getSegmentIndex();
  if (_end.getSegmentFraction() >= 1.0)
  {
    includedEndIndex += 1;
  }

  if (!_start.isNode())
  {
    Coordinate c = _start.getCoordinate();
    shared_ptr<Node> n = nf->createNode(map, c, way->getStatus(),
      way->getCircularError());
    map->addNode(n);
    result->addNode(n->getId());
  }

  for (int i = includedStartIndex; i <= includedEndIndex; i++)
  {
    result->addNode(way->getNodeId(i));
  }

  if (!_end.isNode())
  {
    Coordinate c = _end.getCoordinate();
    shared_ptr<Node> n = nf->createNode(map, c, way->getStatus(), way->getCircularError());
    map->addNode(n);
    result->addNode(n->getId());
  }

  return result;
}
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:50,代码来源:WaySubline.cpp

示例3: _calculateDistance

double KnnWayIterator::_calculateDistance(const BoxInternalData&, int id)
  const
{
  // if the id in the index isn't valid, then report the maximum possible distance.
  double result = numeric_limits<double>::max();

  long otherWayId = _treeIdToWid[id];
  if (otherWayId == _wayId)
  {
    result = 0.0;
  }
  // if this is a valid way id.
  else if (_map.containsWay(otherWayId))
  {
    ConstWayPtr w = _map.getWay(otherWayId);

    // grab the geometry for the way that we're comparing against.
    boost::shared_ptr<LineString> ls = ElementConverter(_map.shared_from_this()).convertToLineString(w);

    Meters d = ls->distance(_lsFast);

    if (_addError)
    {
      Meters acc = w->getCircularError();

      d = std::max(0.0, ls->distance(_lsFast) - (acc + _baseAccuracy));
    }

    _distanceCount++;

    result = d * d;
  }

  return result;
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例4: findMatch

WaySublineMatchString MaximalSublineMatcher::findMatch(const ConstOsmMapPtr &map,
  const ConstWayPtr& way1, const ConstWayPtr& way2, double &score, Meters maxRelevantDistance) const
{
  Meters mrd = maxRelevantDistance == -1 ? way1->getCircularError() + way2->getCircularError() :
    maxRelevantDistance;
//  LOG_INFO("min split size: " << _minSplitSize << " _maxAngle " << _maxAngle << " mrd: " << mrd);
//  assert(_minSplitSize >= 0.0 && _maxAngle >= 0.0 && mrd >= 0.0);

  MaximalSubline::ThresholdMatchCriteria* threshold =
    new MaximalSubline::ThresholdMatchCriteria(mrd, _maxAngle);
  // This should use the _minSplitSize rather than mrd, but that causes some tests to fail. We
  // should look into the problem and solve it. See #6159
  MaximalSubline ms(threshold, mrd);

  vector<WaySublineMatch> matches = ms.findAllMatches(map, way1, way2, score);

  return WaySublineMatchString(matches);
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:18,代码来源:MaximalSublineMatcher.cpp

示例5: ElementConverter

WayBufferFilter::WayBufferFilter(ConstOsmMapPtr map, ConstWayPtr baseWay, Meters buffer,
  double matchPercent) :
  _map(map)
{
  _matchPercent = matchPercent;
  _buffer = buffer + baseWay->getCircularError();
  _baseLs = ElementConverter(map).convertToLineString(baseWay);
  _baseLength = _baseLs->getLength();
  _bufferAccuracy = -1;
}
开发者ID:drew-bower,项目名称:hootenanny,代码行数:10,代码来源:WayBufferFilter.cpp

示例6: KnnIterator

KnnWayIterator::KnnWayIterator(const OsmMap& map, ConstWayPtr way,
  const RStarTree* tree, const vector<long>& treeIdToWid, bool addError) :
  KnnIterator(tree, 0.0, 0.0, Box()),
  _map(map),
  _treeIdToWid(treeIdToWid)
{
  _wayId = way->getId();
  _ls = ElementConverter(map.shared_from_this()).convertToLineString(way);
  _lsFast = _ls.get();
  _indexSlush = _map.getIndex().getIndexSlush();
  _distanceCount = 0;
  _addError = addError;
  _baseAccuracy = way->getCircularError();
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例7: m

/// @todo this is in desperate need of a rewrite by someone with more rest than myself. -JRS
vector<WaySublineMatch> MaximalSubline::_snapIntersections(const ConstOsmMapPtr& map,
        const ConstWayPtr& w1, const ConstWayPtr& w2, vector<WaySublineMatch>& rawSublineMatches)
{
    // this only works if the rawSublineMatches are in order. We order by subline1
    sort(rawSublineMatches.begin(), rawSublineMatches.end(), lessThan);

    // make sure that ordering by subline1 results in sorted subline2s. If this isn't the case then
    // there isn't much we can do.
    for (size_t i = 2; i < rawSublineMatches.size(); i++)
    {
        if (rawSublineMatches[i].getSubline2().getStart() >
                rawSublineMatches[i - 1].getSubline2().getStart())
        {
            LOG_WARN("Way matches sublines out of order. This is unusual and may give a sub-optimal "
                     "result.");
            return rawSublineMatches;
        }
    }

    for (size_t i = 0; i < rawSublineMatches.size(); i++)
    {
        // if any of the raw sublines are crazy small, then don't try to snap the intersections.
        if (rawSublineMatches[i].getSubline1().getLength() < _spacing * 2 ||
                rawSublineMatches[i].getSubline2().getLength() < _spacing * 2)
        {
            return rawSublineMatches;
        }
    }

    ////
    // calculate a series of point pair matches along the lines.
    ////

    // discretize the first line into a series of points.
    vector< pair<WayLocation, WayLocation> > pairs;
    pairs = _discretizePointPairs(map, w1, w2, rawSublineMatches);
    assert(pairs.size() > 0);
    //LOG_DEBUG_VAR(pairs);

    // extract features on the point pairs and populate a matrix.
    Meters acc = w1->getCircularError() + w2->getCircularError();

    cv::Mat m(pairs.size(), 2, CV_64F);

    size_t currentSubline = 0;

    vector<int> starts(rawSublineMatches.size(), numeric_limits<int>::max());
    vector<int> ends(rawSublineMatches.size(), 0);

    for (size_t i = 0; i < pairs.size(); i++)
    {
        WayLocation& wl1 = pairs[i].first;
        WayLocation& wl2 = pairs[i].second;
        // If the rawSublineMatches is smaller than _spacing, then it may not directly overlap with
        // one of the point pairs. To avoid this, we create a subline that surrounds the point pair
        // and will guarantee that each rawSublineMatches will touch at least one point pair.
        WaySubline ws1 = WaySubline(wl1.move(-_spacing / 2.0), wl1.move(_spacing / 2.0));
        WaySubline ws2 = WaySubline(wl2.move(-_spacing / 2.0), wl2.move(_spacing / 2.0));

        if (currentSubline < rawSublineMatches.size())
        {
            // figure out the first and last match for this subline.
            if (rawSublineMatches[currentSubline].getSubline1().touches(ws1) ||
                    rawSublineMatches[currentSubline].getSubline2().touches(ws2))
            {
                starts[currentSubline] = min<int>(starts[currentSubline], i);
                ends[currentSubline] = max<int>(ends[currentSubline], i);
            }
            else
            {
                // if this is past the current subline, advance to the right subline.
                while (currentSubline < rawSublineMatches.size() &&
                        rawSublineMatches[currentSubline].getSubline1().getEnd() < ws1.getStart() &&
                        rawSublineMatches[currentSubline].getSubline2().getEnd() < ws2.getStart())
                {
                    currentSubline++;
                }
            }
        }

        Meters distance = wl1.getCoordinate().distance(wl2.getCoordinate());
        Radians angle1 = WayHeading::calculateHeading(wl1);
        Radians angle2 = WayHeading::calculateHeading(wl2);
        Radians angleDiff = WayHeading::deltaMagnitude(angle1, angle2);

        m.at<double>(i, 0) = distance / acc;
        m.at<double>(i, 1) = angleDiff;
    }

    //LOG_DEBUG("starts: " << starts);
    //LOG_DEBUG("ends: " << ends);

    // create the matrix of constraints.
    vector<int> finalStarts;
    vector<int> finalEnds;

    if (starts[0] != 0)
    {
        finalStarts.push_back(0);
//.........这里部分代码省略.........
开发者ID:giserh,项目名称:hootenanny,代码行数:101,代码来源:MaximalSubline.cpp


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