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.");
188 shapeCont.addPolygonUpdateCommand(pd->getPolygonID(), cmd);
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());
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
double ymin() const
Returns minimum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
virtual bool wrapInt(const std::string &objID, const int variable, const int value)=0
static void setLineWidth(std::string polygonID, double lineWidth)
Interface for objects listening to vehicle state changes.
MSDynamicShapeUpdater * makeDynamicShapeUpdater()
Creates and returns a dynamic shapes updater.
static PositionVector makePositionVector(const TraCIPositionVector &vector)
static TraCIColor makeTraCIColor(const RGBColor &color)
static const std::string DEFAULT_IMG_FILE
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
void setLineWidth(double lineWidth)
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_WIDTH
void setShapeColor(const RGBColor &col)
Sets a new color.
const Polygons & getPolygons() const
Returns all polygons.
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
static SubscriptionResults mySubscriptionResults
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.
void setShapeType(const std::string &type)
Sets a new type.
T get(const std::string &id) const
Retrieves an item.
const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
A RT-tree for efficient storing of SUMO's Named objects.
static void setFilled(std::string polygonID, bool filled)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static SUMOTrafficObject * getTrafficObject(const std::string &id)
Obtain a traffic object with the given id if one exists.
const PositionVector & getShape() const
Returns whether the shape of the polygon.
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Storage for geometrical objects.
virtual bool wrapString(const std::string &objID, const int variable, const std::string &value)=0
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 void registerHighlight(const std::string &objectID, const int type, const std::string &polygonID)
register highlight of the specified type if the given id
void insertIDs(std::vector< std::string > &into) const
static TraCIPositionVector makeTraCIPositionVector(const PositionVector &positionVector)
helper functions
double getLineWidth() const
Returns whether the polygon is filled.
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
A class that stores a 2D geometrical boundary.
The simulated network and simulation perfomer.
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
static std::string getType(const std::string &polygonID)
static bool exists(std::string polyID)
Checks if a polygon of the given name exists already in the simulation.
static RGBColor makeRGBColor(const TraCIColor &color)
TRACI_CONST int TRACI_ID_LIST
void Remove(const float a_min[2], const float a_max[2], Named *const &a_data)
Remove entry.
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 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)
virtual bool removePolygon(const std::string &id, bool useLock=true)
Removes a polygon from the container.
Representation of a vehicle.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
ShapeContainer & getShapeContainer()
Returns the shapes container.
static NamedRTree * getTree()
Returns a tree filled with polygon instances.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
const RGBColor & getShapeColor() const
Returns the color of the Shape.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static const bool DEFAULT_RELATIVEPATH
static void remove(const std::string &polygonID, int layer=0)
static TraCIPositionVector getShape(const std::string &polygonID)
static void setShape(const std::string &polygonID, const TraCIPositionVector &shape)
A wrapper for a Command function with parameter.
double xmin() const
Returns minimum x-coordinate.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
bool getFill() const
Returns whether the polygon is filled.
virtual void reshapePolygon(const std::string &id, const PositionVector &shape)
Assigns a shape to the named polygon.
static std::shared_ptr< VariableWrapper > makeWrapper()
static void setColor(const std::string &polygonID, const TraCIColor &color)
virtual bool wrapDouble(const std::string &objID, const int variable, const double value)=0
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Representation of a vehicle, person, or container.
virtual bool wrapColor(const std::string &objID, const int variable, const TraCIColor &value)=0
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
static TraCIColor getColor(const std::string &polygonID)
static bool getFilled(const std::string &polygonID)
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
static NamedRTree * myTree
static SUMOPolygon * getPolygon(const std::string &id)
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
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)
virtual SUMOTime polygonDynamicsUpdate(SUMOTime t, PolygonDynamics *pd)
Regular update event for updating polygon dynamics.
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
double ymax() const
Returns maximum y-coordinate.
static ContextSubscriptionResults myContextSubscriptionResults
void setFill(bool fill)
Sets whether the polygon shall be filled.
static const double DEFAULT_ANGLE
LIBSUMO_ID_PARAMETER_API static LIBSUMO_SUBSCRIPTION_API void setType(const std::string &polygonID, const std::string &setType)
static double getLineWidth(const std::string &polygonID)