GEOS  3.9.1dev
SnapOverlayOp.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2009 Sandro Santilli <strk@kbt.io>
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 unique_ptr
24 
25 #include <memory> // for unique_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
33 namespace geos {
34 namespace geom {
35 class Geometry;
36 struct GeomPtrPair;
37 }
38 }
39 
40 namespace geos {
41 namespace operation { // geos::operation
42 namespace overlay { // geos::operation::overlay
43 namespace snap { // geos::operation::overlay::snap
44 
57 
58 public:
59 
60  static std::unique_ptr<geom::Geometry>
61  overlayOp(const geom::Geometry& g0, const geom::Geometry& g1,
62  OverlayOp::OpCode opCode)
63  {
64  SnapOverlayOp op(g0, g1);
65  return op.getResultGeometry(opCode);
66  }
67 
68  static std::unique_ptr<geom::Geometry>
70  {
71  return overlayOp(g0, g1, OverlayOp::opINTERSECTION);
72  }
73 
74  static std::unique_ptr<geom::Geometry>
75  Union(const geom::Geometry& g0, const geom::Geometry& g1)
76  {
77  return overlayOp(g0, g1, OverlayOp::opUNION);
78  }
79 
80  static std::unique_ptr<geom::Geometry>
82  {
83  return overlayOp(g0, g1, OverlayOp::opDIFFERENCE);
84  }
85 
86  static std::unique_ptr<geom::Geometry>
88  {
89  return overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE);
90  }
91 
93  :
94  geom0(g1),
95  geom1(g2)
96  {
97  computeSnapTolerance();
98  }
99 
100 
101  typedef std::unique_ptr<geom::Geometry> GeomPtr;
102 
103  GeomPtr getResultGeometry(OverlayOp::OpCode opCode);
104 
105 private:
106 
107  void computeSnapTolerance();
108 
109  void snap(geom::GeomPtrPair& ret);
110 
111  void removeCommonBits(const geom::Geometry& geom0,
112  const geom::Geometry& geom1,
113  geom::GeomPtrPair& ret);
114 
115  // re-adds common bits to the given geom
116  void prepareResult(geom::Geometry& geom);
117 
118 
121 
123 
124  std::unique_ptr<precision::CommonBitsRemover> cbr;
125 
126  // Declare type as noncopyable
127  SnapOverlayOp(const SnapOverlayOp& other) = delete;
128  SnapOverlayOp& operator=(const SnapOverlayOp& rhs) = delete;
129 };
130 
131 } // namespace geos::operation::overlay::snap
132 } // namespace geos::operation::overlay
133 } // namespace geos::operation
134 } // namespace geos
135 
136 #ifdef _MSC_VER
137 #pragma warning(pop)
138 #endif
139 
140 #endif // ndef GEOS_OP_OVERLAY_SNAP_SNAPOVERLAYOP_H
SnapOverlayOp(const geom::Geometry &g1, const geom::Geometry &g2)
Definition: SnapOverlayOp.h:92
#define GEOS_DLL
Definition: export.h:28
Performs an overlay operation using snapping and enhanced precision to improve the robustness of the ...
Definition: SnapOverlayOp.h:56
static std::unique_ptr< geom::Geometry > symDifference(const geom::Geometry &g0, const geom::Geometry &g1)
Definition: SnapOverlayOp.h:87
OpCode
The spatial functions supported by this class.
Definition: OverlayOp.h:79
std::unique_ptr< precision::CommonBitsRemover > cbr
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
static std::unique_ptr< geom::Geometry > overlayOp(const geom::Geometry &g0, const geom::Geometry &g1, OverlayOp::OpCode opCode)
Definition: SnapOverlayOp.h:61
static std::unique_ptr< geom::Geometry > Union(const geom::Geometry &g0, const geom::Geometry &g1)
Definition: SnapOverlayOp.h:75
static std::unique_ptr< geom::Geometry > intersection(const geom::Geometry &g0, const geom::Geometry &g1)
Definition: SnapOverlayOp.h:69
GeomPtr getResultGeometry(OverlayOp::OpCode opCode)
Basic namespace for all GEOS functionalities.
std::unique_ptr< geom::Geometry > GeomPtr
static std::unique_ptr< geom::Geometry > difference(const geom::Geometry &g0, const geom::Geometry &g1)
Definition: SnapOverlayOp.h:81