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


C++ ConstWayPtr类代码示例

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


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

示例1: if

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,代码来源:

示例2: NeedsReviewException

void MaximalSublineStringMatcher::_validateElement(const ConstOsmMapPtr& map, ElementId eid) const
{
  ConstElementPtr e = map->getElement(eid);

  if (e->getElementType() == ElementType::Relation)
  {
    ConstRelationPtr r = dynamic_pointer_cast<const Relation>(e);

    if (OsmSchema::getInstance().isMultiLineString(*r) == false)
    {
      throw NeedsReviewException("Internal Error: When matching sublines expected a multilinestring "
        "relation not a " + r->getType() + ".  A non-multilinestring should never be found here.  "
        "Please report this to [email protected]");
    }

    const vector<RelationData::Entry>& entries = r->getMembers();
    for (size_t i = 0; i < entries.size(); i++)
    {
      if (entries[i].getElementId().getType() != ElementType::Way)
      {
        throw NeedsReviewException("MultiLineString relations can only contain ways when matching "
                                   "sublines.");
      }
    }
  }
  if (e->getElementType() == ElementType::Way)
  {
    ConstWayPtr w = dynamic_pointer_cast<const Way>(e);

    if (w->getNodeCount() <= 1)
    {
      throw NeedsReviewException("Internal Error: Attempting to match against a zero length way.");
    }
  }
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:35,代码来源:MaximalSublineStringMatcher.cpp

示例3: _createWayNodes

void OsmApiDbSqlChangesetFileWriter::_createWayNodes(ConstWayPtr way)
{
  LOG_TRACE("Creating way nodes for: " << way->getElementId());

  const std::vector<long> nodeIds = way->getNodeIds();
  for (size_t i = 0; i < nodeIds.size(); i++)
  {
    const long nodeId = nodeIds.at(i);
    LOG_VART(ElementId(ElementType::Node, nodeId));

    QString values =
      QString("(way_id, node_id, version, sequence_id) VALUES (%1, %2, 1, %3);\n")
        .arg(way->getId())
        .arg(nodeId)
        .arg(i + 1);
    _outputSql.write(("INSERT INTO " + ApiDb::getWayNodesTableName() + " " + values).toUtf8());

    values =
      QString("(way_id, node_id, sequence_id) VALUES (%1, %2, %3);\n")
        .arg(way->getId())
        .arg(nodeId)
        .arg(i + 1);
    _outputSql.write(("INSERT INTO " + ApiDb::getCurrentWayNodesTableName() + " " + values).toUtf8());
  }
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例4: splitCorners

void CornerSplitter::splitCorners()
{
  // Get a list of ways (that look like roads) in the map
  HighwayCriterion highwayCrit;
  for (WayMap::const_iterator it = _map->getWays().begin(); it != _map->getWays().end(); ++it)
  {
    if (highwayCrit.isSatisfied(it->second))
    {
      _todoWays.push_back(it->first);
    }
  }

  // Traverse each way, looking for corners to split
  // Splitting a way will usually result in adding a new way to _todoWays
  for (size_t i = 0; i < _todoWays.size(); i++)
  {
    ConstWayPtr pWay = _map->getWay(_todoWays[i]);
    size_t nodeCount = pWay->getNodeCount();

    // If the way has just two nodes, there are no corners
    if (nodeCount > 2)
    {
      // Look until we find a split, or get to the end
      bool split = false;
      for (size_t nodeIdx = 1; nodeIdx < nodeCount-1 && !split; nodeIdx++)
      {
        WayLocation prev(_map, pWay, nodeIdx-1, 0.0);
        WayLocation current(_map, pWay, nodeIdx, 0.0);
        WayLocation next(_map, pWay, nodeIdx+1, 0.0);

        // Calculate headings
        const double twopi = M_PI*2.0;
        double h1 = atan2(current.getCoordinate().y - prev.getCoordinate().y,
                          current.getCoordinate().x - prev.getCoordinate().x);
        double h2 = atan2(next.getCoordinate().y - current.getCoordinate().y,
                          next.getCoordinate().x - current.getCoordinate().x);

        double threshold = toRadians(55.0);
        double delta = fabs(h2-h1);

        if (delta > M_PI)
          delta = twopi - delta;


        // If we make enough of a turn, split the way
        if (delta > threshold)
        {
          LOG_TRACE("splitting way with delta: " << delta);
          _splitWay(pWay->getId(), nodeIdx, pWay->getNodeId(nodeIdx));
          split = true;
        }
      }
    }
  }
}
开发者ID:ngageoint,项目名称:hootenanny,代码行数:55,代码来源:CornerSplitter.cpp

示例5: hasDuplicateCoords

bool WayCleaner::hasDuplicateCoords(ConstWayPtr way, const OsmMap& map, const bool logDetails)
{
  const vector<long> nodeIds = way->getNodeIds();

  if (nodeIds.size() == 2 &&
      map.getNode(nodeIds.at(0))->toCoordinate() == map.getNode(nodeIds.at(1))->toCoordinate())
  {
    if (logDetails)
    {
      LOG_WARN(
        "Duplicate coordinate " << map.getNode(nodeIds.at(0))->toCoordinate() <<
        " for node with ID:'s " << nodeIds[0] << " and " << nodeIds[1] <<
        " found at indexes 0 and 1; For way with ID: " << way->getElementId().getId());
      LOG_VARW(nodeIds);
    }
    return true;
  }

  bool found = false;
  QList<Coordinate> coords;
  for (size_t i = 0; i < nodeIds.size(); i++)
  {
    const Coordinate coord = map.getNode(nodeIds[i])->toCoordinate();
    if (coords.contains(coord))
    {
      //the only duplicated coords allowed are the first and last for a closed way, if the node ID's
      //match
      if (i == (nodeIds.size() - 1) && nodeIds[0] == nodeIds[i])
      {
        found = false;
      }
      else
      {
        found = true;
      }
      if (found)
      {
        if (logDetails)
        {
          LOG_WARN(
            "Duplicate coord " << map.getNode(nodeIds[i])->toCoordinate() << " for node with ID: " <<
            nodeIds[i] << " found at index: " << i << " For way with ID: " << way->getElementId().getId());
          LOG_VARW(nodeIds);
        }
        return found;
      }
    }
    else
    {
      coords.append(coord);
    }
  }
  return found;
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:54,代码来源:WayCleaner.cpp

示例6: if

WayLocation::WayLocation(ConstOsmMapPtr map, ConstWayPtr way, double distance) :
  _map(map)
{
  double d = 0.0;

  _segmentIndex = -1;
  _segmentFraction = -1;

  _way = way;
  double length = ElementConverter(map).convertToLineString(way)->getLength();

  if (distance <= 0)
  {
    _segmentIndex = 0.0;
    _segmentFraction = 0;
  }
  else if (distance >= length)
  {
    _segmentIndex = _way->getNodeCount() - 1;
    _segmentFraction = 0.0;
  }
  else
  {
    Coordinate last = _map->getNode(way->getNodeId(0))->toCoordinate();

    _segmentIndex = way->getNodeCount() - 1;
    _segmentFraction = 0;

    for (size_t i = 1; i < way->getNodeCount(); i++)
    {
      ConstNodePtr n = _map->getNode(_way->getNodeId(i));
      Coordinate next = n->toCoordinate();
      double delta = next.distance(last);
      last = next;

      if (d <= distance && d + delta > distance)
      {
        _segmentIndex = i - 1;
        _segmentFraction = (distance - d) / delta;
        // this can sometimes happen due to rounding errors.
        if (_segmentFraction >= 1.0)
        {
          _segmentFraction = 0.0;
          _segmentIndex++;
        }
        _way = way;
        break;
      }
      d += delta;
    }
  }
  assert(_segmentFraction < 1.0);
  assert((size_t)_segmentIndex <= _way->getNodeCount() - 1);
}
开发者ID:ngageoint,项目名称:hootenanny,代码行数:54,代码来源:WayLocation.cpp

示例7: WayLocation

WaySubline::WaySubline(const WaySubline& from, const ConstOsmMapPtr& newMap)
{
  if (from.isValid())
  {
    ConstWayPtr oldWay = from.getStart().getWay();
    ConstWayPtr newWay = newMap->getWay(oldWay->getId());
    _start = WayLocation(newMap, newWay,
      from.getStart().getSegmentIndex(), from.getStart().getSegmentFraction());
    _end = WayLocation(newMap, newWay,
      from.getEnd().getSegmentIndex(), from.getEnd().getSegmentFraction());
  }
}
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:12,代码来源:WaySubline.cpp

示例8: _calculateStartWayLocation

WayLocation MaximalSubline::_calculateStartWayLocation(const ConstOsmMapPtr& map,
        const ConstWayPtr& a, const ConstWayPtr& b, int indexA, int indexB)
{
    Coordinate ca1 = map->getNode(a->getNodeId(indexA))->toCoordinate();
    Coordinate ca2 = map->getNode(a->getNodeId(indexA + 1))->toCoordinate();
    Coordinate cb1 = map->getNode(b->getNodeId(indexB))->toCoordinate();

    LineSegment lsA(ca1, ca2);
    Coordinate start;
    lsA.closestPoint(cb1, start);

    return LocationOfPoint(map, a).locate(start);
}
开发者ID:giserh,项目名称:hootenanny,代码行数:13,代码来源:MaximalSubline.cpp

示例9: hasDuplicateNodes

bool WayCleaner::hasDuplicateNodes(ConstWayPtr way, const bool logDetails)
{
  const vector<long> nodeIds = way->getNodeIds();

  if (nodeIds.size() == 2 && nodeIds.at(0) == nodeIds.at(1))
  {
    if (logDetails)
    {
      LOG_WARN(
        "Duplicate node with ID: " << nodeIds[0] << " found at indexes 0 and 1; For way with ID: " <<
        way->getElementId().getId());
      LOG_VARW(nodeIds);
    }
    return true;
  }

  bool found = false;
  QList<long> nodeIdsTemp;
  for (size_t i = 0; i < nodeIds.size(); i++)
  {
    if (nodeIdsTemp.contains(nodeIds[i]))
    {
      //the only duplicated nodes allowed are the first and last for a closed way
      if (i == (nodeIds.size() - 1) && nodeIds[0] == nodeIds[i])
      {
        found = false;
      }
      else
      {
        found = true;
      }
      if (found)
      {
        if (logDetails)
        {
          LOG_WARN(
            "Duplicate node with ID: " << nodeIds[i] << " found at index: " << i <<
            " For way with ID: " << way->getElementId().getId());
          LOG_VARW(nodeIds);
        }
        return found;
      }
    }
    else
    {
      nodeIdsTemp.append(nodeIds[i]);
    }
  }
  return found;
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:50,代码来源:WayCleaner.cpp

示例10: 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,代码来源:

示例11: create

shared_ptr<LineString> ElementConverter::convertToLineString(const ConstWayPtr& w) const
{
  const std::vector<long>& ids = w->getNodeIds();
  int size = ids.size();
  if (size == 1)
  {
    size = 2;
  }
  CoordinateSequence* cs = GeometryFactory::getDefaultInstance()->getCoordinateSequenceFactory()->
                           create(size, 2);

  for (size_t i = 0; i < ids.size(); i++)
  {
    shared_ptr<const Node> n = _constProvider->getNode(ids[i]);
    cs->setAt(n->toCoordinate(), i);
  }

  // a linestring cannot contain 1 point. Do this to keep it valid.
  if (ids.size() == 1)
  {
    shared_ptr<const Node> n = _constProvider->getNode(ids[0]);
    cs->setAt(n->toCoordinate(), 1);
  }

  shared_ptr<LineString> result(GeometryFactory::getDefaultInstance()->createLineString(cs));

  return result;
}
开发者ID:BSteine,项目名称:hootenanny,代码行数:28,代码来源:ElementConverter.cpp

示例12: reverse

WaySubline WaySubline::reverse(const ConstWayPtr& reversedWay) const
{
  WaySubline result;

  // sanity check to make sure they're actually reversed, this isn't conclusive but should help
  // if there is a major goof.
  assert(reversedWay->getNodeCount() == getWay()->getNodeCount());
  assert(reversedWay->getNodeId(0) == getWay()->getLastNodeId());

  double l = ElementConverter(getMap()).convertToLineString(getWay())->getLength();

  result._start = WayLocation(getMap(), reversedWay, l - getEnd().calculateDistanceOnWay());
  result._end = WayLocation(getMap(), reversedWay, l - getStart().calculateDistanceOnWay());

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

示例13: LOG_VART

NodePtr PertyWaySplitVisitor::_getNodeAddedBySplit(const QList<long>& nodeIdsBeforeSplit,
  const vector<ElementPtr>& newElementsAfterSplit) const
{
  //newElementsAfterSplit is assumed to only contain ways; find the new node created by the way
  //split; it will be the last node in the first way, which is the same as the first node in the
  //last way
  ConstWayPtr firstWay = boost::dynamic_pointer_cast<Way>(newElementsAfterSplit.at(0));
  const long lastNodeIdInFirstWay = firstWay->getNodeIds().at(firstWay->getNodeCount() - 1);
  LOG_VART(lastNodeIdInFirstWay);
  ConstWayPtr lastWay = boost::dynamic_pointer_cast<Way>(newElementsAfterSplit.at(1));
  const long firstNodeIdInLastWay = lastWay->getNodeIds().at(0);
  LOG_VART(firstNodeIdInLastWay);
  assert(lastNodeIdInFirstWay == firstNodeIdInLastWay);
  assert(!nodeIdsBeforeSplit.contains(lastNodeIdInFirstWay));
  LOG_VART(nodeIdsBeforeSplit);
  return _map->getNode(firstNodeIdInLastWay);
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例14: 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

示例15: 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


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