41#define INVALID_STOP_POS -1
59 for (StopParVector::const_iterator s = route->
getFirstRoute()->getStops().begin(); s != route->
getFirstRoute()->getStops().end(); ++s) {
63 for (StopParVector::const_iterator s = pars.
stops.begin(); s != pars.
stops.end(); ++s) {
72 assert(stopEdge != 0);
74 if (errorHandler !=
nullptr) {
75 errorHandler->
inform(
"Stop edge '" + stopEdge->
getID() +
"' does not allow vehicle '" +
getID() +
"'.");
89 iter += stopPar.
index;
93 if (stopPar.
jump >= 0) {
95 if (errorHandler !=
nullptr) {
96 errorHandler->
inform(
"Jumps are not supported from internal stop edge '" + stopEdge->
getID() +
"'.");
119 const bool removeLoops,
MsgHandler* errorHandler) {
121 std::string noRouteMsg =
"The vehicle '" +
getID() +
"' has no valid route.";
124 if (routeDef ==
nullptr) {
125 errorHandler->
inform(noRouteMsg);
136 if (current ==
nullptr || current->size() == 0) {
138 errorHandler->
inform(noRouteMsg);
151 mandatory.push_back(m.edge);
153 current->recheckForLoops(mandatory);
155 if (current->size() == 0) {
156 errorHandler->
inform(noRouteMsg +
" (after removing loops)");
171 if (replaced !=
nullptr) {
186 if ((
int)oldRoute.size() > attr) {
187 const ROEdge* old = oldRoute[attr];
189 for (
int i = 0; i < attr; i++) {
190 if (oldRoute[i] == old) {
195 for (
const ROEdge* cand : current->getEdgeVector()) {
209std::vector<ROVehicle::Mandatory>
212 std::vector<Mandatory> mandatory;
214 double departPos = 0;
218 mandatory.push_back(
Mandatory(requiredStart, departPos));
236 mandatory.push_back(
Mandatory(e, endPos, stop.jump));
245 mandatory.push_back(
Mandatory(requiredEnd, arrivalPos));
253 if (typeos !=
nullptr &&
getType() !=
nullptr && !
getType()->saved) {
262 const bool writeTrip = options.
exists(
"write-trips") && options.
getBool(
"write-trips");
263 const bool writeGeoTrip = writeTrip && options.
getBool(
"write-trips.geo");
264 const bool writeJunctions = writeTrip && options.
getBool(
"write-trips.junctions");
265 const bool writeNamedRoute = !asAlternatives && options.
getBool(
"named-routes");
266 const bool writeCosts = options.
exists(
"write-costs") && options.
getBool(
"write-costs");
267 const bool writeExit = options.
exists(
"exit-times") && options.
getBool(
"exit-times");
268 const bool writeLength = options.
exists(
"route-length") && options.
getBool(
"route-length");
272 if (writeNamedRoute) {
278 writeLength, routeID);
281 routeID = it->second;
286 if (cloneIndex == 0) {
292 p.
write(os, options, tag);
297 const ROEdge* from =
nullptr;
298 const ROEdge* to =
nullptr;
299 if (edges.size() > 0) {
300 if (edges.front()->isTazConnector()) {
301 if (edges.size() > 1) {
303 if (from->
isTazConnector() && writeJunctions && edges.front()->getSuccessors().size() > 0) {
311 if (edges.back()->isTazConnector()) {
312 if (edges.size() > 1) {
313 to = edges[edges.size() - 2];
314 if (to->
isTazConnector() && writeJunctions && edges.back()->getPredecessors().size() > 0) {
320 to = edges[edges.size() - 1];
323 if (from !=
nullptr) {
334 }
else if (writeJunctions) {
351 }
else if (writeJunctions) {
358 std::vector<std::string> viaOut;
371 assert(viaEdge !=
nullptr);
373 Position viaPos = viaEdge->
getLanes()[0]->getShape().positionAtOffset2D(viaEdge->
getLanes()[0]->getShape().length2D() / 2);
380 }
else if (writeJunctions) {
383 viaOut.push_back(viaEdge->
getID());
388 }
else if (writeNamedRoute) {
std::vector< const ROEdge * > ConstROEdgeVector
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
@ GIVEN
The lane is given.
@ GIVEN
The position is given.
@ GIVEN
The arrival lane is given.
@ GIVEN
The arrival position is given.
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_TRIP
a single trip definition (used by router)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_FROM_JUNCTION
int gPrecision
the precision for floating point outputs
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
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)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
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 ATTR_TYPE &attr, const T &val, const bool isNull=false)
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
const RONode * getToJunction() const
bool isTazConnector() const
const RONode * getFromJunction() const
bool isInternal() const
return whether this edge is an internal edge
bool prohibits(const ROVehicle *const vehicle, bool checkRestrictions=false) const
Returns whether this edge prohibits the given vehicle to pass it.
const ROEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of incoming edges.
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
const std::vector< ROLane * > & getLanes() const
Returns this edge's lanes.
double getLength() const
Returns the length of the edge.
The router's network representation.
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
double getMaxTraveltime() const
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
A routable thing such as a vehicle or person.
SUMOVehicleClass getVClass() const
SUMOVehicleParameter & getParameterMutable()
bool isPartOfFlow() const
bool myRoutingSuccess
Whether the last routing was successful.
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
const std::string & getID() const
Returns the id of the routable.
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
Base class for a vehicle's route definition.
std::shared_ptr< RORoute > addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, std::shared_ptr< RORoute > current, SUMOTime begin, MsgHandler *errorHandler)
Adds an alternative to the list of routes and returns the route that was replaced or nullptr.
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes, bool withCost, bool withLength) const
Saves the built route / route alternatives.
std::shared_ptr< const RORoute > getFirstRoute() const
std::shared_ptr< RORoute > buildCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Triggers building of the complete route (via preComputeCurrentRoute) or returns precomputed route.
std::shared_ptr< const RORoute > getUsedRoute() const
void validateAlternatives(const ROVehicle *veh, MsgHandler *errorHandler)
removes invalid alternatives and raise an error or warning
bool discardSilent() const
whether this route shall be silently discarded
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.
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at, 0 for triggered vehicles.
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
void saveAsXML(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options, int cloneIndex=0) const
Saves the complete vehicle description.
ROVehicle(const SUMOVehicleParameter &pars, RORouteDef *route, const SUMOVTypeParameter *type, const RONet *net, MsgHandler *errorHandler=0)
Constructor.
virtual ~ROVehicle()
Destructor.
SUMOTime myJumpTime
Whether this vehicle has any jumps defined.
std::vector< Mandatory > getMandatoryEdges(const ROEdge *requiredStart, const ROEdge *requiredEnd) const
void updateIndex(const std::shared_ptr< RORoute > replaced, const std::shared_ptr< RORoute > current, int &attr)
update departEdge / arrivalEdge
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
virtual double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) 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.
int index
at which position in the stops list
SUMOTime jump
transfer time if there shall be a jump from this stop to the next route edge
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::string id
The vehicle's id.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
int departEdge
(optional) The initial edge within the route of the vehicle
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id, bool silent=false)
Interprets negative edge positions and fits them onto a given edge.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
information for mandatory edges