SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AGPosition Class Reference

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

#include <AGPosition.h>

Public Member Functions

 AGPosition (const AGStreet &str, SUMOReal pos)
 Constructs an AGPosition at a certain point on a street.
 AGPosition (const AGStreet &str)
 Constructs an AGPosition at a random point on a street.
SUMOReal distanceTo (const AGPosition &otherPos) const
 Computes the distance between two AGPosition objects.
SUMOReal getPosition () const
 Provides the relative position of this AGPosition on the street.
const AGStreetgetStreet () const
 Provides the street this AGPosition is located on.
SUMOReal minDistanceTo (const std::list< AGPosition > &positions) const
 Computes the distance to the closest position in a list.
SUMOReal 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 SUMOReal randomPositionInStreet (const AGStreet &street)
 Determines a random relative position on a street.

Private Attributes

Position pos2d
SUMOReal 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).

Should this class be derived from Position?

Definition at line 63 of file AGPosition.h.


Constructor & Destructor Documentation

AGPosition::AGPosition ( const AGStreet str,
SUMOReal  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.


Member Function Documentation

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 126 of file AGPosition.cpp.

References Position::add(), AGStreet::edge, ROEdge::getFromNode(), AGStreet::getLength(), RONode::getPosition(), ROEdge::getToNode(), Position::mul(), position, street, and Position::sub().

SUMOReal 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 70 of file AGPosition.cpp.

References Position::distanceTo(), and pos2d.

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

SUMOReal 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 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.

Returns:
the street

Definition at line 108 of file AGPosition.cpp.

References street.

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

SUMOReal 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 76 of file AGPosition.cpp.

References distanceTo(), and SUMOReal.

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

SUMOReal 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 92 of file AGPosition.cpp.

References distanceTo(), and SUMOReal.

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 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 AGStreet::getLength(), position, and street.

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

SUMOReal AGPosition::randomPositionInStreet ( const AGStreet street)
staticprivate

Determines a random relative position on a street.

Returns:
the random relative position

Definition at line 120 of file AGPosition.cpp.

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


Field Documentation

Position AGPosition::pos2d
private

Definition at line 144 of file AGPosition.h.

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

SUMOReal AGPosition::position
private

Definition at line 143 of file AGPosition.h.

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

const AGStreet* AGPosition::street
private

Definition at line 142 of file AGPosition.h.

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


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