#include <PCPolyContainer.h>
Definition at line 48 of file 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, Polygon2D * > | PolyCont |
| Definition of a container of polygons, accessed by the string key. | |
Public Member Functions | |
| void | clear () throw () |
| Removes all stored objects (polygons and pois). | |
| bool | containsPolygon (const std::string &kidey) throw () |
| Returns the information whether a polygon with the given key is in the container. | |
| int | getEnumIDFor (const std::string &key) throw () |
| Retuns a unique id for a given name. | |
| unsigned int | getNoPOIs () throw () |
| Returns the number of stored pois. | |
| unsigned int | getNoPolygons () throw () |
| Returns the number of stored polygons. | |
| bool | insert (const std::string &id, PointOfInterest *poi, int layer, bool ignorePrunning=false) throw () |
| Adds a poi to the storage. | |
| bool | insert (const std::string &id, Polygon2D *poly, int layer, bool ignorePrunning=false) throw () |
| Adds a polygon to the storage. | |
| PCPolyContainer (bool prune, const Boundary &prunningBoundary, const std::vector< std::string > &removeByNames) throw () | |
| Constructor. | |
| void | report () throw () |
| Reports how many polygons and pois were added. | |
| void | save (const std::string &file) throw (IOError) |
| Saves the stored polygons into the given file. | |
| ~PCPolyContainer () throw () | |
| Destructor. | |
Data Fields | |
| bool | myDoPrunne |
| Information whether the prunning boundary shall be used. | |
| std::map< std::string, int > | myIDEnums |
| An id to int map for proper enumeration. | |
| POICont | myPOICont |
| The poi container, accessed by the pois' ids. | |
| std::map< PointOfInterest *, int > | myPOILayerMap |
| A map from pois to the layers they are located in. | |
| PolyCont | myPolyCont |
| The polygon container, accessed by the polygons' ids. | |
| std::map< Polygon2D *, int > | myPolyLayerMap |
| 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 | |
| PCPolyContainer & | operator= (const PCPolyContainer &s) |
| Invalidated assignment operator. | |
| PCPolyContainer (const PCPolyContainer &s) | |
| Invalidated copy constructor. | |
| typedef std::map<std::string, PointOfInterest*> PCPolyContainer::POICont |
Definition of a container of pois, accessed by the string key.
Definition at line 160 of file PCPolyContainer.h.
| typedef std::map<std::string, Polygon2D*> PCPolyContainer::PolyCont |
Definition of a container of polygons, accessed by the string key.
Definition at line 155 of file PCPolyContainer.h.
| PCPolyContainer::PCPolyContainer | ( | bool | prune, | |
| const Boundary & | prunningBoundary, | |||
| const std::vector< std::string > & | removeByNames | |||
| ) | throw () |
Constructor.
| [in] | prune | Whether added polygons/pois shall be prunned |
| [in] | prunningBoundary | The pruning boundary (onyl valid if prune==true) |
| [in] | removeByNames | Names of objects that shall not be added |
Definition at line 48 of file PCPolyContainer.cpp.
00051 : myPrunningBoundary(prunningBoundary), myDoPrunne(prune), 00052 myRemoveByNames(removeByNames) {}
| PCPolyContainer::~PCPolyContainer | ( | ) | throw () |
Destructor.
Definition at line 55 of file PCPolyContainer.cpp.
References clear().
00055 { 00056 clear(); 00057 }
| PCPolyContainer::PCPolyContainer | ( | const PCPolyContainer & | s | ) | [private] |
Invalidated copy constructor.
| void PCPolyContainer::clear | ( | ) | throw () |
Removes all stored objects (polygons and pois).
All items are deleted
Definition at line 122 of file PCPolyContainer.cpp.
References myPOICont, myPOILayerMap, myPolyCont, and myPolyLayerMap.
Referenced by ~PCPolyContainer().
00122 { 00123 // polys 00124 for (PolyCont::iterator i=myPolyCont.begin(); i!=myPolyCont.end(); i++) { 00125 delete(*i).second; 00126 } 00127 myPolyCont.clear(); 00128 myPolyLayerMap.clear(); 00129 // pois 00130 for (POICont::iterator i=myPOICont.begin(); i!=myPOICont.end(); i++) { 00131 delete(*i).second; 00132 } 00133 myPOICont.clear(); 00134 myPOILayerMap.clear(); 00135 }
| bool PCPolyContainer::containsPolygon | ( | const std::string & | kidey | ) | throw () |
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 116 of file PCPolyContainer.cpp.
References myPolyCont.
00116 { 00117 return myPolyCont.find(id)!=myPolyCont.end(); 00118 }
| int PCPolyContainer::getEnumIDFor | ( | const std::string & | key | ) | throw () |
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 173 of file PCPolyContainer.cpp.
References myIDEnums.
00173 { 00174 if (myIDEnums.find(key)==myIDEnums.end()) { 00175 myIDEnums[key] = 0; 00176 return 0; 00177 } else { 00178 myIDEnums[key] = myIDEnums[key] + 1; 00179 return myIDEnums[key]; 00180 } 00181 }
| unsigned int PCPolyContainer::getNoPOIs | ( | ) | throw () [inline] |
Returns the number of stored pois.
Definition at line 112 of file PCPolyContainer.h.
References myPOICont.
Referenced by report().
00112 { 00113 return (unsigned int) myPOICont.size(); 00114 }
| unsigned int PCPolyContainer::getNoPolygons | ( | ) | throw () [inline] |
Returns the number of stored polygons.
Definition at line 104 of file PCPolyContainer.h.
References myPolyCont.
Referenced by report().
00104 { 00105 return (unsigned int) myPolyCont.size(); 00106 }
| bool PCPolyContainer::insert | ( | const std::string & | id, | |
| PointOfInterest * | poi, | |||
| int | layer, | |||
| bool | ignorePrunning = false | |||
| ) | throw () |
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.
| [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] | ignorePrunning | Whether the poi shall be kept, even though it would be prunned |
Definition at line 89 of file PCPolyContainer.cpp.
References Boundary::around(), myDoPrunne, myPOICont, myPOILayerMap, myPrunningBoundary, and myRemoveByNames.
00090 { 00091 // check whether the poi lies within the wished area 00092 // - if such an area was given 00093 if (myDoPrunne&&!ignorePrunning) { 00094 if (!myPrunningBoundary.around(*poi)) { 00095 delete poi; 00096 return true; 00097 } 00098 } 00099 // check whether the polygon was named to be a removed one 00100 if (find(myRemoveByNames.begin(), myRemoveByNames.end(), id)!=myRemoveByNames.end()) { 00101 delete poi; 00102 return true; 00103 } 00104 // 00105 POICont::iterator i=myPOICont.find(id); 00106 if (i!=myPOICont.end()) { 00107 return false; 00108 } 00109 myPOICont[id] = poi; 00110 myPOILayerMap[poi] = layer; 00111 return true; 00112 }
| bool PCPolyContainer::insert | ( | const std::string & | id, | |
| Polygon2D * | poly, | |||
| int | layer, | |||
| bool | ignorePrunning = false | |||
| ) | throw () |
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.
| [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] | ignorePrunning | Whether the polygon shall be kept, even though it would be prunned |
Definition at line 61 of file PCPolyContainer.cpp.
References myDoPrunne, myPolyCont, myPolyLayerMap, myPrunningBoundary, myRemoveByNames, and Boundary::partialWithin().
Referenced by PCLoaderArcView::load(), PCLoaderXML::myCharacters(), and PCLoaderXML::myStartElement().
00062 { 00063 // check whether the polygon lies within the wished area 00064 // - if such an area was given 00065 if (myDoPrunne&&!ignorePrunning) { 00066 Boundary b = poly->getShape().getBoxBoundary(); 00067 if (!b.partialWithin(myPrunningBoundary)) { 00068 delete poly; 00069 return true; 00070 } 00071 } 00072 // check whether the polygon was named to be a removed one 00073 if (find(myRemoveByNames.begin(), myRemoveByNames.end(), id)!=myRemoveByNames.end()) { 00074 delete poly; 00075 return true; 00076 } 00077 // 00078 PolyCont::iterator i=myPolyCont.find(id); 00079 if (i!=myPolyCont.end()) { 00080 return false; 00081 } 00082 myPolyCont[id] = poly; 00083 myPolyLayerMap[poly] = layer; 00084 return true; 00085 }
| PCPolyContainer& PCPolyContainer::operator= | ( | const PCPolyContainer & | s | ) | [private] |
Invalidated assignment operator.
| void PCPolyContainer::report | ( | ) | throw () |
Reports how many polygons and pois were added.
Definition at line 139 of file PCPolyContainer.cpp.
References getNoPOIs(), getNoPolygons(), toString(), and WRITE_MESSAGE.
00139 { 00140 WRITE_MESSAGE(" " + toString(getNoPolygons()) + " polygons loaded."); 00141 WRITE_MESSAGE(" " + toString(getNoPOIs()) + " pois loaded."); 00142 }
| void PCPolyContainer::save | ( | const std::string & | file | ) | throw (IOError) |
Saves the stored polygons into the given file.
| [in] | file | The name of the file to write stored objects' definitions into IOError If the file could not been opened |
Definition at line 146 of file PCPolyContainer.cpp.
References OutputDevice::close(), StringUtils::escapeXML(), OutputDevice::getDevice(), myPOICont, myPOILayerMap, myPolyCont, myPolyLayerMap, and OutputDevice::writeXMLHeader().
00146 { 00147 OutputDevice& out = OutputDevice::getDevice(file); 00148 out.writeXMLHeader("shapes"); 00149 // write polygons 00150 for (PolyCont::iterator i=myPolyCont.begin(); i!=myPolyCont.end(); ++i) { 00151 out << " <poly id=\"" << StringUtils::escapeXML((*i).second->getID()) << "\" type=\"" 00152 << (*i).second->getType() << "\" color=\"" 00153 << (*i).second->getColor() << "\" fill=\"" 00154 << (*i).second->fill() << "\""; 00155 out << " layer=\"" << myPolyLayerMap[(*i).second] << "\""; 00156 out << " shape=\"" << (*i).second->getShape() << "\"/>\n"; 00157 } 00158 // write pois 00159 for (POICont::iterator i=myPOICont.begin(); i!=myPOICont.end(); ++i) { 00160 out << " <poi id=\"" << StringUtils::escapeXML((*i).second->getID()) << "\" type=\"" 00161 << (*i).second->getType() << "\" color=\"" 00162 << *static_cast<RGBColor*>((*i).second) << '"'; 00163 out << " layer=\"" << myPOILayerMap[(*i).second] << "\""; 00164 out << " x=\"" << (*i).second->x() << "\"" 00165 << " y=\"" << (*i).second->y() << "\"" 00166 << "/>\n"; 00167 } 00168 out.close(); 00169 }
Information whether the prunning boundary shall be used.
Definition at line 178 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 165 of file PCPolyContainer.h.
Referenced by getEnumIDFor().
The poi container, accessed by the pois' ids.
Definition at line 162 of file PCPolyContainer.h.
Referenced by clear(), getNoPOIs(), insert(), and save().
| std::map<PointOfInterest*, int> PCPolyContainer::myPOILayerMap |
A map from pois to the layers they are located in.
Definition at line 171 of file PCPolyContainer.h.
The polygon container, accessed by the polygons' ids.
Definition at line 157 of file PCPolyContainer.h.
Referenced by clear(), containsPolygon(), getNoPolygons(), insert(), and save().
| std::map<Polygon2D*, int> PCPolyContainer::myPolyLayerMap |
A map from polygons to the layers they are located in.
Definition at line 168 of file PCPolyContainer.h.
The boundary that described the rectangle within which an object must be in order to be kept.
Definition at line 175 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 181 of file PCPolyContainer.h.
Referenced by insert().
1.5.6