00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef GEOS_PRECISION_H
00051 #define GEOS_PRECISION_H
00052
00053 #include <geos/platform.h>
00054 #include <geos/geom.h>
00055 #include <geos/geomUtil.h>
00056 #include <string>
00057 #include <vector>
00058
00059 using namespace std;
00060
00061 namespace geos {
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 class CommonBits {
00072 private:
00073 bool isFirst;
00074 int commonMantissaBitsCount;
00075 int64 commonBits;
00076 int64 commonSignExp;
00077 public:
00084 static int64 signExpBits(int64 num);
00094 static int numCommonMostSigMantissaBits(int64 num1, int64 num2);
00101 static int64 zeroLowerBits(int64 bits, int nBits);
00108 static int getBit(int64 bits, int i);
00109 CommonBits();
00110 void add(double num);
00111 double getCommon();
00115 string toString(int64 bits){return "";};
00116 };
00117
00118 class CommonCoordinateFilter: public CoordinateFilter {
00119 private:
00120 CommonBits *commonBitsX;
00121 CommonBits *commonBitsY;
00122 public:
00123 CommonCoordinateFilter();
00124 ~CommonCoordinateFilter();
00125 void filter_rw(Coordinate *coord);
00126 void filter_ro(const Coordinate *coord);
00127 Coordinate* getCommonCoordinate();
00128 };
00129
00130 class Translater: public CoordinateFilter {
00131 private:
00132 Coordinate trans;
00133 public:
00134 Translater(Coordinate &newTrans);
00135 void filter_rw(Coordinate *coord);
00136 void filter_ro(const Coordinate *coord){};
00137 };
00138
00139
00140
00141
00142
00143
00144 class CommonBitsRemover {
00145 private:
00146 Coordinate commonCoord;
00147 CommonCoordinateFilter *ccFilter;
00148 public:
00149 CommonBitsRemover();
00150 ~CommonBitsRemover();
00159 void add(Geometry *geom);
00163 Coordinate& getCommonCoordinate();
00171 Geometry* removeCommonBits(Geometry *geom);
00179 void addCommonBits(Geometry *geom);
00180 };
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 class CommonBitsOp {
00192 private:
00193 bool returnToOriginalPrecision;
00194 CommonBitsRemover *cbr;
00201 Geometry* removeCommonBits(Geometry *geom0);
00210 vector<Geometry*>* removeCommonBits(Geometry *geom0, Geometry *geom1);
00211 public:
00215 CommonBitsOp();
00222 CommonBitsOp(bool nReturnToOriginalPrecision);
00229 Geometry* intersection(Geometry *geom0, Geometry *geom1);
00236 Geometry* Union(Geometry *geom0, Geometry *geom1);
00243 Geometry* difference(Geometry *geom0, Geometry *geom1);
00251 Geometry* symDifference(Geometry *geom0, Geometry *geom1);
00259 Geometry* buffer(Geometry *geom0, double distance);
00270 Geometry* computeResultPrecision(Geometry *result);
00271 };
00272
00273
00274
00275
00276
00277
00278
00279 class EnhancedPrecisionOp {
00280 public:
00287 static Geometry* intersection(Geometry *geom0, Geometry *geom1);
00294 static Geometry* Union(Geometry *geom0, Geometry *geom1);
00301 static Geometry* difference(Geometry *geom0, Geometry *geom1);
00308 static Geometry* symDifference(Geometry *geom0, Geometry *geom1);
00318 static Geometry* buffer(Geometry *geom, double distance);
00319 };
00320
00321 class SimpleGeometryPrecisionReducer;
00322
00323 class PrecisionReducerCoordinateOperation: public CoordinateOperation {
00324 private:
00325 SimpleGeometryPrecisionReducer *sgpr;
00326 public:
00327 PrecisionReducerCoordinateOperation(SimpleGeometryPrecisionReducer *newSgpr);
00328 CoordinateSequence* edit(const CoordinateSequence *coordinates, const Geometry *geom);
00329 };
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344 class SimpleGeometryPrecisionReducer {
00345 private:
00346 PrecisionModel *newPrecisionModel;
00347 bool removeCollapsed;
00348
00349 public:
00350 SimpleGeometryPrecisionReducer(PrecisionModel *pm);
00358 void setRemoveCollapsedComponents(bool nRemoveCollapsed);
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370 PrecisionModel* getPrecisionModel();
00371
00372 bool getRemoveCollapsed();
00373 Geometry* reduce(const Geometry *geom);
00374 };
00375
00376 }
00377 #endif