SUMO - Simulation of Urban MObility
PositionVector Class Reference

A list of positions. More...

#include <PositionVector.h>

Inheritance diagram for PositionVector:
AbstractPoly

Data Structures

class  as_poly_cw_sorter
 
class  increasing_x_y_sorter
 

Public Member Functions

void add (SUMOReal xoff, SUMOReal yoff, SUMOReal zoff)
 
void append (const PositionVector &v, SUMOReal sameThreshold=2.0)
 
int appendWithCrossingPoint (const PositionVector &v)
 
SUMOReal area () const
 Returns the area (0 for non-closed) More...
 
bool around (const Position &p, SUMOReal offset=0) const
 Returns the information whether the position vector describes a polygon lying around the given point The optional offset is added to the polygon's bounderies. More...
 
SUMOReal beginEndAngle () const
 
void closePolygon ()
 ensures that the last position equals the first More...
 
PositionVector convexHull () const
 
bool crosses (const Position &p1, const Position &p2) const
 
SUMOReal distance (const Position &p, bool perpendicular=false) const
 
std::vector< SUMORealdistances (const PositionVector &s, bool perpendicular=false) const
 
void eraseAt (int i)
 
void extrapolate (SUMOReal val)
 
Line getBegLine () const
 
Boundary getBoxBoundary () const
 Returns a boundary enclosing this list of lines. More...
 
Position getCentroid () const
 Returns the centroid (closes the polygon if unclosed) More...
 
Line getEndLine () const
 
Position getLineCenter () const
 
Position getPolygonCenter () const
 Returns the arithmetic of all corner points. More...
 
PositionVector getSubpart (SUMOReal beginOffset, SUMOReal endOffset) const
 
PositionVector getSubpart2D (SUMOReal beginOffset, SUMOReal endOffset) const
 
PositionVector getSubpartByIndex (int beginIndex, int count) const
 
int indexOfClosest (const Position &p) const
 
void insertAt (int index, const Position &p)
 
int insertAtClosest (const Position &p)
 
PositionVector intersectionPoints2D (const Line &line) const
 
bool intersects (const Position &p1, const Position &p2) const
 
bool intersects (const PositionVector &v1) const
 
std::vector< SUMORealintersectsAtLengths2D (const PositionVector &other) const
 For all intersections between this vector and other, return the 2D-length of the subvector from this vectors start to the intersection. More...
 
std::vector< SUMORealintersectsAtLengths2D (const Line &line) const
 For all intersections between this vector and line, return the 2D-length of the subvector from this vectors start to the intersection. More...
 
Position intersectsAtPoint (const Position &p1, const Position &p2) const
 
Position intersectsAtPoint (const PositionVector &v1) const
 
bool isClosed () const
 
SUMOReal isLeft (const Position &P0, const Position &P1, const Position &P2) const
 
SUMOReal length () const
 Returns the length. More...
 
SUMOReal length2D () const
 Returns the length. More...
 
Line lineAt (int pos) const
 
void move2side (SUMOReal amount)
 
SUMOReal nearest_offset_to_point2D (const Position &p, bool perpendicular=true) const
 
bool operator== (const PositionVector &v2) const
 comparing operation More...
 
const Positionoperator[] (int index) const
 returns the position at the given index !!! exceptions? More...
 
Positionoperator[] (int index)
 
bool overlapsWith (const AbstractPoly &poly, SUMOReal offset=0) const
 Returns the information whether the given polygon overlaps with this Again a boundary may be specified. More...
 
bool partialWithin (const AbstractPoly &poly, SUMOReal offset=0) const
 Returns the information whether this polygon lies partially within the given polygon. More...
 
Position pop_front ()
 Removes and returns the position at the fron of the list. More...
 
Position positionAtOffset (SUMOReal pos, SUMOReal lateralOffset=0) const
 Returns the position at the given length. More...
 
Position positionAtOffset2D (SUMOReal pos, SUMOReal lateralOffset=0) const
 Returns the position at the given length. More...
 
 PositionVector ()
 Constructor. More...
 
 PositionVector (const std::vector< Position > &v)
 Constructor. More...
 
void pruneFromBeginAt (const Position &p)
 
void pruneFromEndAt (const Position &p)
 
void push_back_noDoublePos (const Position &p)
 
void push_front (const Position &p)
 Puts the given position at the front of the list. More...
 
void push_front_noDoublePos (const Position &p)
 
void removeColinearPoints ()
 
void removeDoublePoints (SUMOReal minDist=POSITION_EPS, bool assertLength=false)
 Removes positions if too near. More...
 
void replaceAt (int index, const Position &by)
 
void reshiftRotate (SUMOReal xoff, SUMOReal yoff, SUMOReal rot)
 
PositionVector reverse () const
 
SUMOReal rotationDegreeAtOffset (SUMOReal pos) const
 Returns the rotation at the given length. More...
 
void scaleAbsolute (SUMOReal offset)
 enlarges/shrinks the polygon by an absolute offset based at the centroid More...
 
void scaleRelative (SUMOReal factor)
 enlarges/shrinks the polygon by a factor based at the centroid More...
 
SUMOReal slopeDegreeAtOffset (SUMOReal pos) const
 Returns the slope at the given length. More...
 
void sortAsPolyCWByAngle ()
 
void sortByIncreasingXY ()
 
std::pair< PositionVector, PositionVectorsplitAt (SUMOReal where) const
 Returns the two lists made when this list vector is splitted at the given point. More...
 
Position transformToVectorCoordinates (const Position &p, bool extend=false) const
 return position p within the length-wise coordinate system defined by this position vector. The x value is the same as that returned by nearest_offset_to_point2D(p) and the y value is the perpendicular distance to this vector with the sign indicating the side (right is postive). if extend is true, the vector is extended on both sides and the x-coordinate of the result may be below 0 or above the length of the original vector More...
 
 ~PositionVector ()
 Destructor. More...
 
Adding items to the container
void push_back (const PositionVector &p)
 Appends all positions from the given vector. More...
 

Static Public Member Functions

static Position positionAtOffset (const Position &p1, const Position &p2, SUMOReal pos, SUMOReal lateralOffset)
 Returns the position between the two given point at the specified position */. More...
 
static Position positionAtOffset2D (const Position &p1, const Position &p2, SUMOReal pos, SUMOReal lateralOffset)
 Returns the position between the two given point at the specified position */. More...
 

Private Types

typedef std::vector< Positionvp
 

Friends

std::ostream & operator<< (std::ostream &os, const PositionVector &geom)
 Output operator. More...
 

Detailed Description

A list of positions.

Definition at line 53 of file PositionVector.h.

Member Typedef Documentation

typedef std::vector<Position> PositionVector::vp
private

Definition at line 56 of file PositionVector.h.

Constructor & Destructor Documentation

PositionVector::PositionVector ( )

Constructor.

Creates an empty position vector

Definition at line 59 of file PositionVector.cpp.

PositionVector::PositionVector ( const std::vector< Position > &  v)

Constructor.

Parameters
[in]vThe vector to copy

Definition at line 62 of file PositionVector.cpp.

PositionVector::~PositionVector ( )

Destructor.

Definition at line 67 of file PositionVector.cpp.

Member Function Documentation

void PositionVector::add ( SUMOReal  xoff,
SUMOReal  yoff,
SUMOReal  zoff 
)

Definition at line 514 of file PositionVector.cpp.

Referenced by NBEdge::init(), and NBNode::reshiftPosition().

int PositionVector::appendWithCrossingPoint ( const PositionVector v)
SUMOReal PositionVector::area ( ) const

Returns the area (0 for non-closed)

Definition at line 415 of file PositionVector.cpp.

References isClosed(), push_back(), and SUMOReal.

Referenced by getCentroid(), and NBNodesEdgesSorter::sortNodesEdges().

bool PositionVector::around ( const Position p,
SUMOReal  offset = 0 
) const
virtual

Returns the information whether the position vector describes a polygon lying around the given point The optional offset is added to the polygon's bounderies.

Implements AbstractPoly.

Definition at line 92 of file PositionVector.cpp.

References GeomHelper::Angle2D(), around(), M_PI, scaleAbsolute(), SUMOReal, Position::x(), and Position::y().

Referenced by around(), NBEdge::computeAngle(), NBNode::computeNodeShape(), NBNode::getCenter(), and NIVissimTL::NIVissimTLSignal::isWithin().

void PositionVector::closePolygon ( )

ensures that the last position equals the first

Definition at line 1108 of file PositionVector.cpp.

References push_back().

