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  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, const bool geo = false, const SUMOReal zOffset = 0., const std::string laneID = "", const SUMOReal 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:257
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:152
void writeXML(OutputDevice &out, const bool geo=false, const SUMOReal zOffset=0., const std::string laneID="", const SUMOReal pos=0.)
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.
SUMOReal getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:94
const std::string & getID() const
Returns the id.
Definition: Named.h:66
const std::string & getImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:101
static const SUMOReal DEFAULT_ANGLE
Definition: Shape.h:151
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
void setWidth(SUMOReal width)
set the image width of the POI
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
SUMOReal getHeight() const
Returns the image height of the POI.
A 2D- or 3D-Shape.
Definition: Shape.h:46
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
An upper class for objects with additional parameters.
Definition: Parameterised.h:47
static const SUMOReal DEFAULT_LAYER
Definition: Shape.h:150
const std::string & getType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:71
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.
const RGBColor & getColor() const
Returns the color of the Shape.
Definition: Shape.h:79
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...
SUMOReal myHalfImgHeight
The half height of the image when rendering this POI.
SUMOReal getLayer() const
Returns the layer of the Shape.
Definition: Shape.h:87
SUMOReal getWidth() const
Returns the image width 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:213
A point-of-interest.
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
A color information.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static const SUMOReal DEFAULT_IMG_WIDTH
Definition: Shape.h:153
virtual ~PointOfInterest()
Destructor.