本文整理汇总了C++中ConstWayPtr::getNodeId方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstWayPtr::getNodeId方法的具体用法?C++ ConstWayPtr::getNodeId怎么用?C++ ConstWayPtr::getNodeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstWayPtr
的用法示例。
在下文中一共展示了ConstWayPtr::getNodeId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _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);
}
示例2: 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;
}
}
}
}
}
示例3: 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);
}
示例4: 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;
}
示例5:
const set<long>& WayMergeManipulation::getImpactedWayIds(const ConstOsmMapPtr& map) const
{
_impactedWays.clear();
_impactedWays.insert(_left);
_impactedWays.insert(_right);
NodeToWayMap& n2w = *map->getIndex().getNodeToWayMap();
ConstWayPtr left = map->getWay(_left);
ConstWayPtr right = map->getWay(_right);
const set<long>& s1 = n2w.at(left->getNodeId(0));
_impactedWays.insert(s1.begin(), s1.end());
const set<long>& s2 = n2w.at(left->getLastNodeId());
_impactedWays.insert(s2.begin(), s2.end());
const set<long>& s3 = n2w.at(right->getNodeId(0));
_impactedWays.insert(s3.begin(), s3.end());
const set<long>& s4 = n2w.at(right->getLastNodeId());
_impactedWays.insert(s4.begin(), s4.end());
return _impactedWays;
}
示例6: 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;
}