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. More... | |
typedef std::map< std::string, Polygon * > | PolyCont |
Definition of a container of polygons, accessed by the string key. More... | |
Public Member Functions | |
void | clear () |
Removes all stored objects (polygons and pois) More... | |
bool | containsPolygon (const std::string &kidey) |
Returns the information whether a polygon with the given key is in the container. More... | |
int | getEnumIDFor (const std::string &key) |
Retuns a unique id for a given name. More... | |
unsigned int | getNoPOIs () |
Returns the number of stored pois. More... | |
unsigned int | getNoPolygons () |
Returns the number of stored polygons. More... | |
bool | insert (const std::string &id, Polygon *poly, int layer, bool ignorePruning=false) |
Adds a polygon to the storage. More... | |
bool | insert (const std::string &id, PointOfInterest *poi, int layer, bool ignorePruning=false) |
Adds a poi to the storage. More... | |
PCPolyContainer (bool prune, const Boundary &pruningBoundary, const std::vector< std::string > &removeByNames) | |
Constructor. More... | |
void | report () |
Reports how many polygons and pois were added. More... | |
void | save (const std::string &file, bool useGeo) |
Saves the stored polygons into the given file. More... | |
~PCPolyContainer () | |
Destructor. More... | |
Data Fields | |
bool | myDoPrune |
Information whether the pruning boundary shall be used. More... | |
std::map< std::string, int > | myIDEnums |
An id to int map for proper enumeration. More... | |
POICont | myPOICont |
The poi container, accessed by the pois' ids. More... | |
std::map< PointOfInterest *, int > | myPOILayerMap |
A map from pois to the layers they are located in. More... | |
PolyCont | myPolyCont |
The polygon container, accessed by the polygons' ids. More... | |
std::map< Polygon *, int > | myPolyLayerMap |
A map from polygons to the layers they are located in. More... | |
Boundary | myPruningBoundary |
The boundary that described the rectangle within which an object must be in order to be kept. More... | |
std::vector< std::string > | myRemoveByNames |
List of names of polygons/pois that shall be removed. More... | |
Private Member Functions | |
PCPolyContainer & | operator= (const PCPolyContainer &s) |
Invalidated assignment operator. More... | |
PCPolyContainer (const PCPolyContainer &s) | |
Invalidated copy constructor. More... | |
A storage for loaded polygons and pois.
Definition at line 52 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 165 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 160 of file PCPolyContainer.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 55 of file PCPolyContainer.cpp.
PCPolyContainer::~PCPolyContainer | ( | ) |
|
private |
Invalidated copy constructor.
void PCPolyContainer::clear | ( | ) |
Removes all stored objects (polygons and pois)
All items are deleted
Definition at line 133 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 127 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 216 of file PCPolyContainer.cpp.
References myIDEnums.
Referenced by PCLoaderDlrNavteq::loadPolyFile().
|
inline |
Returns the number of stored pois.
Definition at line 116 of file PCPolyContainer.h.
Referenced by report().
|
inline |
Returns the number of stored polygons.
Definition at line 108 of file PCPolyContainer.h.
Referenced by report().
bool PCPolyContainer::insert | ( | const std::string & | id, |
Polygon * | poly, | ||
int | layer, | ||
bool | ignorePruning = false |
||
) |
Adds a polygon to the storage.
If pruning if 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] | 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] | ignorePruning | Whether the polygon shall be kept, even though it would be pruned |
Definition at line 68 of file PCPolyContainer.cpp.
References PositionVector::getBoxBoundary(), SUMO::Polygon::getShape(), myDoPrune, myPolyCont, myPolyLayerMap, myPruningBoundary, myRemoveByNames, Boundary::partialWithin(), and WRITE_ERROR.
Referenced by PCLoaderOSM::addPOI(), PCLoaderOSM::addPolygon(), PCLoaderVisum::load(), PCLoaderArcView::load(), PCLoaderDlrNavteq::loadPOIFile(), PCLoaderDlrNavteq::loadPolyFile(), and PCLoaderXML::myStartElement().
bool PCPolyContainer::insert | ( | const std::string & | id, |
PointOfInterest * | poi, | ||
int | layer, | ||
bool | ignorePruning = false |
||
) |
Adds a poi to the storage.
If pruning if 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] | 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] | ignorePruning | Whether the poi shall be kept, even though it would be pruned |
Definition at line 98 of file PCPolyContainer.cpp.
References Boundary::around(), myDoPrune, myPOICont, myPOILayerMap, myPruningBoundary, myRemoveByNames, and WRITE_ERROR.
|
private |
Invalidated assignment operator.
void PCPolyContainer::report | ( | ) |
Reports how many polygons and pois were added.
Definition at line 150 of file PCPolyContainer.cpp.
References getNoPOIs(), getNoPolygons(), toString(), and WRITE_MESSAGE.
void PCPolyContainer::save | ( | const std::string & | file, |
bool | useGeo | ||
) |
Saves the stored polygons 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 157 of file PCPolyContainer.cpp.
References GeoConvHelper::cartesian2geo(), OutputDevice::close(), OutputDevice::closeTag(), Shape::DEFAULT_ANGLE, Shape::DEFAULT_IMG_FILE, Shape::DEFAULT_IMG_HEIGHT, Shape::DEFAULT_IMG_WIDTH, StringUtils::escapeXML(), GEO_OUTPUT_ACCURACY, Shape::getAngle(), Shape::getColor(), OutputDevice::getDevice(), GeoConvHelper::getFinal(), PointOfInterest::getHeight(), Named::getID(), Shape::getImgFile(), Shape::getLayer(), Parameterised::getMap(), Shape::getType(), PointOfInterest::getWidth(), myPOICont, myPolyCont, OutputDevice::openTag(), OutputDevice::setPrecision(), SUMO_ATTR_ANGLE, SUMO_ATTR_COLOR, SUMO_ATTR_HEIGHT, SUMO_ATTR_ID, SUMO_ATTR_IMGFILE, SUMO_ATTR_KEY, SUMO_ATTR_LAT, SUMO_ATTR_LAYER, SUMO_ATTR_LON, SUMO_ATTR_TYPE, SUMO_ATTR_VALUE, SUMO_ATTR_WIDTH, SUMO_ATTR_X, SUMO_ATTR_Y, SUMO_TAG_PARAM, SUMO_TAG_POI, GeoConvHelper::usingGeoProjection(), WRITE_WARNING, OutputDevice::writeAttr(), GeoConvHelper::writeLocation(), OutputDevice::writeXMLHeader(), Position::x(), and Position::y().
bool PCPolyContainer::myDoPrune |
Information whether the pruning boundary shall be used.
Definition at line 183 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 170 of file PCPolyContainer.h.
Referenced by getEnumIDFor().
POICont PCPolyContainer::myPOICont |
The poi container, accessed by the pois' ids.
Definition at line 167 of file PCPolyContainer.h.
std::map<PointOfInterest*, int> PCPolyContainer::myPOILayerMap |
A map from pois to the layers they are located in.
Definition at line 176 of file PCPolyContainer.h.
PolyCont PCPolyContainer::myPolyCont |
The polygon container, accessed by the polygons' ids.
Definition at line 162 of file PCPolyContainer.h.
Referenced by clear(), containsPolygon(), insert(), and save().
std::map<Polygon*, int> PCPolyContainer::myPolyLayerMap |
A map from polygons to the layers they are located in.
Definition at line 173 of file PCPolyContainer.h.
Boundary PCPolyContainer::myPruningBoundary |
The boundary that described the rectangle within which an object must be in order to be kept.
Definition at line 180 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 186 of file PCPolyContainer.h.
Referenced by insert().