SUMO - Simulation of Urban MObility
TraCI_POI.cpp
Go to the documentation of this file.
1 /****************************************************************************/
11 // C++ TraCI client API implementation
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14 // Copyright (C) 2017-2017 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
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 
37 #include <microsim/MSNet.h>
38 #include "TraCI_POI.h"
39 #include "TraCI.h"
40 
41 
42 
43 
44 // ===========================================================================
45 // member definitions
46 // ===========================================================================
47 std::vector<std::string>
49  std::vector<std::string> ids;
51  shapeCont.getPOIs().insertIDs(ids);
52  return ids;
53 }
54 
55 int
57  return (int)getIDList().size();
58 }
59 
60 std::string
61 TraCI_POI::getType(const std::string& poiID) {
62  return getPoI(poiID)->getType();
63 }
64 
66 TraCI_POI::getColor(const std::string& poiID) {
67  PointOfInterest* sumoPoi = getPoI(poiID);
68  RGBColor col = sumoPoi->getColor();
69  return TraCI::makeTraCIColor(col);
70 }
71 
73 TraCI_POI::getPosition(const std::string& poiID) {
74  TraCIPosition pos;
75  PointOfInterest* p = getPoI(poiID);
76  pos.x = p->x();
77  pos.y = p->y();
78  pos.z = p->z();
79  return pos;
80 }
81 
82 std::string
83 TraCI_POI::getParameter(const std::string& poiID, const std::string& param) {
84  PointOfInterest* p = getPoI(poiID);
85  return p->getParameter(param, "");
86 }
87 
88 void
89 TraCI_POI::setType(const std::string& poiID, const std::string& type) {
90  PointOfInterest* p = getPoI(poiID);
91  p->setType(type);
92 }
93 
94 void
95 TraCI_POI::setPosition(const std::string& poiID, const TraCIPosition& pos) {
96  PointOfInterest* p = getPoI(poiID);
97  p->set(TraCI::makePosition(pos));
98 }
99 
100 void
101 TraCI_POI::setColor(const std::string& poiID, const TraCIColor& c) {
102  PointOfInterest* p = getPoI(poiID);
104 }
105 
106 bool
107 TraCI_POI::add(const std::string& poiID, const TraCIPosition& pos, const TraCIColor& c, const std::string& type, int layer) {
109  return shapeCont.addPOI(poiID, type, TraCI::makeRGBColor(c), (double) layer,
112  TraCI::makePosition(pos),
115 }
116 
117 bool
118 TraCI_POI::remove(const std::string& poiID, int /* layer */) {
120  return shapeCont.removePOI(poiID);
121 }
122 
123 void
124 TraCI_POI::addParameter(const std::string& poiID, const std::string& param, const std::string& value) {
125  PointOfInterest* p = getPoI(poiID);
126  p->addParameter(param, value);
127 }
128 
129 
131 TraCI_POI::getPoI(const std::string& id) {
133  if (sumoPoi == 0) {
134  throw TraCIException("POI '" + id + "' is not known");
135  }
136  return sumoPoi;
137 }
138 
139 
140 /****************************************************************************/
double x
Definition: TraCIDefs.h:72
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:152
double z() const
Returns the z-position.
Definition: Position.h:73
static void setColor(const std::string &poiID, const TraCIColor &c)
Definition: TraCI_POI.cpp:101
static TraCIColor makeTraCIColor(const RGBColor &color)
Definition: TraCI.cpp:128
double y() const
Returns the y-position.
Definition: Position.h:68
T get(const std::string &id) const
Retrieves an item.
static const double DEFAULT_IMG_HEIGHT
Definition: Shape.h:154
static void setType(const std::string &poiID, const std::string &setType)
Definition: TraCI_POI.cpp:89
double x() const
Returns the x-position.
Definition: Position.h:63
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:158
static void addParameter(const std::string &poiID, const std::string &param, const std::string &value)
Definition: TraCI_POI.cpp:124
static std::vector< std::string > getIDList()
Definition: TraCI_POI.cpp:48
Storage for geometrical objects.
void set(double x, double y)
set positions x and y
Definition: Position.h:93
void insertIDs(std::vector< std::string > &into) const
double z
Definition: TraCIDefs.h:72
A 3D-position.
Definition: TraCIDefs.h:71
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:433
virtual bool removePOI(const std::string &id)
Removes a PoI from the container.
static std::string getParameter(const std::string &poiID, const std::string &param)
Definition: TraCI_POI.cpp:83
static TraCIPosition getPosition(const std::string &poiID)
Definition: TraCI_POI.cpp:73
static PointOfInterest * getPoI(const std::string &id)
Definition: TraCI_POI.cpp:131
const std::string & getType() const
Returns the (abstract) type of the Shape.
Definition: Shape.h:71
static bool add(const std::string &poiID, const TraCIPosition &pos, const TraCIColor &c, const std::string &type, int layer)
Definition: TraCI_POI.cpp:107
void addParameter(const std::string &key, const std::string &value)
Adds a parameter.
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
static TraCIColor getColor(const std::string &poiID)
Definition: TraCI_POI.cpp:66
void setType(const std::string &type)
Sets a new type.
Definition: Shape.h:113
const RGBColor & getColor() const
Returns the color of the Shape.
Definition: Shape.h:79
static void setPosition(const std::string &poiID, const TraCIPosition &pos)
Definition: TraCI_POI.cpp:95
static std::string getType(const std::string &poiID)
Definition: TraCI_POI.cpp:61
static Position makePosition(const TraCIPosition &position)
Definition: TraCI.cpp:153
static const double DEFAULT_IMG_WIDTH
Definition: Shape.h:153
A point-of-interest.
static int getIDCount()
Definition: TraCI_POI.cpp:56
double y
Definition: TraCIDefs.h:72
static RGBColor makeRGBColor(const TraCIColor &color)
Definition: TraCI.cpp:138
virtual bool addPOI(const std::string &id, const std::string &type, const RGBColor &color, double layer, double angle, const std::string &imgFile, const Position &pos, double width, double height, bool ignorePruning=false)
Builds a POI using the given values and adds it to the container.
static bool remove(const std::string &poiID, int layer=0)
Definition: TraCI_POI.cpp:118
void setColor(const RGBColor &col)
Sets a new color.
Definition: Shape.h:121
static const double DEFAULT_ANGLE
Definition: Shape.h:151
const POIs & getPOIs() const
Returns all pois.