61 const bool emptyDestinationsAllowed,
62 const bool ignoreErrors) :
66 myActiveContainerPlan(0),
67 myActiveContainerPlanSize(0),
68 myTryRepair(tryRepair),
69 myEmptyDestinationsAllowed(emptyDestinationsAllowed),
72 myKeepVTypeDist(
OptionsCont::getOptions().getBool(
"keep-vtype-distributions")),
73 myCurrentVTypeDistribution(0),
74 myCurrentAlternatives(0) {
112 for (ConstROEdgeVector::const_iterator i = viaEdges.begin(); i != viaEdges.end(); ++i) {
157 const std::string fromID = attrs.
get<std::string>(
SUMO_ATTR_FROM, pid.c_str(), ok);
160 throw ProcessError(
"The from edge '" + fromID +
"' within a ride of person '" + pid +
"' is not known.");
162 if (!plan.empty() && plan.back()->getDestination() != from) {
165 }
else if (plan.empty()) {
166 throw ProcessError(
"The start edge for person '" + pid +
"' is not known.");
168 const std::string toID = attrs.
get<std::string>(
SUMO_ATTR_TO, pid.c_str(), ok);
171 throw ProcessError(
"The to edge '" + toID +
"' within a ride of person '" + pid +
"' is not known.");
182 (*myActiveContainerPlan) << attrs;
186 (*myActiveContainerPlan) << attrs;
196 (*myActiveContainerPlan) << attrs;
228 while (st.hasNext()) {
229 const std::string typeID = st.next();
293 WRITE_WARNING(
"No probability for a route in '" + rid +
"', using default.");
405 if (ok && index < 0) {
415 const std::string routeID = st.
next();
468 if (route->
getID()[0] !=
'!') {
563 (*myActiveContainerPlan) << attrs;
568 std::string errorSuffix;
594 if (containerstop == 0) {
605 if (parkingarea == 0) {
616 if (!ok || stop.
lane ==
"") {
617 myErrorOutput->
inform(
"A stop must be placed on a bus stop, a container stop, a parking area or a lane" + errorSuffix);
650 const std::string& rid) {
652 std::istringstream in(desc, std::ios::binary);
658 const std::string
id = st.next();
663 into.push_back(edge);
682 +
"\n The route can not be build.");
688 +
"\n The route can not be build.");
692 double departPos = 0.;
693 double arrivalPos = 0.;
695 WRITE_WARNING(
"The attribute departPos is no longer supported for walks, please use the person attribute, the arrivalPos of the previous step or explicit stops.");
705 const std::string mode = st.next();
708 }
else if (mode ==
"bicycle") {
710 }
else if (mode ==
"public") {
731 const RORoute* route = routeDef != 0 ? routeDef->getFirstRoute() : 0;
742 if (attrs.
hasAttribute(SUMO_ATTR_DURATION) && duration <= 0) {
746 if (attrs.
hasAttribute(SUMO_ATTR_SPEED) && speed <= 0) {
749 double departPos = 0.;
750 double arrivalPos = 0.;
752 WRITE_WARNING(
"The attribute departPos is no longer supported for walks, please use the person attribute, the arrivalPos of the previous step or explicit stops.");
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
const int VEHPARS_TO_TAZ_SET
RORouteDef * myCurrentAlternatives
The currently parsed route alternatives.
void addRide(const ROEdge *const from, const ROEdge *const to, const std::string &lines, const std::string &destStop)
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
virtual void myEndElement(int element)
Called when a closing tag occurs.
description of a vehicle type
void closeVehicleTypeDistribution()
std::string containerstop
(Optional) container stop if one is assigned to the stop
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
void closePerson()
Ends the processing of a person.
std::string vtypeid
The vehicle's type id.
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
void openRouteDistribution(const SUMOSAXAttributes &attrs)
a flow definition (used by router)
Represents a generic random distribution.
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
static void readEdgeVector(std::istream &in, std::vector< const E *> &edges, const std::string &rid)
Reads an edge vector binary.
Structure representing possible vehicle parameter.
ConstROEdgeVector myActiveRoute
The current route.
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
double defaultProbability
The probability when being added to a distribution without an explicit probability.
std::string getString() const
Returns the current content as a string.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
void addWalk(const SUMOSAXAttributes &attrs)
add a fully specified walk
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
int repetitionsDone
The number of times the vehicle was already inserted.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
SUMOVehicleClass vehicleClass
The vehicle's class.
double myActiveRouteProbability
The probability of the current route.
MsgHandler *const myErrorOutput
Depending on the "ignore-errors" option different outputs are used.
virtual void myEndElement(int element)
Called when a closing tag occurs.
double getLength() const
Returns the length of the edge.
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
const double DEFAULT_VEH_PROB
int myActiveContainerPlanSize
The number of stages in myActiveContainerPlan.
std::vector< const ROEdge * > ConstROEdgeVector
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
const std::string & getID() const
Returns the id.
std::string myActiveRouteID
The id of the current route.
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
const std::string DEFAULT_VTYPE_ID
const SUMOTime myBegin
The begin time.
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
void closeVehicle()
Ends the processing of a vehicle.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
static double parseWalkPos(SumoXMLAttr attr, const std::string &id, double maxPos, const std::string &val, std::mt19937 *rng=0)
parse departPos or arrivalPos for a walk
std::string parkingarea
(Optional) parking area if one is assigned to the stop
#define WRITE_WARNING(msg)
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
RandomDistributor< SUMOVTypeParameter * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
static OptionsCont & getOptions()
Retrieves the options.
std::string toTaz
The vehicle's destination zone (district)
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
RORouteHandler(RONet &net, const std::string &file, const bool tryRepair, const bool emptyDestinationsAllowed, const bool ignoreErrors)
standard constructor
RONet & myNet
The current route.
int getNumPredecessors() const
Returns the number of edges connected to this edge.
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter *> *vehTypeDistribution)
Adds a vehicle type distribution.
std::string busstop
(Optional) bus stop if one is assigned to the stop
A vehicle as used by router.
bool addRouteDef(RORouteDef *def)
ROPerson * myActivePerson
The plan of the current person.
std::string routeid
The vehicle's route id.
double startPos
The stopping position start.
Encapsulated SAX-Attributes.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
const SUMOVehicleParameter::Stop * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Retrieves a stopping place from the network.
std::vector< PlanItem * > & getPlan()
void addContainer(const SUMOTime depart, const std::string desc)
void parseEdges(const std::string &desc, ConstROEdgeVector &into, const std::string &rid)
Parse edges from strings.
void addStop(const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
SUMOTime depart
The vehicle's departure time.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime string2time(const std::string &r)
A person as used by router.
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
std::string fromTaz
The vehicle's origin zone (district)
double endPos
The stopping position end.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
vehicle is a passenger car (a "normal" car)
A basic edge for routing applications.
const int VEHPARS_FROM_TAZ_SET
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)
std::string lane
The lane to stop at.
Parser for routes during their loading.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
bool isInternal() const
return whether this edge is an internal edge
void closeContainer()
Ends the processing of a container.
static bool checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
The router's network representation.
void openRoute(const SUMOSAXAttributes &attrs)
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
const std::string DEFAULT_PEDTYPE_ID
void addWalk(const ConstROEdgeVector &edges, const double duration, const double speed, const double departPos, const double arrivalPos, const std::string &busStop)
Definition of vehicle stop (position and duration)
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
const bool myKeepVTypeDist
whether to keep the the vtype distribution in output
const bool myTryRepair
Information whether routes shall be repaired.
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
void inform(std::string msg, bool addType=true)
adds a new error to the list
A storage for options typed value containers)
OutputDevice_String * myActiveContainerPlan
The plan of the current container.
Base class for a vehicle's route definition.
std::string id
The vehicle type's id.
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA...
void closeRoute(const bool mayBeDisconnected=false)
bool wasSet(int what) const
Returns whether the given parameter was set.
const RGBColor * myActiveRouteColor
The currently parsed route's color.
double myCurrentCosts
The currently parsed route costs.
virtual ~RORouteHandler()
standard destructor
void addPersonTrip(const SUMOSAXAttributes &attrs)
add a routing request for a walking or intermodal person
bool closeTag()
Closes the most recently opened tag.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
a single trip definition (used by router)
void closeFlow()
Ends the processing of a flow.
const ROEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself ...
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
std::string myActiveRouteRefID
The id of the route the current route references to.
bool addPerson(ROPerson *person)
void parseFromViaTo(std::string element, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
A complete router's route.
An output device that encapsulates an ofstream.
void closeRouteDistribution()
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
std::string id
The vehicle's id.