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


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

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


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

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

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

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

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

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

示例6: addElement

void ElementCacheLRU::addElement(ConstElementPtr &newElement)
{
  ConstNodePtr newNode;
  ConstWayPtr newWay;
  ConstRelationPtr newRelation;

  switch ( newElement->getElementType().getEnum() )
  {
  case ElementType::Node:
    newNode = dynamic_pointer_cast<const Node>(newElement);
    if ( newNode != ConstNodePtr() )
    {
      // Do we have to replace an entry?
      if ( _nodes.size() == _maxCountPerType )
      {
        _removeOldest(ElementType::Node);
      }

      _nodes.insert(std::make_pair(newNode->getId(),
       std::make_pair(newNode, boost::posix_time::microsec_clock::universal_time())));
        //LOG_DEBUG("Added new node with ID " << newNode->getId() );
    }
    break;
  case ElementType::Way:
    newWay = dynamic_pointer_cast<const Way>(newElement);
    if ( newWay != ConstWayPtr() )
    {
      // Do we have to replace an entry?
      if ( _ways.size() == _maxCountPerType )
      {
        _removeOldest(ElementType::Way);
      }
      _ways.insert(std::make_pair(newWay->getId(),
        std::make_pair(newWay, boost::posix_time::microsec_clock::universal_time())));
    }

    break;
  case ElementType::Relation:
    newRelation = dynamic_pointer_cast<const Relation>(newElement);
    if ( newRelation != ConstRelationPtr() )
    {
      // Do we have to replace an entry?
      if ( _relations.size() == _maxCountPerType )
      {
        _removeOldest(ElementType::Relation);
      }

      _relations.insert(std::make_pair(newRelation->getId(),
        std::make_pair(newRelation, boost::posix_time::microsec_clock::universal_time())));
    }
    break;
  default:
    throw HootException(QString("Unexpected element type: %1").arg(
                          newElement->getElementType().toString()));

    break;
  }

  // Reset all iterators to maintain interface contract
  resetElementIterators();
}
开发者ID:digideskio,项目名称:hootenanny,代码行数:61,代码来源:ElementCacheLRU.cpp


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