Eclipse SUMO - Simulation of Urban MObility
ShapeHandler.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // The XML-Handler for network loading
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <utils/common/RGBColor.h>
24 #include <utils/geom/Position.h>
26 
27 
28 // ===========================================================================
29 // class declarations
30 // ===========================================================================
31 class ShapeContainer;
32 class Parameterised;
33 class GeoConvHelper;
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
47 class ShapeHandler : public SUMOSAXHandler {
48 public:
57  ShapeHandler(const std::string& file, ShapeContainer& sc, const GeoConvHelper* = nullptr);
58 
60  virtual ~ShapeHandler();
61 
63  static bool loadFiles(const std::vector<std::string>& files, ShapeHandler& sh);
64 
65 protected:
67 
68 
76  virtual void myStartElement(int element, const SUMOSAXAttributes& attrs);
77 
85  virtual void myEndElement(int element);
87 
89  virtual Position getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, bool friendlyPos, double lanePosLat) = 0;
90 
92  virtual bool addLanePosParams();
93 
94 protected:
96  void setDefaults(const std::string& prefix, const RGBColor& color, const std::string& icon, const double layer, const bool fill = false);
97 
99  void addPOI(const SUMOSAXAttributes& attrs, const bool ignorePruning, const bool useProcessing);
100 
102  void addPoly(const SUMOSAXAttributes& attrs, const bool ignorePruning, const bool useProcessing);
103 
106 
107 protected:
110 
112  std::string myPrefix;
113 
116 
118  std::string myDefaultIcon;
119 
122 
125 
128 
131 
133  ShapeHandler(const ShapeHandler& s) = delete;
134 
136  ShapeHandler& operator=(const ShapeHandler& s) = delete;
137 };
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:53
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.
Storage for geometrical objects.
The XML-Handler for network loading.
Definition: ShapeHandler.h:47
virtual bool addLanePosParams()
Whether some input attributes shall be automatically added as params (Can be implemented in all child...
ShapeHandler & operator=(const ShapeHandler &s)=delete
invalidate assignment operator
std::string myPrefix
The prefix to use.
Definition: ShapeHandler.h:112
ShapeHandler(const ShapeHandler &s)=delete
invalidate copy constructor
virtual void myEndElement(int element)
Called when a closing tag occurs.
void addPOI(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a POI
void addPoly(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a polygon
RGBColor myDefaultColor
The default color to use.
Definition: ShapeHandler.h:115
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
ShapeContainer & myShapeContainer
reference to shape container in which all Shares are being added
Definition: ShapeHandler.h:109
Parameterised * myLastParameterised
element to receive parameters
Definition: ShapeHandler.h:127
static bool loadFiles(const std::vector< std::string > &files, ShapeHandler &sh)
loads all of the given files
virtual Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, bool friendlyPos, double lanePosLat)=0
get position for a given laneID (Has to be implemented in all child)
void setDefaults(const std::string &prefix, const RGBColor &color, const std::string &icon, const double layer, const bool fill=false)
set default values
bool myDefaultFill
Information whether polygons should be filled.
Definition: ShapeHandler.h:124
virtual ~ShapeHandler()
Destructor.
ShapeHandler(const std::string &file, ShapeContainer &sc, const GeoConvHelper *=nullptr)
Constructor.
Parameterised * getLastParameterised() const
get last parameterised object
std::string myDefaultIcon
The default icon to use.
Definition: ShapeHandler.h:118
const GeoConvHelper * myGeoConvHelper
geo-conversion to use during loading
Definition: ShapeHandler.h:130
double myDefaultLayer
The default layer to use.
Definition: ShapeHandler.h:121