45 #ifdef CHECK_MEMORY_LEAKS
47 #endif // CHECK_MEMORY_LEAKS
62 const bool isPermanent,
const RGBColor*
const c,
63 const std::vector<SUMOVehicleParameter::Stop>& stops)
64 :
Named(id), myEdges(edges), myAmPermanent(isPermanent),
65 myReferenceCounter(isPermanent ? 1 : 0),
66 myColor(c), myStops(stops) {}
88 return (
unsigned)
myEdges.size();
128 myDistDict[id] = std::make_pair(routeDist, permanent);
137 RouteDict::iterator it =
myDict.find(
id);
139 RouteDistDict::iterator it2 =
myDistDict.find(
id);
140 if (it2 ==
myDistDict.end() || it2->second.first->getOverallProb() == 0) {
143 return it2->second.first->get(rng);
151 RouteDistDict::iterator it2 =
myDistDict.find(
id);
155 return it2->second.first;
162 delete i->second.first;
165 for (RouteDict::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
174 RouteDistDict::iterator it =
myDistDict.find(
id);
175 if (it !=
myDistDict.end() && !it->second.second) {
176 const std::vector<const MSRoute*>& routes = it->second.first->getVals();
177 for (std::vector<const MSRoute*>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
180 delete it->second.first;
189 for (RouteDict::const_iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
190 into.push_back((*i).first);
193 into.push_back((*i).first);
201 ConstMSEdgeVector::const_iterator i =
myEdges.begin();
205 for (; i !=
myEdges.end(); ++i) {
211 if (upTo || i !=
myEdges.end() - 1) {
221 MSEdgeVector::const_iterator i = edgelist.begin();
222 for (; i != edgelist.end(); ++i) {
239 for (RouteDict::iterator it =
myDict.begin(); it !=
myDict.end(); ++it) {
256 const MSEdge* fromEdge,
const MSEdge* toEdge,
bool includeInternal)
const {
257 ConstMSEdgeVector::const_iterator it = std::find(
myEdges.begin(),
myEdges.end(), fromEdge);
262 ConstMSEdgeVector::const_iterator it2 = std::find(it + 1,
myEdges.end(), toEdge);
264 if (fromEdge == toEdge) {
265 if (fromPos < toPos) {
266 return toPos - fromPos;
267 }
else if (it2 ==
myEdges.end()) {
279 bool isFirstIteration =
true;
282 if (fromEdge == toEdge) {
284 if (fromPos <= toPos) {
285 return toPos - fromPos;
290 }
else if (fromEdge > toEdge) {
294 for (; it !=
end(); ++it) {
295 if (it == toEdge && !isFirstIteration) {
299 const std::vector<MSLane*>& lanes = (*it)->getLanes();
300 distance += lanes[0]->getLength();
301 #ifdef HAVE_INTERNAL_LANES
302 if (includeInternal) {
304 for (std::vector<MSLane*>::const_iterator laneIt = lanes.begin(); laneIt != lanes.end(); ++laneIt) {
305 const MSLinkCont& links = (*laneIt)->getLinkCont();
306 for (MSLinkCont::const_iterator linkIt = links.begin(); linkIt != links.end(); ++linkIt) {
307 if ((*linkIt) == 0 || (*linkIt)->getLane() == 0) {
310 std::string succLaneId = (*(it + 1))->getLanes()[0]->getID();
311 if ((*linkIt)->getLane()->getID().compare(succLaneId) == 0) {
312 distance += (*linkIt)->getLength();
321 isFirstIteration =
false;
336 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.
const MSEdge * getLastEdge() const
returns the destination edge
std::vector< const MSEdge * > ConstMSEdgeVector
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
#define UNUSED_PARAMETER(x)
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)
SUMOReal getDistanceBetween(SUMOReal fromPos, SUMOReal toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
static RouteDistDict myDistDict
The dictionary container.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
MSRoute(const std::string &id, const ConstMSEdgeVector &edges, const bool isPermanent, const RGBColor *const c, const std::vector< SUMOVehicleParameter::Stop > &stops)
Constructor.
ConstMSEdgeVector::const_iterator MSRouteIterator
bool contains(const MSEdge *const edge) const
std::map< std::string, std::pair< RandomDistributor< const MSRoute * > *, bool > > RouteDistDict
Definition of the dictionary container.
virtual ~MSRoute()
Destructor.
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.
ConstMSEdgeVector myEdges
The list of edges to pass.
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.
std::vector< MSEdge * > MSEdgeVector
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 void checkDist(const std::string &id)
Checks the distribution whether it is permanent and deletes it if not.
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.
bool containsAnyOf(const MSEdgeVector &edgelist) const