47std::vector<std::string>
49 std::vector<std::string> ids;
56Polygon::getIDCount() {
57 return (
int)getIDList().size();
62Polygon::getType(
const std::string& polygonID) {
63 return getPolygon(polygonID)->getShapeType();
68Polygon::getShape(
const std::string& polygonID) {
75Polygon::getFilled(
const std::string& polygonID) {
76 return getPolygon(polygonID)->getFill();
80Polygon::getLineWidth(
const std::string& polygonID) {
81 return getPolygon(polygonID)->getLineWidth();
85Polygon::getColor(
const std::string& polygonID) {
92Polygon::getParameter(
const std::string& polygonID,
const std::string& key) {
93 return getPolygon(polygonID)->getParameter(key,
"");
101Polygon::setType(
const std::string& polygonID,
const std::string& polygonType) {
102 getPolygon(polygonID)->setShapeType(polygonType);
107Polygon::setShape(
const std::string& polygonID,
const TraCIPositionVector& shape) {
109 getPolygon(polygonID);
116Polygon::setColor(
const std::string& polygonID,
const TraCIColor& c) {
122Polygon::add(
const std::string& polygonID,
const TraCIPositionVector& shape,
const TraCIColor& color,
bool fill,
const std::string& polygonType,
int layer,
double lineWidth) {
126 if (!shapeCont.
addPolygon(polygonID, polygonType, col, (
double)layer,
Shape::DEFAULT_ANGLE,
Shape::DEFAULT_IMG_FILE,
Shape::DEFAULT_RELATIVEPATH, pShape,
false, fill, lineWidth)) {
127 throw TraCIException(
"Could not add polygon '" + polygonID +
"'");
129 if (myTree !=
nullptr) {
132 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
133 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
134 myTree->Insert(cmin, cmax, p);
140Polygon::addHighlightPolygon(
const std::string& objectID,
const int type,
const std::string& polygonID,
const TraCIPositionVector& shape,
const TraCIColor& color,
bool fill,
const std::string& polygonType,
int layer,
double lineWidth) {
141 add(polygonID, shape, color, fill, polygonType, layer, lineWidth);
147Polygon::addDynamics(
const std::string& polygonID,
const std::string& trackedObjectID,
const std::vector<double>& timeSpan,
const std::vector<double>& alphaSpan,
bool looped,
bool rotate) {
148 if (timeSpan.empty()) {
149 if (trackedObjectID ==
"") {
150 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': dynamics underspecified (either a tracked object ID or a time span have to be provided).");
153 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': looped==true requires time line of positive length.");
156 if (timeSpan.size() == 1) {
157 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': time span cannot have length one.");
158 }
else if (timeSpan.size() > 0 && timeSpan[0] != 0.0) {
159 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': first element of time span must be zero.");
161 if (timeSpan.size() != alphaSpan.size() && alphaSpan.size() != 0) {
162 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': alpha span must have length zero or equal to time span length.");
164 if (timeSpan.size() >= 2) {
165 for (
unsigned int i = 1; i < timeSpan.size(); ++i) {
166 if (timeSpan[i - 1] > timeSpan[i]) {
167 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': entries of time span must be ordered ascendingly.");
176 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': polygon doesn't exist.");
192Polygon::remove(
const std::string& polygonID,
int ) {
195 if (myTree !=
nullptr) {
199 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
200 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
201 myTree->Remove(cmin, cmax, p);
205 throw TraCIException(
"Could not remove polygon '" + polygonID +
"'");
211Polygon::setFilled(std::string polygonID,
bool filled) {
217Polygon::setLineWidth(std::string polygonID,
double lineWidth) {
224Polygon::getPolygon(
const std::string&
id) {
227 throw TraCIException(
"Polygon '" +
id +
"' is not known");
234Polygon::getTrafficObject(
const std::string&
id) {
241 if (sumoVehicle !=
nullptr) {
245 if (transportable !=
nullptr) {
248 throw TraCIException(
"Traffic object '" +
id +
"' is not known");
254Polygon::setParameter(
const std::string& polygonID,
const std::string& key,
const std::string& value) {
265 if (myTree ==
nullptr) {
270 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
271 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
272 myTree->Insert(cmin, cmax, i.second);
286 shape = getPolygon(
id)->getShape();
290std::shared_ptr<VariableWrapper>
291Polygon::makeWrapper() {
292 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
297Polygon::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->wrapInt(objID, variable, getFilled(objID));
310 return wrapper->wrapDouble(objID, variable, getLineWidth(objID));
312 return wrapper->wrapPositionVector(objID, variable, getShape(objID));
315 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->
readString()));
318 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->
readString()));
326Polygon::exists(std::string polyID) {
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
A class that stores a 2D geometrical boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
Interface for objects listening to vehicle state changes.
The simulated network and simulation perfomer.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
ShapeContainer & getShapeContainer()
Returns the shapes container.
MSDynamicShapeUpdater * makeDynamicShapeUpdater()
Creates and returns a dynamic shapes updater.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given 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.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
A wrapper for a Command function with parameter.
const std::string & getPolygonID() const
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
const PositionVector & getShape() const
Returns the shape of the polygon.
void setFill(bool fill)
Sets whether the polygon shall be filled.
void setLineWidth(double lineWidth)
set line width
Representation of a vehicle, person, or container.
Representation of a vehicle.
Storage for geometrical objects.
virtual SUMOTime polygonDynamicsUpdate(SUMOTime t, PolygonDynamics *pd)
Regular update event for updating polygon dynamics.
virtual void reshapePolygon(const std::string &id, const PositionVector &shape)
Assigns a shape to the named polygon.
virtual bool removePolygon(const std::string &id, bool useLock=true)
Removes a polygon from the container.
const Polygons & getPolygons() const
Returns all polygons.
virtual bool addPolygon(const std::string &id, const std::string &type, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool relativePath, const PositionVector &shape, bool geo, bool fill, double lineWidth, bool ignorePruning=false, const std::string &name=Shape::DEFAULT_NAME)
Builds a polygon using the given values and adds it to the container.
virtual PolygonDynamics * addPolygonDynamics(double simtime, std::string polyID, SUMOTrafficObject *trackedObject, const std::vector< double > &timeSpan, const std::vector< double > &alphaSpan, bool looped, bool rotate)
Adds dynamics (animation / tracking) to the given polygon.
virtual void addPolygonUpdateCommand(std::string polyID, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > *cmd)
Register update command (for descheduling at removal)
virtual void registerHighlight(const std::string &objectID, const int type, const std::string &polygonID)
register highlight of the specified type if the given id
static const bool DEFAULT_RELATIVEPATH
static const std::string DEFAULT_IMG_FILE
static const double DEFAULT_ANGLE
const RGBColor & getShapeColor() const
Returns the color of the Shape.
static PositionVector makePositionVector(const TraCIPositionVector &vector)
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 TRACI_ID_LIST
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_WIDTH
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_SHAPE
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_PARAMETER_WITH_KEY