GEOS  3.13.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 {
65 
66 private:
67 
68 
69  // Constants
70  static constexpr int NUM_SNAP_TRIES = 5;
75  static constexpr double SNAP_TOL_FACTOR = 1e12;
76 
77  static std::unique_ptr<Geometry> overlaySnapping(
78  const Geometry* geom0, const Geometry* geom1, int opCode, double snapTol);
79 
80  static std::unique_ptr<Geometry> overlaySnapBoth(
81  const Geometry* geom0, const Geometry* geom1, int opCode, double snapTol);
82 
83  static std::unique_ptr<Geometry> overlaySnapTol(
84  const Geometry* geom0, const Geometry* geom1, int opCode, double snapTol);
85 
86  static double snapTolerance(const Geometry* geom);
87 
95  static double ordinateMagnitude(const Geometry* geom);
96 
104  static std::unique_ptr<Geometry>
105  overlaySR(const Geometry* geom0, const Geometry* geom1, int opCode);
106 
118  static std::unique_ptr<Geometry>
119  snapSelf(const Geometry* geom, double snapTol);
120 
121 
122 public:
123 
124  class SRUnionStrategy : public operation::geounion::UnionStrategy {
125 
126  std::unique_ptr<geom::Geometry> Union(const geom::Geometry* g0, const geom::Geometry* g1) override
127  {
128  return OverlayNGRobust::Overlay(g0, g1, OverlayNG::UNION);
129  };
130 
131  bool isFloatingPrecision() const override
132  {
133  return true;
134  };
135 
136  };
137 
138  static std::unique_ptr<Geometry> Intersection(
139  const Geometry* g0, const Geometry* g1);
140 
141  static std::unique_ptr<Geometry> Union(
142  const Geometry* g0, const Geometry* g1);
143 
144  static std::unique_ptr<Geometry> Difference(
145  const Geometry* g0, const Geometry* g1);
146 
147  static std::unique_ptr<Geometry> SymDifference(
148  const Geometry* g0, const Geometry* g1);
149 
150  static std::unique_ptr<Geometry> Union(
151  const Geometry* a);
152 
153  static std::unique_ptr<Geometry> Overlay(
154  const Geometry* geom0, const Geometry* geom1, int opCode);
155 
156  static std::unique_ptr<Geometry> overlaySnapTries(
157  const Geometry* geom0, const Geometry* geom1, int opCode);
158 
163  static double snapTolerance(const Geometry* geom0, const Geometry* geom1);
164 
165 
166 
167 
168 };
169 
170 
171 } // namespace geos.operation.overlayng
172 } // namespace geos.operation
173 } // namespace geos
174 
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
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