00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef GEOS_UTIL_H
00017 #define GEOS_UTIL_H
00018
00019 #include <memory>
00020 #include <string>
00021 #include <geos/platform.h>
00022 #include <geos/geom.h>
00023
00024 using namespace std;
00025
00026 namespace geos {
00027
00036 class GEOSException {
00037 public:
00038 GEOSException();
00039
00040 GEOSException(string msg);
00041
00043 GEOSException(string nname,string msg);
00044
00045 virtual ~GEOSException();
00046
00048 virtual string toString();
00049
00050 virtual void setName(string nname);
00051 virtual void setMessage(string msg);
00052 protected:
00053 string txt;
00054 string name;
00055 };
00056
00060 class AssertionFailedException: public GEOSException {
00061 public:
00062 AssertionFailedException();
00063 AssertionFailedException(string msg);
00064 ~AssertionFailedException();
00065 };
00066
00074 class IllegalArgumentException: public GEOSException {
00075 public:
00076 IllegalArgumentException();
00077 IllegalArgumentException(string msg);
00078 ~IllegalArgumentException();
00079 };
00080
00088 class TopologyException: public GEOSException {
00089 public:
00090 TopologyException(string msg);
00091 TopologyException(string msg,const Coordinate *newPt);
00092 ~TopologyException();
00093 Coordinate* getCoordinate();
00094 private:
00095 Coordinate *pt;
00096 };
00097
00106 class UnsupportedOperationException: public GEOSException {
00107 public:
00108 UnsupportedOperationException();
00109 UnsupportedOperationException(string msg);
00110 ~UnsupportedOperationException();
00111 };
00112
00113 class Coordinate;
00114 class Assert {
00115 public:
00116 static void isTrue(bool assertion);
00117 static void isTrue(bool assertion, string message);
00118
00119 static void equals(const Coordinate& expectedValue, const Coordinate& actualValue);
00120 static void equals(const Coordinate& expectedValue, const Coordinate& actualValue, string message);
00121
00122 static void shouldNeverReachHere();
00123 static void shouldNeverReachHere(string message);
00124 };
00125
00126 class CoordinateArrayFilter:public CoordinateFilter {
00127 public:
00128 CoordinateSequence* pts;
00129 int n;
00130 CoordinateArrayFilter(int size);
00131 virtual ~CoordinateArrayFilter();
00132 virtual const CoordinateSequence* getCoordinates() const;
00133 virtual void filter_ro(const Coordinate &coord);
00134 virtual void filter_rw(Coordinate &coord);
00135 };
00136
00137 class UniqueCoordinateArrayFilter:public CoordinateFilter {
00138 public:
00139 CoordinateSequence *list;
00140 UniqueCoordinateArrayFilter();
00141 virtual ~UniqueCoordinateArrayFilter();
00142 virtual const CoordinateSequence* getCoordinates() const;
00143 virtual void filter_ro(const Coordinate *coord);
00144 virtual void filter_rw(Coordinate *coord);
00145 };
00146
00147
00157 class GeometricShapeFactory {
00158 private:
00159 class Dimensions {
00160 public:
00161 Dimensions();
00162 Coordinate base;
00163 Coordinate centre;
00164 double width;
00165 double height;
00166 void setBase(const Coordinate& newBase);
00167 void setCentre(const Coordinate& newCentre);
00168 void setSize(double size);
00169 void setWidth(double nWidth);
00170 void setHeight(double nHeight);
00171 Envelope* getEnvelope();
00172 };
00173 const GeometryFactory* geomFact;
00174 Dimensions dim;
00175 int nPts;
00176 public:
00187 GeometricShapeFactory(const GeometryFactory *factory);
00188
00189 ~GeometricShapeFactory();
00190
00196 LineString* createArc(double startAng,double endAng);
00197
00203 Polygon* createCircle();
00204
00210 Polygon* createRectangle();
00211
00220 void setBase(const Coordinate& base);
00221
00229 void setCentre(const Coordinate& centre);
00230
00236 void setHeight(double height);
00237
00241 void setNumPoints(int nNPts);
00242
00249 void setSize(double size);
00250
00256 void setWidth(double width);
00257
00258 };
00259
00260 }
00261 #endif
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313