GEOS: SnapOverlayOp.h Source File

GEOS 3.3.8

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

SnapOverlayOp.h
1 /**********************************************************************
2 * $Id: SnapOverlayOp.h 3538 2011-12-09 10:44:54Z strk $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2009 Sandro Santilli <strk@keybit.net>
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 ***********************************************************************
15 *
16 * Last port: operation/overlay/snap/SnapOverlayOp.java r320 (JTS-1.12)
17 *
18 **********************************************************************/
19
20 #ifndef GEOS_OP_OVERLAY_SNAP_SNAPOVERLAYOP_H
21 #define GEOS_OP_OVERLAY_SNAP_SNAPOVERLAYOP_H
22
23 #include <geos/operation/overlay/OverlayOp.h> // for enums
24 #include <geos/precision/CommonBitsRemover.h> // for dtor visibility by auto_ptr
25
26 #include <memory> // for auto_ptr
27
28 #ifdef _MSC_VER
29 #pragma warning(push)
30 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
31 #endif
32
33 // Forward declarations
34 namespace geos {
35 namespace geom {
36 class Geometry;
37 struct GeomPtrPair;
38 }
39 }
40
41 namespace geos {
42 namespace operation { // geos::operation
43 namespace overlay { // geos::operation::overlay
44 namespace snap { // geos::operation::overlay::snap
45
57 class GEOS_DLL SnapOverlayOp
58 {
59
60 public:
61
62 static std::auto_ptr<geom::Geometry>
63 overlayOp(const geom::Geometry& g0, const geom::Geometry& g1,
64 OverlayOp::OpCode opCode)
65 {
66 SnapOverlayOp op(g0, g1);
67 return op.getResultGeometry(opCode);
68 }
69
70 static std::auto_ptr<geom::Geometry>
71 intersection(const geom::Geometry& g0, const geom::Geometry& g1)
72 {
73 return overlayOp(g0, g1, OverlayOp::opINTERSECTION);
74 }
75
76 static std::auto_ptr<geom::Geometry>
77 Union(const geom::Geometry& g0, const geom::Geometry& g1)
78 {
79 return overlayOp(g0, g1, OverlayOp::opUNION);
80 }
81
82 static std::auto_ptr<geom::Geometry>
83 difference(const geom::Geometry& g0, const geom::Geometry& g1)
84 {
85 return overlayOp(g0, g1, OverlayOp::opDIFFERENCE);
86 }
87
88 static std::auto_ptr<geom::Geometry>
89 symDifference(const geom::Geometry& g0, const geom::Geometry& g1)
90 {
91 return overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE);
92 }
93
94 SnapOverlayOp(const geom::Geometry& g1, const geom::Geometry& g2)
95 :
96 geom0(g1),
97 geom1(g2)
98 {
99 computeSnapTolerance();
100 }
101
102
103 typedef std::auto_ptr<geom::Geometry> GeomPtr;
104
105 GeomPtr getResultGeometry(OverlayOp::OpCode opCode);
106
107 private:
108
109 void computeSnapTolerance();
110
111 void snap(geom::GeomPtrPair& ret);
112
113 void removeCommonBits(const geom::Geometry& geom0,
114 const geom::Geometry& geom1,
115 geom::GeomPtrPair& ret);
116
117 // re-adds common bits to the given geom
118 void prepareResult(geom::Geometry& geom);
119
120
121 const geom::Geometry& geom0;
122 const geom::Geometry& geom1;
123
124 double snapTolerance;
125
126 std::auto_ptr<precision::CommonBitsRemover> cbr;
127
128 // Declare type as noncopyable
129 SnapOverlayOp(const SnapOverlayOp& other);
130 SnapOverlayOp& operator=(const SnapOverlayOp& rhs);
131 };
132
133 } // namespace geos::operation::overlay::snap
134 } // namespace geos::operation::overlay
135 } // namespace geos::operation
136 } // namespace geos
137
138 #ifdef _MSC_VER
139 #pragma warning(pop)
140 #endif
141
142 #endif // ndef GEOS_OP_OVERLAY_SNAP_SNAPOVERLAYOP_H
143
144 /**********************************************************************
145 * $Log$
146 **********************************************************************/
147