GEOS  3.6.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@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/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 auto_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 
52 public:
53 
54  static std::auto_ptr<geom::Geometry>
55  overlayOp(const geom::Geometry& g0, const geom::Geometry& g1,
56  OverlayOp::OpCode opCode)
57  {
58  SnapIfNeededOverlayOp op(g0, g1);
59  return op.getResultGeometry(opCode);
60  }
61 
62  static std::auto_ptr<geom::Geometry>
63  intersection(const geom::Geometry& g0, const geom::Geometry& g1)
64  {
65  return overlayOp(g0, g1, OverlayOp::opINTERSECTION);
66  }
67 
68  static std::auto_ptr<geom::Geometry>
69  Union(const geom::Geometry& g0, const geom::Geometry& g1)
70  {
71  return overlayOp(g0, g1, OverlayOp::opUNION);
72  }
73 
74  static std::auto_ptr<geom::Geometry>
75  difference(const geom::Geometry& g0, const geom::Geometry& g1)
76  {
77  return overlayOp(g0, g1, OverlayOp::opDIFFERENCE);
78  }
79 
80  static std::auto_ptr<geom::Geometry>
81  symDifference(const geom::Geometry& g0, const geom::Geometry& g1)
82  {
83  return overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE);
84  }
85 
87  :
88  geom0(g1),
89  geom1(g2)
90  {
91  }
92 
93 
94  typedef std::auto_ptr<geom::Geometry> GeomPtr;
95 
96  GeomPtr getResultGeometry(OverlayOp::OpCode opCode);
97 
98 private:
99 
100  const geom::Geometry& geom0;
101  const geom::Geometry& geom1;
102 
103  // Declare type as noncopyable
105  SnapIfNeededOverlayOp& operator=(const SnapIfNeededOverlayOp& rhs);
106 };
107 
108 
109 } // namespace geos::operation::overlay::snap
110 } // namespace geos::operation::overlay
111 } // namespace geos::operation
112 } // namespace geos
113 
114 #endif // ndef GEOS_OP_OVERLAY_SNAP_SNAPIFNEEDEDOVERLAYOP_H
The code for the Intersection overlay operation.
Definition: OverlayOp.h:79
The code for the Union overlay operation.
Definition: OverlayOp.h:81
OpCode
The spatial functions supported by this class.
Definition: OverlayOp.h:77
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:167
The code for the Difference overlay operation.
Definition: OverlayOp.h:83
OverlayOp::overlayOp Adapter for use with geom::BinaryOp.
Definition: OverlayOp.h:376
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
The code for the Symmetric Difference overlay operation.
Definition: OverlayOp.h:85