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-2015 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  SUMOReal layer = DEFAULT_LAYER,
67  SUMOReal angle = DEFAULT_ANGLE,
68  const std::string& imgFile = DEFAULT_IMG_FILE,
70  SUMOReal 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 SUMOReal getWidth() const {
88  return myHalfImgWidth * 2.0;
89  }
90 
92  inline SUMOReal getHeight() const {
93  return myHalfImgHeight * 2.0;
94  }
96 
97 
98 
101 
103  inline void setWidth(SUMOReal width) {
104  myHalfImgWidth = width / 2.0;
105  }
106 
108  inline void setHeight(SUMOReal 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, bool geo = false, const SUMOReal zOffset = 0.) {
118  out.openTag(SUMO_TAG_POI);
122  out.writeAttr(SUMO_ATTR_LAYER, getLayer() + zOffset);
123  if (geo) {
124  Position pos(*this);
126  out.writeAttr(SUMO_ATTR_LON, pos.x());
127  out.writeAttr(SUMO_ATTR_LAT, pos.y());
128  } else {
129  out.writeAttr(SUMO_ATTR_X, x());
130  out.writeAttr(SUMO_ATTR_Y, y());
131  }
134  }
137  }
140  }
143  }
144  for (std::map<std::string, std::string>::const_iterator j = getMap().begin(); j != getMap().end(); ++j) {
145  out.openTag(SUMO_TAG_PARAM);
146  out.writeAttr(SUMO_ATTR_KEY, (*j).first);
147  out.writeAttr(SUMO_ATTR_VALUE, (*j).second);
148  out.closeTag();
149  }
150  out.closeTag();
151  }
152 
153 
154 protected:
157 
160 
161 };
162 
163 
164 #endif
165 
166 /****************************************************************************/
167 
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:257
const std::string & getImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:101
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:152
void setHeight(SUMOReal height)
set the image height of the POI
A layer number.
static std::string escapeXML(const std::string &orig)
Replaces the standard escapes by their XML entities.
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
static const SUMOReal DEFAULT_ANGLE
Definition: Shape.h:151
void setWidth(SUMOReal width)
set the image width of the POI
const std::string & getID() const
Returns the id.
Definition: Named.h:65
SUMOReal myHalfImgWidth
The half width of the image when rendering this POI.
static const SUMOReal DEFAULT_IMG_HEIGHT
Definition: Shape.h:154
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A 2D- or 3D-Shape.
Definition: Shape.h:46
An upper class for objects with additional parameters.
Definition: Parameterised.h:47
const RGBColor & getColor() const
Returns the color of the Shape.
Definition: Shape.h:79
static const SUMOReal DEFAULT_LAYER
Definition: Shape.h:150
PointOfInterest(const std::string &id, const std::string &type, const RGBColor &color, const Position &pos, SUMOReal layer=DEFAULT_LAYER, SUMOReal angle=DEFAULT_ANGLE, const std::string &imgFile=DEFAULT_IMG_FILE, SUMOReal width=DEFAULT_IMG_WIDTH, SUMOReal height=DEFAULT_IMG_HEIGHT)
Constructor.
void writeXML(OutputDevice &out, bool geo=false, const SUMOReal zOffset=0.)
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
SUMOReal myHalfImgHeight
The half height of the image when rendering this POI.
SUMOReal getWidth() const
Returns whether the image width of the POI.
SUMOReal getHeight() const
Returns whether the image hidth of the POI.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
bool closeTag()
Closes the most recently opened tag.
#define SUMOReal
Definition: config.h:214
A point-of-interest.
SUMOReal getLayer() const
Returns the layer of the Shape.
Definition: Shape.h:87
const std::string & getType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:71
A color information.
SUMOReal getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:94
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static const SUMOReal DEFAULT_IMG_WIDTH
Definition: Shape.h:153
virtual ~PointOfInterest()
Destructor.