本文整理汇总了C++中ConstWayPtr::getNodeCount方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstWayPtr::getNodeCount方法的具体用法?C++ ConstWayPtr::getNodeCount怎么用?C++ ConstWayPtr::getNodeCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstWayPtr
的用法示例。
在下文中一共展示了ConstWayPtr::getNodeCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: _validateElement
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.");
}
}
}
示例3: _calculateSublineScores
void MaximalSubline::_calculateSublineScores(const ConstOsmMapPtr& map, const ConstWayPtr& way1,
const ConstWayPtr& way2, Sparse2dMatrix& scores)
{
_criteria->setWays(map, way1, way2);
for (int n1 = 0; n1 < (int)way1->getNodeCount() - 1; n1++)
{
for (int n2 = 0; n2 < (int)way2->getNodeCount() - 1; n2++)
{
double s = _criteria->match(n1, n2);
if (s > 0.0)
{
scores.set(n1, n2, s);
}
}
}
}
示例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;
}
}
}
}
}
示例5: 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;
}
示例6: _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);
}
示例7: createAtEndOfWay
WayLocation WayLocation::createAtEndOfWay(const ConstOsmMapPtr& map, const ConstWayPtr way)
{
return WayLocation(map, way, way->getNodeCount() - 1, 0.0);
}
示例8: isZeroLengthWay
bool WayCleaner::isZeroLengthWay(ConstWayPtr way, const ConstOsmMapPtr& map)
{
return way->getNodeCount() == 2 && (hasDuplicateNodes(way) || hasDuplicateCoords(way, *map));
}