GEOS  3.14.0dev
GeometryPrecisionReducer.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2012 Sandro Santilli <strk@kbt.io>
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: precision/GeometryPrecisionReducer.cpp rev. 1.10 (JTS-1.7)
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/export.h>
22 #include <geos/geom/GeometryFactory.h> // for GeometryFactory::Ptr
23 #include <memory> // for unique_ptr
24 
25 // Forward declarations
26 namespace geos {
27 namespace geom {
28 class PrecisionModel;
29 class GeometryFactory;
30 class Geometry;
31 }
32 }
33 
34 namespace geos {
35 namespace precision { // geos.precision
36 
57 class GEOS_DLL GeometryPrecisionReducer {
58 
59 private:
60 
61  // Externally owned
62  const geom::GeometryFactory* newFactory;
63 
64  const geom::PrecisionModel& targetPM;
65 
66  bool removeCollapsed;
67  bool changePrecisionModel;
68  bool useAreaReducer;
69  bool isPointwise;
70 
71  std::unique_ptr<geom::Geometry> fixPolygonalTopology(const geom::Geometry& geom);
72 
73  geom::GeometryFactory::Ptr createFactory(
74  const geom::GeometryFactory& oldGF,
75  const geom::PrecisionModel& newPM);
76 
85  std::unique_ptr<geom::Geometry> changePM(
86  const geom::Geometry* geom,
87  const geom::PrecisionModel& newPM);
88 
90  GeometryPrecisionReducer& operator=(GeometryPrecisionReducer const&); /*= delete*/
91 
92 public:
93 
105  static std::unique_ptr<geom::Geometry>
106  reduce(const geom::Geometry& g, const geom::PrecisionModel& precModel);
107 
108  static std::unique_ptr<geom::Geometry>
109  reducePointwise(const geom::Geometry& g, const geom::PrecisionModel& precModel);
110 
111  static std::unique_ptr<geom::Geometry>
112  reduceKeepCollapsed(const geom::Geometry& g, const geom::PrecisionModel& precModel);
113 
115  : newFactory(nullptr)
116  , targetPM(pm)
117  , removeCollapsed(true)
118  , changePrecisionModel(false)
119  , useAreaReducer(false)
120  , isPointwise(false)
121  {}
122 
134  : newFactory(&changeFactory)
135  , targetPM(*(changeFactory.getPrecisionModel()))
136  , removeCollapsed(true)
137  , changePrecisionModel(false)
138  , useAreaReducer(false)
139  , isPointwise(false)
140  {}
141 
149  void
151  {
152  removeCollapsed = remove;
153  }
154 
165  void
167  {
168  changePrecisionModel = change;
169  }
170 
171  void
172  setUseAreaReducer(bool useAR)
173  {
174  useAreaReducer = useAR;
175  }
176 
188  void
189  setPointwise(bool pointwise)
190  {
191  isPointwise = pointwise;
192  }
193 
194  std::unique_ptr<geom::Geometry> reduce(const geom::Geometry& geom);
195 
196 
197 
198 };
199 
200 } // namespace geos.precision
201 } // namespace geos
202 
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:70
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:197
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:88
Reduces the precision of a geom::Geometry according to the supplied geom::PrecisionModel,...
Definition: GeometryPrecisionReducer.h:57
GeometryPrecisionReducer(const geom::GeometryFactory &changeFactory)
Create a reducer that will change the precision model of the new reduced Geometry.
Definition: GeometryPrecisionReducer.h:133
void setPointwise(bool pointwise)
Sets whether the precision reduction will be done in pointwise fashion only.
Definition: GeometryPrecisionReducer.h:189
void setChangePrecisionModel(bool change)
Sets whether the geom::PrecisionModel of the new reduced Geometry will be changed to be the geom::Pre...
Definition: GeometryPrecisionReducer.h:166
static std::unique_ptr< geom::Geometry > reduce(const geom::Geometry &g, const geom::PrecisionModel &precModel)
void setRemoveCollapsedComponents(bool remove)
Definition: GeometryPrecisionReducer.h:150
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25