本文整理汇总了C++中ConstWayPtr::getNodeIds方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstWayPtr::getNodeIds方法的具体用法?C++ ConstWayPtr::getNodeIds怎么用?C++ ConstWayPtr::getNodeIds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstWayPtr
的用法示例。
在下文中一共展示了ConstWayPtr::getNodeIds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
}
示例2: 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;
}
示例3: _getNodeAddedBySplit
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);
}
示例4: 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;
}
示例5: 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;
}