48std::vector<std::string>
50 std::vector<std::string> ids;
58 return (
int)getIDList().size();
63POI::getType(
const std::string& poiID) {
64 return getPoI(poiID)->getShapeType();
69POI::getColor(
const std::string& poiID) {
75POI::getPosition(
const std::string& poiID,
const bool includeZ) {
81POI::getWidth(
const std::string& poiID) {
82 return getPoI(poiID)->getWidth();
87POI::getHeight(
const std::string& poiID) {
88 return getPoI(poiID)->getHeight();
93POI::getAngle(
const std::string& poiID) {
94 return getPoI(poiID)->getShapeNaviDegree();
99POI::getImageFile(
const std::string& poiID) {
100 return getPoI(poiID)->getShapeImgFile();
105POI::getParameter(
const std::string& poiID,
const std::string& key) {
106 return getPoI(poiID)->getParameter(key,
"");
114POI::setType(
const std::string& poiID,
const std::string& poiType) {
115 getPoI(poiID)->setShapeType(poiType);
120POI::setPosition(
const std::string& poiID,
double x,
double y) {
128POI::setColor(
const std::string& poiID,
const TraCIColor& c) {
134POI::setWidth(
const std::string& poiID,
double width) {
135 getPoI(poiID)->setWidth(width);
140POI::setHeight(
const std::string& poiID,
double height) {
141 getPoI(poiID)->setHeight(height);
146POI::setAngle(
const std::string& poiID,
double angle) {
147 getPoI(poiID)->setShapeNaviDegree(angle);
152POI::setImageFile(
const std::string& poiID,
const std::string& imageFile) {
153 getPoI(poiID)->setShapeImgFile(imageFile);
158POI::add(
const std::string& poiID,
double x,
double y,
const TraCIColor& color,
const std::string& poiType,
159 int layer,
const std::string& imgFile,
double width,
double height,
double angle,
const std::string& icon) {
162 Position(x, y),
false,
"", 0,
false, 0, icon, layer,
165 if (ok && myTree !=
nullptr) {
167 const float cmin[2] = {(float)p->
x(), (float)p->
y()};
168 const float cmax[2] = {(float)p->
x(), (float)p->
y()};
169 myTree->Insert(cmin, cmax, p);
176POI::remove(
const std::string& poiID,
int ) {
179 if (p !=
nullptr && myTree !=
nullptr) {
180 const float cmin[2] = {(float)p->
x(), (float)p->
y()};
181 const float cmax[2] = {(float)p->
x(), (float)p->
y()};
182 myTree->Remove(cmin, cmax, p);
189POI::highlight(
const std::string& poiID,
const TraCIColor& col,
double size,
const int alphaMax,
const double duration,
const int type) {
200 const unsigned int nPoints = 34;
204#ifdef DEBUG_DYNAMIC_SHAPES
205 std::cout <<
SIMTIME <<
" Vehicle::highlight() for vehicle '" << vehicleID <<
"'\n"
206 <<
" circle: " << circlePV << std::endl;
212 while (Polygon::exists(polyID)) {
221 lyr += (type + 1) / 257.;
224 Polygon::addHighlightPolygon(poiID, type, polyID, circle, col,
true,
"highlight", (
int)lyr, lw);
227 double maxAttack = 1.0;
228 std::vector<double> timeSpan;
230 timeSpan = {0,
MIN2(maxAttack, duration / 3.), 2.*duration / 3., duration};
233 std::vector<double> alphaSpan;
235 alphaSpan = {0., (double) alphaMax, ((
double) alphaMax) / 3., 0.};
238 Polygon::addDynamics(polyID,
"", timeSpan, alphaSpan,
false,
false);
243POI::setParameter(
const std::string& poiID,
const std::string& key,
const std::string& value) {
254POI::getPoI(
const std::string&
id) {
256 if (sumoPoi ==
nullptr) {
257 throw TraCIException(
"POI '" +
id +
"' is not known");
265 if (myTree ==
nullptr) {
268 for (
const auto& i : shapeCont.
getPOIs()) {
269 const float cmin[2] = {(float)i.second->x(), (float)i.second->y()};
270 const float cmax[2] = {(float)i.second->x(), (float)i.second->y()};
271 myTree->Insert(cmin, cmax, i.second);
286 shape.push_back(*getPoI(
id));
290std::shared_ptr<VariableWrapper>
292 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
297POI::handleVariable(
const std::string& objID,
const int variable, VariableWrapper* wrapper,
tcpip::Storage* paramData) {
300 return wrapper->wrapStringList(objID, variable, getIDList());
302 return wrapper->wrapInt(objID, variable, getIDCount());
304 return wrapper->wrapString(objID, variable, getType(objID));
306 return wrapper->wrapColor(objID, variable, getColor(objID));
308 return wrapper->wrapPosition(objID, variable, getPosition(objID));
310 return wrapper->wrapPosition(objID, variable, getPosition(objID,
true));
312 return wrapper->wrapDouble(objID, variable, getWidth(objID));
314 return wrapper->wrapDouble(objID, variable, getHeight(objID));
316 return wrapper->wrapDouble(objID, variable, getAngle(objID));
318 return wrapper->wrapString(objID, variable, getImageFile(objID));
321 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
324 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->
readString()));
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
static PositionVector makeRing(const double radius1, const double radius2, const Position ¢er, unsigned int nPoints)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
ShapeContainer & getShapeContainer()
Returns the shapes container.
const std::string & getID() const
Returns the id.
T get(const std::string &id) const
Retrieves an item.
void insertIDs(std::vector< std::string > &into) const
A RT-tree for efficient storing of SUMO's Named objects.
C++ TraCI client API implementation.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
double getHeight() const
Returns the image height of the POI.
double getWidth() const
Returns the image width of the POI.
A point in 2D or 3D with translation and scaling methods.
double x() const
Returns the x-position.
double y() const
Returns the y-position.
Storage for geometrical objects.
virtual bool removePOI(const std::string &id)
Removes a PoI from the container.
virtual void movePOI(const std::string &id, const Position &pos)
Assigns a new position to the named PoI.
virtual bool addPOI(const std::string &id, const std::string &type, const RGBColor &color, const Position &pos, bool geo, const std::string &lane, double posOverLane, bool friendlyPos, double posLat, const std::string &icon, double layer, double angle, const std::string &imgFile, bool relativePath, double width, double height, bool ignorePruning=false)
Builds a POI using the given values and adds it to the container.
const POIs & getPOIs() const
Returns all pois.
static const bool DEFAULT_RELATIVEPATH
double getShapeLayer() const
Returns the layer of the Shape.
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
static TraCIPositionVector makeTraCIPositionVector(const PositionVector &positionVector)
helper functions
static TraCIColor makeTraCIColor(const RGBColor &color)
static RGBColor makeRGBColor(const TraCIColor &color)
virtual std::string readString()
virtual int readUnsignedByte()
TRACI_CONST int VAR_IMAGEFILE
TRACI_CONST int TRACI_ID_LIST
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int VAR_ANGLE
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_POSITION
TRACI_CONST int VAR_WIDTH
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_HEIGHT
TRACI_CONST int VAR_POSITION3D
TRACI_CONST int VAR_PARAMETER_WITH_KEY