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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // The XML-Handler for network loading
18 /****************************************************************************/
19 #ifndef ShapeHandler_h
20 #define ShapeHandler_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <utils/common/RGBColor.h>
33 #include <utils/geom/Position.h>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class ShapeContainer;
41 class Parameterised;
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
55 class ShapeHandler : public SUMOSAXHandler {
56 public:
65  ShapeHandler(const std::string& file, ShapeContainer& sc);
66 
68  virtual ~ShapeHandler();
69 
71  static bool loadFiles(const std::vector<std::string>& files, ShapeHandler& sh);
72 
73 protected:
75 
76 
84  virtual void myStartElement(int element,
85  const SUMOSAXAttributes& attrs);
86 
94  virtual void myEndElement(int element);
96 
98  virtual Position getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, double lanePosLat) = 0;
99 
101  virtual bool addLanePosParams() {
102  return false;
103  }
104 
105 protected:
107  void setDefaults(const std::string& prefix, const RGBColor& color, const double layer, const bool fill = false);
108 
110  void addPOI(const SUMOSAXAttributes& attrs, const bool ignorePruning, const bool useProcessing);
111 
113  void addPoly(const SUMOSAXAttributes& attrs, const bool ignorePruning, const bool useProcessing);
114 
115 protected:
117 
118 private:
120  std::string myPrefix;
121 
124 
127 
130 
133 
136 
137 private:
139  ShapeHandler(const ShapeHandler& s) = delete;
140 
142  ShapeHandler& operator=(const ShapeHandler& s) = delete;
143 };
144 
145 
146 #endif
147 
148 /****************************************************************************/
149 
double myDefaultLayer
The default layer to use.
Definition: ShapeHandler.h:126
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:123
Parameterised * myLastParameterised
element to receive parameters
Definition: ShapeHandler.h:135
SAX-handler base for SUMO-files.
std::string myPrefix
The prefix to use.
Definition: ShapeHandler.h:120
The XML-Handler for network loading.
Definition: ShapeHandler.h:55
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:101
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
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:129
An upper class for objects with additional parameters.
Definition: Parameterised.h:50
void addPoly(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a polygon
virtual ~ShapeHandler()
Destructor.
ShapeContainer & myShapeContainer
Definition: ShapeHandler.h:116
bool myReportFile
flag to check if problems hast to be handled as errors instead warnings
Definition: ShapeHandler.h:132