SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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. 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)
 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, intmyIDEnums
 An id to int map for proper enumeration. More...
 
POICont myPOICont
 The poi container, accessed by the pois' ids. More...
 
std::map< PointOfInterest *, intmyPOILayerMap
 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 *, intmyPolyLayerMap
 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

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

Detailed Description

A storage for loaded polygons and pois.

Definition at line 52 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 164 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 159 of file PCPolyContainer.h.

Constructor & Destructor Documentation

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

Constructor.

Parameters
[in]pruneWhether added polygons/pois shall be pruned
[in]pruningBoundaryThe pruning boundary (only valid if prune==true)
[in]removeByNamesNames of objects that shall not be added

Definition at line 54 of file PCPolyContainer.cpp.

PCPolyContainer::~PCPolyContainer ( )

Destructor.

Definition at line 61 of file PCPolyContainer.cpp.

References clear().

PCPolyContainer::PCPolyContainer ( const PCPolyContainer s)
private

Invalidated copy constructor.

Member Function Documentation

void PCPolyContainer::clear ( )

Removes all stored objects (polygons and pois)

All items are deleted

Definition at line 132 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 126 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 224 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 116 of file PCPolyContainer.h.

Referenced by report().

unsigned int PCPolyContainer::getNoPolygons ( )
inline

Returns the number of stored polygons.

Returns
How many polygons were added before

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.

Parameters
[in]idThe id of the polygon to add
[in]polyThe polygon to add
[in]layerThe layer the polygon shall be located within
[in]ignorePruningWhether the polygon shall be kept, even though it would be pruned
Returns
Whether the polygon could be added

Definition at line 67 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.

Parameters
[in]idThe id of the poi to add
[in]polyThe poi to add
[in]layerThe layer the poi shall be located within
[in]ignorePruningWhether the poi shall be kept, even though it would be pruned
Returns
Whether the poi could be added

Definition at line 97 of file PCPolyContainer.cpp.

References Boundary::around(), myDoPrune, myPOICont, myPOILayerMap, myPruningBoundary, myRemoveByNames, and WRITE_ERROR.

PCPolyContainer& PCPolyContainer::operator= ( const PCPolyContainer s)
private

Invalidated assignment operator.

void PCPolyContainer::report ( )

Reports how many polygons and pois were added.

Definition at line 149 of file PCPolyContainer.cpp.

References getNoPOIs(), getNoPolygons(), toString(), and WRITE_MESSAGE.

Field Documentation

bool PCPolyContainer::myDoPrune

Information whether the pruning boundary shall be used.

Definition at line 182 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 169 of file PCPolyContainer.h.

Referenced by getEnumIDFor().

POICont PCPolyContainer::myPOICont

The poi container, accessed by the pois' ids.

Definition at line 166 of file PCPolyContainer.h.

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

std::map<PointOfInterest*, int> PCPolyContainer::myPOILayerMap

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

Definition at line 175 of file PCPolyContainer.h.

Referenced by clear(), and insert().

PolyCont PCPolyContainer::myPolyCont

The polygon container, accessed by the polygons' ids.

Definition at line 161 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 172 of file PCPolyContainer.h.

Referenced by clear(), and insert().

Boundary PCPolyContainer::myPruningBoundary

The boundary that described the rectangle within which an object must be in order to be kept.

Definition at line 179 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 185 of file PCPolyContainer.h.

Referenced by insert().


The documentation for this class was generated from the following files: