Eclipse SUMO - Simulation of Urban MObility
AGPosition Class Reference

A location in the 2D plane freely positioned on a street. More...

#include <AGPosition.h>

Collaboration diagram for AGPosition:
[legend]

Public Member Functions

 AGPosition (const AGStreet &str)
 Constructs an AGPosition at a random point on a street. More...
 
 AGPosition (const AGStreet &str, double pos)
 Constructs an AGPosition at a certain point on a street. More...
 
double distanceTo (const AGPosition &otherPos) const
 Computes the distance between two AGPosition objects. More...
 
double getPosition () const
 Provides the relative position of this AGPosition on the street. More...
 
const AGStreetgetStreet () const
 Provides the street this AGPosition is located on. More...
 
double minDistanceTo (const std::list< AGPosition > &positions) const
 Computes the distance to the closest position in a list. More...
 
double minDistanceTo (const std::map< int, AGPosition > &positions) const
 Computes the distance to the closest position in a map. More...
 
bool operator== (const AGPosition &pos) const
 Tests whether two positions are at the same place. More...
 
void print () const
 Prints out a summary of the properties of this class on standard output. More...
 

Private Member Functions

Position compute2dPosition () const
 

Static Private Member Functions

static double randomPositionInStreet (const AGStreet &street)
 Determines a random relative position on a street. More...
 

Private Attributes

Position pos2d
 
double position
 
const AGStreetstreet
 

Detailed Description

A location in the 2D plane freely positioned on a street.

This class restricts the Position class in the way that it must be a position on a street. As a consequence, this position can be described either by x and y coordinates or by a street and its distance to the beginning of the street (the relative position).

@TODO Should this class be derived from Position?

Definition at line 53 of file AGPosition.h.

Constructor & Destructor Documentation

◆ AGPosition() [1/2]

AGPosition::AGPosition ( const AGStreet str,
double  pos 
)

Constructs an AGPosition at a certain point on a street.

An AGPosition is determined by a street and the relative position on the street. This relative position is the distance from the from node of the street.

param[in] str the street on which the AGPosition is located param[in] pos the distance from the from node of the street

Definition at line 38 of file AGPosition.cpp.

◆ AGPosition() [2/2]

AGPosition::AGPosition ( const AGStreet str)

Constructs an AGPosition at a random point on a street.

This constructor determines the distance from the from node with a random number based on a uniform density.

param[in] str the street on which the AGPosition is located

Definition at line 43 of file AGPosition.cpp.

Member Function Documentation

◆ compute2dPosition()

Position AGPosition::compute2dPosition ( ) const
private

Creates a Position object to the street and position attribute of this class.

This method may only be called when street and position are initialised!

Returns
the Position object

Definition at line 117 of file AGPosition.cpp.

References Position::add(), ROEdge::getFromJunction(), ROEdge::getLength(), RONode::getPosition(), ROEdge::getToJunction(), Position::mul(), position, street, and Position::sub().

◆ distanceTo()

double AGPosition::distanceTo ( const AGPosition otherPos) const

Computes the distance between two AGPosition objects.

Parameters
[in]theother position the distance in computed to
Returns
the distance

Definition at line 61 of file AGPosition.cpp.

References Position::distanceTo(), and pos2d.

Referenced by AGChild::allocateASchool(), AGActivity::availableTranspMeans(), AGTrip::getRideBackArrTime(), AGTrip::getTimeTrip(), minDistanceTo(), AGActivity::possibleTranspMean(), and AGActivity::timeToDrive().

Here is the caller graph for this function:

◆ getPosition()

double AGPosition::getPosition ( ) const

Provides the relative position of this AGPosition on the street.

This relative position is the distance from the from node of the associated street.

Returns
the relative position

Definition at line 105 of file AGPosition.cpp.

References position.

Referenced by AGActivityTripWriter::addTrip(), AGWorkAndSchool::carsToTrips(), AGTrip::setArr(), and AGTrip::setDep().

Here is the caller graph for this function:

◆ getStreet()

const AGStreet & AGPosition::getStreet ( ) const

Provides the street this AGPosition is located on.

Returns
the street

Definition at line 99 of file AGPosition.cpp.

References street.

Referenced by AGActivityTripWriter::addTrip(), AGWorkAndSchool::carsToTrips(), AGTrip::setArr(), and AGTrip::setDep().

Here is the caller graph for this function:

◆ minDistanceTo() [1/2]

double AGPosition::minDistanceTo ( const std::list< AGPosition > &  positions) const

Computes the distance to the closest position in a list.

minDistanceTo computes the distance to all positions in the given list and returns the minimal distance.

Parameters
[in]positionsthe list of positions the distances are computed to
Returns
the minimal distance

Definition at line 67 of file AGPosition.cpp.

References distanceTo().

Referenced by AGActivity::availableTranspMeans(), AGHousehold::isCloseFromPubTransport(), and AGActivity::possibleTranspMean().

Here is the caller graph for this function:

◆ minDistanceTo() [2/2]

double AGPosition::minDistanceTo ( const std::map< int, AGPosition > &  positions) const

Computes the distance to the closest position in a map.

minDistanceTo computes the distance to all positions given as the second elements of a map and returns the minimal distance.

Parameters
[in]positionsthe map of positions the distances are computed to
Returns
the minimal distance

Definition at line 83 of file AGPosition.cpp.

References distanceTo().

◆ operator==()

bool AGPosition::operator== ( const AGPosition pos) const

Tests whether two positions are at the same place.

Compares the x and y coordinates with a threshold (see Position::almostSame)

Parameters
[in]posthe position with which the comparison is done
Returns
true if both AGPositions are (almost) at the same place

Definition at line 55 of file AGPosition.cpp.

References Position::almostSame(), and pos2d.

◆ print()

void AGPosition::print ( ) const

Prints out a summary of the properties of this class on standard output.

Definition at line 49 of file AGPosition.cpp.

References ROEdge::getLength(), position, and street.

Referenced by AGTrip::print(), and AGWorkPosition::print().

Here is the caller graph for this function:

◆ randomPositionInStreet()

double AGPosition::randomPositionInStreet ( const AGStreet street)
staticprivate

Determines a random relative position on a street.

Returns
the random relative position

Definition at line 111 of file AGPosition.cpp.

References ROEdge::getLength(), and RandHelper::rand().

Field Documentation

◆ pos2d

Position AGPosition::pos2d
private

Definition at line 134 of file AGPosition.h.

Referenced by distanceTo(), and operator==().

◆ position

double AGPosition::position
private

Definition at line 133 of file AGPosition.h.

Referenced by compute2dPosition(), getPosition(), and print().

◆ street

const AGStreet* AGPosition::street
private

Definition at line 132 of file AGPosition.h.

Referenced by compute2dPosition(), getStreet(), and print().


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