SUMO - Simulation of Urban MObility
SUMOPolygon.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2004-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 /****************************************************************************/
19 // A 2D-polygon
20 /****************************************************************************/
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 
35 #include "SUMOPolygon.h"
36 
37 
38 // ===========================================================================
39 // member definitions
40 // ===========================================================================
41 SUMOPolygon::SUMOPolygon(const std::string& id, const std::string& type,
42  const RGBColor& color, const PositionVector& shape, bool geo, bool fill,
43  double layer, double angle, const std::string& imgFile) :
44  Shape(id, type, color, layer, angle, imgFile),
45  myShape(shape),
46  myGEO(geo),
47  myFill(fill) {
48 }
49 
50 
52 
53 
54 void
58  if (getType().size() > 0) {
60  }
64  PositionVector shape = getShape();
65  if (geo) {
66  out.writeAttr(SUMO_ATTR_GEO, true);
67  for (int i = 0; i < (int) shape.size(); i++) {
69  }
70  }
71  out.writeAttr(SUMO_ATTR_SHAPE, shape);
74  }
77  }
78  writeParams(out);
79  out.closeTag();
80 }
81 
82 
83 /****************************************************************************/
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:260
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:151
A layer number.
const PositionVector & getShape() const
Returns whether the shape of the polygon.
Definition: SUMOPolygon.h:84
SUMOPolygon(const std::string &id, const std::string &type, const RGBColor &color, const PositionVector &shape, bool geo, bool fill, double layer=DEFAULT_LAYER, double angle=DEFAULT_ANGLE, const std::string &imgFile=DEFAULT_IMG_FILE)
Constructor.
Definition: SUMOPolygon.cpp:41
const std::string & getID() const
Returns the id.
Definition: Named.h:74
virtual ~SUMOPolygon()
Destructor.
Definition: SUMOPolygon.cpp:51
const std::string & getImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:100
void writeParams(OutputDevice &out) const
double getLayer() const
Returns the layer of the Shape.
Definition: Shape.h:86
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
double getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:93
A list of positions.
A 2D- or 3D-Shape.
Definition: Shape.h:45
edge: the shape in xml-definition
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
bool getFill() const
Returns whether the polygon is filled.
Definition: SUMOPolygon.h:92
const std::string & getType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:70
const RGBColor & getColor() const
Returns the color of the Shape.
Definition: Shape.h:78
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void writeXML(OutputDevice &out, bool geo=false)
Definition: SUMOPolygon.cpp:55
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool closeTag()
Closes the most recently opened tag.
A color information.
Fill the polygon.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static const double DEFAULT_ANGLE
Definition: Shape.h:150
begin/end of the description of a polygon