SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PCPolyContainer Class Reference

A storage for loaded polygons and pois. More...

#include <PCPolyContainer.h>

Inheritance diagram for PCPolyContainer:
Inheritance graph
Collaboration diagram for PCPolyContainer:
Collaboration graph

Public Types

typedef NamedObjectCont
< PointOfInterest * > 
POIs
 
typedef NamedObjectCont
< SUMO::Polygon * > 
Polygons
 

Public Member Functions

bool add (SUMO::Polygon *poly, bool ignorePruning=false)
 Adds a polygon to the storage. More...
 
bool add (PointOfInterest *poi, bool ignorePruning=false)
 Adds a poi to the storage. More...
 
void addLanePos (const std::string &poiID, const std::string &laneID, SUMOReal lanePos)
 
virtual bool addPOI (const std::string &id, const std::string &type, const RGBColor &color, SUMOReal layer, SUMOReal angle, const std::string &imgFile, const Position &pos, SUMOReal width, SUMOReal height, bool ignorePruning=false)
 Builds a POI using the given values and adds it to the container. More...
 
virtual bool addPolygon (const std::string &id, const std::string &type, const RGBColor &color, SUMOReal layer, SUMOReal angle, const std::string &imgFile, const PositionVector &shape, bool fill, bool ignorePruning=false)
 Builds a polygon using the given values and adds it to the container. More...
 
int getEnumIDFor (const std::string &key)
 Retuns a unique id for a given name. More...
 
const POIsgetPOIs () const
 Returns all pois. More...
 
const PolygonsgetPolygons () const
 Returns all polygons. More...
 
virtual void movePOI (const std::string &id, const Position &pos)
 Assigns a new position to the named PoI. More...
 
 PCPolyContainer (bool prune, const Boundary &pruningBoundary, const std::vector< std::string > &removeByNames)
 Constructor. More...
 
virtual bool removePOI (const std::string &id)
 Removes a PoI from the container. More...
 
virtual bool removePolygon (const std::string &id)
 Removes a polygon from the container. More...
 
virtual void reshapePolygon (const std::string &id, const PositionVector &shape)
 Assigns a shape to the named polygon. More...
 
void save (const std::string &file, bool useGeo)
 Saves the stored polygons and pois into the given file. More...
 
 ~PCPolyContainer ()
 Destructor. More...
 

Protected Attributes

POIs myPOIs
 stored POIs More...
 
Polygons myPolygons
 stored Polygons More...
 

Private Member Functions

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

Private Attributes

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...
 
std::map< std::string,
std::pair< std::string,
SUMOReal > > 
myLanePosPois
 An id to pos map for lane pos specs. 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...
 

Detailed Description

A storage for loaded polygons and pois.

Definition at line 52 of file PCPolyContainer.h.

Member Typedef Documentation

Definition at line 58 of file ShapeContainer.h.

Definition at line 57 of file ShapeContainer.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 56 of file PCPolyContainer.cpp.

PCPolyContainer::~PCPolyContainer ( )
PCPolyContainer::PCPolyContainer ( const PCPolyContainer s)
private

Invalidated copy constructor.

Member Function Documentation

bool PCPolyContainer::add ( SUMO::Polygon poly,
bool  ignorePruning = false 
)
virtual

Adds a polygon to the storage.

If pruning is 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]polyThe polygon to add
[in]ignorePruningWhether the polygon shall be kept, even though it would be pruned
Returns
Whether the polygon could be added

Reimplemented from ShapeContainer.

Definition at line 70 of file PCPolyContainer.cpp.

References ShapeContainer::add(), PositionVector::getBoxBoundary(), Named::getID(), SUMO::Polygon::getShape(), myDoPrune, myPruningBoundary, myRemoveByNames, and Boundary::partialWithin().

Referenced by PCLoaderOSM::addPOI(), PCLoaderOSM::addPolygon(), PCLoaderVisum::load(), PCLoaderArcView::load(), PCLoaderDlrNavteq::loadPOIFile(), and PCLoaderDlrNavteq::loadPolyFile().

bool PCPolyContainer::add ( PointOfInterest poi,
bool  ignorePruning = false 
)
virtual

Adds a poi to the storage.

If pruning is 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]polyThe poi to add
[in]ignorePruningWhether the poi shall be kept, even though it would be pruned
Returns
Whether the poi could be added

Reimplemented from ShapeContainer.

Definition at line 90 of file PCPolyContainer.cpp.

References ShapeContainer::add(), Boundary::around(), Named::getID(), myDoPrune, myPruningBoundary, and myRemoveByNames.

void PCPolyContainer::addLanePos ( const std::string &  poiID,
const std::string &  laneID,
SUMOReal  lanePos 
)

Definition at line 109 of file PCPolyContainer.cpp.

References myLanePosPois.

bool ShapeContainer::addPOI ( const std::string &  id,
const std::string &  type,
const RGBColor color,
SUMOReal  layer,
SUMOReal  angle,
const std::string &  imgFile,
const Position pos,
SUMOReal  width,
SUMOReal  height,
bool  ignorePruning = false 
)
virtualinherited

Builds a POI using the given values and adds it to the container.

Parameters
[in]idThe name of the POI
[in]typeThe (abstract) type of the POI
[in]colorThe color of the POI
[in]layerThe layer of the POI
[in]angleThe rotation of the POI
[in]imgFileThe raster image of the POI
[in]posThe position of the POI
[in]widthThe width of the POI image
[in]heightThe height of the POI image
Returns
whether the poi could be added

