Eclipse SUMO - Simulation of Urban MObility
|
A storage for loaded polygons and pois. More...
#include <PCPolyContainer.h>
Data Structures | |
struct | LanePos |
LanePos. More... | |
Public Types | |
typedef NamedObjectCont< PointOfInterest * > | POIs |
typedef NamedObjectCont< SUMOPolygon * > | Polygons |
containers | |
Public Member Functions | |
bool | add (PointOfInterest *poi, bool ignorePruning=false) |
Adds a poi to the storage. | |
bool | add (SUMOPolygon *poly, bool ignorePruning=false) |
Adds a polygon to the storage. | |
void | addLanePos (const std::string &poiID, const std::string &laneID, const double lanePos, const bool friendlyPos, const double lanePosLat) |
add lane pos | |
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. | |
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) | |
void | clearState () |
Remove all dynamics before quick-loading state. | |
int | getEnumIDFor (const std::string &key) |
Retuns a unique id for a given name. | |
const POIs & | getPOIs () const |
Returns all pois. | |
const Polygons & | getPolygons () const |
Returns all polygons. | |
virtual void | movePOI (const std::string &id, const Position &pos) |
Assigns a new position to the named PoI. | |
PCPolyContainer (bool prune, const Boundary &pruningBoundary, const std::vector< std::string > &removeByNames) | |
Constructor. | |
virtual SUMOTime | polygonDynamicsUpdate (SUMOTime t, PolygonDynamics *pd) |
Regular update event for updating polygon dynamics. | |
virtual void | registerHighlight (const std::string &objectID, const int type, const std::string &polygonID) |
register highlight of the specified type if the given id | |
virtual bool | removePOI (const std::string &id) |
Removes a PoI from the container. | |
virtual bool | removePolygon (const std::string &id, bool useLock=true) |
Removes a polygon from the container. | |
virtual bool | removePolygonDynamics (const std::string &polyID) |
Remove dynamics (animation / tracking) for the given polygon. | |
virtual void | removeTrackers (std::string objectID) |
Remove all tracking polygons for the given object. | |
virtual void | reshapePolygon (const std::string &id, const PositionVector &shape) |
Assigns a shape to the named polygon. | |
void | save (const std::string &file, bool useGeo) |
Saves the stored polygons and pois into the given file. | |
void | saveDlrTDP (const std::string &prefix) |
Saves the stored polygons and pois into the given file in dlrTDP format. | |
~PCPolyContainer () | |
Destructor. | |
Protected Member Functions | ||||
virtual void | cleanupPolygonDynamics (const std::string &id) | |||
Unschedules the removal and update commands of the given polygon. | ||||
Management of highlights. For each type, only one highlight can be active, | ||||
Remove any previously added highlight polygon of the specified type
| ||||
virtual void | clearHighlight (const std::string &objectID, const int type, std::string &toRemove) | |||
virtual void | clearHighlights (const std::string &objectID, SUMOPolygon *p) | |||
Clears all highlight information from the maps when the object leaves the net (Highlight polygons and dynamics are removed via removeTrackers()) | ||||
Protected Attributes | |
std::map< std::string, std::string > | myHighlightedObjects |
inverse map to myHighlightPolygons saves the highlighted object for each polygon | |
std::map< std::string, std::map< int, std::string > > | myHighlightPolygons |
maps objects to a map of highlight types to highlighting polygons | |
POIs | myPOIs |
stored POIs | |
std::map< std::string, PolygonDynamics * > | myPolygonDynamics |
stored PolygonDynamics | |
Polygons | myPolygons |
stored Polygons | |
std::map< const std::string, std::set< const SUMOPolygon * > > | myTrackingPolygons |
Information about tracked objects. | |
Private Member Functions | |
PCPolyContainer & | operator= (const PCPolyContainer &s)=delete |
Invalidated assignment operator. | |
PCPolyContainer (const PCPolyContainer &s) | |
Invalidated copy constructor. | |
Static Private Member Functions | |
static void | writeDlrTDPHeader (OutputDevice &device, const OptionsCont &oc) |
write DLR TDP Header | |
Private Attributes | |
bool | myDoPrune |
Information whether the pruning boundary shall be used. | |
std::map< std::string, int > | myIDEnums |
An id to int map for proper enumeration. | |
std::map< std::string, LanePos > | myLanePosPois |
An id to pos map for lane pos specs. | |
std::map< const std::string, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > * > | myPolygonUpdateCommands |
Command pointers for scheduled polygon update. Maps PolyID->Command. | |
Boundary | myPruningBoundary |
The boundary that described the rectangle within which an object must be in order to be kept. | |
std::vector< std::string > | myRemoveByNames |
List of names of polygons/pois that shall be removed. | |
A storage for loaded polygons and pois.
Definition at line 48 of file PCPolyContainer.h.
|
inherited |
Definition at line 54 of file ShapeContainer.h.
|
inherited |
containers
Definition at line 53 of file ShapeContainer.h.
PCPolyContainer::PCPolyContainer | ( | bool | prune, |
const Boundary & | pruningBoundary, | ||
const std::vector< std::string > & | removeByNames | ||
) |
Constructor.
[in] | prune | Whether added polygons/pois shall be pruned |
[in] | pruningBoundary | The pruning boundary (only valid if prune==true) |
[in] | removeByNames | Names of objects that shall not be added |
Definition at line 43 of file PCPolyContainer.cpp.
PCPolyContainer::~PCPolyContainer | ( | ) |
Destructor.
Definition at line 50 of file PCPolyContainer.cpp.
References NamedObjectCont< T >::clear(), ShapeContainer::myPOIs, and ShapeContainer::myPolygons.
|
private |
Invalidated copy constructor.
|
virtual |
Adds a poi to the storage.
If pruning is enabled, "ignorePruning" is false and the poi lies outside the pruning boundary, or if the poi's name is within the names of objects to discard, the poi is deleted and false is returned.
Afterwards it is tested whether a poi with the same name is already stored. If so, an error message is printed, the poi is deleted and false is returned, otherwise true.
[in] | poly | The poi to add |
[in] | ignorePruning | Whether the poi shall be kept, even though it would be pruned |
Reimplemented from ShapeContainer.
Definition at line 77 of file PCPolyContainer.cpp.
References ShapeContainer::add(), Boundary::around(), Named::getID(), myDoPrune, myPruningBoundary, and myRemoveByNames.
|
virtual |
Adds a polygon to the storage.
If pruning is enabled, "ignorePruning" is false and the polygon lies outside the pruning boundary, or if the polygon's name is within the names of objects to discard, the polygon is deleted and false is returned.
Afterwards it is tested whether a polygon with the same name is already stored. If so, an error message is printed, the polygon is deleted and false is returned, otherwise true.
[in] | poly | The polygon to add |
[in] | ignorePruning | Whether the polygon shall be kept, even though it would be pruned |
Reimplemented from ShapeContainer.
Definition at line 57 of file PCPolyContainer.cpp.
References ShapeContainer::add(), PositionVector::getBoxBoundary(), Named::getID(), SUMOPolygon::getShape(), myDoPrune, myPruningBoundary, myRemoveByNames, and Boundary::partialWithin().
Referenced by PCLoaderOSM::addPOI(), PCLoaderOSM::addPolygon(), PCLoaderArcView::load(), PCLoaderVisum::load(), PCLoaderDlrNavteq::loadPOIFile(), and PCLoaderDlrNavteq::loadPolyFile().
void PCPolyContainer::addLanePos | ( | const std::string & | poiID, |
const std::string & | laneID, | ||
const double | lanePos, | ||
const bool | friendlyPos, | ||
const double | lanePosLat | ||
) |
|
virtualinherited |
Builds a POI using the given values and adds it to the container.
[in] | id | The name of the POI |
[in] | type | The (abstract) type of the POI |
[in] | color | The color of the POI |
[in] | pos | The position of the POI |
[in[ | geo use GEO coordinates (lon/lat) | |
[in] | lane | The Lane in which this POI is placed |
[in] | posOverLane | The position over Lane |
[in] | friendlyPos | enable or disable friendly position over lane |
[in] | posLat | The position lateral over Lane |
[in] | icon | The icon of the POI |
[in] | layer | The layer of the POI |
[in] | angle | The rotation of the POI |
[in] | imgFile | The raster image of the POI |
[in] | relativePath | set image file as relative path |
[in] | width | The width of the POI image |
[in] | height | The height of the POI image |
Reimplemented in GUIShapeContainer.
Definition at line 145 of file ShapeContainer.cpp.
References ShapeContainer::add().
Referenced by LIBSUMO_NAMESPACE::POI::add(), and ShapeHandler::addPOI().
|
virtualinherited |
Builds a polygon using the given values and adds it to the container.
[in] | id | The name of the polygon |
[in] | type | The (abstract) type of the polygon |
[in] | color | The color of the polygon |
[in] | layer | The layer of the polygon |
[in] | angle | The rotation of the polygon |
[in] | imgFile | The raster image of the polygon |
[in] | relativePath | set image file as relative path |
[in] | shape | The shape of the polygon |
[in] | geo | specify if shape was loaded as GEO coordinate |
[in] | fill | Whether the polygon shall be filled |
[in] | lineWidth | Line width when drawing unfilled polygon |
Reimplemented in GUIShapeContainer.
Definition at line 63 of file ShapeContainer.cpp.
References ShapeContainer::add().
Referenced by LIBSUMO_NAMESPACE::Polygon::add(), NLHandler::addDistrict(), ShapeHandler::addPoly(), MSPModel_JuPedSim::preparePolygonForDrawing(), and NWWriter_OpenDrive::writeNetwork().
|
virtualinherited |
Adds dynamics (animation / tracking) to the given polygon.
polyID | ID of the polygon which should become dynamic |
Reimplemented in GUIShapeContainer.
Definition at line 73 of file ShapeContainer.cpp.
References NamedObjectCont< T >::get(), PolygonDynamics::getTrackedObjectID(), ShapeContainer::myPolygonDynamics, ShapeContainer::myPolygons, ShapeContainer::myTrackingPolygons, and ShapeContainer::removePolygonDynamics().
Referenced by LIBSUMO_NAMESPACE::Polygon::addDynamics(), and GUIShapeContainer::addPolygonDynamics().
|
virtualinherited |
Register update command (for descheduling at removal)
Definition at line 287 of file ShapeContainer.cpp.
References ShapeContainer::myPolygonUpdateCommands.
Referenced by LIBSUMO_NAMESPACE::Polygon::addDynamics().
|
protectedvirtualinherited |
Unschedules the removal and update commands of the given polygon.
[in] | id | The id of the polygon |
Definition at line 214 of file ShapeContainer.cpp.
References ShapeContainer::myPolygonUpdateCommands.
Referenced by ShapeContainer::removePolygonDynamics().
|
protectedvirtualinherited |
Definition at line 252 of file ShapeContainer.cpp.
References ShapeContainer::myHighlightedObjects, and ShapeContainer::myHighlightPolygons.
Referenced by ShapeContainer::registerHighlight().
|
protectedvirtualinherited |
Clears all highlight information from the maps when the object leaves the net (Highlight polygons and dynamics are removed via removeTrackers())
Definition at line 268 of file ShapeContainer.cpp.
References Named::getID(), and ShapeContainer::myHighlightPolygons.
Referenced by ShapeContainer::removePolygonDynamics().
|
inherited |
Remove all dynamics before quick-loading state.
Definition at line 206 of file ShapeContainer.cpp.
References ShapeContainer::myPolygonUpdateCommands.
Referenced by MSNet::clearState().
int PCPolyContainer::getEnumIDFor | ( | const std::string & | key | ) |
Retuns a unique id for a given name.
The unique id is generated by having an internal map of ids to running numbers. The first call to this method will return 0, all subsequent with the same key will return numbers increased by one at each call.
[in] | key | The key to get a running number for |
Definition at line 200 of file PCPolyContainer.cpp.
References myIDEnums.
Referenced by PCLoaderDlrNavteq::loadPolyFile().
|
inlineinherited |
Returns all pois.
Definition at line 157 of file ShapeContainer.h.
References ShapeContainer::myPOIs.
Referenced by LIBSUMO_NAMESPACE::POI::add(), ShapeHandler::addPOI(), LIBSUMO_NAMESPACE::POI::getPoI(), GUIShapeContainer::getPOIIds(), LIBSUMO_NAMESPACE::POI::getTree(), PCLoaderVisum::load(), NWWriter_OpenDrive::mapmatchRoadObjects(), LIBSUMO_NAMESPACE::POI::remove(), NWWriter_OpenDrive::writeRoadObjects(), and NWWriter_OpenDrive::writeSignals().
|
inlineinherited |
Returns all polygons.
Definition at line 152 of file ShapeContainer.h.
References ShapeContainer::myPolygons.
Referenced by LIBSUMO_NAMESPACE::Polygon::add(), MSPModel_JuPedSim::add(), NLHandler::addDistrict(), ShapeHandler::addPoly(), MSPModel_JuPedSim::buildPedestrianNetwork(), MSDevice_FCD::buildShapeFilter(), GUIViewTraffic::changePedestrianNetworkColor(), LIBSUMO_NAMESPACE::Polygon::exists(), LIBSUMO_NAMESPACE::Polygon::getPolygon(), GUIShapeContainer::getPolygonIDs(), LIBSUMO_NAMESPACE::Polygon::getTree(), MSPModel_JuPedSim::initialize(), PCLoaderVisum::load(), PCLoaderDlrNavteq::loadPolyFile(), NWWriter_OpenDrive::mapmatchRoadObjects(), MSPModel_JuPedSim::preparePolygonForDrawing(), LIBSUMO_NAMESPACE::Polygon::remove(), NWWriter_OpenDrive::writeNetwork(), and NWWriter_OpenDrive::writeRoadObjects().
|
virtualinherited |
Assigns a new position to the named PoI.
[in] | id | The id of the PoI to move |
[in] | pos | The PoI's new position |
Reimplemented in GUIShapeContainer.
Definition at line 169 of file ShapeContainer.cpp.
References NamedObjectCont< T >::get(), and ShapeContainer::myPOIs.
Referenced by LIBSUMO_NAMESPACE::POI::setPosition().
|
privatedelete |
Invalidated assignment operator.
|
virtualinherited |
Regular update event for updating polygon dynamics.
[in] | t | The time at which the update is called |
[in] | pd | The dynamics to be updated |
Reimplemented in GUIShapeContainer.
Definition at line 224 of file ShapeContainer.cpp.
References PolygonDynamics::getPolygonID(), ShapeContainer::myPolygonUpdateCommands, ShapeContainer::removePolygon(), and PolygonDynamics::update().
Referenced by LIBSUMO_NAMESPACE::Polygon::addDynamics(), and GUIShapeContainer::polygonDynamicsUpdate().
|
virtualinherited |
register highlight of the specified type if the given id
Definition at line 236 of file ShapeContainer.cpp.
References ShapeContainer::clearHighlight(), ShapeContainer::myHighlightedObjects, ShapeContainer::myHighlightPolygons, and ShapeContainer::removePolygon().
Referenced by LIBSUMO_NAMESPACE::Polygon::addHighlightPolygon().
|
virtualinherited |
Removes a PoI from the container.
[in] | id | The id of the PoI |
Reimplemented in GUIShapeContainer.
Definition at line 163 of file ShapeContainer.cpp.
References ShapeContainer::myPOIs, and NamedObjectCont< T >::remove().
Referenced by LIBSUMO_NAMESPACE::POI::remove().
|
virtualinherited |
Removes a polygon from the container.
[in] | id | The id of the polygon |
Reimplemented in GUIShapeContainer.
Definition at line 153 of file ShapeContainer.cpp.
References ShapeContainer::myPolygons, NamedObjectCont< T >::remove(), and ShapeContainer::removePolygonDynamics().
Referenced by ShapeContainer::polygonDynamicsUpdate(), ShapeContainer::registerHighlight(), LIBSUMO_NAMESPACE::Polygon::remove(), GUIShapeContainer::removePolygon(), MSPModel_JuPedSim::removePolygonFromDrawing(), and ShapeContainer::removeTrackers().
|
virtualinherited |
Remove dynamics (animation / tracking) for the given polygon.
polyID | ID of the polygon for which dynamics shall be removed |
Definition at line 113 of file ShapeContainer.cpp.
References ShapeContainer::cleanupPolygonDynamics(), ShapeContainer::clearHighlights(), NamedObjectCont< T >::get(), ShapeContainer::myPolygonDynamics, ShapeContainer::myPolygons, and ShapeContainer::myTrackingPolygons.
Referenced by ShapeContainer::addPolygonDynamics(), and ShapeContainer::removePolygon().
|
virtualinherited |
Remove all tracking polygons for the given object.
Definition at line 293 of file ShapeContainer.cpp.
References ShapeContainer::myTrackingPolygons, and ShapeContainer::removePolygon().
Referenced by MSDynamicShapeUpdater::vehicleStateChanged().
|
virtualinherited |
Assigns a shape to the named polygon.
[in] | id | The id of the polygon to reshape |
[in] | shape | The polygon's new shape |
Reimplemented in GUIShapeContainer.
Definition at line 178 of file ShapeContainer.cpp.
References NamedObjectCont< T >::get(), ShapeContainer::myPolygons, and SUMOPolygon::setShape().
Referenced by LIBSUMO_NAMESPACE::Polygon::setShape().
void PCPolyContainer::save | ( | const std::string & | file, |
bool | useGeo | ||
) |
Saves the stored polygons and pois into the given file.
[in] | file | The name of the file to write stored objects' definitions into |
[in] | useGeo | Whether to write output in geo-coordinates |
IOError | If the file could not be opened |
Definition at line 102 of file PCPolyContainer.cpp.
References OutputDevice::close(), OutputDevice::getDevice(), GeoConvHelper::getFinal(), OptionsCont::getFloat(), OptionsCont::getOptions(), gPrecisionGeo, myLanePosPois, ShapeContainer::myPOIs, ShapeContainer::myPolygons, OutputDevice::setPrecision(), TL, GeoConvHelper::usingGeoProjection(), WRITE_WARNING, GeoConvHelper::writeLocation(), and OutputDevice::writeXMLHeader().
Referenced by main().
void PCPolyContainer::saveDlrTDP | ( | const std::string & | prefix | ) |
Saves the stored polygons and pois into the given file in dlrTDP format.
[in] | prefix | The prefix of the file to write stored objects' definitions into |
Definition at line 149 of file PCPolyContainer.cpp.
References GeoConvHelper::cartesian2geo(), OutputDevice::close(), OutputDevice::getDevice(), GeoConvHelper::getFinal(), OptionsCont::getOptions(), Position::mul(), ShapeContainer::myPOIs, ShapeContainer::myPolygons, OutputDevice::setPrecision(), GeoConvHelper::usingGeoProjection(), writeDlrTDPHeader(), Position::x(), and Position::y().
Referenced by main().
|
staticprivate |
write DLR TDP Header
Definition at line 133 of file PCPolyContainer.cpp.
References OptionsCont::writeConfiguration().
Referenced by saveDlrTDP().
|
private |
Information whether the pruning boundary shall be used.
Definition at line 152 of file PCPolyContainer.h.
|
protectedinherited |
inverse map to myHighlightPolygons saves the highlighted object for each polygon
Definition at line 213 of file ShapeContainer.h.
Referenced by ShapeContainer::clearHighlight(), and ShapeContainer::registerHighlight().
|
protectedinherited |
maps objects to a map of highlight types to highlighting polygons
Definition at line 211 of file ShapeContainer.h.
Referenced by ShapeContainer::clearHighlight(), ShapeContainer::clearHighlights(), and ShapeContainer::registerHighlight().
|
private |
An id to int map for proper enumeration.
Definition at line 146 of file PCPolyContainer.h.
Referenced by getEnumIDFor().
|
private |
An id to pos map for lane pos specs.
Definition at line 143 of file PCPolyContainer.h.
Referenced by addLanePos(), and save().
|
protectedinherited |
stored POIs
Definition at line 221 of file ShapeContainer.h.
Referenced by ShapeContainer::add(), GUIShapeContainer::addPOI(), ShapeContainer::getPOIs(), ShapeContainer::movePOI(), GUIShapeContainer::movePOI(), ShapeContainer::removePOI(), GUIShapeContainer::removePOI(), save(), saveDlrTDP(), and ~PCPolyContainer().
|
protectedinherited |
stored PolygonDynamics
Definition at line 208 of file ShapeContainer.h.
Referenced by ShapeContainer::addPolygonDynamics(), ShapeContainer::removePolygonDynamics(), and ShapeContainer::~ShapeContainer().
|
protectedinherited |
stored Polygons
Definition at line 205 of file ShapeContainer.h.
Referenced by ShapeContainer::add(), GUIShapeContainer::addPolygon(), ShapeContainer::addPolygonDynamics(), GUIShapeContainer::computeActivePolygons(), ShapeContainer::getPolygons(), ShapeContainer::removePolygon(), GUIShapeContainer::removePolygon(), ShapeContainer::removePolygonDynamics(), ShapeContainer::reshapePolygon(), GUIShapeContainer::reshapePolygon(), save(), saveDlrTDP(), and ~PCPolyContainer().
|
privateinherited |
Command pointers for scheduled polygon update. Maps PolyID->Command.
Definition at line 225 of file ShapeContainer.h.
Referenced by ShapeContainer::addPolygonUpdateCommand(), ShapeContainer::cleanupPolygonDynamics(), ShapeContainer::clearState(), ShapeContainer::polygonDynamicsUpdate(), and ShapeContainer::~ShapeContainer().
|
private |
The boundary that described the rectangle within which an object must be in order to be kept.
Definition at line 149 of file PCPolyContainer.h.
|
private |
List of names of polygons/pois that shall be removed.
Definition at line 155 of file PCPolyContainer.h.
|
protectedinherited |
Information about tracked objects.
Definition at line 218 of file ShapeContainer.h.
Referenced by ShapeContainer::addPolygonDynamics(), ShapeContainer::removePolygonDynamics(), and ShapeContainer::removeTrackers().