59 for (std::vector<SUMOVehicleParameter::Stop>::const_iterator s = pars.
stops.begin(); s != pars.
stops.end(); ++s) {
62 if (pars.
via.size() != 0) {
66 for (std::vector<std::string>::const_iterator it = pars.
via.begin(); it != pars.
via.end(); ++it) {
77 assert(stopEdge != 0);
79 if (errorHandler !=
nullptr) {
80 errorHandler->
inform(
"Stop edge '" + stopEdge->
getID() +
"' does not allow vehicle '" +
getID() +
"'.");
85 std::vector<SUMOVehicleParameter::Stop>::iterator iter =
getParameter().
stops.begin();
86 ConstROEdgeVector::iterator edgeIter =
myStopEdges.begin();
95 ConstROEdgeVector::const_iterator stopEdgeIt = std::find(edges.begin(), edges.end(), stopEdge);
96 if (stopEdgeIt == edges.end()) {
101 if (edgeIter > stopEdgeIt || (edgeIter == stopEdgeIt && iter->endPos >= stopPar.
endPos)) {
109 iter += stopPar.
index;
110 edgeIter += stopPar.
index;
129 const bool removeLoops,
MsgHandler* errorHandler) {
131 std::string noRouteMsg =
"The vehicle '" +
getID() +
"' has no valid route.";
134 if (routeDef ==
nullptr) {
135 errorHandler->
inform(noRouteMsg);
140 if (current ==
nullptr || current->
size() == 0) {
143 errorHandler->
inform(noRouteMsg);
156 if (current->
size() == 0) {
158 errorHandler->
inform(noRouteMsg +
" (after removing loops)");
173 mandatory.push_back(requiredStart);
176 if (e->isInternal()) {
180 if (mandatory.size() == 0 || after != mandatory.back()) {
181 mandatory.push_back(before);
182 mandatory.push_back(after);
185 if (mandatory.size() == 0 || e != mandatory.back()) {
186 mandatory.push_back(e);
191 if (mandatory.size() < 2 || mandatory.back() != requiredEnd) {
192 mandatory.push_back(requiredEnd);
201 if (typeos !=
nullptr &&
getType() !=
nullptr && !
getType()->saved) {
210 const bool writeTrip = options.
exists(
"write-trips") && options.
getBool(
"write-trips");
211 const bool writeGeoTrip = writeTrip && options.
getBool(
"write-trips.geo");
212 const bool writeJunctions = writeTrip && options.
getBool(
"write-trips.junctions");
213 const bool writeNamedRoute = !asAlternatives && options.
getBool(
"named-routes");
214 const bool writeCosts = options.
exists(
"write-costs") && options.
getBool(
"write-costs");
215 const bool writeExit = options.
exists(
"exit-times") && options.
getBool(
"exit-times");
216 const bool writeLength = options.
exists(
"route-length") && options.
getBool(
"route-length");
219 if (writeNamedRoute) {
225 writeLength, routeID);
228 routeID = it->second;
237 const ROEdge* from =
nullptr;
238 const ROEdge* to =
nullptr;
239 if (edges.size() > 0) {
240 if (edges.front()->isTazConnector()) {
241 if (edges.size() > 1) {
243 if (from->
isTazConnector() && writeJunctions && edges.front()->getSuccessors().size() > 0) {
251 if (edges.back()->isTazConnector()) {
252 if (edges.size() > 1) {
253 to = edges[edges.size() - 2];
254 if (to->
isTazConnector() && writeJunctions && edges.back()->getPredecessors().size() > 0) {
260 to = edges[edges.size() - 1];
263 if (from !=
nullptr) {
274 }
else if (writeJunctions) {
291 }
else if (writeJunctions) {
298 std::vector<std::string> viaOut;
311 assert(viaEdge !=
nullptr);
313 Position viaPos = viaEdge->
getLanes()[0]->getShape().positionAtOffset2D(viaEdge->
getLanes()[0]->getShape().length2D() / 2);
320 }
else if (writeJunctions) {
323 viaOut.push_back(viaEdge->
getID());
328 }
else if (writeNamedRoute) {
333 for (std::vector<SUMOVehicleParameter::Stop>::const_iterator stop =
getParameter().stops.begin(); stop !=
getParameter().stops.end(); ++stop) {
std::vector< const ROEdge * > ConstROEdgeVector
@ GIVEN
The lane is given.
@ GIVEN
The position is given.
@ GIVEN
The arrival lane is given.
@ GIVEN
The arrival position is given.
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_TRIP
a single trip definition (used by router)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
int gPrecision
the precision for floating point outputs
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precision or resets it to default.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
A basic edge for routing applications.
const ROEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
const ROEdge * getNormalAfter() const
if this edge is an internal edge, return its first normal successor, otherwise the edge itself
bool isTazConnector() const
bool prohibits(const ROVehicle *const vehicle) const
Returns whether this edge prohibits the given vehicle to pass it.
const RONode * getFromJunction() const
const std::vector< ROLane * > & getLanes() const
Returns this edge's lanes.
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
const ROEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of incoming edges.
const RONode * getToJunction() const
The router's network representation.
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
A routable thing such as a vehicle or person.
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
const std::string & getID() const
Returns the id of the routable.
SUMOVehicleClass getVClass() const
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
bool myRoutingSuccess
Whether the last routing was successful.
Base class for a vehicle's route definition.
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const
Saves the built route / route alternatives.
RORoute * buildCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Triggers building of the complete route (via preComputeCurrentRoute) or returns precomputed route.
const RORoute * getFirstRoute() const
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
Adds an alternative to the list of routes.
const RORoute * getUsedRoute() const
bool discardSilent() const
whether this route shall be silently discarded
A complete router's route.
const ROEdge * getFirst() const
Returns the first edge in the route.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the list of stops this route contains.
int size() const
Returns the number of edges in this route.
ConstROEdgeVector getNormalEdges() const
return edges that shall be written in the route definition
void recheckForLoops(const ConstROEdgeVector &mandatory)
Checks whether this route contains loops and removes such.
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, const bool withCosts, const bool withProb, const bool withExitTimes, const bool withLength, const std::string &id="") const
const ConstROEdgeVector & getStopEdges() const
static std::map< ConstROEdgeVector, std::string > mySavedRoutes
map of all routes that were already saved with a name
const ROEdge * getDepartEdge() const
Returns the first edge the vehicle takes.
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at, 0 for triggered vehicles.
ConstROEdgeVector getMandatoryEdges(const ROEdge *requiredStart, const ROEdge *requiredEnd) const
compute mandatory edges
void saveAsXML(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options) const
Saves the complete vehicle description.
ConstROEdgeVector myStopEdges
The edges where the vehicle stops.
ROVehicle(const SUMOVehicleParameter &pars, RORouteDef *route, const SUMOVTypeParameter *type, const RONet *net, MsgHandler *errorHandler=0)
Constructor.
virtual ~ROVehicle()
Destructor.
void addStop(const SUMOVehicleParameter::Stop &stopPar, const RONet *net, MsgHandler *errorHandler)
Adds a stop to this vehicle.
void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)
RORouteDef *const myRoute
The route the vehicle takes.
SUMOAbstractRouter< E, V > & getVehicleRouter(SUMOVehicleClass svc) const
Structure representing possible vehicle parameter.
void write(OutputDevice &dev) const
Writes the vtype.
bool saved
Information whether this type was already saved (needed by routers)
Definition of vehicle stop (position and duration)
std::string edge
The edge to stop at (used only in NETEDIT)
int index
at which position in the stops list
double endPos
The stopping position end.
Structure representing possible vehicle parameter.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.