 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
33 #include <xercesc/sax/HandlerBase.hpp>
34 #include <xercesc/sax/AttributeList.hpp>
35 #include <xercesc/sax/SAXParseException.hpp>
36 #include <xercesc/sax/SAXException.hpp>
69 myCurrentEdge(nullptr),
70 myCurrentLaneIndex(-1),
71 myHaveReportedAboutOverwriting(false),
72 myHaveReportedAboutTypeOverride(false),
73 myHaveWarnedAboutDeprecatedLaneId(false),
74 myKeepEdgeShape(!options.getBool(
"plain.extend-edge-shape")) {
115 assert(stopOffsets.size() == 1);
117 std::stringstream ss;
122 std::stringstream ss;
123 ss <<
"Duplicate definition of stopOffset for ";
131 std::stringstream ss;
132 ss <<
"Ignoring invalid stopOffset for ";
138 ss <<
" (offset larger than the edge length).";
140 ss <<
" (negative offset).";
334 WRITE_ERROR(
"Additional lane information could not be set - the edge with id '" +
myCurrentID +
"' is not known.");
389 WRITE_ERROR(
"Unable to project coordinates for lane '" + laneID +
"'.");
404 WRITE_WARNING(
"Ignoring 'split' because it cannot be assigned to an edge");
429 e.
lanes.push_back(lane);
436 if (e.
lanes.empty()) {
438 e.
lanes.push_back(l);
457 if (e.
node ==
nullptr) {
474 std::string oldBegID = begNodeID;
475 std::string oldEndID = endNodeID;
527 std::string lsfS =
toString(result);
546 if (edge ==
nullptr) {
577 if (stopOffsets.size() != 0) {
609 for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
611 if (edge ==
nullptr) {
613 WRITE_ERROR(
"Unknown edge '" + (*it) +
"' in roundabout");
616 roundabout.insert(edge);
void addSplit(const SUMOSAXAttributes &attrs)
Parses a split and stores it in mySplits. Splits are executed Upon reading the end tag of an edge.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
const std::vector< std::string > getStringVector(int attr) const
Tries to read given attribute assuming it is a string vector.
Information on vClass specific stop offsets at lane end.
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
void myEndElement(int element)
Called when a closing tag occurs.
int offsetFactor
direction in which to apply the offset (used by netgenerate for lefthand networks)
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
bool myIsUpdate
Whether this edge definition is an update of a previously inserted edge.
#define WRITE_WARNING(msg)
Storage for edges, including some functionality operating on multiple edges.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
SAX-handler base for SUMO-files.
std::vector< Parameterised * > myLastParameterised
element to receive parameters
A container for traffic light definitions and built programs.
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
parameter associated to a certain key
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
NBEdgeCont & myEdgeCont
The edges container (for insertion of build edges)
void setLaneType(int lane, const std::string &type)
set lane specific type (negative lane implies set for all lanes)
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
double myCurrentSpeed
The current edge's maximum speed.
OptionsCont & myOptions
A reference to the program's options.
begin/end of the description of a single lane
void processSplits(NBEdge *e, std::vector< Split > splits, NBNodeCont &nc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc)
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
int getPriority() const
Returns the priority of the edge.
NIXMLEdgesHandler(NBNodeCont &nc, NBEdgeCont &ec, NBTypeCont &tc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, OptionsCont &options)
Constructor.
void setDistance(double distance)
set lane specific speed (negative lane implies set for all lanes)
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
double length() const
Returns the length.
NBTypeCont & myTypeCont
The types container (for retrieval of type defaults)
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given
void addEdge(const SUMOSAXAttributes &attrs)
Parses an edge and stores the values in "myCurrentEdge".
void setLoadedLength(double val)
set loaded lenght
double speed
The speed after this change.
bool knows(const std::string &type) const
Returns whether the named type is in the container.
A container for districts.
The information about how to spread the lanes from the given position.
bool myReinitKeepEdgeShape
Whether the edge shape shall be kept at reinitilization.
Container for nodes during the netbuilding process.
The representation of a single edge during network building.
Finds a split at the given position.
double myCurrentEndOffset
The current edge's offset till the destination node.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
const Position & getPosition() const
void setLaneShape(int lane, const PositionVector &shape)
sets a custom lane shape
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
begin/end of the description of a neighboring lane
NBNode * getToNode() const
Returns the destination node of the edge.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
NBNode * node
The new node that is created for this split.
std::string myCurrentType
The current edge's type.
const std::map< int, double > & getStopOffsets() const
Returns the stopOffset to the end of the edge.
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
T get(const std::string &str) const
const std::vector< std::string > getOptStringVector(int attr, const char *objectid, bool &ok, bool report=true) const
convenience function to avoid the default argument and the template stuff at getOpt<>
std::set< NBEdge * > EdgeSet
container for unique edges
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
double myBikeLaneWidth
The width of the bike lane that shall be added to the current edge.
std::vector< int > lanes
The lanes after this change.
double mySidewalkWidth
The width of the sidewalk that shall be added to the current edge.
PositionVector myShape
The shape of the edge.
int getNumLanes() const
Returns the number of lanes.
begin/end of the description of an edge
bool hasLoadedLength() const
Returns whether a length was set explicitly.
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
bool myHaveReportedAboutOverwriting
Information whether at least one edge's attributes were overwritten.
NBNodeCont & myNodeCont
The nodes container (for retrieval of referenced nodes)
NBTrafficLightLogicCont & myTLLogicCont
The traffic lights container to add built tls to (when invalidating tls because of splits)
NBNode * myFromNode
The nodes the edge starts and ends at.
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
set preferred Vehicle Class
double myLength
The current edge's length.
A storage for options typed value containers)
NBEdge * myCurrentEdge
The currently processed edge.
Lane & getLaneStruct(int lane)
~NIXMLEdgesHandler()
Destructor.
int getPriority(const std::string &type) const
Returns the priority for the given type.
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.
void addSidewalk(double width)
add a pedestrian sidewalk of the given width and shift existing connctions
void addBikeLane(double width)
add a bicycle lane of the given width and shift existing connctions
static const double UNSPECIFIED_SPEED
unspecified lane speed
double pos
The position of this change.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
static const double UNSPECIFIED_LOADED_LENGTH
no length override given
const std::string & getStreetName() const
Returns the street name of this edge.
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
bool myHaveWarnedAboutDeprecatedLaneId
NBDistrictCont & myDistrictCont
The districts container (needed if an edge must be split)
double getLength() const
Returns the computed length of the edge.
void addLane(const SUMOSAXAttributes &attrs)
Parses a lane and modifies myCurrentEdge according to the given attribures.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
bool setNodes(const SUMOSAXAttributes &attrs)
Sets from/to node information of the currently parsed edge.
std::vector< NBEdgeCont::Split > mySplits
The list of this edge's splits.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
double myCurrentWidth
The current edge's lane width.
void deleteLane(int index, bool recompute, bool shiftIndices)
delete lane
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
LaneSpreadFunction myLanesSpread
Information about how to spread the lanes.
SVCPermissions myPermissions
Information about lane permissions.
void reinit(NBNode *from, NBNode *to, const std::string &type, double speed, int nolanes, int priority, PositionVector geom, double width, double endOffset, const std::string &streetName, LaneSpreadFunction spread=LANESPREAD_RIGHT, bool tryIgnoreNodePositions=false)
Resets initial values.
void setAcceleration(int lane, bool accelRamp)
marks one lane as acceleration lane
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
void deleteEdge(const SUMOSAXAttributes &attrs)
parses delete tag and deletes the specified edge or lane
A storage for available types of edges.
const bool myKeepEdgeShape
Whether the edge shape shall be kept generally.
double getSpeed() const
Returns the speed allowed on this edge.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
int myCurrentLaneIndex
The currently processed lane index.
void extract(NBDistrictCont &dc, NBEdge *edge, bool remember=false)
Removes the given edge from the container like erase but does not delete it.
double getWidth(const std::string &type) const
Returns the lane width for the given type [m].
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
std::string idAfter
The id for the edge after the split.
std::map< SVCPermissions, double > parseStopOffsets(const SUMOSAXAttributes &attrs, bool &ok)
Extract stopOffsets from attributes of stopOffset element.
static const double UNSPECIFIED_WIDTH
unspecified lane width
bool myHaveReportedAboutTypeOverride
Information whether at least one edge's type was changed.
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
const std::string & getTypeID() const
get ID of type
std::string myCurrentStreetName
The current edge's street name.
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
lane spread functions
void addRoundabout(const SUMOSAXAttributes &attrs)
Parses a roundabout and stores it in myEdgeCont.
double getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
Represents a single node (junction) during network building.
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
roundabout defined in junction
Encapsulated SAX-Attributes.
edge: the shape in xml-definition
A structure which describes changes of lane number or speed along the road.
int myCurrentLaneNo
The current edge's number of lanes.
const std::string & getID() const
Returns the id.
static NBNode * processNodeType(const SUMOSAXAttributes &attrs, NBNode *node, const std::string &nodeID, const Position &position, bool updateEdgeGeometries, NBNodeCont &nc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc)
parses node attributes (not related to positioning)
PositionVector tryGetShape(const SUMOSAXAttributes &attrs)
Tries to parse the shape definition.
std::string idBefore
The id for the edge before the split.
double getBikeLaneWidth(const std::string &type) const
Returns the lane width for a bike lane to be added [m].
NBNode * getFromNode() const
Returns the origin node of the edge.
#define WRITE_MESSAGE(msg)
int myCurrentPriority
The current edge's priority.
bool setStopOffsets(int lane, std::map< int, double > offsets, bool overwrite=false)
set lane and vehicle class specific stopOffset (negative lane implies set for all lanes)
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
LaneSpreadFunction tryGetLaneSpread(const SUMOSAXAttributes &attrs)
Tries to parse the spread type.
double getDistance() const
std::string myCurrentID
The current edge's id.
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
std::string nameID
the default node id
const std::string & getID() const