GEOS 3.4.2

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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
49 class SnapIfNeededOverlayOp
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
86 SnapIfNeededOverlayOp(const geom::Geometry& g1, const geom::Geometry& g2)
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
104 SnapIfNeededOverlayOp(const SnapIfNeededOverlayOp& other);
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