 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
54 for (std::vector<PlanItem*>::const_iterator it =
myPlan.begin(); it !=
myPlan.end(); ++it) {
62 const std::string& vTypes,
const double departPos,
const double arrivalPos,
const std::string& busStop,
double walkFactor) {
63 PersonTrip* trip =
new PersonTrip(from, to, modeSet, departPos, arrivalPos, busStop, walkFactor);
76 if (type ==
nullptr) {
104 myPlan.back()->addTripItem(
new Ride(from, to, lines, -1., arrivalPos, destStop));
113 myPlan.back()->addTripItem(
new Walk(edges, -1., duration, speed, departPos, arrivalPos, busStop));
119 myPlan.push_back(
new Stop(stopPar, stopEdge));
126 std::string comment =
"";
127 if (extended &&
cost >= 0.) {
130 if (
from !=
nullptr) {
140 comment =
" <!-- " + name +
" -->";
157 std::string comment =
"";
158 if (extended && cost >= 0.) {
168 if (arr != 0. && destStop ==
"") {
171 if (destStop !=
"") {
175 comment =
" <!-- " + name +
" -->";
184 for (
auto* item : myTripItems) {
192 for (std::vector<ROVehicle*>::const_iterator it = myVehicles.begin(); it != myVehicles.end(); ++it) {
193 (*it)->saveAsXML(os, typeos, asAlternatives, options);
202 Position fromPos = from->getLanes()[0]->getShape().positionAtOffset2D(getDepartPos());
215 Position toPos = to->getLanes()[0]->getShape().positionAtOffset2D(
MIN2(getArrivalPos(), to->getLanes()[0]->getShape().length2D()));
227 std::vector<std::string> allowedModes;
229 allowedModes.push_back(
"public");
232 allowedModes.push_back(
"car");
235 allowedModes.push_back(
"bicycle");
237 if (allowedModes.size() > 0) {
241 if (dep != 0 && dep != std::numeric_limits<double>::infinity()) {
244 if (arr != 0 && arr != std::numeric_limits<double>::infinity()) {
248 if (getStopDest() !=
"") {
251 if (walkFactor != 1) {
256 for (std::vector<TripItem*>::const_iterator it = myTripItems.begin(); it != myTripItems.end(); ++it) {
257 (*it)->saveAsXML(os, extended);
265 for (
TripItem* tItem : myTripItems) {
266 result += tItem->getDuration();
274 std::vector<ROIntermodalRouter::TripItem> result;
277 bool carUsed =
false;
278 for (std::vector<ROIntermodalRouter::TripItem>::const_iterator it = result.begin(); it != result.end(); ++it) {
279 if (!it->edges.empty()) {
280 if (it->line ==
"") {
281 if (it + 1 == result.end() && trip->
getStopDest() ==
"") {
286 }
else if (veh !=
nullptr && it->line == veh->
getID()) {
295 if (result.empty()) {
296 errorHandler->
inform(
"No route for trip in person '" +
getID() +
"'.");
308 for (std::vector<PlanItem*>::iterator it =
myPlan.begin(); it !=
myPlan.end(); ++it) {
309 if ((*it)->needsRouting()) {
311 std::vector<ROVehicle*>& vehicles = trip->
getVehicles();
312 if (vehicles.empty()) {
315 for (std::vector<ROVehicle*>::iterator v = vehicles.begin(); v != vehicles.end();) {
317 v = vehicles.erase(v);
324 time += (*it)->getDuration();
332 const bool writeTrip = options.
exists(
"write-trips") && options.
getBool(
"write-trips");
333 const bool writeGeoTrip = writeTrip && options.
getBool(
"write-trips.geo");
335 for (std::vector<PlanItem*>::const_iterator it =
myPlan.begin(); it !=
myPlan.end(); ++it) {
336 (*it)->saveVehicles(os, typeos, asAlternatives, options);
340 if (typeos !=
nullptr &&
getType() !=
nullptr && !
getType()->saved) {
352 for (std::vector<PlanItem*>::const_iterator it =
myPlan.begin(); it !=
myPlan.end(); ++it) {
353 (*it)->saveAsXML(os, asAlternatives, writeTrip, writeGeoTrip);
void saveAsXML(OutputDevice &os, const bool extended, const bool asTrip, const bool writeGeoTrip) const
bool myRoutingSuccess
Whether the last routing was successful.
const std::string intended
void addVehicle(ROVehicle *veh)
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color)
Static storage of an output device and its base (abstract) implementation.
bool hasNext()
returns the information whether further substrings exist
void saveVehicles(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options) const
A ride is part of a trip, e.g., go from here to here by car or bus.
std::string vtypeid
The vehicle's type id.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
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
void saveAsXML(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options) const
Saves the complete person description.
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)
@ SVC_BICYCLE
vehicle is a bicycle
Base class for a vehicle's route definition.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
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.
A vehicle as used by router.
Structure representing possible vehicle parameter.
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
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.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
A walk is part of a trip, e.g., go from here to here by foot.
void saveAsXML(OutputDevice &os, const bool extended) const
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Every person has a plan comprising of multiple planItems.
Structure representing possible vehicle parameter.
const std::string DEFAULT_VTYPE_ID
void addStop(const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
A planItem can be a Trip which contains multiple tripItems.
std::string id
The vehicle's id.
@ SUMO_ATTR_EDGES
the edges of a route
void addTrip(const ROEdge *const from, const ROEdge *const to, const SVCPermissions modeSet, const std::string &vTypes, const double departPos, const double arrivalPos, const std::string &busStop, double walkFactor)
const std::string & getID() const
Returns the id of the routable.
double getDepartPos(bool replaceDefault=true) const
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
A planItem can be a Stop.
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.
SUMOTime getDuration() const
return duration sum of all trip items
std::vector< ROVehicle * > & getVehicles()
std::string time2string(SUMOTime t)
A complete router's route.
void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)
A storage for options typed value containers)
@ DEPART_TRIGGERED
The departure is person triggered.
std::vector< TripItem * > myTripItems
the fully specified trips
void addWalk(const ConstROEdgeVector &edges, const double duration, const double speed, const double departPos, const double arrivalPos, const std::string &busStop)
void write(OutputDevice &dev) const
Writes the vtype.
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
std::vector< PlanItem * > myPlan
The plan of the person.
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.
A routable thing such as a vehicle or person.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const int VEHPARS_VTYPE_SET
virtual ~ROPerson()
Destructor.
ROPerson(const SUMOVehicleParameter &pars, const SUMOVTypeParameter *type)
Constructor.
const int VEHPARS_DEPARTPOS_SET
const std::string & getStopDest() const
IntermodalRouter< E, L, N, V > & getIntermodalRouter() const
void addRide(const ROEdge *const from, const ROEdge *const to, const std::string &lines, double arrivalPos, const std::string &destStop)
A basic edge for routing applications.
@ SVC_BUS
vehicle is a bus
int gPrecision
the precision for floating point outputs
void saveAsXML(OutputDevice &os, const bool extended) const
bool computeIntermodal(SUMOTime time, const RORouterProvider &provider, PersonTrip *const trip, const ROVehicle *const veh, MsgHandler *const errorHandler)
@ DEPART_POS_GIVEN
The position is given.
const std::string getStoppingPlaceName(const std::string &id) const
return the name for the given stopping place id
const ROEdge * getOrigin() const
A TripItem is part of a trip, e.g., go from here to here by car.
const ROEdge * getDestination() const
double getWalkFactor() const
SVCPermissions getModes() const
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
const std::string DEFAULT_BIKETYPE_ID
virtual void addTripItem(TripItem *tripIt)
const std::string & getID() const
Returns the id.
const std::string destStop
double getArrivalPos(bool replaceDefault=true) const
double departPos
(optional) The position the vehicle shall depart from
std::vector< const ROEdge * > ConstROEdgeVector
Definition of vehicle stop (position and duration)