 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
55 const bool emptyDestinationsAllowed,
56 const bool ignoreErrors,
57 const bool checkSchema) :
60 myActivePerson(nullptr),
61 myActiveContainerPlan(nullptr),
62 myActiveContainerPlanSize(0),
63 myTryRepair(tryRepair),
64 myEmptyDestinationsAllowed(emptyDestinationsAllowed),
67 myKeepVTypeDist(
OptionsCont::getOptions().getBool(
"keep-vtype-distributions")),
68 myCurrentVTypeDistribution(nullptr),
69 myCurrentAlternatives(nullptr),
92 if (fromTaz ==
nullptr) {
117 for (ConstROEdgeVector::const_iterator i = viaEdges.begin(); i != viaEdges.end(); ++i) {
124 if (toTaz ==
nullptr) {
153 if (type ==
nullptr) {
166 const std::string fromID = attrs.
get<std::string>(
SUMO_ATTR_FROM, pid.c_str(), ok);
168 if (from ==
nullptr) {
169 throw ProcessError(
"The from edge '" + fromID +
"' within a ride of person '" + pid +
"' is not known.");
171 if (!plan.empty() && plan.back()->getDestination() != from) {
174 }
else if (plan.empty()) {
175 throw ProcessError(
"The start edge for person '" + pid +
"' is not known.");
179 const std::string toID = attrs.
getOpt<std::string>(
SUMO_ATTR_TO, pid.c_str(), ok,
"");
184 throw ProcessError(
"The to edge '" + toID +
"' within a ride of person '" + pid +
"' is not known.");
186 }
else if (busStopID !=
"") {
188 if (stop ==
nullptr) {
205 (*myActiveContainerPlan) << attrs;
209 (*myActiveContainerPlan) << attrs;
219 (*myActiveContainerPlan) << attrs;
250 while (st.hasNext()) {
251 const std::string typeID = st.next();
253 if (type ==
nullptr) {
315 WRITE_WARNING(
"No probability for a route in '" + rid +
"', using default.");
368 const ROEdge* last =
nullptr;
371 if (last !=
nullptr) {
373 if (intern->isInternal() && intern->getSuccessors().size() == 1 && intern->getSuccessors().front() == roe) {
374 fullRoute.push_back(intern);
378 fullRoute.push_back(roe);
431 if (ok && index < 0) {
441 const std::string routeID = st.
next();
443 if (route ==
nullptr) {
476 if (type ==
nullptr) {
490 if (route ==
nullptr) {
494 if (route->
getID()[0] !=
'!') {
576 copyPerson->
getPlan().push_back(item->clone());
663 (*myActiveContainerPlan) << attrs;
668 std::string errorSuffix;
683 if (busstop ==
nullptr) {
694 if (containerstop ==
nullptr) {
705 if (parkingarea ==
nullptr) {
716 if (!ok || stop.
lane ==
"") {
717 myErrorOutput->
inform(
"A stop must be placed on a bus stop, a container stop, a parking area or a lane" + errorSuffix);
721 if (edge ==
nullptr) {
775 const std::string& rid) {
777 std::istringstream in(desc, std::ios::binary);
783 const std::string
id = st.next();
785 if (edge ==
nullptr) {
788 into.push_back(edge);
797 const double range = 100;
800 WRITE_ERROR(
"Cannot convert geo-positions because the network has no geo-reference");
805 if (type !=
nullptr) {
816 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
817 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
818 std::set<const Named*> lanes;
820 t->
Search(cmin, cmax, sv);
822 double minDist = std::numeric_limits<double>::max();
823 const ROLane* best =
nullptr;
824 for (
const Named* o : lanes) {
825 const ROLane* cand = static_cast<const ROLane*>(o);
830 if (dist < minDist) {
835 if (best ==
nullptr) {
842 into.push_back(bestEdge);
858 if (from ==
nullptr) {
860 +
"\n The route can not be build.");
863 double arrivalPos = 0;
865 if (toID !=
"" && to ==
nullptr) {
867 +
"\n The route can not be build.");
870 if (toID ==
"" && busStopID ==
"") {
872 +
"\n The route can not be build.");
878 if (stop ==
nullptr) {
893 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.");
902 const std::string mode = st.next();
905 }
else if (mode ==
"bicycle") {
907 }
else if (mode ==
"public") {
928 const RORoute* route = routeDef !=
nullptr ? routeDef->getFirstRoute() :
nullptr;
929 if (route ==
nullptr) {
946 double departPos = 0.;
947 double arrivalPos = 0.;
949 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.");
966 for (
ROLane* lane : edgeItem.second->getLanes()) {
967 Boundary b = lane->getShape().getBoxBoundary();
968 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
969 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
void cacheParamRestrictions(const std::vector< std::string > &restrictionKeys)
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)
static StopPos checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
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.
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
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.