39 #include <xercesc/sax/HandlerBase.hpp>
40 #include <xercesc/sax/AttributeList.hpp>
41 #include <xercesc/sax/SAXParseException.hpp>
42 #include <xercesc/sax/SAXException.hpp>
57 #ifdef CHECK_MEMORY_LEAKS
59 #endif // CHECK_MEMORY_LEAKS
83 myCurrentEdge(0), myHaveReportedAboutOverwriting(false),
84 myHaveWarnedAboutDeprecatedLaneId(false),
85 myKeepEdgeShape(!options.getBool(
"plain.extend-edge-shape"))
269 WRITE_ERROR(
"Additional lane information could not be set - the edge with id '" +
myCurrentID +
"' is not known.");
284 std::string allowed, disallowed, preferred;
316 WRITE_WARNING(
"Ignoring 'split' because it cannot be assigned to an edge");
335 WRITE_ERROR(
"Additional lane information could not be set - the edge with id '" +
myCurrentID +
"' is not known.");
342 std::vector<std::string> lanes;
344 for (std::vector<std::string>::iterator i = lanes.begin(); i != lanes.end(); ++i) {
347 e.
lanes.push_back(lane);
354 if (e.
lanes.empty()) {
356 e.
lanes.push_back((
int) l);
371 std::string oldBegID = begNodeID;
372 std::string oldEndID = endNodeID;
429 std::string lsfS =
toString(result);
474 std::vector<Split>::iterator i;
481 sort((*i).lanes.begin(), (*i).lanes.end());
482 noLanesMax =
MAX2(noLanesMax, (
unsigned int)(*i).lanes.size());
490 std::vector<int> currLanes;
491 for (
unsigned int l = 0; l < e->
getNumLanes(); ++l) {
492 currLanes.push_back(l);
494 std::string edgeid = e->
getID();
497 const Split& exp = *i;
498 assert(exp.
lanes.size() != 0);
505 std::string pid = e->
getID();
509 std::vector<int> newLanes = exp.
lanes;
515 unsigned int rightMostP = currLanes[0];
516 unsigned int rightMostN = newLanes[0];
517 for (
int l = 0; l < (
int) rightMostP - (
int) rightMostN; ++l) {
521 unsigned int leftMostP = currLanes.back();
522 unsigned int leftMostN = newLanes.back();
523 for (
int l = 0; l < (
int) leftMostN - (
int) leftMostP; ++l) {
527 for (
unsigned int l = 0; l < noLanesMax; ++l) {
528 if (find(currLanes.begin(), currLanes.end(), l) == currLanes.end()) {
531 if (find(newLanes.begin(), newLanes.end(), l) == newLanes.end()) {
538 currLanes = newLanes;
542 }
else if (exp.
pos == 0) {
548 currLanes = exp.
lanes;
563 unsigned int maxLeft = (*i).lanes.back();
565 if (maxLeft < noLanesMax) {
572 unsigned int maxRight = (*i).lanes.front();
void invalidateConnections(bool reallowSetting=false)
The information about how to spread the lanes from the given position.
const std::string & getTypeID() const
LaneSpreadFunction myLanesSpread
Information about how to spread the lanes.
Finds a split at the given position.
static bool transformCoordinates(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
bool isInStringVector(const std::string &optionName, const std::string &itemName)
Returns the named option is a list of string values containing the specified item.
Position positionAtOffset(SUMOReal pos) const
Returns the position at the given length.
int nameid
A numerical id.
bool hasDefaultGeometry() const
Returns whether the geometry consists only of the node positions.
std::string myCurrentID
The current edge's id.
const SUMOReal SUMO_const_halfLaneAndOffset
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
PositionVector myShape
The shape of the edge.
A container for traffic light definitions and built programs.
void setLaneWidth(int lane, SUMOReal width)
set lane specific width (negative lane implies set for all lanes)
void setSpeed(int lane, SUMOReal speed)
set lane specific speed (negative lane implies set for all lanes)
void setOffset(int lane, SUMOReal offset)
set lane specific end-offset (negative lane implies set for all lanes)
const SUMOReal SUMO_const_laneWidthAndOffset
bool setNodes(const SUMOSAXAttributes &attrs)
Sets from/to node information of the currently parsed edge.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
void incLaneNo(unsigned int by)
NBNode * myFromNode
The nodes the edge starts and ends at.
const SUMOReal SUMOXML_INVALID_POSITION
A container for districts.
NIXMLEdgesHandler(NBNodeCont &nc, NBEdgeCont &ec, NBTypeCont &tc, NBDistrictCont &dc, NBTrafficLightLogicCont &tlc, OptionsCont &options)
Constructor.
bool addLane2LaneConnection(unsigned int fromLane, NBEdge *dest, unsigned int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false)
Adds a connection between the specified this edge's lane and an approached one.
bool myHaveReportedAboutOverwriting
Information whether at least one edge's attributes were overwritten.
SUMOReal getLaneWidth() const
Returns the default width of lanes of this edge.
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
NBDistrictCont & myDistrictCont
The districts container (needed if an edge must be split)
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
SAX-handler base for SUMO-files.
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...
SUMOReal getWidth(const std::string &type) const
Returns the lane width for the given type [m/s].
#define WRITE_WARNING(msg)
The connection was computed and validated.
static OptionsCont & getOptions()
Retrieves the options.
const bool myKeepEdgeShape
Whether the edge shape shall be kept generally.
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.
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges.
SUMOReal getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
const std::string & getID() const
Returns the id.
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
std::vector< Split > mySplits
The list of this edge's splits.
int getPriority() const
Returns the priority of the edge.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
bool myHaveWarnedAboutDeprecatedLaneId
Encapsulated SAX-Attributes.
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
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
A structure which describes changes of lane number along the road.
void addSplit(const SUMOSAXAttributes &attrs)
Parses a split and stores it in mySplits. Splits are executed Upon reading the end tag of an edge...
unsigned int getNumLanes() const
Returns the number of lanes.
std::string myCurrentType
The current edge's type.
int getPriority(const std::string &type) const
Returns the priority for the given type.
bool hasLoadedLength() const
Returns whether a length was set explicitly.
Storage for edges, including some functionality operating on multiple edges.
std::vector< int > lanes
The lanes until this change.
NBNodeCont & myNodeCont
The nodes container (for retrieval of referenced nodes)
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers. ...
NBTrafficLightLogicCont & myTLLogicCont
The traffic lights container to add built tls to (when invalidating tls because of splits) ...
Sorts splits by their position (increasing)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool knows(const std::string &type) const
Returns whether the named type is in the container.
LaneSpreadFunction tryGetLaneSpread(const SUMOSAXAttributes &attrs)
Tries to parse the spread type.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
void setLoadedLength(SUMOReal val)
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
SUMOReal length() const
Returns the length.
static int _2int(const E *const data)
void decLaneNo(unsigned int by, int dir=0)
NBNode * getToNode() const
Returns the destination node of the edge.
SVCPermissions myPermissions
Information about lane permissions.
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.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
SUMOReal myCurrentSpeed
The current edge's maximum speed.
static const SUMOReal UNSPECIFIED_LOADED_LENGTH
no length override given
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
const PositionVector & getGeometry() const
Returns the geometry of the edge.
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.
OptionsCont & myOptions
A reference to the program's options.
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
NBTypeCont & myTypeCont
The types container (for retrieval of type defaults)
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
Represents a single node (junction) during network building.
Position gpos
A 2D-position (for the node to insert at this place)
T get(const std::string &str) const
void move2side(SUMOReal amount)
SUMOReal myCurrentOffset
The current edge's offset till the destination node.
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 myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NBEdgeCont & myEdgeCont
The edges container (for insertion of build edges)
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
int myCurrentLaneNo
The current edge's number of lanes.
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Container for nodes during the netbuilding process.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
SUMOReal myCurrentWidth
The current edge's lane width.
SUMOReal myLength
The current edge's length.
SUMOReal pos
The position of this change.
std::string myCurrentStreetName
The current edge's street name.
#define WRITE_MESSAGE(msg)
void invalidateTLS(NBTrafficLightLogicCont &tlCont)
causes the traffic light to be computed anew
const std::string & getStreetName() const
Returns the street name of this edge.
void addLane(const SUMOSAXAttributes &attrs)
Parses a lane and modifies myCurrentEdge according to the given attribures.
SUMOReal getOffset() const
Returns the offset to the destination node.
int myCurrentPriority
The current edge's priority.
void reinit(NBNode *from, NBNode *to, const std::string &type, SUMOReal speed, unsigned int nolanes, int priority, PositionVector geom, SUMOReal width, SUMOReal offset, const std::string &streetName, LaneSpreadFunction spread=LANESPREAD_RIGHT, bool tryIgnoreNodePositions=false)
Resets initial values.
A storage for available types of edges.
PositionVector tryGetShape(const SUMOSAXAttributes &attrs)
Tries to parse the shape definition.
NBNode * getFromNode() const
Returns the origin node of the edge.