Referenced by NIXMLNodesHandler::addNode(), NBNode::getCenter(), and NLHandler::openJunction().

PositionVector PositionVector::convexHull ( ) const

Definition at line 567 of file PositionVector.cpp.

References simpleHull_2D(), and sortAsPolyCWByAngle().

bool PositionVector::crosses ( const Position p1,
const Position p2 
) const
virtual

Implements AbstractPoly.

Definition at line 448 of file PositionVector.cpp.

References intersects().

std::vector< SUMOReal > PositionVector::distances ( const PositionVector s,
bool  perpendicular = false 
) const
void PositionVector::eraseAt ( int  i)
Position PositionVector::getCentroid ( ) const

Returns the centroid (closes the polygon if unclosed)

Definition at line 330 of file PositionVector.cpp.

References area(), isClosed(), length(), push_back(), and SUMOReal.

Referenced by NBEdge::computeAngle(), scaleAbsolute(), and scaleRelative().

Position PositionVector::getLineCenter ( ) const
Position PositionVector::getPolygonCenter ( ) const

Returns the arithmetic of all corner points.

Note
: this is different from the centroid!

Definition at line 318 of file PositionVector.cpp.

References SUMOReal.

Referenced by NIVissimNodeCluster::buildNBNode(), NIVissimDistrictConnection::dict_BuildDistrictNodes(), GUIPolygon::drawGL(), and NBNode::getCenter().

PositionVector PositionVector::getSubpart2D ( SUMOReal  beginOffset,
SUMOReal  endOffset 
) const
PositionVector PositionVector::getSubpartByIndex ( int  beginIndex,
int  count 
) const

Definition at line 749 of file PositionVector.cpp.

References push_back().

Referenced by NBNode::buildWalkingAreas().

int PositionVector::indexOfClosest ( const Position p) const

Definition at line 908 of file PositionVector.cpp.

References Position::distanceTo(), max, and SUMOReal.

void PositionVector::insertAt ( int  index,
const Position p 
)
int PositionVector::insertAtClosest ( const Position p)
PositionVector PositionVector::intersectionPoints2D ( const Line line) const

Returns any intersection Points with the given line (ignoring z-coordinates)

Definition at line 575 of file PositionVector.cpp.

References GeomHelper::intersection_position2D(), GeomHelper::intersects(), Line::p1(), Line::p2(), and push_back_noDoublePos().

Referenced by Line::intersectsAtLengths2D().

bool PositionVector::intersects ( const Position p1,
const Position p2 
) const
bool PositionVector::intersects ( const PositionVector v1) const

Returns the information whether this list of points interesects one the given lines

Definition at line 146 of file PositionVector.cpp.

References intersects().

std::vector< SUMOReal > PositionVector::intersectsAtLengths2D ( const PositionVector other) const

For all intersections between this vector and other, return the 2D-length of the subvector from this vectors start to the intersection.

Definition at line 943 of file PositionVector.cpp.

Referenced by NBNodeShapeComputer::closestIntersection(), NBNodeShapeComputer::computeNodeShapeDefault(), computeSameEnd(), NBEdge::firstIntersection(), MSLink::setRequestInformation(), and NBEdge::startShapeAt().

std::vector< SUMOReal > PositionVector::intersectsAtLengths2D ( const Line line) const

For all intersections between this vector and line, return the 2D-length of the subvector from this vectors start to the intersection.

Definition at line 954 of file PositionVector.cpp.

References Position::distanceTo2D(), GeomHelper::intersection_position2D(), GeomHelper::intersects(), Line::length2D(), Line::p1(), Line::p2(), and SUMOReal.

Position PositionVector::intersectsAtPoint ( const Position p1,
const Position p2 
) const
Position PositionVector::intersectsAtPoint ( const PositionVector v1) const

Returns the position of the intersection

Definition at line 173 of file PositionVector.cpp.

References intersects(), intersectsAtPoint(), and Position::INVALID.

bool PositionVector::isClosed ( ) const

Definition at line 1191 of file PositionVector.cpp.

Referenced by area(), and getCentroid().

SUMOReal PositionVector::isLeft ( const Position P0,
const Position P1,
const Position P2 
) const

Definition at line 560 of file PositionVector.cpp.

References Position::x(), and Position::y().

Referenced by transformToVectorCoordinates().

