 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
28 #include <xercesc/sax/HandlerBase.hpp>
29 #include <xercesc/sax/AttributeList.hpp>
30 #include <xercesc/sax/SAXParseException.hpp>
31 #include <xercesc/sax/SAXException.hpp>
60 myLastParameterised(nullptr) {
126 bool needConversion =
true;
127 if (node !=
nullptr) {
130 needConversion =
false;
137 needConversion =
true;
142 needConversion =
true;
166 bool updateEdgeGeometries,
171 if (node !=
nullptr) {
183 std::set<NBTrafficLightDefinition*> oldTLS;
185 if (node ==
nullptr) {
186 node =
new NBNode(nodeID, position, type);
188 throw ProcessError(
"Could not insert node though checked this before (id='" + nodeID +
"').");
196 node->
reinit(position, type, updateEdgeGeometries);
203 for (std::set<NBTrafficLightDefinition*>::iterator i = oldTLS.begin(); i != oldTLS.end(); ++i) {
204 if ((*i)->getNodes().size() == 0) {
214 WRITE_ERROR(
"Unable to project node shape at node '" + node->
getID() +
"'.");
216 if (shape.size() > 2) {
252 if (node ==
nullptr) {
265 const std::string clusterString = attrs.
get<std::string>(
SUMO_ATTR_NODES,
nullptr, ok);
267 std::sort(ids.begin(), ids.end());
307 std::set<NBTrafficLightDefinition*> tlDefs;
310 std::string oldTlID =
"";
315 oldTlID = oldDef->
getID();
320 if (tlID != oldTlID || typeS != oldTypeS) {
327 WRITE_ERROR(
"Unknown traffic light type '" + typeS +
"' for node '" + currentNode->
getID() +
"'.");
330 if (tlID !=
"" && tlc.
getPrograms(tlID).size() > 0) {
332 const std::map<std::string, NBTrafficLightDefinition*>& programs = tlc.
getPrograms(tlID);
333 std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
334 for (it = programs.begin(); it != programs.end(); it++) {
335 if (it->second->getType() != type) {
336 WRITE_ERROR(
"Mismatched traffic light type '" + typeS +
"' for tl '" + tlID +
"'.");
339 tlDefs.insert(it->second);
340 it->second->addNode(currentNode);
345 tlID = (tlID ==
"" ? currentNode->
getID() : tlID);
352 tlDefs.insert(tlDef);
356 if (controlledInner.size() != 0) {
357 for (std::set<NBTrafficLightDefinition*>::iterator it = tlDefs.begin(); it != tlDefs.end(); it++) {
358 (*it)->addControlledInnerEdges(controlledInner);
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
@ SUMO_TAG_JOINEXCLUDE
join exlude operation
#define WRITE_WARNING(msg)
@ NODETYPE_DEAD_END_DEPRECATED
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.
@ SUMO_ATTR_TLTYPE
node: the type of traffic light
A container for traffic light definitions and built programs.
void setRightOfWay(RightOfWay rightOfWay)
set method for computing right-of-way
NBEdgeCont & myEdgeCont
The node container to add built nodes to.
static const Position INVALID
used to indicate that a position is valid
@ SUMO_TAG_PARAM
parameter associated to a certain key
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
void setx(double x)
set position x
Position myPosition
The position of the currently parsed node.
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
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 myEndElement(int element)
Called when a closing tag occurs.
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
A traffic light logics which must be computed (only nodes/edges are given)
static OptionsCont & getOptions()
Retrieves the options.
SumoXMLNodeType getType() const
Returns the type of this node.
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
void addCluster2Join(std::set< std::string > cluster, NBNode *node)
add ids of nodes which shall be joined into a single node
@ SUMO_TAG_DELETE
delete certain element
void addJoinExclusion(const SUMOSAXAttributes &attrs)
Container for nodes during the netbuilding process.
virtual FringeType getFringeType(bool &ok) const =0
returns fringe type
NBTrafficLightLogicCont & myTLLogicCont
The traffic lights container to add built tls to.
Parameterised * myLastParameterised
last item the could receive parameters
~NIXMLNodesHandler()
Destructor.
std::string myID
The id of the currently parsed node.
const Position & getPosition() const
bool isTLControlled() const
Returns whether this node is controlled by any tls.
TrafficLightType getType() const
get the algorithm type (static etc..)
@ SUMO_ATTR_KEEP_CLEAR
Whether vehicles must keep the junction clear.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
void set(double x, double y)
set positions x and y
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<>
void closePolygon()
ensures that the last position equals the first
void addNode(const SUMOSAXAttributes &attrs)
static GeoConvHelper * loadLocation(const SUMOSAXAttributes &attrs)
Parses network location description and registers it with GeoConveHelper::setLoaded.
static void processTrafficLightDefinitions(const SUMOSAXAttributes &attrs, NBNode *currentNode, NBTrafficLightLogicCont &tlc)
Builds the defined traffic light or adds a node to it.
A point in 2D or 3D with translation and scaling methods.
void removeTrafficLights()
Removes all references to traffic lights that control this tls.
double x() const
Returns the x-position.
virtual RightOfWay getRightOfWay(bool &ok) const =0
Returns the right-of-way method.
void addJoinExclusion(const std::vector< std::string > &ids, bool check=false)
A storage for options typed value containers)
void setCustomShape(const PositionVector &shape)
set the junction shape
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;.
void setRadius(double radius)
set the turning radius
void addJoinCluster(const SUMOSAXAttributes &attrs)
NIXMLNodesHandler(NBNodeCont &nc, NBEdgeCont &ec, NBTrafficLightLogicCont &tlc, OptionsCont &options)
Constructor.
void mul(double val)
Multiplies both positions with the given value.
@ NODETYPE_RIGHT_BEFORE_LEFT
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
@ SUMO_ATTR_RADIUS
The turning radius at an intersection in m.
@ SUMO_ATTR_CONTROLLED_INNER
NBNodeCont & myNodeCont
The node container to add built nodes to.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double y() const
Returns the y-position.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
bool removeFully(const std::string id)
Removes a logic definition (and all programs) from the dictionary.
@ SUMO_ATTR_RIGHT_OF_WAY
How to compute right of way.
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)
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
void setKeepClear(bool keepClear)
set the keepClear flag
void setFringeType(FringeType fringeType)
set method for computing right-of-way
std::vector< std::string > getVector()
return vector of strings
bool extract(NBNode *node, bool remember=false)
Removes the given node but does not delete it.
@ SUMO_TAG_JOIN
Join operation.
void removeRoundabout(const NBNode *node)
remove roundabout that contains the given node
@ SUMO_ATTR_FRINGE
Fringe type of node.
Represents a single node (junction) during network building.
void sety(double y)
set position y
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
Encapsulated SAX-Attributes.
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
void setz(double z)
set position z
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)
GeoConvHelper * myLocation
The coordinate transformation which was used compute the node coordinates.
static StringBijection< SumoXMLNodeType > NodeTypes
node types
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
The base class for traffic light logic definitions.
OptionsCont & myOptions
A reference to the program's options.
@ SUMO_ATTR_NODES
a list of node ids, used for controlling joining
@ SUMO_TAG_NODE
alternative definition for junction