53 for (std::vector<PlanItem*>::const_iterator it =
myPlan.begin(); it !=
myPlan.end(); ++it) {
61 const std::string& vTypes,
const double departPos,
const double arrivalPos,
62 const std::string& busStop,
double walkFactor,
const std::string& group) {
63 PersonTrip* trip =
new PersonTrip(from, to, modeSet, departPos, arrivalPos, busStop, walkFactor, group);
76 if (type ==
nullptr) {
113 double arrivalPos,
const std::string& destStop,
const std::string& group) {
117 myPlan.back()->addTripItem(
new Ride(from, to, lines, group, -1., arrivalPos, destStop));
126 myPlan.back()->addTripItem(
new Walk(edges, -1., duration, speed, departPos, arrivalPos, busStop));
132 myPlan.push_back(
new Stop(stopPar, stopEdge));
139 std::string comment =
"";
140 if (extended &&
cost >= 0.) {
143 if (
from !=
nullptr) {
153 comment =
" <!-- " + name +
" -->";
155 }
else if (
arr != 0 &&
arr != std::numeric_limits<double>::infinity()) {
175 std::string comment =
"";
176 if (extended && cost >= 0.) {
186 if (destStop !=
"") {
190 comment =
" <!-- " + name +
" -->";
192 }
else if (arr != 0 && arr != std::numeric_limits<double>::infinity()) {
201 for (
auto* item : myTripItems) {
211 veh->saveAsXML(os, typeos, asAlternatives, options);
218 if ((asTrip || extended) && from !=
nullptr) {
221 Position fromPos = from->getLanes()[0]->getShape().positionAtOffset2D(getDepartPos());
234 Position toPos = to->getLanes()[0]->getShape().positionAtOffset2D(
MIN2(getArrivalPos(), to->getLanes()[0]->getShape().length2D()));
246 std::vector<std::string> allowedModes;
248 allowedModes.push_back(
"public");
251 allowedModes.push_back(
"car");
254 allowedModes.push_back(
"taxi");
257 allowedModes.push_back(
"bicycle");
259 if (allowedModes.size() > 0) {
263 if (dep != 0 && dep != std::numeric_limits<double>::infinity()) {
266 if (arr != 0 && arr != std::numeric_limits<double>::infinity()) {
270 if (getStopDest() !=
"") {
273 if (walkFactor != 1) {
276 if (extended && myTripItems.size() != 0) {
277 std::vector<double> costs;
278 for (
TripItem* tripItem : myTripItems) {
279 costs.push_back(tripItem->getCost());
285 for (std::vector<TripItem*>::const_iterator it = myTripItems.begin(); it != myTripItems.end(); ++it) {
286 (*it)->saveAsXML(os, extended);
294 for (
TripItem* tItem : myTripItems) {
295 result += tItem->getDuration();
303 std::vector<ROIntermodalRouter::TripItem> result;
306 bool carUsed =
false;
307 for (std::vector<ROIntermodalRouter::TripItem>::const_iterator it = result.begin(); it != result.end(); ++it) {
308 const auto& item = *it;
309 if (!item.edges.empty()) {
310 if (item.line ==
"") {
315 const ROEdge* first = item.edges.front();
324 const ROEdge* last = item.edges.back();
331 if (it + 1 == result.end() && trip->
getStopDest() ==
"") {
334 trip->
addTripItem(
new Walk(item.edges, item.cost, depPos, arrPos, item.destStop));
336 }
else if (veh !=
nullptr && item.line == veh->
getID()) {
337 trip->
addTripItem(
new Ride(item.edges.front(), item.edges.back(), veh->
getID(), trip->
getGroup(), item.cost, item.arrivalPos, item.destStop));
349 if (result.empty()) {
350 errorHandler->
inform(
"No route for trip in person '" +
getID() +
"'.");
362 for (std::vector<PlanItem*>::iterator it =
myPlan.begin(); it !=
myPlan.end(); ++it) {
363 if ((*it)->needsRouting()) {
365 std::vector<ROVehicle*>& vehicles = trip->
getVehicles();
366 if (vehicles.empty()) {
369 for (std::vector<ROVehicle*>::iterator v = vehicles.begin(); v != vehicles.end();) {
371 v = vehicles.erase(v);
378 time += (*it)->getDuration();
386 const bool writeTrip = options.
exists(
"write-trips") && options.
getBool(
"write-trips");
387 const bool writeGeoTrip = writeTrip && options.
getBool(
"write-trips.geo");
389 for (std::vector<PlanItem*>::const_iterator it =
myPlan.begin(); it !=
myPlan.end(); ++it) {
390 (*it)->saveVehicles(os, typeos, asAlternatives, options);
394 if (typeos !=
nullptr &&
getType() !=
nullptr && !
getType()->saved) {
406 for (std::vector<PlanItem*>::const_iterator it =
myPlan.begin(); it !=
myPlan.end(); ++it) {
407 (*it)->saveAsXML(os, asAlternatives, writeTrip, writeGeoTrip);
std::vector< const ROEdge * > ConstROEdgeVector
std::string time2string(SUMOTime t)
convert SUMOTime to string
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_TAXI
vehicle is a taxi
@ SVC_BUS
vehicle is a bus
const std::string DEFAULT_TAXITYPE_ID
const std::string DEFAULT_VTYPE_ID
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const std::string DEFAULT_BIKETYPE_ID
@ GIVEN
The position is given.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_VTYPE_SET
@ DEPART_TRIGGERED
The departure is person triggered.
@ SUMO_ATTR_EDGES
the edges of a route
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...
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 & openTag(const std::string &xmlElement)
Opens an XML tag.
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 precison 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.
bool isTazConnector() const
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
double getLength() const
Returns the length of the edge.
const ROEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of incoming edges.
The router's network representation.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
const std::string getStoppingPlaceName(const std::string &id) const
return the name for the given stopping place id
A planItem can be a Trip which contains multiple tripItems.
double getDepartPos(bool replaceDefault=true) const
void saveVehicles(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options) const
SVCPermissions getModes() const
void updateMOdes(SVCPermissions additionalModes)
void saveAsXML(OutputDevice &os, const bool extended, const bool asTrip, const bool writeGeoTrip) const
const std::string & getStopDest() const
double getWalkFactor() const
SUMOTime getDuration() const
return duration sum of all trip items
double getArrivalPos(bool replaceDefault=true) const
const ROEdge * getDestination() const
virtual void addTripItem(TripItem *tripIt)
std::vector< ROVehicle * > & getVehicles()
const std::string & getGroup() const
std::vector< TripItem * > myTripItems
the fully specified trips
void addVehicle(ROVehicle *veh)
const ROEdge * getOrigin() const
Every person has a plan comprising of multiple planItems.
A ride is part of a trip, e.g., go from here to here by car or bus.
const std::string destStop
const std::string intended
void saveAsXML(OutputDevice &os, const bool extended) const
A planItem can be a Stop.
A TripItem is part of a trip, e.g., go from here to here by car.
A walk is part of a trip, e.g., go from here to here by foot.
void saveAsXML(OutputDevice &os, const bool extended) const
void addRide(const ROEdge *const from, const ROEdge *const to, const std::string &lines, double arrivalPos, const std::string &destStop, const std::string &group)
virtual ~ROPerson()
Destructor.
ROPerson(const SUMOVehicleParameter &pars, const SUMOVTypeParameter *type)
Constructor.
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 &group)
void computeRoute(const RORouterProvider &provider, const bool removeLoops, MsgHandler *errorHandler)
void addWalk(const ConstROEdgeVector &edges, const double duration, const double speed, const double departPos, const double arrivalPos, const std::string &busStop)
void addStop(const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
bool computeIntermodal(SUMOTime time, const RORouterProvider &provider, PersonTrip *const trip, const ROVehicle *const veh, MsgHandler *const errorHandler)
void saveAsXML(OutputDevice &os, OutputDevice *const typeos, bool asAlternatives, OptionsCont &options) const
Saves the complete person description.
std::vector< PlanItem * > myPlan
The plan of the person.
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.
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
A complete router's route.
void setProbability(double prob)
Sets the probability of the route.
A vehicle as used by router.
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
IntermodalRouter< E, L, N, V > & getIntermodalRouter() 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)
SUMOVehicleClass vehicleClass
The vehicle's class.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
std::string vtypeid
The vehicle's type id.
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.
double departPos
(optional) The position the vehicle shall depart from
std::string id
The vehicle's id.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
bool hasNext()
returns the information whether further substrings exist