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