GEOS  3.14.0dev
OverlayNGRobust.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
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/overlayng/OverlayNGRobust.java 6ef89b09
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/export.h>
22 #include <geos/geom/PrecisionModel.h>
23 #include <geos/operation/union/UnionStrategy.h>
24 #include <geos/operation/overlayng/OverlayNG.h>
25 
26 
27 // Forward declarations
28 namespace geos {
29 namespace geom {
30 class Geometry;
31 }
32 }
33 
34 namespace geos { // geos.
35 namespace operation { // geos.operation
36 namespace overlayng { // geos.operation.overlayng
37 
38 
64 class GEOS_DLL OverlayNGRobust {
66 
67 private:
68 
69 
70  // Constants
71  static constexpr int NUM_SNAP_TRIES = 5;
76  static constexpr double SNAP_TOL_FACTOR = 1e12;
77 
78  static std::unique_ptr<Geometry> overlaySnapping(
79  const Geometry* geom0, const Geometry* geom1, int opCode, double snapTol);
80 
81  static std::unique_ptr<Geometry> overlaySnapBoth(
82  const Geometry* geom0, const Geometry* geom1, int opCode, double snapTol);
83 
84  static std::unique_ptr<Geometry> overlaySnapTol(
85  const Geometry* geom0, const Geometry* geom1, int opCode, double snapTol);
86 
87  static double snapTolerance(const Geometry* geom);
88 
96  static double ordinateMagnitude(const Geometry* geom);
97 
105  static std::unique_ptr<Geometry>
106  overlaySR(const Geometry* geom0, const Geometry* geom1, int opCode);
107 
119  static std::unique_ptr<Geometry>
120  snapSelf(const Geometry* geom, double snapTol);
121 
122 
123 public:
124 
125  class SRUnionStrategy : public operation::geounion::UnionStrategy {
126 
127  std::unique_ptr<geom::Geometry> Union(const geom::Geometry* g0, const geom::Geometry* g1) override
128  {
129  return OverlayNGRobust::Overlay(g0, g1, OverlayNG::UNION);
130  };
131 
132  bool isFloatingPrecision() const override
133  {
134  return true;
135  };
136 
137  };
138 
139  static std::unique_ptr<Geometry> Intersection(
140  const Geometry* g0, const Geometry* g1);
141 
142  static std::unique_ptr<Geometry> Union(
143  const Geometry* g0, const Geometry* g1);
144 
145  static std::unique_ptr<Geometry> Difference(
146  const Geometry* g0, const Geometry* g1);
147 
148  static std::unique_ptr<Geometry> SymDifference(
149  const Geometry* g0, const Geometry* g1);
150 
151  static std::unique_ptr<Geometry> Union(
152  const Geometry* a);
153 
154  static std::unique_ptr<Geometry> Overlay(
155  const Geometry* geom0, const Geometry* geom1, int opCode);
156 
157  static std::unique_ptr<Geometry> overlaySnapTries(
158  const Geometry* geom0, const Geometry* geom1, int opCode);
159 
164  static double snapTolerance(const Geometry* geom0, const Geometry* geom1);
165 
166 
167 
168 
169 };
170 
171 
172 } // namespace geos.operation.overlayng
173 } // namespace geos.operation
174 } // namespace geos
175 
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:197
Definition: UnionStrategy.h:40
Definition: OverlayNGRobust.h:64
static double snapTolerance(const Geometry *geom0, const Geometry *geom1)
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25