 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
55 for (std::vector<PlanItem*>::const_iterator it =
myPlan.begin(); it !=
myPlan.end(); ++it) {
63 const std::string& vTypes,
const double departPos,
const double arrivalPos,
const std::string& busStop,
double walkFactor) {
64 PersonTrip* trip =
new PersonTrip(from, to, modeSet, departPos, arrivalPos, busStop, walkFactor);
77 if (type ==
nullptr) {
105 myPlan.back()->addTripItem(
new Ride(from, to, lines, -1., arrivalPos, destStop));
114 myPlan.back()->addTripItem(
new Walk(edges, -1., duration, speed, departPos, arrivalPos, busStop));
120 myPlan.push_back(
new Stop(stopPar, stopEdge));
127 std::string comment =
"";
128 if (extended &&
cost >= 0.) {
131 if (
from !=
nullptr) {
141 comment =
" <!-- " + name +
" -->";
158 std::string comment =
"";
159 if (extended && cost >= 0.) {
172 if (arr != 0. && destStop ==
"") {
175 if (destStop !=
"") {
179 comment =
" <!-- " + name +
" -->";
188 for (
auto* item : myTripItems) {
196 for (std::vector<ROVehicle*>::const_iterator it = myVehicles.begin(); it != myVehicles.end(); ++it) {
197 (*it)->saveAsXML(os, typeos, asAlternatives, options);
206 Position fromPos = from->getLanes()[0]->getShape().positionAtOffset2D(getDepartPos());
219 Position toPos = to->getLanes()[0]->getShape().positionAtOffset2D(
MIN2(getArrivalPos(), to->getLanes()[0]->getShape().length2D()));
231 std::vector<std::string> allowedModes;
233 allowedModes.push_back(
"public");
236 allowedModes.push_back(
"car");
239 allowedModes.push_back(
"bicycle");
241 if (allowedModes.size() > 0) {
245 if (dep != 0 && dep != std::numeric_limits<double>::infinity()) {
248 if (arr != 0 && arr != std::numeric_limits<double>::infinity()) {
252 if (getStopDest() !=
"") {
255 if (walkFactor != 1) {
260 for (std::vector<TripItem*>::const_iterator it = myTripItems.begin(); it != myTripItems.end(); ++it) {
261 (*it)->saveAsXML(os, extended);
269 for (
TripItem* tItem : myTripItems) {
270 result += tItem->getDuration();
278 std::vector<ROIntermodalRouter::TripItem> result;
281 bool carUsed =
false;
282 for (std::vector<ROIntermodalRouter::TripItem>::const_iterator it = result.begin(); it != result.end(); ++it) {
283 if (!it->edges.empty()) {
284 if (it->line ==
"") {
285 if (it + 1 == result.end() && trip->
getStopDest() ==
"") {
290 }
else if (veh !=
nullptr && it->line == veh->
getID()) {
299 if (result.empty()) {
300 errorHandler->
inform(
"No route for trip in person '" +
getID() +
"'.");
312 for (std::vector<PlanItem*>::iterator it =
myPlan.begin(); it !=
myPlan.end(); ++it) {
313 if ((*it)->needsRouting()) {
314 PersonTrip* trip = static_cast<PersonTrip*>(*it);
315 std::vector<ROVehicle*>& vehicles = trip->
getVehicles();
316 if (vehicles.empty()) {
319 for (std::vector<ROVehicle*>::iterator v = vehicles.begin(); v != vehicles.end();) {
321 v = vehicles.erase(v);
328 time += (*it)->getDuration();
336 const bool writeTrip = options.
exists(
"write-trips") && options.
getBool(
"write-trips");
337 const bool writeGeoTrip = writeTrip && options.
getBool(
"write-trips.geo");
339 for (std::vector<PlanItem*>::const_iterator it =
myPlan.begin(); it !=
myPlan.end(); ++it) {
340 (*it)->saveVehicles(os, typeos, asAlternatives, options);
344 if (typeos !=
nullptr &&
getType() !=
nullptr && !
getType()->saved) {
356 for (std::vector<PlanItem*>::const_iterator it =
myPlan.begin(); it !=
myPlan.end(); ++it) {
357 (*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)
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).
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
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.
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.
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)
The departure is person triggered.
double maxSpeed
The vehicle type's maximum speed [m/s].
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.
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)
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)