ShapeContainer.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include <fstream>
00031 #include <stdlib.h>
00032 #include <iostream>
00033 #include <utility>
00034 #include <string>
00035 #include <cmath>
00036 #include <utils/common/NamedObjectCont.h>
00037 #include <utils/shapes/Polygon2D.h>
00038 #include <utils/shapes/ShapeContainer.h>
00039 #include <utils/common/MsgHandler.h>
00040 #include <utils/common/UtilExceptions.h>
00041 #include <utils/common/ToString.h>
00042 #include <utils/common/StdDefs.h>
00043
00044 #ifdef _WIN32
00045 #include <windows.h>
00046 #endif
00047
00048 #ifdef CHECK_MEMORY_LEAKS
00049 #include <foreign/nvwa/debug_new.h>
00050 #endif // CHECK_MEMORY_LEAKS
00051
00052
00053
00054
00055
00056 ShapeContainer::ShapeContainer() throw()
00057 : myMinLayer(100), myMaxLayer(-100) {}
00058
00059
00060 ShapeContainer::~ShapeContainer() throw() {}
00061
00062
00063 bool
00064 ShapeContainer::add(int layer, Polygon2D *p) throw() {
00065 if (myPolygonLayers.find(layer)==myPolygonLayers.end()) {
00066 myPolygonLayers[layer] = NamedObjectCont<Polygon2D*>();
00067 myMinLayer = MIN2(layer, myMinLayer);
00068 myMaxLayer = MAX2(layer, myMaxLayer);
00069 }
00070 return myPolygonLayers[layer].add(p->getID(), p);
00071 }
00072
00073
00074 bool
00075 ShapeContainer::add(int layer, PointOfInterest *p) throw() {
00076 if (myPOILayers.find(layer)==myPOILayers.end()) {
00077 myPOILayers[layer] = NamedObjectCont<PointOfInterest*>();
00078 myMinLayer = MIN2(layer, myMinLayer);
00079 myMaxLayer = MAX2(layer, myMaxLayer);
00080 }
00081 return myPOILayers[layer].add(p->getID(), p);
00082 }
00083
00084
00085 bool
00086 ShapeContainer::removePolygon(int layer, const std::string &id) throw() {
00087 if (myPolygonLayers.find(layer)==myPolygonLayers.end()) {
00088 return false;
00089 }
00090 return myPolygonLayers.find(layer)->second.remove(id);
00091 }
00092
00093
00094 bool
00095 ShapeContainer::removePOI(int layer, const std::string &id) throw() {
00096 if (myPOILayers.find(layer)==myPOILayers.end()) {
00097 return false;
00098 }
00099 return myPOILayers.find(layer)->second.remove(id);
00100 }
00101
00102
00103 const NamedObjectCont<Polygon2D*> &
00104 ShapeContainer::getPolygonCont(int layer) const throw() {
00105 if (myPolygonLayers.find(layer)==myPolygonLayers.end()) {
00106 myPolygonLayers[layer] = NamedObjectCont<Polygon2D*>();
00107 myMinLayer = MIN2(layer, myMinLayer);
00108 myMaxLayer = MAX2(layer, myMaxLayer);
00109 }
00110 return myPolygonLayers[layer];
00111 }
00112
00113
00114 const NamedObjectCont<PointOfInterest*> &
00115 ShapeContainer::getPOICont(int layer) const throw() {
00116 if (myPOILayers.find(layer)==myPOILayers.end()) {
00117 myPOILayers[layer] = NamedObjectCont<PointOfInterest*>();
00118 myMinLayer = MIN2(layer, myMinLayer);
00119 myMaxLayer = MAX2(layer, myMaxLayer);
00120 }
00121 return myPOILayers[layer];
00122 }
00123
00124
00125
00126
00127