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 ignorePrunning=false)
 Adds a polygon to the storage. More...
 
bool insert (const std::string &id, PointOfInterest *poi, int layer, bool ignorePrunning=false)
 Adds a poi to the storage. More...
 
 PCPolyContainer (bool prune, const Boundary &prunningBoundary, 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 myDoPrunne
 Information whether the prunning 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 myPrunningBoundary
 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 51 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 163 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 158 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 53 of file PCPolyContainer.cpp.

PCPolyContainer::~PCPolyContainer ( )

Destructor.

Definition at line 60 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 127 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 121 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 219 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 115 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 107 of file PCPolyContainer.h.

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 66 of file PCPolyContainer.cpp.

References PositionVector::getBoxBoundary(), SUMO::Polygon::getShape(), myDoPrunne, myPolyCont, myPolyLayerMap, myPrunningBoundary, myRemoveByNames, and Boundary::partialWithin().

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  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 94 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 144 of file PCPolyContainer.cpp.

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

Field Documentation

bool PCPolyContainer::myDoPrunne

Information whether the prunning boundary shall be used.

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

Referenced by getEnumIDFor().

POICont PCPolyContainer::myPOICont

The poi container, accessed by the pois' ids.

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

Referenced by clear(), and insert().

PolyCont PCPolyContainer::myPolyCont

The polygon container, accessed by the polygons' ids.

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

Referenced by clear(), and insert().

Boundary PCPolyContainer::myPrunningBoundary

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

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

Referenced by insert().


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