Eclipse 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) | |
Constructs an AGPosition at a random point on a street. | |
AGPosition (const AGStreet &str, double pos) | |
Constructs an AGPosition at a certain point on a street. | |
double | distanceTo (const AGPosition &otherPos) const |
Computes the distance between two AGPosition objects. | |
double | getPosition () const |
Provides the relative position of this AGPosition on the street. | |
const AGStreet & | getStreet () const |
Provides the street this AGPosition is located on. | |
double | minDistanceTo (const std::list< AGPosition > &positions) const |
Computes the distance to the closest position in a list. | |
double | minDistanceTo (const std::map< int, AGPosition > &positions) const |
Computes the distance to the closest position in a map. | |
bool | operator== (const AGPosition &pos) const |
Tests whether two positions are at the same place. | |
void | print () const |
Prints out a summary of the properties of this class on standard output. | |
Private Member Functions | |
Position | compute2dPosition () const |
Static Private Member Functions | |
static double | randomPositionInStreet (const AGStreet &street) |
Determines a random relative position on a street. | |
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).
@TODO Should this class be derived from Position?
Definition at line 53 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 38 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 43 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 117 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 61 of file AGPosition.cpp.
References Position::distanceTo(), and pos2d.
Referenced by AGChild::allocateASchool(), AGActivity::availableTranspMeans(), AGTrip::getRideBackArrTime(), AGTrip::getTimeTrip(), minDistanceTo(), 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 105 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 99 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 67 of file AGPosition.cpp.
References distanceTo().
Referenced by AGActivity::availableTranspMeans(), AGHousehold::isCloseFromPubTransport(), 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 83 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 55 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 49 of file AGPosition.cpp.
References ROEdge::getLength(), position, and street.
Referenced by AGTrip::print(), and AGWorkPosition::print().
|
staticprivate |
Determines a random relative position on a street.
Definition at line 111 of file AGPosition.cpp.
References ROEdge::getLength(), and RandHelper::rand().
|
private |
Definition at line 134 of file AGPosition.h.
Referenced by distanceTo(), and operator==().
|
private |
Definition at line 133 of file AGPosition.h.
Referenced by compute2dPosition(), getPosition(), and print().
|
private |
Definition at line 132 of file AGPosition.h.
Referenced by compute2dPosition(), getStreet(), and print().