SUMO - Simulation of Urban MObility
PointOfInterest.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2005-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 /****************************************************************************/
20 // A point-of-interest (2D)
21 /****************************************************************************/
22 #ifndef PointOfInterest_h
23 #define PointOfInterest_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
38 #include <utils/geom/Position.h>
40 #include "Shape.h"
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
50 class PointOfInterest : public Shape, public Position, public Parameterised {
51 public:
67  PointOfInterest(const std::string& id, const std::string& type,
68  const RGBColor& color, const Position& pos, bool geo,
69  const std::string& lane, double posOverLane, double posLat,
70  double layer = DEFAULT_LAYER,
71  double angle = DEFAULT_ANGLE,
72  const std::string& imgFile = DEFAULT_IMG_FILE,
73  double width = DEFAULT_IMG_WIDTH,
74  double height = DEFAULT_IMG_HEIGHT) :
75  Shape(id, type, color, layer, angle, imgFile),
76  Position(pos),
77  myGeo(geo),
78  myLane(lane),
79  myPosOverLane(posOverLane),
80  myPosLat(posLat),
81  myHalfImgWidth(width / 2.0),
82  myHalfImgHeight(height / 2.0) {
83  }
84 
85 
87  virtual ~PointOfInterest() { }
88 
89 
92 
94  inline double getWidth() const {
95  return myHalfImgWidth * 2.0;
96  }
97 
99  inline double getHeight() const {
100  return myHalfImgHeight * 2.0;
101  }
103 
104 
107 
109  inline void setWidth(double width) {
110  myHalfImgWidth = width / 2.0;
111  }
112 
114  inline void setHeight(double height) {
115  myHalfImgHeight = height / 2.0;
116  }
118 
119 
120  /* @brief POI definition to the given device
121  * @param[in] geo Whether to write the output in geo-coordinates
122  */
123  void writeXML(OutputDevice& out, const bool geo = false, const double zOffset = 0., const std::string laneID = "", const double pos = 0., const double posLat = 0.) {
124  out.openTag(SUMO_TAG_POI);
126  if (getType().size() > 0) {
128  }
130  out.writeAttr(SUMO_ATTR_LAYER, getLayer() + zOffset);
131  if (laneID != "") {
132  out.writeAttr(SUMO_ATTR_LANE, laneID);
133  out.writeAttr(SUMO_ATTR_POSITION, pos);
134  if (posLat != 0) {
135  out.writeAttr(SUMO_ATTR_POSITION_LAT, posLat);
136  }
137  } else {
138  if (geo) {
139  Position POICartesianPos(*this);
140  GeoConvHelper::getFinal().cartesian2geo(POICartesianPos);
141  out.writeAttr(SUMO_ATTR_LON, POICartesianPos.x());
142  out.writeAttr(SUMO_ATTR_LAT, POICartesianPos.y());
143  } else {
144  out.writeAttr(SUMO_ATTR_X, x());
145  out.writeAttr(SUMO_ATTR_Y, y());
146  }
147  }
150  }
153  }
156  }
159  }
160  writeParams(out);
161  out.closeTag();
162  }
163 
164 
165 protected:
167  bool myGeo;
168 
170  std::string myLane;
171 
174 
176  double myPosLat;
177 
180 
183 
184 };
185 
186 
187 #endif
188 
189 /****************************************************************************/
190 
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.
double myPosOverLane
position over lane in which this POI is placed (main used by netedit)
double y() const
Returns the y-position.
Definition: Position.h:67
static const double DEFAULT_IMG_HEIGHT
Definition: Shape.h:153
double x() const
Returns the x-position.
Definition: Position.h:62
begin/end of the description of a Point of interest
const std::string & getID() const
Returns the id.
Definition: Named.h:74
double getHeight() const
Returns the image height of the POI.
const std::string & getImgFile() const
Returns the imgFile of the Shape.
Definition: Shape.h:100
PointOfInterest(const std::string &id, const std::string &type, const RGBColor &color, const Position &pos, bool geo, const std::string &lane, double posOverLane, double posLat, 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.
void writeParams(OutputDevice &out) const
double myPosLat
latereal position over lane in which this POI is placed (main used by netedit)
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.
void writeXML(OutputDevice &out, const bool geo=false, const double zOffset=0., const std::string laneID="", const double pos=0., const double posLat=0.)
double myHalfImgHeight
The half height of the image when rendering this POI.
std::string myLane
ID of lane in which this POI is placed (main used by netedit)
double getNaviDegree() const
Returns the angle of the Shape in navigational degrees.
Definition: Shape.h:93
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A 2D- or 3D-Shape.
Definition: Shape.h:45
double myHalfImgWidth
The half width of the image when rendering this POI.
An upper class for objects with additional parameters.
Definition: Parameterised.h:50
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:70
void setHeight(double height)
set the image height of the POI
const RGBColor & getColor() const
Returns the color of the Shape.
Definition: Shape.h:78
void setWidth(double width)
set the image width of the POI
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:152
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool closeTag()
Closes the most recently opened tag.
A point-of-interest.
bool myGeo
flag to check if POI was loaded as GEO Position (main used by netedit)
A color information.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static const double DEFAULT_ANGLE
Definition: Shape.h:150
static const double DEFAULT_LAYER
Definition: Shape.h:149
virtual ~PointOfInterest()
Destructor.