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.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // The XML-Handler for network loading
16 /****************************************************************************/
17 #ifndef ShapeHandler_h
18 #define ShapeHandler_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <utils/common/RGBColor.h>
27 #include <utils/geom/Position.h>
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class ShapeContainer;
35 class Parameterised;
36 
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
49 class ShapeHandler : public SUMOSAXHandler {
50 public:
59  ShapeHandler(const std::string& file, ShapeContainer& sc);
60 
62  virtual ~ShapeHandler();
63 
65  static bool loadFiles(const std::vector<std::string>& files, ShapeHandler& sh);
66 
67 protected:
69 
70 
78  virtual void myStartElement(int element,
79  const SUMOSAXAttributes& attrs);
80 
88  virtual void myEndElement(int element);
90 
92  virtual Position getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, double lanePosLat) = 0;
93 
95  virtual bool addLanePosParams() {
96  return false;
97  }
98 
99 protected:
101  void setDefaults(const std::string& prefix, const RGBColor& color, const double layer, const bool fill = false);
102 
104  void addPOI(const SUMOSAXAttributes& attrs, const bool ignorePruning, const bool useProcessing);
105 
107  void addPoly(const SUMOSAXAttributes& attrs, const bool ignorePruning, const bool useProcessing);
108 
109 protected:
111 
112 private:
114  std::string myPrefix;
115 
118 
121 
124 
127 
128 private:
130  ShapeHandler(const ShapeHandler& s) = delete;
131 
133  ShapeHandler& operator=(const ShapeHandler& s) = delete;
134 };
135 
136 
137 #endif
138 
139 /****************************************************************************/
140 
double myDefaultLayer
The default layer to use.
Definition: ShapeHandler.h:120
ShapeHandler(const std::string &file, ShapeContainer &sc)
Constructor.
void setDefaults(const std::string &prefix, const RGBColor &color, const double layer, const bool fill=false)
set default values
virtual void myEndElement(int element)
Called when a closing tag occurs.
virtual Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, double lanePosLat)=0
get position for a given laneID
static bool loadFiles(const std::vector< std::string > &files, ShapeHandler &sh)
loads all of the given files
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Storage for geometrical objects.
RGBColor myDefaultColor
The default color to use.
Definition: ShapeHandler.h:117
Parameterised * myLastParameterised
element to receive parameters
Definition: ShapeHandler.h:126
SAX-handler base for SUMO-files.
std::string myPrefix
The prefix to use.
Definition: ShapeHandler.h:114
The XML-Handler for network loading.
Definition: ShapeHandler.h:49
ShapeHandler & operator=(const ShapeHandler &s)=delete
invalidate assignment operator
Encapsulated SAX-Attributes.
virtual bool addLanePosParams()
Whether some input attributes shall be automatically added as params.
Definition: ShapeHandler.h:95
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
void addPOI(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a POI
bool myDefaultFill
Information whether polygons should be filled.
Definition: ShapeHandler.h:123
An upper class for objects with additional parameters.
Definition: Parameterised.h:44
void addPoly(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a polygon
virtual ~ShapeHandler()
Destructor.
ShapeContainer & myShapeContainer
Definition: ShapeHandler.h:110