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


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

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


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

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

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

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

WaySublineMatchString MaximalNearestSublineMatcher::findMatch(const ConstOsmMapPtr& map,
  const ConstWayPtr& way1, const ConstWayPtr& way2, double& score, Meters maxRelevantDistance) const
{
  LOG_VART(way1->getElementId());
  LOG_VART(way2->getElementId());

  score = 0;
  Meters mrd =
    maxRelevantDistance == -1 ? way1->getCircularError() + way2->getCircularError() :
    maxRelevantDistance;

  OsmMapPtr mapCopy(new OsmMap());
  CopyMapSubsetOp(map,
               way1->getElementId(),
               way2->getElementId()).apply(mapCopy);

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

  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.
    LOG_TRACE("Returning invalid result...");
    return WaySublineMatchString();
  }
  _snapToEnds(map, interval1);
  WayPtr subline1 = WaySubline(interval1[0], interval1[1]).toWay(mapCopy);
  LOG_VART(subline1->getNodeIds());

  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])
  {
    LOG_TRACE("Returning invalid result...");
    return WaySublineMatchString();
  }
  _snapToEnds(map, interval2);

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

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

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

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


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