/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file NIXMLNodesHandler.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Michael Behrisch17/// @date Tue, 20 Nov 200118///19// Importer for network nodes stored in XML20/****************************************************************************/21#pragma once22#include <config.h>2324#include <utils/xml/SUMOSAXHandler.h>25#include <utils/geom/Position.h>262728// ===========================================================================29// class declarations30// ===========================================================================31class OptionsCont;32class GeoConvHelper;33class NBNode;34class NBNodeCont;35class NBTrafficLightLogicCont;363738// ===========================================================================39// class definitions40// ===========================================================================41/**42* @class NIXMLNodesHandler43* @brief Importer for network nodes stored in XML44*45* This SAX-handler parses node information and stores it in the given node46* container. Additionally, the given tls-container may be filled with47* additional information.48*/49class NIXMLNodesHandler : public SUMOSAXHandler {5051public:52/** @brief Constructor53*54* @param[in, filled] nc The node container to fill55* @param[in, filled] tlc The traffic lights container to fill56* @param[in] options The options to use57* @todo Options are only given to determine whether "flip-y" is set; maybe this should be done by giving a bool58* @todo Why are options not const?59*/60NIXMLNodesHandler(NBNodeCont& nc, NBEdgeCont& ec, NBTrafficLightLogicCont& tlc,61OptionsCont& options);626364/// @brief Destructor65~NIXMLNodesHandler();6667/** @brief parses node attributes (not related to positioning)68*/69static NBNode* processNodeType(const SUMOSAXAttributes& attrs, NBNode* node, const std::string& nodeID, const Position& position,70bool updateEdgeGeometries,71NBNodeCont& nc, NBEdgeCont& ec,72NBTrafficLightLogicCont& tlc,73GeoConvHelper* from_srs = nullptr);7475protected:76/// @name inherited from GenericSAXHandler77//@{7879/** @brief Called on the opening of a tag;80*81* In dependence to the obtained type, an appropriate parsing method is called.82*83* @param[in] element ID of the currently opened element84* @param[in] attrs Attributes within the currently opened element85* @exception ProcessError If something fails (not used herein)86* @note policy is to throw no exception in order to allow further processing87* @todo ProcessErrors are thrown when parsing traffic lights!?88*/89void myStartElement(int element,90const SUMOSAXAttributes& attrs);91/** @brief Called when a closing tag occurs92*93* @param[in] element ID of the currently opened element94* @exception ProcessError If something fails95* @see GenericSAXHandler::myEndElement96*/97void myEndElement(int element);98//@}99100101private:102/*103* @brief Parses node information104* Tries to parse a node. If the node can be parsed, it is stored within105* "myNodeCont". Otherwise an error is generated. Then, if given106* the tls information is parsed and inserted into "myTLLogicCont".107*/108void addNode(const SUMOSAXAttributes& attrs);109110/*111* @brief Parses node deletion information112*/113void deleteNode(const SUMOSAXAttributes& attrs);114115/*116* @brief Parses a cluster of nodes to be joined117*/118void addJoinCluster(const SUMOSAXAttributes& attrs);119120/*121* @brief Parses a list of nodes to be excluded from joining122*/123void addJoinExclusion(const SUMOSAXAttributes& attrs);124125126/** @brief Builds the defined traffic light or adds a node to it127*128* @param[in] attrs Attributes within the currently opened node129* @param[in] currentNode The built node to add the tls information to130*/131static void processTrafficLightDefinitions(const SUMOSAXAttributes& attrs,132NBNode* currentNode, NBTrafficLightLogicCont& tlc);133134135private:136/// @brief A reference to the program's options137OptionsCont& myOptions;138139/// @brief The id of the currently parsed node140std::string myID;141142/// @brief The position of the currently parsed node143Position myPosition;144145/// @brief The node container to add built nodes to146NBNodeCont& myNodeCont;147148/// @brief The node container to add built nodes to149NBEdgeCont& myEdgeCont;150151/// @brief The traffic lights container to add built tls to152NBTrafficLightLogicCont& myTLLogicCont;153154/// @brief The coordinate transformation which was used compute the node coordinates155GeoConvHelper* myLocation;156157/// @brief last item the could receive parameters158Parameterised* myLastParameterised;159160private:161/** @brief invalid copy constructor */162NIXMLNodesHandler(const NIXMLNodesHandler& s);163164/** @brief invalid assignment operator */165NIXMLNodesHandler& operator=(const NIXMLNodesHandler& s);166167};168169170