SUMO - Simulation of Urban MObility
PointOfInterest.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // A point-of-interest (2D)
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2005-2016 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef PointOfInterest_h
24 #define PointOfInterest_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
39 #include <utils/geom/Position.h>
41 #include "Shape.h"
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
51 class PointOfInterest : public Shape, public Position, public Parameterised {
52 public:
64  PointOfInterest(const std::string& id, const std::string& type,
65  const RGBColor& color, const Position& pos,
66  double layer = DEFAULT_LAYER,
67  double angle = DEFAULT_ANGLE,
68  const std::string& imgFile = DEFAULT_IMG_FILE,
69  double width = DEFAULT_IMG_WIDTH,
70  double height = DEFAULT_IMG_HEIGHT) :
71  Shape(id, type, color, layer, angle, imgFile),
72  Position(pos),
73  myHalfImgWidth(width / 2.0),
74  myHalfImgHeight(height / 2.0) {
75  }
76 
77 
79  virtual ~PointOfInterest() { }
80 
81 
82 
85 
87  inline double getWidth() const {
88  return myHalfImgWidth * 2.0;
89  }
90 
92  inline double getHeight() const {
93  return myHalfImgHeight * 2.0;
94  }
96 
97 
98 
101 
103  inline void setWidth(double width) {
104  myHalfImgWidth = width / 2.0;
105  }
106 
108  inline void setHeight(double height) {
109  myHalfImgHeight = height / 2.0;
110  }
112 
113 
114  /* @brief POI definition to the given device
115  * @param[in] geo Whether to write the output in geo-coordinates
116  */
117  void writeXML(OutputDevice& out, const bool geo = false, const double zOffset = 0., const std::string laneID = "", const double pos = 0.) {
118  out.openTag(SUMO_TAG_POI);
122  out.writeAttr(SUMO_ATTR_LAYER, getLayer() + zOffset);
123  if (laneID != "") {
124  out.writeAttr(SUMO_ATTR_LANE, laneID);
125  out.writeAttr(SUMO_ATTR_POSITION, pos);
126  } else {
127  if (geo) {
128  Position pos(*this);
130  out.writeAttr(SUMO_ATTR_LON, pos.x());
131  out.writeAttr(SUMO_ATTR_LAT, pos.y());
132  } else {
133  out.writeAttr(SUMO_ATTR_X, x());
134  out.writeAttr(SUMO_ATTR_Y, y());
135  }
136  }
139  }
142  }
145  }
148  }
149  for (std::map<std::string, std::string>::const_iterator j = getMap().begin(); j != getMap().end(); ++j) {
150  out.openTag(SUMO_TAG_PARAM);
151  out.writeAttr(SUMO_ATTR_KEY, (*j).first);
152  out.writeAttr(SUMO_ATTR_VALUE, (*j).second);
153  out.closeTag();
154  }
155  out.closeTag();
156  }
157 
158 
159 protected:
162 
165 
166 };
167 
168 
169 #endif
170 
171 /****************************************************************************/
172 
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
void writeXML(OutputDevice &out, const bool geo=false, const double zOffset=0., const std::string laneID="", const double pos=0.)
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:152
A layer number.
double y() const
Returns the y-position.
Definition: Position.h:68
static const double DEFAULT_IMG_HEIGHT
Definition: Shape.h:154
double x() const
Returns the x-position.
Definition: Position.h:63
begin/end of the description of a polygon
const std::string & getID() const
Returns the id.
Definition: Named.h:66
double getHeight() const
Returns the image height of the POI.
const std::string & getImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:101
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.
double myHalfImgHeight
The half height of the image when rendering this POI.
double getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:94
PointOfInterest(const std::string &id, const std::string &type, const RGBColor &color, const Position &pos, double layer=DEFAULT_LAYER, double angle=DEFAULT_ANGLE, const std::string &imgFile=DEFAULT_IMG_FILE, double width=DEFAULT_IMG_WIDTH, double height=DEFAULT_IMG_HEIGHT)
Constructor.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
parameter associated to a certain key
A 2D- or 3D-Shape.
Definition: Shape.h:46
double myHalfImgWidth
The half width of the image when rendering this POI.
An upper class for objects with additional parameters.
Definition: Parameterised.h:51
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
double getWidth() const
Returns the image width of the POI.
const std::string & getType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:71
void setHeight(double height)
set the image height of the POI
const RGBColor & getColor() const
Returns the color of the Shape.
Definition: Shape.h:79
void setWidth(double width)
set the image width of the POI
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
static const double DEFAULT_IMG_WIDTH
Definition: Shape.h:153
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
bool closeTag()
Closes the most recently opened tag.
A point-of-interest.
A color information.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static const double DEFAULT_ANGLE
Definition: Shape.h:151
static const double DEFAULT_LAYER
Definition: Shape.h:150
virtual ~PointOfInterest()
Destructor.