SUMO - Simulation of Urban MObility
PCPolyContainer Class Reference

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, intmyIDEnums
 An id to int map for proper enumeration.
POICont myPOICont
 The poi container, accessed by the pois' ids.
std::map< PointOfInterest *, intmyPOILayerMap
 A map from pois to the layers they are located in.
PolyCont myPolyCont
 The polygon container, accessed by the polygons' ids.
std::map< Polygon *, intmyPolyLayerMap
 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

PCPolyContaineroperator= (const PCPolyContainer &s)
 Invalidated assignment operator.
 PCPolyContainer (const PCPolyContainer &s)
 Invalidated copy constructor.

Detailed Description

A storage for loaded polygons and pois.

Definition at line 50 of file PCPolyContainer.h.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

PCPolyContainer::PCPolyContainer ( bool  prune,
const Boundary prunningBoundary,
const std::vector< std::string > &  removeByNames 
)

Constructor.

Parameters:
[in]pruneWhether added polygons/pois shall be prunned
[in]prunningBoundaryThe pruning boundary (onyl valid if prune==true)
[in]removeByNamesNames of objects that shall not be added

Definition at line 52 of file PCPolyContainer.cpp.

Destructor.

Definition at line 59 of file PCPolyContainer.cpp.

References clear().

Invalidated copy constructor.


Member Function Documentation

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.

Parameters:
[in]idThe id of the polygon to get the information about
Returns:
Whether the named polygon was added before

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.

Parameters:
[in]keyThe key to get a running number for
Returns:
Unique id (running number of calls that used this key)

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.

Returns:
How many pois were added before

Definition at line 114 of file PCPolyContainer.h.

References myPOICont.

Referenced by report().

unsigned int PCPolyContainer::getNoPolygons ( ) [inline]

Returns the number of stored polygons.

Returns:
How many polygons were added before

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.

Parameters:
[in]idThe id of the polygon to add
[in]polyThe polygon to add
[in]layerThe layer the polygon shall be located within
[in]ignorePrunningWhether the polygon shall be kept, even though it would be prunned
Returns:
Whether the polygon could been added (no one with the same id was added before)

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.

Parameters:
[in]idThe id of the poi to add
[in]polyThe poi to add
[in]layerThe layer the poi shall be located within
[in]ignorePrunningWhether the poi shall be kept, even though it would be prunned
Returns:
Whether the poi could been added (no one with the same id was added before)

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.

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.

Parameters:
[in]fileThe name of the file to write stored objects' definitions into
Exceptions:
IOErrorIf 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().


Field Documentation

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().

A map from pois to the layers they are located in.

Definition at line 173 of file PCPolyContainer.h.

Referenced by clear(), insert(), and save().

The polygon container, accessed by the polygons' ids.

Definition at line 159 of file PCPolyContainer.h.

Referenced by clear(), containsPolygon(), getNoPolygons(), insert(), and save().

A map from polygons to the layers they are located in.

Definition at line 170 of file PCPolyContainer.h.

Referenced by clear(), insert(), and save().

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().


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines