 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
44 FXMutex MSRoute::myDictMutex(
true);
53 const bool isPermanent,
const RGBColor*
const c,
54 const std::vector<SUMOVehicleParameter::Stop>& stops) :
55 Named(id), myEdges(edges), myAmPermanent(isPermanent),
56 myReferenceCounter(isPermanent ? 1 : 0),
104 FXMutexLock f(myDictMutex);
115 FXMutexLock f(myDictMutex);
128 FXMutexLock f(myDictMutex);
131 myDistDict[id] = std::make_pair(routeDist, permanent);
141 FXMutexLock f(myDictMutex);
143 RouteDict::iterator it =
myDict.find(
id);
145 RouteDistDict::iterator it2 =
myDistDict.find(
id);
146 if (it2 ==
myDistDict.end() || it2->second.first->getOverallProb() == 0) {
149 return it2->second.first->get(rng);
158 FXMutexLock f(myDictMutex);
160 RouteDistDict::iterator it2 =
myDistDict.find(
id);
164 return it2->second.first;
171 FXMutexLock f(myDictMutex);
174 delete i->second.first;
177 for (RouteDict::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
187 FXMutexLock f(myDictMutex);
189 RouteDistDict::iterator it =
myDistDict.find(
id);
190 if (it !=
myDistDict.end() && !it->second.second) {
191 const std::vector<const MSRoute*>& routes = it->second.first->getVals();
192 for (std::vector<const MSRoute*>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
195 delete it->second.first;
204 FXMutexLock f(myDictMutex);
207 for (RouteDict::const_iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
208 into.push_back((*i).first);
211 into.push_back((*i).first);
219 ConstMSEdgeVector::const_iterator i =
myEdges.begin();
220 if (from !=
nullptr) {
223 for (; i !=
myEdges.end(); ++i) {
229 if (upTo || i !=
myEdges.end() - 1) {
239 MSEdgeVector::const_iterator i = edgelist.begin();
240 for (; i != edgelist.end(); ++i) {
258 FXMutexLock f(myDictMutex);
260 for (RouteDict::iterator it =
myDict.begin(); it !=
myDict.end(); ++it) {
266 if (item.second.first->getVals().size() > 0) {
279 const MSEdge* fromEdge,
const MSEdge* toEdge,
bool includeInternal,
int routePosition)
const {
281 if (routePosition < 0 || routePosition >= (
int)
myEdges.size()) {
286 if (fromEdge == toEdge) {
287 if (fromPos <= toPos) {
288 return toPos - fromPos;
291 return fromEdge->
getLength() - fromPos + toPos;
295 if (fromEdge ==
myEdges.front()) {
313 ConstMSEdgeVector::const_iterator it = std::find(
myEdges.begin() + routePosition,
myEdges.end(), fromEdge);
316 return std::numeric_limits<double>::max();
318 ConstMSEdgeVector::const_iterator it2 = std::find(it + 1,
myEdges.end(), toEdge);
320 if (fromEdge == toEdge) {
321 if (fromPos <= toPos) {
322 return toPos - fromPos;
323 }
else if (it2 ==
myEdges.end()) {
325 return std::numeric_limits<double>::max();
335 bool isFirstIteration =
true;
336 double distance = -fromPos;
338 if (fromEdge == toEdge) {
340 if (fromPos <= toPos) {
341 return toPos - fromPos;
344 return std::numeric_limits<double>::max();
346 }
else if (fromEdge > toEdge) {
348 return std::numeric_limits<double>::max();
350 for (; it !=
end(); ++it) {
351 if (it == toEdge && !isFirstIteration) {
355 distance += (*it)->getLength();
356 if (includeInternal && (it + 1) !=
end()) {
357 distance += (*it)->getInternalFollowingLengthTo(*(it + 1));
360 isFirstIteration =
false;
375 const std::vector<SUMOVehicleParameter::Stop>&
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.
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
const RGBColor *const myColor
The color.
void release() const
deletes the route if there are no further references to it
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Base class for objects which have an id.
Static storage of an output device and its base (abstract) implementation.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
ConstMSEdgeVector::const_iterator MSRouteIterator
std::map< std::string, const MSRoute * > RouteDict
Definition of the dictionary container.
const MSEdge * getLastEdge() const
returns the destination edge
std::vector< const MSEdge * > ConstMSEdgeVector
const RGBColor & getColor() const
Returns the color.
double getLength() const
return the length of the edge
static void insertIDs(std::vector< std::string > &into)
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
MSRoute(const std::string &id, const ConstMSEdgeVector &edges, const bool isPermanent, const RGBColor *const c, const std::vector< SUMOVehicleParameter::Stop > &stops)
Constructor.
bool isInternal() const
return whether this edge is an internal edge
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
int size() const
Returns the number of edges to pass.
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
std::vector< SUMOVehicleParameter::Stop > myStops
List of the stops on the parsed route.
virtual ~MSRoute()
Destructor.
static void clear()
Clears the dictionary (delete all known routes, too)
static void dict_saveState(OutputDevice &out)
Saves all known routes into the given stream.
const MSEdge * operator[](int index) const
A road/street connecting two junctions.
const MSJunction * getToJunction() const
static RouteDistDict myDistDict
The dictionary container.
int myReferenceCounter
Information by how many vehicles the route is used.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
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.
std::map< std::string, std::pair< RandomDistributor< const MSRoute * > *, bool > > RouteDistDict
Definition of the dictionary container.
std::vector< MSEdge * > MSEdgeVector
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
begin/end of the description of a route
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
void addReference() const
increments the reference counter for the route
bool containsAnyOf(const MSEdgeVector &edgelist) const
ConstMSEdgeVector myEdges
The list of edges to pass.
bool contains(const MSEdge *const edge) const
std::string myID
The name of the object.
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true, int routePosition=0) const
Compute the distance between 2 given edges on this route, including the length of internal lanes....
const MSEdgeVector & getPredecessors() const