/****************************************************************************/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 ShapeHandler.h14/// @author Jakob Erdmann15/// @date Feb 201516///17// The XML-Handler for network loading18/****************************************************************************/19#pragma once20#include <config.h>2122#include <utils/common/RGBColor.h>23#include <utils/geom/Position.h>24#include <utils/xml/SUMOSAXHandler.h>252627// ===========================================================================28// class declarations29// ===========================================================================30class ShapeContainer;31class Parameterised;32class GeoConvHelper;333435// ===========================================================================36// class definitions37// ===========================================================================38/**39* @class ShapeHandler40* @brief The XML-Handler for network loading41*42* The SAX2-handler responsible for parsing networks and routes to load.43* This is an extension of the MSRouteHandler as routes and vehicles may also44* be loaded from network descriptions.45*/46class ShapeHandler : public SUMOSAXHandler {47public:48/** @brief Constructor49* @param[in] file Name of the parsed file50* @param[in, out] net The network to fill51* @param[in] detBuilder The detector builder to use52* @param[in] triggerBuilder The trigger builder to use53* @param[in] edgeBuilder The builder of edges to use54* @param[in] junctionBuilder The builder of junctions to use55*/56ShapeHandler(const std::string& file, ShapeContainer& sc, const GeoConvHelper* = nullptr);5758/// @brief Destructor59virtual ~ShapeHandler();6061/// @brief loads all of the given files62static bool loadFiles(const std::vector<std::string>& files, ShapeHandler& sh);6364protected:65/// @name inherited from GenericSAXHandler66//@{67/** @brief Called on the opening of a tag;68*69* @param[in] element ID of the currently opened element70* @param[in] attrs Attributes within the currently opened element71* @exception ProcessError If something fails72* @see GenericSAXHandler::myStartElement73* @todo Refactor/describe74*/75virtual void myStartElement(int element, const SUMOSAXAttributes& attrs);7677/** @brief Called when a closing tag occurs78*79* @param[in] element ID of the currently opened element80* @exception ProcessError If something fails81* @see GenericSAXHandler::myEndElement82* @todo Refactor/describe83*/84virtual void myEndElement(int element);85//@}8687/// @brief get position for a given laneID (Has to be implemented in all child)88virtual Position getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, bool friendlyPos, double lanePosLat) = 0;8990/// @brief Whether some input attributes shall be automatically added as params (Can be implemented in all child)91virtual bool addLanePosParams();9293protected:94/// @brief set default values95void setDefaults(const std::string& prefix, const RGBColor& color, const std::string& icon, const double layer, const bool fill = false);9697/// @brief adds a POI98void addPOI(const SUMOSAXAttributes& attrs, const bool ignorePruning, const bool useProcessing);99100/// @brief adds a polygon101void addPoly(const SUMOSAXAttributes& attrs, const bool ignorePruning, const bool useProcessing);102103/// @brief get last parameterised object104Parameterised* getLastParameterised() const;105106protected:107/// @brief reference to shape container in which all Shares are being added108ShapeContainer& myShapeContainer;109110/// @brief The prefix to use111std::string myPrefix;112113/// @brief The default color to use114RGBColor myDefaultColor;115116/// @brief The default icon to use117std::string myDefaultIcon;118119/// @brief The default layer to use120double myDefaultLayer;121122/// @brief Information whether polygons should be filled123bool myDefaultFill;124125/// @brief element to receive parameters126Parameterised* myLastParameterised;127128/// @brief geo-conversion to use during loading129const GeoConvHelper* myGeoConvHelper;130131/// @brief invalidate copy constructor132ShapeHandler(const ShapeHandler& s) = delete;133134/// @brief invalidate assignment operator135ShapeHandler& operator=(const ShapeHandler& s) = delete;136};137138139