38 #include <xercesc/sax/HandlerBase.hpp> 39 #include <xercesc/sax/AttributeList.hpp> 40 #include <xercesc/sax/SAXParseException.hpp> 41 #include <xercesc/sax/SAXException.hpp> 74 myCurrentEdge(0), myHaveReportedAboutOverwriting(false),
75 myHaveReportedAboutTypeOverride(false),
76 myHaveWarnedAboutDeprecatedLaneId(false),
77 myKeepEdgeShape(!options.getBool(
"plain.extend-edge-shape")) {
295 WRITE_ERROR(
"Additional lane information could not be set - the edge with id '" +
myCurrentID +
"' is not known.");
350 WRITE_ERROR(
"Unable to project coordinates for lane '" + laneID +
"'.");
361 WRITE_WARNING(
"Ignoring 'split' because it cannot be assigned to an edge");
382 std::vector<std::string> lanes;
384 for (std::vector<std::string>::iterator i = lanes.begin(); i != lanes.end(); ++i) {
387 e.
lanes.push_back(lane);
394 if (e.
lanes.empty()) {
396 e.
lanes.push_back(l);
401 e.
speed /= (double) 3.6;
427 std::string oldBegID = begNodeID;
428 std::string oldEndID = endNodeID;
485 std::string lsfS =
toString(result);
515 for (EdgeVector::const_iterator e = incoming.begin(); e != incoming.end(); ++e) {
516 (*e)->removeFromConnections(edge, -1, lane,
false,
true);
549 std::vector<Split>::iterator i;
555 sort((*i).lanes.begin(), (*i).lanes.end());
556 noLanesMax =
MAX2(noLanesMax, (
int)(*i).lanes.size());
559 std::vector<int> currLanes;
561 currLanes.push_back(l);
571 std::string firstID =
"";
574 const Split& exp = *i;
575 assert(exp.
lanes.size() != 0);
591 std::vector<int> newLanes = exp.
lanes;
597 int rightMostP = currLanes[0];
598 int rightMostN = newLanes[0];
599 for (
int l = 0; l < (int) rightMostP - (
int) rightMostN; ++l) {
603 int leftMostP = currLanes.back();
604 int leftMostN = newLanes.back();
605 for (
int l = 0; l < (int) leftMostN - (
int) leftMostP; ++l) {
609 for (
int l = 0; l < noLanesMax; ++l) {
610 if (find(currLanes.begin(), currLanes.end(), l) == currLanes.end()) {
613 if (find(newLanes.begin(), newLanes.end(), l) == newLanes.end()) {
620 currLanes = newLanes;
621 }
else if (exp.
pos == 0) {
623 if (laneCountDiff < 0) {
628 currLanes = exp.
lanes;
642 for (
int lane = 0; lane < (int)e->
getNumLanes(); ++lane) {
643 start.
lanes.push_back(lane);
649 int maxLeft = (*i).lanes.back();
651 if (maxLeft < noLanesMax) {
658 int maxRight = (*i).lanes.front();
684 for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
688 WRITE_ERROR(
"Unknown edge '" + (*it) +
"' in roundabout");
691 roundabout.insert(edge);
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
void invalidateConnections(bool reallowSetting=false)
invalidate current connections of edge
The information about how to spread the lanes from the given position.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
LaneSpreadFunction myLanesSpread
Information about how to spread the lanes.
Finds a split at the given position.
static const double UNSPECIFIED_LOADED_LENGTH
no length override given
EdgeVector getIncomingEdges() const
Returns the list of incoming edges unsorted.
begin/end of the description of a single lane
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
std::string myCurrentID
The current edge's id.
static NBNode * processNodeType(const SUMOSAXAttributes &attrs, NBNode *node, const std::string &nodeID, const Position &position, bool updateEdgeGeometries, NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
parses node attributes (not related to positioning)
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
lane spread functions
void markAsSplit(const NBNode *node)
mark a node as being created form a split
PositionVector myShape
The shape of the edge.
A container for traffic light definitions and built programs.
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
void addRoundabout(const SUMOSAXAttributes &attrs)
Parses a roundabout and stores it in myEdgeCont.
bool setNodes(const SUMOSAXAttributes &attrs)
Sets from/to node information of the currently parsed edge.
int getPriority() const
Returns the priority of the edge.
const std::string & getTypeID() const
get ID of type
const double SUMO_const_halfLaneAndOffset
double myCurrentSpeed
The current edge's maximum speed.
The representation of a single edge during network building.
const double SUMO_const_laneWidthAndOffset
int getPriority(const std::string &type) const
Returns the priority for the given type.
NBNode * myFromNode
The nodes the edge starts and ends at.
A container for districts.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false, const bool adaptToLaneRemoval=false)
Removes the specified connection(s)
NIXMLEdgesHandler(NBNodeCont &nc, NBEdgeCont &ec, NBTypeCont &tc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, OptionsCont &options)
Constructor.
bool myHaveReportedAboutOverwriting
Information whether at least one edge's attributes were overwritten.
bool hasLoadedLength() const
Returns whether a length was set explicitly.
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
void setLoadedLength(double val)
set loaded lenght
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
NBDistrictCont & myDistrictCont
The districts container (needed if an edge must be split)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
Lane & getLaneStruct(int lane)
SAX-handler base for SUMO-files.
void addSidewalk(double width)
add a pedestrian sidewalk of the given width and shift existing connctions
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
static const double UNSPECIFIED_WIDTH
unspecified lane width
std::vector< Parameterised * > myLastParameterised
element to receive parameters
#define WRITE_WARNING(msg)
The connection was computed and validated.
static OptionsCont & getOptions()
Retrieves the options.
void setLaneShape(int lane, const PositionVector &shape)
sets a custom lane shape
double getWidth(const std::string &type) const
Returns the lane width for the given type [m].
void setAcceleration(int lane, bool accelRamp)
marks one lane as acceleration lane
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
const bool myKeepEdgeShape
Whether the edge shape shall be kept generally.
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
bool myReinitKeepEdgeShape
Whether the edge shape shall be kept at reinitilization.
void addEdge(const SUMOSAXAttributes &attrs)
Parses an edge and stores the values in "myCurrentEdge".
~NIXMLEdgesHandler()
Destructor.
static const double UNSPECIFIED_SPEED
unspecified lane speed
void invalidateTLS(NBTrafficLightLogicCont &tlCont, bool removedConnections, bool addedConnections)
causes the traffic light to be computed anew
void incLaneNo(int by)
increment lane
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
bool knows(const std::string &type) const
Returns whether the named type is in the container.
double getBikeLaneWidth(const std::string &type) const
Returns the lane width for a bike lane to be added [m].
std::vector< Split > mySplits
The list of this edge's splits.
std::set< NBEdge * > EdgeSet
container for unique edges
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double getSidewalkWidth(const std::string &type) const
Returns the lane width for a sidewalk to be added [m].
bool myHaveWarnedAboutDeprecatedLaneId
void decLaneNo(int by)
decrement lane
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 extract(NBDistrictCont &dc, NBEdge *edge, bool remember=false)
Removes the given edge from the container like erase but does not delete it.
void deleteEdge(const SUMOSAXAttributes &attrs)
parses delete tag and deletes the specified edge or lane
int getNumLanes() const
Returns the number of lanes.
parameter associated to a certain key
void deleteLane(int index, bool recompute=true)
delete lane
A structure which describes changes of lane number or speed along the road.
double pos
The position of this change.
void addSplit(const SUMOSAXAttributes &attrs)
Parses a split and stores it in mySplits. Splits are executed Upon reading the end tag of an edge...
std::string nameID
the default node id
T get(const std::string &str) const
std::string myCurrentType
The current edge's type.
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
double myLength
The current edge's length.
roundabout defined in junction
Storage for edges, including some functionality operating on multiple edges.
std::vector< int > lanes
The lanes after this change.
const std::string & getStreetName() const
Returns the street name of this edge.
double myCurrentEndOffset
The current edge's offset till the destination node.
NBNodeCont & myNodeCont
The nodes container (for retrieval of referenced nodes)
edge: the shape in xml-definition
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
NBTrafficLightLogicCont & myTLLogicCont
The traffic lights container to add built tls to (when invalidating tls because of splits) ...
Sorts splits by their position (increasing)
LaneSpreadFunction tryGetLaneSpread(const SUMOSAXAttributes &attrs)
Tries to parse the spread type.
begin/end of the description of a neighboring lane
void reinit(NBNode *from, NBNode *to, const std::string &type, double speed, int nolanes, int priority, PositionVector geom, double width, double offset, const std::string &streetName, LaneSpreadFunction spread=LANESPREAD_RIGHT, bool tryIgnoreNodePositions=false)
Resets initial values.
double myBikeLaneWidth
The width of the bike lane that shall be added to the current edge.
void move2side(double amount)
move position vector to side using certain ammount
begin/end of the description of an edge
double getSpeed() const
Returns the speed allowed on this edge.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
virtual std::vector< std::string > getStringVector(int attr) const =0
Tries to read given attribute assuming it is a string vector.
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
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.
SVCPermissions myPermissions
Information about lane permissions.
std::string idAfter
The id for the edge after the split.
double length() const
Returns the length.
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
bool myIsUpdate
Whether this edge definition is an update of a previously inserted edge.
bool addLane2LaneConnection(int fromLane, NBEdge *dest, int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, double contPos=UNSPECIFIED_CONTPOS, double visibility=UNSPECIFIED_VISIBILITY_DISTANCE, double speed=UNSPECIFIED_SPEED, const PositionVector &customShape=PositionVector::EMPTY)
Adds a connection between the specified this edge's lane and an approached one.
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
set preferred Vehicle Class
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
void myEndElement(int element)
Called when a closing tag occurs.
A storage for options typed value containers)
NBEdge * myCurrentEdge
The currently processed edge.
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
void addBikeLane(double width)
add a bicycle lane of the given width and shift existing connctions
OptionsCont & myOptions
A reference to the program's options.
double myCurrentWidth
The current edge's lane width.
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
double speed
The speed after this change.
NBTypeCont & myTypeCont
The types container (for retrieval of type defaults)
const Position & getPosition() const
Represents a single node (junction) during network building.
bool myHaveReportedAboutTypeOverride
Information whether at least one edge's type was changed.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NBNode * getFromNode() const
Returns the origin node of the edge.
NBEdgeCont & myEdgeCont
The edges container (for insertion of build edges)
int myCurrentLaneNo
The current edge's number of lanes.
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
Container for nodes during the netbuilding process.
std::string myCurrentStreetName
The current edge's street name.
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
double getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
double mySidewalkWidth
The width of the sidewalk that shall be added to the current edge.
#define WRITE_MESSAGE(msg)
std::string idBefore
The id for the edge before the split.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void addLane(const SUMOSAXAttributes &attrs)
Parses a lane and modifies myCurrentEdge according to the given attribures.
NBNode * getToNode() const
Returns the destination node of the edge.
int myCurrentPriority
The current edge's priority.
NBNode * node
The new node that is created for this split.
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
A storage for available types of edges.
PositionVector tryGetShape(const SUMOSAXAttributes &attrs)
Tries to parse the shape definition.