 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
56 for (std::vector<SUMOVehicleParameter::Stop>::const_iterator s = pars.
stops.begin(); s != pars.
stops.end(); ++s) {
59 if (pars.
via.size() != 0) {
63 for (std::vector<std::string>::const_iterator it = pars.
via.begin(); it != pars.
via.end(); ++it) {
74 assert(stopEdge != 0);
76 if (errorHandler !=
nullptr) {
77 errorHandler->
inform(
"Stop edge '" + stopEdge->
getID() +
"' does not allow vehicle '" +
getID() +
"'.");
82 std::vector<SUMOVehicleParameter::Stop>::iterator iter =
getParameter().
stops.begin();
83 ConstROEdgeVector::iterator edgeIter =
myStopEdges.begin();
92 ConstROEdgeVector::const_iterator stopEdgeIt = std::find(edges.begin(), edges.end(), stopEdge);
93 if (stopEdgeIt == edges.end()) {
98 if (edgeIter > stopEdgeIt || (edgeIter == stopEdgeIt && iter->endPos >= stopPar.
endPos)) {
106 iter += stopPar.
index;
107 edgeIter += stopPar.
index;
126 const bool removeLoops,
MsgHandler* errorHandler) {
128 std::string noRouteMsg =
"The vehicle '" +
getID() +
"' has no valid route.";
131 if (routeDef ==
nullptr) {
132 errorHandler->
inform(noRouteMsg);
137 if (current ==
nullptr || current->
size() == 0) {
139 errorHandler->
inform(noRouteMsg);
151 if (current->
size() == 0) {
153 errorHandler->
inform(noRouteMsg +
" (after removing loops)");
168 mandatory.push_back(requiredStart);
171 if (e->isInternal()) {
175 if (mandatory.size() == 0 || after != mandatory.back()) {
176 mandatory.push_back(before);
177 mandatory.push_back(after);
180 if (mandatory.size() == 0 || e != mandatory.back()) {
181 mandatory.push_back(e);
186 if (mandatory.size() < 2 || mandatory.back() != requiredEnd) {
187 mandatory.push_back(requiredEnd);
196 if (typeos !=
nullptr &&
getType() !=
nullptr && !
getType()->saved) {
205 const bool writeTrip = options.
exists(
"write-trips") && options.
getBool(
"write-trips");
206 const bool writeGeoTrip = writeTrip && options.
getBool(
"write-trips.geo");
213 const ROEdge* from =
nullptr;
214 const ROEdge* to =
nullptr;
215 if (edges.size() > 0) {
216 if (edges.front()->isTazConnector()) {
217 if (edges.size() > 1) {
223 if (edges.back()->isTazConnector()) {
224 if (edges.size() > 1) {
225 to = edges[edges.size() - 2];
228 to = edges[edges.size() - 1];
231 if (from !=
nullptr) {
266 assert(viaEdge !=
nullptr);
267 Position viaPos = viaEdge->
getLanes()[0]->getShape().positionAtOffset2D(viaEdge->
getLanes()[0]->getShape().length2D() / 2);
268 viaPositions.push_back(viaPos);
271 for (
int i = 0; i < (int)viaPositions.size(); i++) {
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
Adds an alternative to the list of routes.
bool myRoutingSuccess
Whether the last routing was successful.
The arrival position is given.
RORoute * buildCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Triggers building of the complete route (via preComputeCurrentRoute) or returns precomputed route.
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at, 0 for triggered vehicles.
std::string lane
The lane to stop at.
The arrival lane is given.
Static storage of an output device and its base (abstract) implementation.
void addStop(const SUMOVehicleParameter::Stop &stopPar, const RONet *net, MsgHandler *errorHandler)
Adds a stop to this vehicle.
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
const RORoute * getFirstRoute() const
void setPrecision(int precision=gPrecision)
Sets the precison or resets it to default.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
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)
Base class for a vehicle's route definition.
bool saved
Information whether this type was already saved (needed by routers)
The router's network representation.
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
Structure representing possible vehicle parameter.
const std::vector< ROLane * > & getLanes() const
Returns this edge's lanes.
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
int size() const
Returns the number of edges in this route.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void recheckForLoops(const ConstROEdgeVector &mandatory)
Checks whether this route contains loops and removes such.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
ROVehicle(const SUMOVehicleParameter &pars, RORouteDef *route, const SUMOVTypeParameter *type, const RONet *net, MsgHandler *errorHandler=0)
Constructor.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
Structure representing possible vehicle parameter.
ConstROEdgeVector getMandatoryEdges(const ROEdge *requiredStart, const ROEdge *requiredEnd) const
compute mandatory edges
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
const std::string & getID() const
Returns the id of the routable.
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, bool asAlternatives, bool withExitTimes) const
Saves the built route / route alternatives.
const ROEdge * getDepartEdge() const
Returns the first edge the vehicle takes.
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
A point in 2D or 3D with translation and scaling methods.
A complete router's route.
SUMOAbstractRouter< E, V > & getVehicleRouter() const
A storage for options typed value containers)
double endPos
The stopping position end.
const ROEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
void write(OutputDevice &dev) const
Writes the vtype.
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag tag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
const ConstROEdgeVector & getStopEdges() const
A routable thing such as a vehicle or person.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
bool prohibits(const ROVehicle *const vehicle) const
Returns whether this edge prohibits the given vehicle to pass it.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
int index
at which position in the stops list
const ROEdge * getFirst() const
Returns the first edge in the route.
A basic edge for routing applications.
void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)
const ROEdge * getNormalAfter() const
if this edge is an internal edge, return its first normal successor, otherwise the edge itself
virtual ~ROVehicle()
Destructor.
int gPrecision
the precision for floating point outputs
RORouteDef *const myRoute
The route the vehicle takes.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
const std::string & getID() const
Returns the id.
ConstROEdgeVector myStopEdges
The edges where the vehicle stops.
a single trip definition (used by router)
std::vector< const ROEdge * > ConstROEdgeVector
Definition of vehicle stop (position and duration)
void saveAsXML(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options) const
Saves the complete vehicle description.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the list of stops this route contains.