SUMO - Simulation of Urban MObility
|
A storage for loaded polygons and pois. More...
#include <PCPolyContainer.h>
Public Types | |
typedef std::map< std::string, PointOfInterest * > | POICont |
Definition of a container of pois, accessed by the string key. | |
typedef std::map< std::string, Polygon * > | PolyCont |
Definition of a container of polygons, accessed by the string key. | |
Public Member Functions | |
void | clear () |
Removes all stored objects (polygons and pois) | |
bool | containsPolygon (const std::string &kidey) |
Returns the information whether a polygon with the given key is in the container. | |
int | getEnumIDFor (const std::string &key) |
Retuns a unique id for a given name. | |
unsigned int | getNoPOIs () |
Returns the number of stored pois. | |
unsigned int | getNoPolygons () |
Returns the number of stored polygons. | |
bool | insert (const std::string &id, Polygon *poly, int layer, bool ignorePrunning=false) |
Adds a polygon to the storage. | |
bool | insert (const std::string &id, PointOfInterest *poi, int layer, bool ignorePrunning=false) |
Adds a poi to the storage. | |
PCPolyContainer (bool prune, const Boundary &prunningBoundary, const std::vector< std::string > &removeByNames) | |
Constructor. | |
void | report () |
Reports how many polygons and pois were added. | |
void | save (const std::string &file) |
Saves the stored polygons into the given file. | |
~PCPolyContainer () | |
Destructor. | |
Data Fields | |
bool | myDoPrunne |
Information whether the prunning boundary shall be used. | |
std::map< std::string, int > | myIDEnums |
An id to int map for proper enumeration. | |
POICont | myPOICont |
The poi container, accessed by the pois' ids. | |
std::map< PointOfInterest *, int > | myPOILayerMap |
A map from pois to the layers they are located in. | |
PolyCont | myPolyCont |
The polygon container, accessed by the polygons' ids. | |
std::map< Polygon *, int > | myPolyLayerMap |
A map from polygons to the layers they are located in. | |
Boundary | myPrunningBoundary |
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. | |
Private Member Functions | |
PCPolyContainer & | operator= (const PCPolyContainer &s) |
Invalidated assignment operator. | |
PCPolyContainer (const PCPolyContainer &s) | |
Invalidated copy constructor. |
A storage for loaded polygons and pois.
Definition at line 50 of file PCPolyContainer.h.
typedef std::map<std::string, PointOfInterest*> PCPolyContainer::POICont |
Definition of a container of pois, accessed by the string key.
Definition at line 162 of file PCPolyContainer.h.
typedef std::map<std::string, Polygon*> PCPolyContainer::PolyCont |
Definition of a container of polygons, accessed by the string key.
Definition at line 157 of file PCPolyContainer.h.
PCPolyContainer::PCPolyContainer | ( | bool | prune, |
const Boundary & | prunningBoundary, | ||
const std::vector< std::string > & | removeByNames | ||
) |
Constructor.
[in] | prune | Whether added polygons/pois shall be prunned |
[in] | prunningBoundary | The pruning boundary (onyl valid if prune==true) |
[in] | removeByNames | Names of objects that shall not be added |
Definition at line 52 of file PCPolyContainer.cpp.
PCPolyContainer::PCPolyContainer | ( | const PCPolyContainer & | s | ) | [private] |
Invalidated copy constructor.
void PCPolyContainer::clear | ( | ) |
Removes all stored objects (polygons and pois)
All items are deleted
Definition at line 126 of file PCPolyContainer.cpp.
References myPOICont, myPOILayerMap, myPolyCont, and myPolyLayerMap.
Referenced by ~PCPolyContainer().
bool PCPolyContainer::containsPolygon | ( | const std::string & | kidey | ) |
Returns the information whether a polygon with the given key is in the container.
[in] | id | The id of the polygon to get the information about |
Definition at line 120 of file PCPolyContainer.cpp.
References myPolyCont.
Referenced by PCLoaderDlrNavteq::loadPolyFile().
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 178 of file PCPolyContainer.cpp.
References myIDEnums.
Referenced by PCLoaderDlrNavteq::loadPolyFile().
unsigned int PCPolyContainer::getNoPOIs | ( | ) | [inline] |
Returns the number of stored pois.
Definition at line 114 of file PCPolyContainer.h.
References myPOICont.
Referenced by report().
unsigned int PCPolyContainer::getNoPolygons | ( | ) | [inline] |
Returns the number of stored polygons.
Definition at line 106 of file PCPolyContainer.h.
References myPolyCont.
Referenced by report().
bool PCPolyContainer::insert | ( | const std::string & | id, |
Polygon * | poly, | ||
int | layer, | ||
bool | ignorePrunning = false |
||
) |
Adds a polygon to the storage.
If prunning if enabled, "ignorePrunning" is false and the polygon lies outside the prunning boundary, or if the polygon's name is within the names of objects to discard, the polygon is deleted and true is returned.
Otherwise, it is tested whether a polygon with the same name is already stored. If so, false is returned (the polygon is not deleted), otherwise true.
[in] | id | The id of the polygon to add |
[in] | poly | The polygon to add |
[in] | layer | The layer the polygon shall be located within |
[in] | ignorePrunning | Whether the polygon shall be kept, even though it would be prunned |
Definition at line 65 of file PCPolyContainer.cpp.
References PositionVector::getBoxBoundary(), Polygon::getShape(), myDoPrunne, myPolyCont, myPolyLayerMap, myPrunningBoundary, myRemoveByNames, and Boundary::partialWithin().
Referenced by PCLoaderVisum::load(), PCLoaderArcView::load(), PCLoaderOSM::loadIfSet(), PCLoaderDlrNavteq::loadPOIFile(), PCLoaderDlrNavteq::loadPolyFile(), PCLoaderXML::myCharacters(), and PCLoaderXML::myStartElement().
bool PCPolyContainer::insert | ( | const std::string & | id, |
PointOfInterest * | poi, | ||
int | layer, | ||
bool | ignorePrunning = false |
||
) |
Adds a poi to the storage.
If prunning if enabled, "ignorePrunning" is false and the poi lies outside the prunning boundary, or if the poi's name is within the names of objects to discard, the poi is deleted and true is returned.
Otherwise, it is tested whether a poi with the same name is already stored. If so, false is returned (the poi is not deleted), otherwise true.
[in] | id | The id of the poi to add |
[in] | poly | The poi to add |
[in] | layer | The layer the poi shall be located within |
[in] | ignorePrunning | Whether the poi shall be kept, even though it would be prunned |
Definition at line 93 of file PCPolyContainer.cpp.
References Boundary::around(), myDoPrunne, myPOICont, myPOILayerMap, myPrunningBoundary, and myRemoveByNames.
PCPolyContainer& PCPolyContainer::operator= | ( | const PCPolyContainer & | s | ) | [private] |
Invalidated assignment operator.
void PCPolyContainer::report | ( | ) |
Reports how many polygons and pois were added.
Definition at line 143 of file PCPolyContainer.cpp.
References getNoPOIs(), getNoPolygons(), toString(), and WRITE_MESSAGE.
void PCPolyContainer::save | ( | const std::string & | file | ) |
Saves the stored polygons into the given file.
[in] | file | The name of the file to write stored objects' definitions into |
IOError | If the file could not been opened |
Definition at line 150 of file PCPolyContainer.cpp.
References OutputDevice::close(), OutputDevice::closeTag(), SUMOSAXAttributes::ENCODING, StringUtils::escapeXML(), OutputDevice::getDevice(), myPOICont, myPOILayerMap, myPolyCont, myPolyLayerMap, OutputDevice::openTag(), and OutputDevice::writeXMLHeader().
Information whether the prunning boundary shall be used.
Definition at line 180 of file PCPolyContainer.h.
Referenced by insert().
std::map<std::string, int> PCPolyContainer::myIDEnums |
An id to int map for proper enumeration.
Definition at line 167 of file PCPolyContainer.h.
Referenced by getEnumIDFor().
The poi container, accessed by the pois' ids.
Definition at line 164 of file PCPolyContainer.h.
Referenced by clear(), getNoPOIs(), insert(), and save().
std::map<PointOfInterest*, int> PCPolyContainer::myPOILayerMap |
A map from pois to the layers they are located in.
Definition at line 173 of file PCPolyContainer.h.
The polygon container, accessed by the polygons' ids.
Definition at line 159 of file PCPolyContainer.h.
Referenced by clear(), containsPolygon(), getNoPolygons(), insert(), and save().
std::map<Polygon*, int> PCPolyContainer::myPolyLayerMap |
A map from polygons to the layers they are located in.
Definition at line 170 of file PCPolyContainer.h.
The boundary that described the rectangle within which an object must be in order to be kept.
Definition at line 177 of file PCPolyContainer.h.
Referenced by insert().
std::vector<std::string> PCPolyContainer::myRemoveByNames |
List of names of polygons/pois that shall be removed.
Definition at line 183 of file PCPolyContainer.h.
Referenced by insert().