GEOS 3.9.1
SnapIfNeededOverlayOp.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2009 2011 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/SnapIfNeededOverlayOp.java r320 (JTS-1.12)
16 *
17 **********************************************************************/
18
19#ifndef GEOS_OP_OVERLAY_SNAP_SNAPIFNEEDEDOVERLAYOP_H
20#define GEOS_OP_OVERLAY_SNAP_SNAPIFNEEDEDOVERLAYOP_H
21
22#include <geos/operation/overlay/OverlayOp.h> // for enums
23
24#include <memory> // for unique_ptr
25
26// Forward declarations
27namespace geos {
28namespace geom {
29class Geometry;
30}
31}
32
33namespace geos {
34namespace operation { // geos::operation
35namespace overlay { // geos::operation::overlay
36namespace snap { // geos::operation::overlay::snap
37
48
49public:
50
51 static std::unique_ptr<geom::Geometry>
52 overlayOp(const geom::Geometry& g0, const geom::Geometry& g1,
53 OverlayOp::OpCode opCode)
54 {
55 SnapIfNeededOverlayOp op(g0, g1);
56 return op.getResultGeometry(opCode);
57 }
58
59 static std::unique_ptr<geom::Geometry>
60 intersection(const geom::Geometry& g0, const geom::Geometry& g1)
61 {
62 return overlayOp(g0, g1, OverlayOp::opINTERSECTION);
63 }
64
65 static std::unique_ptr<geom::Geometry>
66 Union(const geom::Geometry& g0, const geom::Geometry& g1)
67 {
68 return overlayOp(g0, g1, OverlayOp::opUNION);
69 }
70
71 static std::unique_ptr<geom::Geometry>
72 difference(const geom::Geometry& g0, const geom::Geometry& g1)
73 {
74 return overlayOp(g0, g1, OverlayOp::opDIFFERENCE);
75 }
76
77 static std::unique_ptr<geom::Geometry>
78 symDifference(const geom::Geometry& g0, const geom::Geometry& g1)
79 {
80 return overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE);
81 }
82
84 :
85 geom0(g1),
86 geom1(g2)
87 {
88 }
89
90
91 typedef std::unique_ptr<geom::Geometry> GeomPtr;
92
93 GeomPtr getResultGeometry(OverlayOp::OpCode opCode);
94
95private:
96
97 const geom::Geometry& geom0;
98 const geom::Geometry& geom1;
99
100 // Declare type as noncopyable
101 SnapIfNeededOverlayOp(const SnapIfNeededOverlayOp& other) = delete;
102 SnapIfNeededOverlayOp& operator=(const SnapIfNeededOverlayOp& rhs) = delete;
103};
104
105
106} // namespace geos::operation::overlay::snap
107} // namespace geos::operation::overlay
108} // namespace geos::operation
109} // namespace geos
110
111#endif // ndef GEOS_OP_OVERLAY_SNAP_SNAPIFNEEDEDOVERLAYOP_H
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
OpCode
The spatial functions supported by this class.
Definition: OverlayOp.h:79
@ opSYMDIFFERENCE
The code for the Symmetric Difference overlay operation.
Definition: OverlayOp.h:87
@ opUNION
The code for the Union overlay operation.
Definition: OverlayOp.h:83
@ opINTERSECTION
The code for the Intersection overlay operation.
Definition: OverlayOp.h:81
@ opDIFFERENCE
The code for the Difference overlay operation.
Definition: OverlayOp.h:85
Performs an overlay operation using snapping and enhanced precision to improve the robustness of the ...
Definition: SnapIfNeededOverlayOp.h:47
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26