Reimplemented in GUIShapeContainer.

Definition at line 71 of file ShapeContainer.cpp.

References ShapeContainer::add().

Referenced by ShapeHandler::addPOI(), and TraCIServerAPI_POI::processSet().

bool ShapeContainer::addPolygon ( const std::string &  id,
const std::string &  type,
const RGBColor color,
SUMOReal  layer,
SUMOReal  angle,
const std::string &  imgFile,
const PositionVector shape,
bool  fill,
bool  ignorePruning = false 
)
virtualinherited

Builds a polygon using the given values and adds it to the container.

Parameters
[in]idThe name of the polygon
[in]typeThe (abstract) type of the polygon
[in]colorThe color of the polygon
[in]layerThe layer of the polygon
[in]angleThe rotation of the polygon
[in]imgFileThe raster image of the polygon
[in]shapeThe shape of the polygon
[in]fillWhether the polygon shall be filled
Returns
whether the polygon could be added

Reimplemented in GUIShapeContainer.

Definition at line 62 of file ShapeContainer.cpp.

References ShapeContainer::add().

Referenced by NLHandler::addDistrict(), ShapeHandler::addPoly(), and TraCIServerAPI_Polygon::processSet().

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

References myIDEnums.

Referenced by PCLoaderDlrNavteq::loadPolyFile().

const POIs& ShapeContainer::getPOIs ( ) const
inlineinherited
const Polygons& ShapeContainer::getPolygons ( ) const
inlineinherited
void ShapeContainer::movePOI ( const std::string &  id,
const Position pos 
)
virtualinherited

Assigns a new position to the named PoI.

Parameters
[in]idThe id of the PoI to move
[in]posThe PoI's new position

Reimplemented in GUIShapeContainer.

Definition at line 92 of file ShapeContainer.cpp.

References NamedObjectCont< T >::get(), and ShapeContainer::myPOIs.

Referenced by TraCIServerAPI_POI::processSet().

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

Invalidated assignment operator.

bool ShapeContainer::removePOI ( const std::string &  id)
virtualinherited

Removes a PoI from the container.

Parameters
[in]idThe id of the PoI
Returns
Whether the poi could be removed

Reimplemented in GUIShapeContainer.

Definition at line 85 of file ShapeContainer.cpp.

References ShapeContainer::myPOIs, and NamedObjectCont< T >::remove().

Referenced by GNEViewNet::onLeftBtnPress(), and TraCIServerAPI_POI::processSet().

bool ShapeContainer::removePolygon ( const std::string &  id)
virtualinherited

Removes a polygon from the container.

Parameters
[in]idThe id of the polygon
Returns
Whether the polygon could be removed

Reimplemented in GUIShapeContainer.

Definition at line 79 of file ShapeContainer.cpp.

References ShapeContainer::myPolygons, and NamedObjectCont< T >::remove().

Referenced by TraCIServerAPI_Polygon::processSet().

void ShapeContainer::reshapePolygon ( const std::string &  id,
const PositionVector shape 
)
virtualinherited

Assigns a shape to the named polygon.

Parameters
[in]idThe id of the polygon to reshape
[in]shapeThe polygon's new shape

Reimplemented in GUIShapeContainer.

Definition at line 101 of file ShapeContainer.cpp.

References NamedObjectCont< T >::get(), ShapeContainer::myPolygons, and SUMO::Polygon::setShape().

Referenced by TraCIServerAPI_Polygon::processSet().

void PCPolyContainer::save ( const std::string &  file,
bool  useGeo 
)

Saves the stored polygons and pois into the given file.

Parameters
[in]fileThe name of the file to write stored objects' definitions into
[in]useGeoWhether to write output in geo-coordinates
Exceptions
IOErrorIf the file could not be opened

Definition at line 115 of file PCPolyContainer.cpp.

References OutputDevice::close(), GEO_OUTPUT_ACCURACY, OutputDevice::getDevice(), GeoConvHelper::getFinal(), OptionsCont::getFloat(), NamedObjectCont< T >::getMyMap(), OptionsCont::getOptions(), myLanePosPois, ShapeContainer::myPOIs, ShapeContainer::myPolygons, OutputDevice::setPrecision(), SUMOReal, GeoConvHelper::usingGeoProjection(), WRITE_WARNING, GeoConvHelper::writeLocation(), and OutputDevice::writeXMLHeader().

Field Documentation

bool PCPolyContainer::myDoPrune
private

Information whether the pruning boundary shall be used.

Definition at line 131 of file PCPolyContainer.h.

Referenced by add().

std::map<std::string, int> PCPolyContainer::myIDEnums
private

An id to int map for proper enumeration.

Definition at line 125 of file PCPolyContainer.h.

Referenced by getEnumIDFor().

std::map<std::string, std::pair<std::string, SUMOReal> > PCPolyContainer::myLanePosPois
private

An id to pos map for lane pos specs.

Definition at line 122 of file PCPolyContainer.h.

Referenced by addLanePos(), and save().

Boundary PCPolyContainer::myPruningBoundary
private

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

Definition at line 128 of file PCPolyContainer.h.

Referenced by add().

std::vector<std::string> PCPolyContainer::myRemoveByNames
private

List of names of polygons/pois that shall be removed.

Definition at line 134 of file PCPolyContainer.h.

Referenced by add().


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