00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEOS_OP_OVERLAY_SNAP_SNAPOVERLAYOP_H
00021 #define GEOS_OP_OVERLAY_SNAP_SNAPOVERLAYOP_H
00022
00023 #include <geos/operation/overlay/OverlayOp.h>
00024 #include <geos/precision/CommonBitsRemover.h>
00025
00026 #include <memory>
00027
00028
00029 namespace geos {
00030 namespace geom {
00031 class Geometry;
00032 }
00033 }
00034
00035 namespace geos {
00036 namespace operation {
00037 namespace overlay {
00038 namespace snap {
00039
00051 class GEOS_DLL SnapOverlayOp
00052 {
00053
00054 public:
00055
00056 static std::auto_ptr<geom::Geometry>
00057 overlayOp(const geom::Geometry& g0, const geom::Geometry& g1,
00058 OverlayOp::OpCode opCode)
00059 {
00060 SnapOverlayOp op(g0, g1);
00061 return op.getResultGeometry(opCode);
00062 }
00063
00064 static std::auto_ptr<geom::Geometry>
00065 intersection(const geom::Geometry& g0, const geom::Geometry& g1)
00066 {
00067 return overlayOp(g0, g1, OverlayOp::opINTERSECTION);
00068 }
00069
00070 static std::auto_ptr<geom::Geometry>
00071 Union(const geom::Geometry& g0, const geom::Geometry& g1)
00072 {
00073 return overlayOp(g0, g1, OverlayOp::opUNION);
00074 }
00075
00076 static std::auto_ptr<geom::Geometry>
00077 difference(const geom::Geometry& g0, const geom::Geometry& g1)
00078 {
00079 return overlayOp(g0, g1, OverlayOp::opDIFFERENCE);
00080 }
00081
00082 static std::auto_ptr<geom::Geometry>
00083 symDifference(const geom::Geometry& g0, const geom::Geometry& g1)
00084 {
00085 return overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE);
00086 }
00087
00088 SnapOverlayOp(const geom::Geometry& g1, const geom::Geometry& g2)
00089 :
00090 geom0(g1),
00091 geom1(g2)
00092 {
00093 computeSnapTolerance();
00094 }
00095
00096
00097 typedef std::auto_ptr<geom::Geometry> GeomPtr;
00098
00099 GeomPtr getResultGeometry(OverlayOp::OpCode opCode);
00100
00101 private:
00102
00103 void computeSnapTolerance();
00104
00105 typedef std::pair<GeomPtr, GeomPtr> GeomPtrPair;
00106
00107 void snap(GeomPtrPair& ret);
00108
00109 void removeCommonBits(const geom::Geometry& geom0,
00110 const geom::Geometry& geom1, GeomPtrPair& ret);
00111
00112
00113 void prepareResult(geom::Geometry& geom);
00114
00115
00116 const geom::Geometry& geom0;
00117 const geom::Geometry& geom1;
00118
00119 double snapTolerance;
00120
00121 std::auto_ptr<precision::CommonBitsRemover> cbr;
00122
00123
00124 SnapOverlayOp(const SnapOverlayOp& other);
00125 SnapOverlayOp& operator=(const SnapOverlayOp& rhs);
00126 };
00127
00128
00129 }
00130 }
00131 }
00132 }
00133
00134 #endif // ndef GEOS_OP_OVERLAY_SNAP_SNAPOVERLAYOP_H
00135
00136
00137
00138
00139