GEOS  3.8.0dev
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
27 namespace geos {
28 namespace geom {
29 class Geometry;
30 }
31 }
32 
33 namespace geos {
34 namespace operation { // geos::operation
35 namespace overlay { // geos::operation::overlay
36 namespace snap { // geos::operation::overlay::snap
37 
50 
51 public:
52 
53  static std::unique_ptr<geom::Geometry>
54  overlayOp(const geom::Geometry& g0, const geom::Geometry& g1,
55  OverlayOp::OpCode opCode)
56  {
57  SnapIfNeededOverlayOp op(g0, g1);
58  return op.getResultGeometry(opCode);
59  }
60 
61  static std::unique_ptr<geom::Geometry>
62  intersection(const geom::Geometry& g0, const geom::Geometry& g1)
63  {
64  return overlayOp(g0, g1, OverlayOp::opINTERSECTION);
65  }
66 
67  static std::unique_ptr<geom::Geometry>
68  Union(const geom::Geometry& g0, const geom::Geometry& g1)
69  {
70  return overlayOp(g0, g1, OverlayOp::opUNION);
71  }
72 
73  static std::unique_ptr<geom::Geometry>
74  difference(const geom::Geometry& g0, const geom::Geometry& g1)
75  {
76  return overlayOp(g0, g1, OverlayOp::opDIFFERENCE);
77  }
78 
79  static std::unique_ptr<geom::Geometry>
80  symDifference(const geom::Geometry& g0, const geom::Geometry& g1)
81  {
82  return overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE);
83  }
84 
86  :
87  geom0(g1),
88  geom1(g2)
89  {
90  }
91 
92 
93  typedef std::unique_ptr<geom::Geometry> GeomPtr;
94 
95  GeomPtr getResultGeometry(OverlayOp::OpCode opCode);
96 
97 private:
98 
99  const geom::Geometry& geom0;
100  const geom::Geometry& geom1;
101 
102  // Declare type as noncopyable
103  SnapIfNeededOverlayOp(const SnapIfNeededOverlayOp& other) = delete;
104  SnapIfNeededOverlayOp& operator=(const SnapIfNeededOverlayOp& rhs) = delete;
105 };
106 
107 
108 } // namespace geos::operation::overlay::snap
109 } // namespace geos::operation::overlay
110 } // namespace geos::operation
111 } // namespace geos
112 
113 #endif // ndef GEOS_OP_OVERLAY_SNAP_SNAPIFNEEDEDOVERLAYOP_H
The code for the Intersection overlay operation.
Definition: OverlayOp.h:80
The code for the Union overlay operation.
Definition: OverlayOp.h:82
OpCode
The spatial functions supported by this class.
Definition: OverlayOp.h:78
Performs an overlay operation using snapping and enhanced precision to improve the robustness of the ...
Definition: SnapIfNeededOverlayOp.h:49
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:187
The code for the Difference overlay operation.
Definition: OverlayOp.h:84
OverlayOp::overlayOp Adapter for use with geom::BinaryOp.
Definition: OverlayOp.h:405
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
The code for the Symmetric Difference overlay operation.
Definition: OverlayOp.h:86