56 const bool emptyDestinationsAllowed,
57 const bool ignoreErrors,
58 const bool checkSchema) :
61 myActivePerson(nullptr),
62 myActiveContainerPlan(nullptr),
63 myActiveContainerPlanSize(0),
64 myTryRepair(tryRepair),
65 myEmptyDestinationsAllowed(emptyDestinationsAllowed),
68 myKeepVTypeDist(
OptionsCont::getOptions().getBool(
"keep-vtype-distributions")),
69 myCurrentVTypeDistribution(nullptr),
70 myCurrentAlternatives(nullptr),
93 if (fromTaz ==
nullptr) {
118 for (ConstROEdgeVector::const_iterator i = viaEdges.begin(); i != viaEdges.end(); ++i) {
125 if (toTaz ==
nullptr) {
154 if (type ==
nullptr) {
167 const std::string fromID = attrs.
get<std::string>(
SUMO_ATTR_FROM, pid.c_str(), ok);
169 if (from ==
nullptr) {
170 throw ProcessError(
"The from edge '" + fromID +
"' within a ride of person '" + pid +
"' is not known.");
172 if (!plan.empty() && plan.back()->getDestination() != from) {
175 }
else if (plan.empty()) {
176 throw ProcessError(
"The start edge for person '" + pid +
"' is not known.");
180 const std::string toID = attrs.
getOpt<std::string>(
SUMO_ATTR_TO, pid.c_str(), ok,
"");
185 throw ProcessError(
"The to edge '" + toID +
"' within a ride of person '" + pid +
"' is not known.");
187 }
else if (busStopID !=
"") {
189 if (stop ==
nullptr) {
206 (*myActiveContainerPlan) << attrs;
210 (*myActiveContainerPlan) << attrs;
220 (*myActiveContainerPlan) << attrs;
251 while (st.hasNext()) {
252 const std::string typeID = st.next();
254 if (type ==
nullptr) {
316 WRITE_WARNING(
"No probability for a route in '" + rid +
"', using default.");
369 const ROEdge* last =
nullptr;
372 if (last !=
nullptr) {
374 if (intern->isInternal() && intern->getSuccessors().size() == 1 && intern->getSuccessors().front() == roe) {
375 fullRoute.push_back(intern);
379 fullRoute.push_back(roe);
382 myActiveRoute = fullRoute;
432 if (ok && index < 0) {
442 const std::string routeID = st.
next();
444 if (route ==
nullptr) {
477 if (type ==
nullptr) {
491 if (route ==
nullptr) {
495 if (route->
getID()[0] !=
'!') {
573 copyPerson->
getPlan().push_back(item->clone());
660 (*myActiveContainerPlan) << attrs;
665 std::string errorSuffix;
680 if (busstop ==
nullptr) {
691 if (containerstop ==
nullptr) {
702 if (parkingarea ==
nullptr) {
713 if (!ok || stop.
lane ==
"") {
714 myErrorOutput->
inform(
"A stop must be placed on a bus stop, a container stop, a parking area or a lane" + errorSuffix);
718 if (edge ==
nullptr) {
772 const std::string& rid) {
774 std::istringstream in(desc, std::ios::binary);
780 const std::string
id = st.next();
782 if (edge ==
nullptr) {
785 into.push_back(edge);
794 const double range = 100;
797 WRITE_ERROR(
"Cannot convert geo-positions because the network has no geo-reference");
802 if (type !=
nullptr) {
813 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
814 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
815 std::set<const Named*> lanes;
817 t->
Search(cmin, cmax, sv);
819 double minDist = std::numeric_limits<double>::max();
820 const ROLane* best =
nullptr;
821 for (
const Named* o : lanes) {
827 if (dist < minDist) {
832 if (best ==
nullptr) {
839 into.push_back(bestEdge);
855 if (from ==
nullptr) {
857 +
"\n The route can not be build.");
860 double arrivalPos = 0;
862 if (toID !=
"" && to ==
nullptr) {
864 +
"\n The route can not be build.");
867 if (toID ==
"" && busStopID ==
"") {
869 +
"\n The route can not be build.");
875 if (stop ==
nullptr) {
890 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.");
899 const std::string mode = st.next();
902 }
else if (mode ==
"bicycle") {
904 }
else if (mode ==
"public") {
925 const RORoute* route = routeDef !=
nullptr ? routeDef->getFirstRoute() :
nullptr;
926 if (route ==
nullptr) {
936 if (attrs.
hasAttribute(SUMO_ATTR_DURATION) && duration <= 0) {
940 if (attrs.
hasAttribute(SUMO_ATTR_SPEED) && speed <= 0) {
943 double departPos = 0.;
944 double arrivalPos = 0.;
946 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.");
963 for (
ROLane* lane : edgeItem.second->getLanes()) {
964 Boundary b = lane->getShape().getBoxBoundary();
965 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
966 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
static double parseWalkPos(SumoXMLAttr attr, const bool hardFail, const std::string &id, double maxPos, const std::string &val, std::mt19937 *rng=0)
parse departPos or arrivalPos for a walk
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 Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
void parseGeoEdges(const PositionVector &positions, bool geo, ConstROEdgeVector &into, const std::string &rid)
Parse edges from coordinates.
void addTransport(const SUMOSAXAttributes &attrs)
Processing of a transport.
double ymin() const
Returns minimum y-coordinate.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
double xmax() const
Returns maximum x-coordinate.
void addContainer(const SUMOSAXAttributes &attrs)
Processing of a container.
NamedRTree * getLaneTree()
initialize lane-RTree
std::string lane
The lane to stop at.
void closeVehicleTypeDistribution()
closes (ends) the building of a distribution
A single lane the router may use.
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector) ...
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.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
void openRouteDistribution(const SUMOSAXAttributes &attrs)
opens a route distribution for reading
a flow definitio nusing a from-to edges instead of a route (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.
int gPrecision
the precision for floating point outputs
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person 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
double repetitionProbability
The probability for emitting a vehicle per second.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
void addWalk(const SUMOSAXAttributes &attrs)
add a fully specified walk
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
A RT-tree for efficient storing of SUMO's Named objects.
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.
std::string busstop
(Optional) bus stop if one is assigned to the stop
MsgHandler *const myErrorOutput
Depending on the "ignore-errors" option different outputs are used.
void closePersonFlow()
Ends the processing of a personFlow.
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)
opens a type distribution for reading
const std::string & getID() const
Returns the id.
bool hasNext()
returns the information whether further substrings exist
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)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
const std::string DEFAULT_VTYPE_ID
ROEdge & getEdge() const
Returns the lane's edge.
Every person has a plan comprising of multiple planItems.
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.
A class that stores a 2D geometrical boundary.
#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.
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.
A vehicle as used by router.
bool addRouteDef(RORouteDef *def)
ROPerson * myActivePerson
The plan of the current person.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
std::string routeid
The vehicle's route id.
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.
void openFlow(const SUMOSAXAttributes &attrs)
opens a flow for reading
A point in 2D or 3D with translation and scaling methods.
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)
const PositionVector & getShape() const
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime string2time(const std::string &r)
double xmin() const
Returns minimum x-coordinate.
A person as used by router.
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
std::string fromTaz
The vehicle's origin zone (district)
void closeTrip()
Ends the processing of a trip.
Boundary & grow(double by)
extends the boundary by the given amount
double endPos
The stopping position end.
void closeVType()
Ends the processing of a vehicle type.
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
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
Base class for objects which have an id.
void addPerson(const SUMOSAXAttributes &attrs)
Processing of a person.
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)
Definition of vehicle stop (position and duration)
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.
void addFlowPerson(SUMOTime depart, const std::string &baseID, int i)
Processing of a person from a personFlow.
Allows to store the object; used as context while traveling the rtree in TraCI.
double departPos
(optional) The position the vehicle shall depart from
double startPos
The stopping position start.
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 addRide(const SUMOSAXAttributes &attrs)
Processing of a ride.
Structure representing possible vehicle parameter.
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
void openRoute(const SUMOSAXAttributes &attrs)
opens a route for reading
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
const NamedObjectCont< ROEdge * > & getEdgeMap() const
bool allowsVehicleClass(SUMOVehicleClass vclass) const
void openTrip(const SUMOSAXAttributes &attrs)
opens a trip for reading
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)
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.
virtual 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.
void addTranship(const SUMOSAXAttributes &attrs)
Processing of a tranship.
Base class for a vehicle's route definition.
std::string id
The vehicle type's id.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
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)
closes (ends) the building of a route.
bool wasSet(int what) const
Returns whether the given parameter was set.
void addRide(const ROEdge *const from, const ROEdge *const to, const std::string &lines, double arrivalPos, const std::string &destStop)
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 x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
NamedRTree * myLaneTree
RTree for finding lanes.
const bool myHardFail
flag to enable or disable hard fails
a single trip definition (used by router)
void closeFlow()
Ends the processing of a flow.
std::string containerstop
(Optional) container stop if one is assigned to the stop
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.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
double ymax() const
Returns maximum y-coordinate.
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
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()
closes (ends) the building of a distribution
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
std::string id
The vehicle's id.
RORouteHandler(RONet &net, const std::string &file, const bool tryRepair, const bool emptyDestinationsAllowed, const bool ignoreErrors, const bool checkSchema)
standard constructor