47 std::vector<std::string>
48 Polygon::getIDList() {
49 std::vector<std::string> ids;
57 Polygon::getIDCount() {
58 return (
int)getIDList().size();
93 Polygon::getParameter(
const std::string& polygonID,
const std::string& key) {
128 if (!shapeCont.
addPolygon(polygonID, polygonType, col, (
double)layer,
Shape::DEFAULT_ANGLE,
Shape::DEFAULT_IMG_FILE,
Shape::DEFAULT_RELATIVEPATH, pShape,
false, fill, lineWidth)) {
129 throw TraCIException(
"Could not add polygon '" + polygonID +
"'");
134 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
135 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
143 add(polygonID, shape, color, fill, polygonType, layer, lineWidth);
149 Polygon::addDynamics(
const std::string& polygonID,
const std::string& trackedID,
const std::vector<double>& timeSpan,
const std::vector<double>& alphaSpan,
bool looped,
bool rotate) {
150 if (timeSpan.empty()) {
151 if (trackedID ==
"") {
152 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).");
155 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': looped==true requires time line of positive length.");
158 if (timeSpan.size() == 1) {
159 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': time span cannot have length one.");
160 }
else if (timeSpan.size() > 0 && timeSpan[0] != 0.0) {
161 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': first element of time span must be zero.");
163 if (timeSpan.size() != alphaSpan.size() && alphaSpan.size() != 0) {
164 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': alpha span must have length zero or equal to time span length.");
166 if (timeSpan.size() >= 2) {
167 for (
unsigned int i = 1; i < timeSpan.size(); ++i) {
168 if (timeSpan[i - 1] > timeSpan[i]) {
169 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': entries of time span must be ordered ascendingly.");
178 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': polygon doesn't exist.");
201 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
202 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
207 throw TraCIException(
"Could not remove polygon '" + polygonID +
"'");
243 if (sumoVehicle !=
nullptr) {
247 if (transportable !=
nullptr) {
256 Polygon::setParameter(
const std::string& polygonID,
const std::string& key,
const std::string& value) {
271 Boundary b = i.second->getShape().getBoxBoundary();
272 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
273 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
292 std::shared_ptr<VariableWrapper>
304 return wrapper->
wrapInt(objID, variable, getIDCount());
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
#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.
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).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
ShapeContainer & getShapeContainer()
Returns the shapes container.
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.
MSDynamicShapeUpdater * makeDynamicShapeUpdater()
Creates and returns a dynamic shapes updater.
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.
void Remove(const float a_min[2], const float a_max[2], Named *const &a_data)
Remove entry.
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
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 whether the shape of the polygon.
void setFill(bool fill)
Sets whether the polygon shall be filled.
void setLineWidth(double lineWidth)
double getLineWidth() const
Returns whether the polygon is filled.
bool getFill() const
Returns whether the polygon is filled.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Storage for geometrical objects.
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)
Builds a polygon using the given values and adds it to the container.
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.
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
const RGBColor & getShapeColor() const
Returns the color of the Shape.
static const std::string DEFAULT_IMG_FILE
void setShapeType(const std::string &type)
Sets a new type.
static const double DEFAULT_ANGLE
void setShapeColor(const RGBColor &col)
Sets a new color.
const std::string & getShapeType() const
Returns the (abstract) type 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)
static bool getFilled(const std::string &polygonID)
static NamedRTree * myTree
static void setShape(const std::string &polygonID, const TraCIPositionVector &shape)
static void setLineWidth(std::string polygonID, double lineWidth)
static double getLineWidth(const std::string &polygonID)
static SUMOTrafficObject * getTrafficObject(const std::string &id)
Obtain a traffic object with the given id if one exists.
static std::string getType(const std::string &polygonID)
static NamedRTree * getTree()
Returns a tree filled with polygon instances.
static SUMOPolygon * getPolygon(const std::string &id)
static void addDynamics(const std::string &polygonID, const std::string &trackedID="", const std::vector< double > &timeSpan=std::vector< double >(), const std::vector< double > &alphaSpan=std::vector< double >(), bool looped=false, bool rotate=true)
static void 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)
static TraCIColor getColor(const std::string &polygonID)
static void setColor(const std::string &polygonID, const TraCIColor &color)
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
static void add(const std::string &polygonID, const TraCIPositionVector &shape, const TraCIColor &color, bool fill=false, const std::string &polygonType="", int layer=0, double lineWidth=1)
static void remove(const std::string &polygonID, int layer=0)
static TraCIPositionVector getShape(const std::string &polygonID)
static ContextSubscriptionResults myContextSubscriptionResults
static void setFilled(std::string polygonID, bool filled)
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
static bool exists(std::string polyID)
Checks if a polygon of the given name exists already in the simulation.
LIBSUMO_ID_PARAMETER_API static LIBSUMO_SUBSCRIPTION_API void setType(const std::string &polygonID, const std::string &setType)
static std::shared_ptr< VariableWrapper > makeWrapper()
static SubscriptionResults mySubscriptionResults
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
virtual bool wrapString(const std::string &objID, const int variable, const std::string &value)=0
virtual bool wrapInt(const std::string &objID, const int variable, const int value)=0
virtual bool wrapDouble(const std::string &objID, const int variable, const double value)=0
virtual bool wrapColor(const std::string &objID, const int variable, const TraCIColor &value)=0
TRACI_CONST int TRACI_ID_LIST
std::vector< TraCIPosition > TraCIPositionVector
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_WIDTH
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
std::map< std::string, SubscriptionResults > ContextSubscriptionResults