SUMOReal PositionVector::length2D ( ) const

Returns the length.

Definition at line 405 of file PositionVector.cpp.

References SUMOReal.

Referenced by NBEdge::computeAngle(), and NIImporter_OpenDrive::loadNetwork().

SUMOReal PositionVector::nearest_offset_to_point2D ( const Position p,
bool  perpendicular = true 
) const
bool PositionVector::operator== ( const PositionVector v2) const

comparing operation

Definition at line 1229 of file PositionVector.cpp.

const Position & PositionVector::operator[] ( int  index) const

returns the position at the given index !!! exceptions?

Definition at line 189 of file PositionVector.cpp.

Position & PositionVector::operator[] ( int  index)

Definition at line 199 of file PositionVector.cpp.

bool PositionVector::overlapsWith ( const AbstractPoly poly,
SUMOReal  offset = 0 
) const
virtual

Returns the information whether the given polygon overlaps with this Again a boundary may be specified.

Implements AbstractPoly.

Definition at line 120 of file PositionVector.cpp.

References AbstractPoly::around().

Referenced by NIVissimAbstractEdge::overlapsWith().

bool PositionVector::partialWithin ( const AbstractPoly poly,
SUMOReal  offset = 0 
) const
virtual

Returns the information whether this polygon lies partially within the given polygon.

Implements AbstractPoly.

Definition at line 437 of file PositionVector.cpp.

References AbstractPoly::around().

Position PositionVector::pop_front ( )

Removes and returns the position at the fron of the list.

Definition at line 84 of file PositionVector.cpp.

Referenced by NBRampsComputer::buildOffRamp(), and NBEdge::getInnerGeometry().

Position PositionVector::positionAtOffset ( const Position p1,
const Position p2,
SUMOReal  pos,
SUMOReal  lateralOffset 
)
static

Returns the position between the two given point at the specified position */.

Definition at line 274 of file PositionVector.cpp.

References Position::distanceTo(), Line::getPositionAtDistance(), Position::INVALID, Line::move2side(), and SUMOReal.

Position PositionVector::positionAtOffset2D ( const Position p1,
const Position p2,
SUMOReal  pos,
SUMOReal  lateralOffset 
)
static

Returns the position between the two given point at the specified position */.

Definition at line 291 of file PositionVector.cpp.

References Position::distanceTo2D(), Line::getPositionAtDistance2D(), Position::INVALID, Line::move2side(), and SUMOReal.

void PositionVector::push_back ( const PositionVector p)

Appends all positions from the given vector.

Parameters
[in]pThe vector from which values shall be appended

Definition at line 72 of file PositionVector.cpp.

Referenced by NBEdgeCont::applyOptions(), area(), NIVissimConnection::buildGeom(), NBRampsComputer::buildOnRamp(), NBNode::buildWalkingAreas(), closePolygon(), NBEdge::computeLaneShape(), NBNode::computeNodeShape(), GUIVehicle::computeSeats(), NBNode::computeSmoothShape(), NIVissimDistrictConnection::dict_BuildDistrictNodes(), extrapolate(), TraCIServer::findObjectShape(), getCentroid(), NIVissimAbstractEdge::getGeomPosition(), TraCIServerAPI_Edge::getShape(), TraCIServerAPI_Polygon::getShape(), TraCIServerAPI_Lane::getShape(), SUMOSAXAttributesImpl_Xerces::getShape(), getSubpart(), getSubpart2D(), getSubpartByIndex(), GUIVehicle::GUIVehicle(), NBEdge::init(), MSPModel_Striping::initWalkingAreaPaths(), NIImporter_OpenStreetMap::insertEdge(), Line::intersectsAtLengths2D(), PCLoaderVisum::load(), PCLoaderDlrNavteq::loadPolyFile(), move2side(), PCLoaderXML::myStartElement(), NIVissimSingleTypeParser_Geschwindigkeitsverteilungsdefinition::parse(), NIVissimSingleTypeParser_Knotendefinition::parse(), NIVissimSingleTypeParser_Laengenverteilungsdefinition::parse(), NIVissimSingleTypeParser_Zeitenverteilungsdefinition::parse(), NIImporter_VISUM::parse_AreaSubPartElement(), GeomConvHelper::parseShapeReporting(), ODMatrix::parseTimeLine(), pruneFromEndAt(), push_back_noDoublePos(), TraCIServer::readTypeCheckingPolygon(), NIImporter_SUMO::reconstructEdgeShape(), NIImporter_DlrNavteq::NodesHandler::report(), NIImporter_DlrNavteq::EdgesHandler::report(), reverse(), NBEdge::setGeometry(), splitAt(), NBEdge::splitGeometry(), and TraCIServerAPI_Vehicle::vtdMap().

