/****************************************************************************/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 RONetHandler.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Michael Behrisch17/// @date Sept 200218///19// The handler that parses a SUMO-network for its usage in a router20/****************************************************************************/21#pragma once22#include <config.h>2324#include <string>25#include <utils/xml/SUMOSAXHandler.h>26#include <utils/common/SUMOVehicleClass.h>27#include <utils/common/UtilExceptions.h>282930// ===========================================================================31// class declarations32// ===========================================================================33class RONet;34class OptionsCont;35class ROEdge;36class ROAbstractEdgeBuilder;373839// ===========================================================================40// class definitions41// ===========================================================================42/**43* @class RONetHandler44* @brief The handler that parses a SUMO-network for its usage in a router45*46* SAX2-Handler for SUMO-network loading. As this class is used for both47* the dua- and the jtrrouter, a reference to the edge builder is given.48*/49class RONetHandler : public SUMOSAXHandler {50public:51/** @brief Constructor52*53* @param[in] net The network instance to fill54* @param[in] eb The abstract edge builder to use55*/56RONetHandler(RONet& net, ROAbstractEdgeBuilder& eb, const bool ignoreInternal, const double minorPenalty, double tlsPenalty, double turnaroundPenalty);575859/// @brief Destructor60virtual ~RONetHandler();6162/// @brief retrieve mapping of edges to bidi edges (must be resolved after loading network)63const std::map<ROEdge*, std::string>& getBidiMap() const {64return myBidiEdges;65}6667protected:68/// @name inherited from GenericSAXHandler69//@{7071/** @brief Called on the opening of a tag;72*73* @param[in] element ID of the currently opened element74* @param[in] attrs Attributes within the currently opened element75* @exception ProcessError If something fails76* @see GenericSAXHandler::myStartElement77*/78virtual void myStartElement(int element, const SUMOSAXAttributes& attrs);7980/** @brief Called when a closing tag occurs81*82* @param[in] element ID of the currently opened element83* @exception ProcessError If something fails84* @see GenericSAXHandler::myEndElement85*/86virtual void myEndElement(int element);87//@}8889protected:90/// @name called from myStartElement91//@{9293/// @brief assign arbitrary vehicle parameters94void addParam(const SUMOSAXAttributes& attrs);9596/** @brief Parses and builds an edge97*98* Parses attributes from an "edge"-element (id, from/to-nodes, function, etc.).99* If the given nodes are not yet known, they are added to the network.100* Uses the internal edge builder to build the edge and adds the edge101* to the network.102*103* @param[in] attrs The attributes (of the "edge"-element) to parse104* @todo The edge is "built" first, then the nodes are added; should be done while constructing, probably a legacy issue105* @todo No exception?106*/107void parseEdge(const SUMOSAXAttributes& attrs);108109110/** @brief Parses and builds a lane111*112* Parses attributes from an "lane"-element (speed, length, vehicle classes, etc.).113* Builds a ROLane using these attributes (if they are valid) and adds it to the edge.114*115* @param[in] attrs The attributes (of the "lane"-element) to parse116* @todo No exception?117*/118virtual void parseLane(const SUMOSAXAttributes& attrs);119120121/** @brief Parses a junction's position122*123* Parses the position of the junction. Sets it to the junction.124*125* @param[in] attrs The attributes (of the "lane"-element) to parse126* @todo In fact, the junction should be built given its position.127* @todo No exception?128*/129void parseJunction(const SUMOSAXAttributes& attrs);130131132/** @begin Parses a connection133* Called on the occurrence of a "connection" element134* @param[in] attrs The attributes (of the "connection"-element) to parse135*/136void parseConnection(const SUMOSAXAttributes& attrs);137138139/** @begin Parses a stopping place140* Called on the occurrence of a "busStop", "trainStop" or "containerStop" element141* @param[in] attrs The attributes to parse142* @param[in] element which kind of stop is to be parsed143*/144void parseStoppingPlace(const SUMOSAXAttributes& attrs, const SumoXMLTag element);145146147/** @begin Parses an access point to a train stop148* Called on the occurrence of an "access" element149* @param[in] attrs The attributes to parse150*/151void parseAccess(const SUMOSAXAttributes& attrs);152153154/** @begin Parses a district and creates a pseudo edge for it155*156* Called on the occurrence of a "district" element, this method157* retrieves the id of the district and creates a district type158* edge with this id.159*160* @param[in] attrs The attributes (of the "district"-element) to parse161* @exception ProcessError If an edge given in district@edges is not known162*/163void parseDistrict(const SUMOSAXAttributes& attrs);164165166/** @begin Parses a district edge and connects it to the district167*168* Called on the occurrence of a "dsource" or "dsink" element, this method169* retrieves the id of the approachable edge. If this edge is known170* and valid, the approaching edge is informed about it (by calling171* "ROEdge::addFollower").172*173* @param[in] attrs The attributes to parse174* @param[in] isSource whether a "dsource or a "dsink" was given175* @todo No exception?176*/177void parseDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource);178179//@}180181/// Parses network location description182void setLocation(const SUMOSAXAttributes& attrs);183184protected:185/// @brief The net to store the information into186RONet& myNet;187188/// @brief the loaded network version189MMVersion myNetworkVersion;190191/// @brief The object used to build of edges of the desired type192ROAbstractEdgeBuilder& myEdgeBuilder;193194/// @brief whether to ignore junction internal edges195const bool myIgnoreInternal;196197/// @brief The name of the edge/node that is currently processed198std::string myCurrentName;199200/// The id of the currently processed edge type201std::string myCurrentTypeID;202203/// @brief The currently built edge204ROEdge* myCurrentEdge;205206/// @brief The currently built stopping place207SUMOVehicleParameter::Stop* myCurrentStoppingPlace;208209/// @brief temporary data for checking node initialisation after network parsing is finished210std::set<std::string> myUnseenNodeIDs;211212/// @brief time penalty for passing a minor link213const double myMinorPenalty;214const double myTLSPenalty;215const double myTurnaroundPenalty;216217/// @brief temporary storage for bidi attributes (to be resolved after loading all edges)218std::map<ROEdge*, std::string> myBidiEdges;219220private:221/// @brief Invalidated copy constructor222RONetHandler(const RONetHandler& src);223224/// @brief Invalidated assignment operator225RONetHandler& operator=(const RONetHandler& src);226227};228229230