GEOS  3.9.1
OverlayUtil.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 #pragma once
16 
17 #include <geos/geom/Point.h>
18 #include <geos/geom/Polygon.h>
19 #include <geos/geom/LineString.h>
20 #include <geos/geom/Geometry.h>
21 
22 #include <geos/export.h>
23 
24 #include <vector>
25 #include <memory>
26 
27 // Forward declarations
28 namespace geos {
29 namespace geom {
30 class Coordinate;
31 class CoordinateSequence;
32 class Envelope;
33 class GeometryFactory;
34 class PrecisionModel;
35 }
36 namespace operation {
37 namespace overlayng {
38 class InputGeometry;
39 class OverlayGraph;
40 }
41 }
42 }
43 
44 
45 namespace geos { // geos.
46 namespace operation { // geos.operation
47 namespace overlayng { // geos.operation.overlayng
48 
49 using namespace geos::geom;
50 
57 class GEOS_DLL OverlayUtil {
58 
59 private:
60 
61  static constexpr double SAFE_ENV_BUFFER_FACTOR = 0.1;
62  static constexpr int SAFE_ENV_GRID_FACTOR = 3;
63 
75  static bool resultEnvelope(int opCode, const InputGeometry* inputGeom, const PrecisionModel* pm, Envelope& rsltEnvelope);
76  static double safeExpandDistance(const Envelope* env, const PrecisionModel* pm);
77  static bool safeEnv(const Envelope* env, const PrecisionModel* pm, Envelope& rsltEnvelope);
78 
79  static bool isEmpty(const Geometry* geom);
80 
86  static bool isDisjoint(const Envelope* envA, const Envelope* envB, const PrecisionModel* pm);
87 
88 
89 public:
90 
91  static bool isFloating(const PrecisionModel* pm);
92 
108  static bool clippingEnvelope(int opCode, const InputGeometry* inputGeom, const PrecisionModel* pm, Envelope& rsltEnvelope);
109 
116  static bool isEmptyResult(int opCode, const Geometry* a, const Geometry* b, const PrecisionModel* pm);
117 
123  static bool isEnvDisjoint(const Geometry* a, const Geometry* b, const PrecisionModel* pm);
124 
132  static std::unique_ptr<Geometry> createEmptyResult(int dim, const GeometryFactory* geomFact);
133 
147  static int resultDimension(int opCode, int dim0, int dim1);
148 
152  static std::unique_ptr<Geometry> createResultGeometry(
153  std::vector<std::unique_ptr<Polygon>>& resultPolyList,
154  std::vector<std::unique_ptr<LineString>>& resultLineList,
155  std::vector<std::unique_ptr<Point>>& resultPointList,
156  const GeometryFactory* geometryFactory);
157 
158  static std::unique_ptr<Geometry> toLines(OverlayGraph* graph, bool isOutputEdges, const GeometryFactory* geomFact);
159 
160 
165  static bool round(const Point* pt, const PrecisionModel* pm, Coordinate& rsltCoord);
166 
167  template<typename T>
168  static void moveGeometry(std::vector<std::unique_ptr<T>>& inGeoms, std::vector<std::unique_ptr<Geometry>>& outGeoms)
169  {
170  static_assert(std::is_base_of<Geometry, T>::value, "");
171  for (auto& geom: inGeoms) {
172  Geometry* outGeom = static_cast<Geometry*>(geom.release());
173  outGeoms.emplace_back(outGeom);
174  }
175  return;
176  }
177 
178 
179 };
180 
181 
182 } // namespace geos.operation.overlayng
183 } // namespace geos.operation
184 } // namespace geos
185 
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Definition: Point.h:66
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
Definition: OverlayGraph.h:54
Definition: OverlayUtil.h:57
static bool round(const Point *pt, const PrecisionModel *pm, Coordinate &rsltCoord)
static int resultDimension(int opCode, int dim0, int dim1)
static std::unique_ptr< Geometry > createResultGeometry(std::vector< std::unique_ptr< Polygon >> &resultPolyList, std::vector< std::unique_ptr< LineString >> &resultLineList, std::vector< std::unique_ptr< Point >> &resultPointList, const GeometryFactory *geometryFactory)
static std::unique_ptr< Geometry > createEmptyResult(int dim, const GeometryFactory *geomFact)
static bool isEmptyResult(int opCode, const Geometry *a, const Geometry *b, const PrecisionModel *pm)
static bool isEnvDisjoint(const Geometry *a, const Geometry *b, const PrecisionModel *pm)
static bool clippingEnvelope(int opCode, const InputGeometry *inputGeom, const PrecisionModel *pm, Envelope &rsltEnvelope)
Definition: IndexedNestedRingTester.h:27
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26