GEOS  3.9.1dev
SnapIfNeededOverlayOp.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 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 
48 
49 public:
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>
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>
73  {
74  return overlayOp(g0, g1, OverlayOp::opDIFFERENCE);
75  }
76 
77  static std::unique_ptr<geom::Geometry>
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 
95 private:
96 
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
SnapIfNeededOverlayOp(const geom::Geometry &g1, const geom::Geometry &g2)
static std::unique_ptr< geom::Geometry > overlayOp(const geom::Geometry &g0, const geom::Geometry &g1, OverlayOp::OpCode opCode)
GeomPtr getResultGeometry(OverlayOp::OpCode opCode)
OpCode
The spatial functions supported by this class.
Definition: OverlayOp.h:79
Performs an overlay operation using snapping and enhanced precision to improve the robustness of the ...
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
static std::unique_ptr< geom::Geometry > symDifference(const geom::Geometry &g0, const geom::Geometry &g1)
Basic namespace for all GEOS functionalities.
static std::unique_ptr< geom::Geometry > difference(const geom::Geometry &g0, const geom::Geometry &g1)
static std::unique_ptr< geom::Geometry > Union(const geom::Geometry &g0, const geom::Geometry &g1)
static std::unique_ptr< geom::Geometry > intersection(const geom::Geometry &g0, const geom::Geometry &g1)