void PositionVector::push_front ( const Position p)

Puts the given position at the front of the list.

Definition at line 78 of file PositionVector.cpp.

Referenced by NBRampsComputer::buildOffRamp(), extrapolate(), NBEdge::init(), NIImporter_DlrNavteq::EdgesHandler::report(), and NBEdge::setGeometry().

void PositionVector::removeColinearPoints ( )

Definition at line 1213 of file PositionVector.cpp.

References GeomHelper::distancePointLine().

void PositionVector::removeDoublePoints ( SUMOReal  minDist = POSITION_EPS,
bool  assertLength = false 
)

Removes positions if too near.

Parameters
[in]minDistThe minimum accepted distance; default: POSITION_EPS
[in]assertLengthWhether the result must at least contain two points (be a line); default: false, to ensure original behaviour

Definition at line 1197 of file PositionVector.cpp.

Referenced by NIImporter_OpenDrive::computeShapes(), NBEdge::init(), and NBEdge::reduceGeometry().

void PositionVector::replaceAt ( int  index,
const Position by 
)

Definition at line 1163 of file PositionVector.cpp.

Referenced by computeSameEnd().

void PositionVector::reshiftRotate ( SUMOReal  xoff,
SUMOReal  yoff,
SUMOReal  rot 
)

Definition at line 522 of file PositionVector.cpp.

Referenced by NBDistrict::reshiftPosition(), and NBEdge::reshiftPosition().

void PositionVector::scaleAbsolute ( SUMOReal  offset)

enlarges/shrinks the polygon by an absolute offset based at the centroid

Definition at line 378 of file PositionVector.cpp.

References getCentroid().

Referenced by around().

void PositionVector::scaleRelative ( SUMOReal  factor)

enlarges/shrinks the polygon by a factor based at the centroid

Definition at line 369 of file PositionVector.cpp.

References getCentroid().

SUMOReal PositionVector::slopeDegreeAtOffset ( SUMOReal  pos) const

Returns the slope at the given length.

Definition at line 258 of file PositionVector.cpp.

References Line::atan2DegreeSlope(), and SUMOReal.

Referenced by MSVehicle::getSlope(), and MSCFModel_KraussAccelBound::maxNextSpeed().

void PositionVector::sortAsPolyCWByAngle ( )

Definition at line 508 of file PositionVector.cpp.

Referenced by convexHull().

void PositionVector::sortByIncreasingXY ( )

Definition at line 538 of file PositionVector.cpp.

std::pair< PositionVector, PositionVector > PositionVector::splitAt ( SUMOReal  where) const

Returns the two lists made when this list vector is splitted at the given point.

Definition at line 454 of file PositionVector.cpp.

References length(), POSITION_EPS, push_back(), SUMOReal, toString(), and WRITE_WARNING.

Referenced by NBEdge::buildInnerEdges(), and NBEdgeCont::splitAt().

Position PositionVector::transformToVectorCoordinates ( const Position p,
bool  extend = false 
) const

return position p within the length-wise coordinate system defined by this position vector. The x value is the same as that returned by nearest_offset_to_point2D(p) and the y value is the perpendicular distance to this vector with the sign indicating the side (right is postive). if extend is true, the vector is extended on both sides and the x-coordinate of the result may be below 0 or above the length of the original vector

Definition at line 861 of file PositionVector.cpp.

References distance(), Position::distanceTo2D(), extrapolate(), Position::INVALID, GeomHelper::INVALID_OFFSET, isLeft(), max, GeomHelper::nearest_offset_on_line_to_point2D(), sign, SUMOReal, and transformToVectorCoordinates().

Referenced by MSPModel_Striping::getNextLaneObstacles(), MSPModel_Striping::moveInDirection(), and transformToVectorCoordinates().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const PositionVector geom 
)
friend

Output operator.

Definition at line 496 of file PositionVector.cpp.


The documentation for this class was generated from the following files: