GEOS 3.2.1
|
00001 /********************************************************************** 00002 * $Id: SnapOverlayOp.h 2809 2009-12-06 01:05:24Z mloskot $ 00003 * 00004 * GEOS - Geometry Engine Open Source 00005 * http://geos.refractions.net 00006 * 00007 * Copyright (C) 2009 Sandro Santilli <strk@keybit.net> 00008 * 00009 * This is free software; you can redistribute and/or modify it under 00010 * the terms of the GNU Lesser General Public Licence as published 00011 * by the Free Software Foundation. 00012 * See the COPYING file for more information. 00013 * 00014 *********************************************************************** 00015 * 00016 * Last port: operation/overlay/snap/SnapOverlayOp.java rev 1.4 (JTS-1.10) 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> // for enums 00024 #include <geos/precision/CommonBitsRemover.h> // for dtor visibility by auto_ptr 00025 00026 #include <memory> // for auto_ptr 00027 00028 // Forward declarations 00029 namespace geos { 00030 namespace geom { 00031 class Geometry; 00032 } 00033 } 00034 00035 namespace geos { 00036 namespace operation { // geos::operation 00037 namespace overlay { // geos::operation::overlay 00038 namespace snap { // geos::operation::overlay::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 // re-adds common bits to the given geom 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 // Declare type as noncopyable 00124 SnapOverlayOp(const SnapOverlayOp& other); 00125 SnapOverlayOp& operator=(const SnapOverlayOp& rhs); 00126 }; 00127 00128 00129 } // namespace geos::operation::overlay::snap 00130 } // namespace geos::operation::overlay 00131 } // namespace geos::operation 00132 } // namespace geos 00133 00134 #endif // ndef GEOS_OP_OVERLAY_SNAP_SNAPOVERLAYOP_H 00135 00136 /********************************************************************** 00137 * $Log$ 00138 **********************************************************************/ 00139