44 #ifdef CHECK_MEMORY_LEAKS
46 #endif // CHECK_MEMORY_LEAKS
62 unsigned int references,
const RGBColor*
const c,
63 const std::vector<SUMOVehicleParameter::Stop>& stops)
64 :
Named(id), myEdges(edges),
65 myReferenceCounter(references),
66 myColor(c), myStops(stops) {}
88 return (
unsigned)
myEdges.size();
137 RouteDict::iterator it =
myDict.find(
id);
139 RouteDistDict::iterator it2 =
myDistDict.find(
id);
140 if (it2 ==
myDistDict.end() || it2->second->getOverallProb() == 0) {
143 return it2->second->get();
151 RouteDistDict::iterator it2 =
myDistDict.find(
id);
165 for (RouteDict::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
175 for (RouteDict::const_iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
176 into.push_back((*i).first);
179 into.push_back((*i).first);
187 MSEdgeVector::const_iterator i =
myEdges.begin();
191 for (; i !=
myEdges.end(); ++i) {
197 if (upTo || i !=
myEdges.end() - 1) {
207 std::vector<MSEdge*>::const_iterator i = edgelist.begin();
208 for (; i != edgelist.end(); ++i) {
225 for (RouteDict::iterator it =
myDict.begin(); it !=
myDict.end(); ++it) {
242 for (MSEdgeVector::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
243 ret += (*i)->getLength();
251 bool isFirstIteration =
true;
253 MSEdgeVector::const_iterator it = std::find(
myEdges.begin(),
myEdges.end(), fromEdge);
259 if (fromEdge == toEdge && fromPos <= toPos) {
261 return (toPos - fromPos);
263 for (; it !=
end(); ++it) {
264 if ((*it) == toEdge && !isFirstIteration) {
268 const std::vector<MSLane*>& lanes = (*it)->getLanes();
269 distance += lanes[0]->getLength();
270 #ifdef HAVE_INTERNAL_LANES
272 for (std::vector<MSLane*>::const_iterator laneIt = lanes.begin(); laneIt != lanes.end(); ++laneIt) {
273 const MSLinkCont& links = (*laneIt)->getLinkCont();
274 for (MSLinkCont::const_iterator linkIt = links.begin(); linkIt != links.end(); ++linkIt) {
275 if ((*linkIt) == 0 || (*linkIt)->getLane() == 0) {
278 std::string succLaneId = (*(it + 1))->getLanes()[0]->getID();
279 if ((*linkIt)->getLane()->getID().compare(succLaneId) == 0) {
280 distance += (*linkIt)->getLength();
286 isFirstIteration =
false;
301 const std::vector<SUMOVehicleParameter::Stop>&
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
std::map< std::string, const MSRoute * > RouteDict
Definition of the dictionary container.
int writeEdgeIDs(OutputDevice &os, const MSEdge *const from, const MSEdge *const upTo=0) const
Output the edge ids up to but not including the id of the given edge.
MSEdgeVector::const_iterator MSRouteIterator
const MSEdge * getLastEdge() const
returns the destination edge
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
SUMOReal getDistanceBetween(SUMOReal fromPos, SUMOReal toPos, const MSEdge *fromEdge, const MSEdge *toEdge) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
static void dict_saveState(OutputDevice &out)
Saves all known routes into the given stream.
static void insertIDs(std::vector< std::string > &into)
A road/street connecting two junctions.
static void clear()
Clears the dictionary (delete all known routes, too)
std::map< std::string, RandomDistributor< const MSRoute * > * > RouteDistDict
Definition of the dictionary container.
std::vector< const MSEdge * > MSEdgeVector
bool containsAnyOf(const std::vector< MSEdge * > &edgelist) const
static RouteDistDict myDistDict
The dictionary container.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
MSEdgeVector myEdges
The list of edges to pass.
bool contains(const MSEdge *const edge) const
virtual ~MSRoute()
Destructor.
SUMOReal getLength() const
void addReference() const
increments the reference counter for the route
std::vector< SUMOVehicleParameter::Stop > myStops
List of the stops on the parsed route.
Base class for objects which have an id.
std::string myID
The name of the object.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
MSRoute(const std::string &id, const MSEdgeVector &edges, unsigned int references, const RGBColor *const c, const std::vector< SUMOVehicleParameter::Stop > &stops)
Constructor.
unsigned size() const
Returns the number of edges to pass.
const MSEdge * operator[](unsigned index) const
Static storage of an output device and its base (abstract) implementation.
const RGBColor & getColor() const
Returns the color.
bool closeTag()
Closes the most recently opened tag.
unsigned int myReferenceCounter
Information by how many vehicles the route is used.
void release() const
deletes the route if there are no further references to it
static unsigned int MaxRouteDistSize
the maximum size for each routeDistribution
static RouteDict myDict
The dictionary container.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
const RGBColor *const myColor
The color.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.