29 #include <xercesc/sax/HandlerBase.hpp> 30 #include <xercesc/sax/AttributeList.hpp> 31 #include <xercesc/sax/SAXParseException.hpp> 32 #include <xercesc/sax/SAXException.hpp> 61 myLastParameterised(nullptr) {
127 bool needConversion =
true;
128 if (node !=
nullptr) {
131 needConversion =
false;
138 needConversion =
true;
143 needConversion =
true;
167 bool updateEdgeGeometries,
172 if (node !=
nullptr) {
184 std::set<NBTrafficLightDefinition*> oldTLS;
186 if (node ==
nullptr) {
187 node =
new NBNode(nodeID, position, type);
189 throw ProcessError(
"Could not insert node though checked this before (id='" + nodeID +
"').");
197 node->
reinit(position, type, updateEdgeGeometries);
204 for (std::set<NBTrafficLightDefinition*>::iterator i = oldTLS.begin(); i != oldTLS.end(); ++i) {
205 if ((*i)->getNodes().size() == 0) {
215 WRITE_ERROR(
"Unable to project node shape at node '" + node->
getID() +
"'.");
217 if (shape.size() > 2) {
253 if (node ==
nullptr) {
266 const std::string clusterString = attrs.
get<std::string>(
SUMO_ATTR_NODES,
nullptr, ok);
268 std::sort(ids.begin(), ids.end());
277 myPosition.sety(attrs.
get<
double>(
SUMO_ATTR_Y, myID.c_str(), ok));
280 myPosition.setz(attrs.
get<
double>(
SUMO_ATTR_Z, myID.c_str(), ok));
308 std::set<NBTrafficLightDefinition*> tlDefs;
311 std::string oldTlID =
"";
316 oldTlID = oldDef->
getID();
321 if (tlID != oldTlID || typeS != oldTypeS) {
328 WRITE_ERROR(
"Unknown traffic light type '" + typeS +
"' for node '" + currentNode->
getID() +
"'.");
331 if (tlID !=
"" && tlc.
getPrograms(tlID).size() > 0) {
333 const std::map<std::string, NBTrafficLightDefinition*>& programs = tlc.
getPrograms(tlID);
334 std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
335 for (it = programs.begin(); it != programs.end(); it++) {
336 if (it->second->getType() != type) {
337 WRITE_ERROR(
"Mismatched traffic light type '" + typeS +
"' for tl '" + tlID +
"'.");
340 tlDefs.insert(it->second);
341 it->second->addNode(currentNode);
346 tlID = (tlID ==
"" ? currentNode->
getID() : tlID);
353 tlDefs.insert(tlDef);
357 if (controlledInner.size() != 0) {
358 for (std::set<NBTrafficLightDefinition*>::iterator it = tlDefs.begin(); it != tlDefs.end(); it++) {
359 (*it)->addControlledInnerEdges(controlledInner);
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
static StringBijection< SumoXMLNodeType > NodeTypes
node types
GeoConvHelper * myLocation
The coordinate transformation which was used compute the node coordinates.
a list of node ids, used for controlling joining
Whether vehicles must keep the junction clear.
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
std::string myID
The id of the currently parsed node.
void addJoinExclusion(const std::vector< std::string > &ids, bool check=false)
void setRightOfWay(RightOfWay rightOfWay)
set method for computing right-of-way
A container for traffic light definitions and built programs.
~NIXMLNodesHandler()
Destructor.
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
double y() const
Returns the y-position.
TrafficLightType getType() const
get the algorithm type (static etc..)
void removeRoundabout(const NBNode *node)
remove roundabout that contains the given node
double x() const
Returns the x-position.
Position myPosition
The position of the currently parsed node.
The base class for traffic light logic definitions.
link,node: the traffic light id responsible for this link
NBTrafficLightLogicCont & myTLLogicCont
The traffic lights container to add built tls to.
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)
const std::string & getID() const
Returns the id.
void set(double x, double y)
set positions x and y
void setCustomShape(const PositionVector &shape)
set the junction shape
SAX-handler base for SUMO-files.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
#define WRITE_WARNING(msg)
static OptionsCont & getOptions()
Retrieves the options.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
NBNodeCont & myNodeCont
The node container to add built nodes to.
virtual RightOfWay getRightOfWay(bool &ok) const =0
Returns the right-of-way method.
void setRadius(double radius)
set the turning radius
bool isTLControlled() const
Returns whether this node is controlled by any tls.
How to compute right of way.
The turning radius at an intersection in m.
NIXMLNodesHandler(NBNodeCont &nc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, OptionsCont &options)
Constructor.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Encapsulated SAX-Attributes.
static GeoConvHelper * loadLocation(const SUMOSAXAttributes &attrs)
Parses network location description and registers it with GeoConveHelper::setLoaded.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
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 node container to add built nodes to.
A point in 2D or 3D with translation and scaling methods.
parameter associated to a certain key
void setx(double x)
set position x
T get(const std::string &str) const
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void deleteNode(const SUMOSAXAttributes &attrs)
void removeTrafficLights()
Removes all references to traffic lights that control this tls.
Parameterised * myLastParameterised
last item the could receive parameters
Storage for edges, including some functionality operating on multiple edges.
void setFringeType(FringeType fringeType)
set method for computing right-of-way
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
node: the type of traffic light
edge: the shape in xml-definition
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<> ...
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
OptionsCont & myOptions
A reference to the program's options.
static void processTrafficLightDefinitions(const SUMOSAXAttributes &attrs, NBNode *currentNode, NBTrafficLightLogicCont &tlc)
Builds the defined traffic light or adds a node to it.
void setKeepClear(bool keepClear)
set the keepClear flag
void addJoinExclusion(const SUMOSAXAttributes &attrs)
std::vector< std::string > getVector()
return vector of strings
void addCluster2Join(std::set< std::string > cluster, NBNode *node)
add ids of nodes which shall be joined into a single 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.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node) ...
void addJoinCluster(const SUMOSAXAttributes &attrs)
alternative definition for junction
A storage for options typed value containers)
SumoXMLNodeType getType() const
Returns the type of this node.
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
const Position & getPosition() const
Represents a single node (junction) during network building.
bool removeFully(const std::string id)
Removes a logic definition (and all programs) from the dictionary.
void myEndElement(int element)
Called when a closing tag occurs.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
void addNode(const SUMOSAXAttributes &attrs)
Container for nodes during the netbuilding process.
void mul(double val)
Multiplies both positions with the given value.
A traffic light logics which must be computed (only nodes/edges are given)
virtual FringeType getFringeType(bool &ok) const =0
returns fringe type
bool extract(NBNode *node, bool remember=false)
Removes the given node but does not delete it.
void closePolygon()
ensures that the last position equals the first
static bool isTrafficLight(SumoXMLNodeType type)
return whether the given type is a traffic light
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
static const Position INVALID
used to indicate that a position is valid
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)