 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
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);
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) {
822 const ROLane* cand = static_cast<const ROLane*>(o);
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) {
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()};
NamedRTree * myLaneTree
RTree for finding lanes.
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
bool isInternal() const
return whether this edge is an internal edge
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
bool wasSet(int what) const
Returns whether the given parameter was set.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
void openRoute(const SUMOSAXAttributes &attrs)
opens a route for reading
void addContainer(const SUMOSAXAttributes &attrs)
Processing of a container.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
#define WRITE_WARNING(msg)
Base class for objects which have an id.
const std::string DEFAULT_PEDTYPE_ID
An output device that encapsulates an ofstream.
void parseFromViaTo(std::string element, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
std::string lane
The lane to stop at.
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
double ymin() const
Returns minimum y-coordinate.
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
bool hasNext()
returns the information whether further substrings exist
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
Allows to store the object; used as context while traveling the rtree in TraCI.
std::string vtypeid
The vehicle's type id.
const ROEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
int myActiveContainerPlanSize
The number of stages in myActiveContainerPlan.
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
std::string busstop
(Optional) bus stop if one is assigned to the stop
void addAlternativeDef(const RORouteDef *alternative)
Adds an alternative loaded from the file.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
double xmax() const
Returns maximum x-coordinate.
void addPersonTrip(const SUMOSAXAttributes &attrs)
add a routing request for a walking or intermodal person
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
A single lane the router may use.
static OptionsCont & getOptions()
Retrieves the options.
Base class for a vehicle's route definition.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
The router's network representation.
A person as used by router.
const SUMOVTypeParameter * getType() const
Returns the type of the routable.
A vehicle as used by router.
std::string parkingarea
(Optional) parking area if one is assigned to the stop
Structure representing possible vehicle parameter.
void closePersonFlow()
Ends the processing of a personFlow.
bool addPerson(ROPerson *person)
double getOverallProb() const
Returns the sum of the probablities of the contained routes.
const bool myHardFail
flag to enable or disable hard fails
bool addRouteDef(RORouteDef *def)
bool allowsVehicleClass(SUMOVehicleClass vclass) const
const PositionVector & getShape() const
std::string getString() const
Returns the current content as a string.
RandomDistributor< SUMOVTypeParameter * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
static bool checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
void addRide(const SUMOSAXAttributes &attrs)
Processing of a ride.
void openTrip(const SUMOSAXAttributes &attrs)
opens a trip for reading
std::string myActiveRouteRefID
The id of the route the current route references to.
void addWalk(const SUMOSAXAttributes &attrs)
add a fully specified walk
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
NamedRTree * getLaneTree()
initialize lane-RTree
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.
a flow definitio nusing a from-to edges instead of a route (used by router)
double xmin() const
Returns minimum x-coordinate.
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
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.
double defaultProbability
The probability when being added to a distribution without an explicit probability.
const std::string DEFAULT_VTYPE_ID
const RGBColor * myActiveRouteColor
The currently parsed route's color.
void addStop(const SUMOVehicleParameter::Stop &stopPar, const ROEdge *const stopEdge)
void addContainer(const SUMOTime depart, const std::string desc)
double myCurrentCosts
The currently parsed route costs.
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
vehicle is a passenger car (a "normal" car)
std::string id
The vehicle's id.
A class that stores a 2D geometrical boundary.
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)
double repetitionProbability
The probability for emitting a vehicle per second.
const SUMOVehicleParameter::Stop * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Retrieves a stopping place from the network.
void closeContainer()
Ends the processing of a container.
std::string fromTaz
The vehicle's origin zone (district)
ROEdge & getEdge() const
Returns the lane's edge.
A point in 2D or 3D with translation and scaling methods.
static void readEdgeVector(std::istream &in, std::vector< const E * > &edges, const std::string &rid)
Reads an edge vector binary.
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
A complete router's route.
std::vector< PlanItem * > & getPlan()
int repetitionsDone
The number of times the vehicle was already inserted.
A storage for options typed value containers)
double endPos
The stopping position end.
const ROEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
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.
double myActiveRouteProbability
The probability of the current route.
std::string routeid
The vehicle's route id.
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void addWalk(const ConstROEdgeVector &edges, const double duration, const double speed, const double departPos, const double arrivalPos, const std::string &busStop)
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
void addLoadedAlternative(RORoute *alternative)
Adds a single alternative loaded from the file An alternative may also be generated during DUA.
SUMOTime string2time(const std::string &r)
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
const bool myTryRepair
Information whether routes shall be repaired.
const SUMOTime myBegin
The begin time.
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
void closeFlow()
Ends the processing of a flow.
double startPos
The stopping position start.
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 registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
void parseEdges(const std::string &desc, ConstROEdgeVector &into, const std::string &rid)
Parse edges from strings.
const NamedObjectCont< ROEdge * > & getEdgeMap() const
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
MsgHandler *const myErrorOutput
Depending on the "ignore-errors" option different outputs are used.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual ~RORouteHandler()
standard destructor
std::vector< std::string > via
List of the via-edges the vehicle must visit.
std::string id
The vehicle type's id.
void closePerson()
Ends the processing of a person.
void closeTrip()
Ends the processing of a trip.
double getLength() const
Returns the length of the edge.
int getNumPredecessors() const
Returns the number of edges connected to this edge.
ConstROEdgeVector myActiveRoute
The current route.
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
RORouteHandler(RONet &net, const std::string &file, const bool tryRepair, const bool emptyDestinationsAllowed, const bool ignoreErrors, const bool checkSchema)
standard constructor
const int VEHPARS_FROM_TAZ_SET
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
opens a type distribution for reading
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
void addRide(const ROEdge *const from, const ROEdge *const to, const std::string &lines, double arrivalPos, const std::string &destStop)
void closeVehicleTypeDistribution()
closes (ends) the building of a distribution
void openFlow(const SUMOSAXAttributes &attrs)
opens a flow for reading
A basic edge for routing applications.
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
A RT-tree for efficient storing of SUMO's Named objects.
const int VEHPARS_TO_TAZ_SET
RONet & myNet
The current route.
Parser for routes during their loading.
RORouteDef * myCurrentAlternatives
The currently parsed route alternatives.
void closeVType()
Ends the processing of a vehicle type.
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
int gPrecision
the precision for floating point outputs
Boundary & grow(double by)
extends the boundary by the given amount
int Search(const float a_min[2], const float a_max[2], const Named::StoringVisitor &c) const
Find all within search rectangle.
std::string toTaz
The vehicle's destination zone (district)
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
void closeRoute(const bool mayBeDisconnected=false)
closes (ends) the building of a route.
void closeVehicle()
Ends the processing of a vehicle.
void addTranship(const SUMOSAXAttributes &attrs)
Processing of a tranship.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
Encapsulated SAX-Attributes.
void addFlowPerson(SUMOTime depart, const std::string &baseID, int i)
Processing of a person from a personFlow.
SUMOVehicleClass vehicleClass
The vehicle's class.
const std::string & getID() const
Returns the id.
const double DEFAULT_VEH_PROB
std::string containerstop
(Optional) container stop if one is assigned to the stop
std::string myActiveRouteID
The id of the current route.
OutputDevice_String * myActiveContainerPlan
The plan of the current container.
void openRouteDistribution(const SUMOSAXAttributes &attrs)
opens a route distribution for reading
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
const bool myKeepVTypeDist
whether to keep the the vtype distribution in output
double departPos
(optional) The position the vehicle shall depart from
a single trip definition (used by router)
ROPerson * myActivePerson
The plan of the current person.
std::vector< const ROEdge * > ConstROEdgeVector
Definition of vehicle stop (position and duration)
double ymax() const
Returns maximum y-coordinate.
void closeRouteDistribution()
closes (ends) the building of a distribution
void addPerson(const SUMOSAXAttributes &attrs)
Processing of a person.
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.