![]() |
SUMO - Simulation of Urban MObility
|
A location in the 2D plane freely positioned on a street. More...
#include <AGPosition.h>
Public Member Functions | |
AGPosition (const AGStreet &str, double pos) | |
Constructs an AGPosition at a certain point on a street. More... | |
AGPosition (const AGStreet &str) | |
Constructs an AGPosition at a random 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 AGStreet & | getStreet () 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 AGStreet * | street |
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).
Should this class be derived from Position?
Definition at line 63 of file AGPosition.h.
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 47 of file AGPosition.cpp.
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 52 of file AGPosition.cpp.
|
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!
Definition at line 126 of file AGPosition.cpp.
References Position::add(), ROEdge::getFromJunction(), ROEdge::getLength(), RONode::getPosition(), ROEdge::getToJunction(), Position::mul(), position, street, and Position::sub().
double AGPosition::distanceTo | ( | const AGPosition & | otherPos | ) | const |
Computes the distance between two AGPosition objects.
[in] | the | other position the distance in computed to |
Definition at line 70 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().
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.
Definition at line 114 of file AGPosition.cpp.
References position.
Referenced by AGActivityTripWriter::addTrip(), AGWorkAndSchool::carsToTrips(), AGTrip::setArr(), and AGTrip::setDep().
const AGStreet & AGPosition::getStreet | ( | ) | const |
Provides the street this AGPosition is located on.
Definition at line 108 of file AGPosition.cpp.
References street.
Referenced by AGActivityTripWriter::addTrip(), AGWorkAndSchool::carsToTrips(), AGTrip::setArr(), and AGTrip::setDep().
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.
[in] | positions | the list of positions the distances are computed to |
Definition at line 76 of file AGPosition.cpp.
References distanceTo().
Referenced by AGActivity::availableTranspMeans(), AGHousehold::isCloseFromPubTransport(), and AGActivity::possibleTranspMean().
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.
[in] | positions | the map of positions the distances are computed to |
Definition at line 92 of file AGPosition.cpp.
References distanceTo().
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)
[in] | pos | the position with which the comparison is done |
Definition at line 64 of file AGPosition.cpp.
References Position::almostSame(), and pos2d.
void AGPosition::print | ( | ) | const |
Prints out a summary of the properties of this class on standard output.
Definition at line 58 of file AGPosition.cpp.
References ROEdge::getLength(), position, and street.
Referenced by AGWorkPosition::print(), and AGTrip::print().
|
staticprivate |
Determines a random relative position on a street.
Definition at line 120 of file AGPosition.cpp.
References ROEdge::getLength(), and RandHelper::rand().
|
private |
Definition at line 144 of file AGPosition.h.
Referenced by distanceTo(), and operator==().
|
private |
Definition at line 143 of file AGPosition.h.
Referenced by compute2dPosition(), getPosition(), and print().
|
private |
Definition at line 142 of file AGPosition.h.
Referenced by compute2dPosition(), getStreet(), and print().