SUMO - Simulation of Urban MObility
Polygon.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A 2D-polygon
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2004-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
36 #include "Polygon.h"
37 using namespace SUMO;
38 
39 
40 // ===========================================================================
41 // member definitions
42 // ===========================================================================
43 Polygon::Polygon(const std::string& id, const std::string& type,
44  const RGBColor& color, const PositionVector& shape, bool fill,
45  double layer, double angle, const std::string& imgFile) :
46  Shape(id, type, color, layer, angle, imgFile),
47  myShape(shape),
48  myFill(fill) {
49 }
50 
51 
53 
54 
55 void
63  PositionVector shape = getShape();
64  if (geo) {
65  out.writeAttr(SUMO_ATTR_GEO, true);
66  for (int i = 0; i < (int) shape.size(); i++) {
68  }
69  }
70  out.writeAttr(SUMO_ATTR_SHAPE, shape);
73  }
76  }
77  writeParams(out);
78  out.closeTag();
79 }
80 
81 /****************************************************************************/
82 
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:152
bool getFill() const
Returns whether the polygon is filled.
Definition: Polygon.h:95
A layer number.
void writeXML(OutputDevice &out, bool geo=false)
Definition: Polygon.cpp:56
const std::string & getID() const
Returns the id.
Definition: Named.h:66
const PositionVector & getShape() const
Returns whether the shape of the polygon.
Definition: Polygon.h:87
const std::string & getImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:101
void writeParams(OutputDevice &out) const
double getLayer() const
Returns the layer of the Shape.
Definition: Shape.h:87
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
Polygon(const std::string &id, const std::string &type, const RGBColor &color, const PositionVector &shape, bool fill, double layer=DEFAULT_LAYER, double angle=DEFAULT_ANGLE, const std::string &imgFile=DEFAULT_IMG_FILE)
Constructor.
Definition: Polygon.cpp:43
double getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:94
A list of positions.
A 2D- or 3D-Shape.
Definition: Shape.h:46
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.
const std::string & getType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:71
const RGBColor & getColor() const
Returns the color of the Shape.
Definition: Shape.h:79
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
Definition: Polygon.h:48
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
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:151
virtual ~Polygon()
Destructor.
Definition: Polygon.cpp:52
begin/end of the description of a polygon