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