GEOS  3.10.1
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 #ifndef GEOS_PRECISION_GEOMETRYPRECISIONREDUCER_H
20 #define GEOS_PRECISION_GEOMETRYPRECISIONREDUCER_H
21 
22 #include <geos/export.h>
23 #include <geos/geom/GeometryFactory.h> // for GeometryFactory::Ptr
24 #include <memory> // for unique_ptr
25 
26 // Forward declarations
27 namespace geos {
28 namespace geom {
29 class PrecisionModel;
30 class GeometryFactory;
31 class Geometry;
32 }
33 }
34 
35 namespace geos {
36 namespace precision { // geos.precision
37 
58 class GEOS_DLL GeometryPrecisionReducer {
59 
60 private:
61 
62  // Externally owned
63  const geom::GeometryFactory* newFactory;
64 
65  const geom::PrecisionModel& targetPM;
66 
67  bool removeCollapsed;
68  bool changePrecisionModel;
69  bool useAreaReducer;
70  bool isPointwise;
71 
72  std::unique_ptr<geom::Geometry> fixPolygonalTopology(const geom::Geometry& geom);
73 
74  geom::GeometryFactory::Ptr createFactory(
75  const geom::GeometryFactory& oldGF,
76  const geom::PrecisionModel& newPM);
77 
86  std::unique_ptr<geom::Geometry> changePM(
87  const geom::Geometry* geom,
88  const geom::PrecisionModel& newPM);
89 
91  GeometryPrecisionReducer& operator=(GeometryPrecisionReducer const&); /*= delete*/
92 
93 public:
94 
106  static std::unique_ptr<geom::Geometry>
107  reduce(const geom::Geometry& g, const geom::PrecisionModel& precModel);
108 
109  static std::unique_ptr<geom::Geometry>
110  reducePointwise(const geom::Geometry& g, const geom::PrecisionModel& precModel);
111 
113  : newFactory(nullptr)
114  , targetPM(pm)
115  , removeCollapsed(true)
116  , changePrecisionModel(false)
117  , useAreaReducer(false)
118  , isPointwise(false)
119  {}
120 
132  : newFactory(&changeFactory)
133  , targetPM(*(changeFactory.getPrecisionModel()))
134  , removeCollapsed(true)
135  , changePrecisionModel(false)
136  , useAreaReducer(false)
137  , isPointwise(false)
138  {}
139 
147  void
149  {
150  removeCollapsed = remove;
151  }
152 
163  void
165  {
166  changePrecisionModel = change;
167  }
168 
169  void
170  setUseAreaReducer(bool useAR)
171  {
172  useAreaReducer = useAR;
173  }
174 
186  void
187  setPointwise(bool pointwise)
188  {
189  isPointwise = pointwise;
190  }
191 
192  std::unique_ptr<geom::Geometry> reduce(const geom::Geometry& geom);
193 
194 };
195 
196 } // namespace geos.precision
197 } // namespace geos
198 
199 #endif // GEOS_PRECISION_GEOMETRYPRECISIONREDUCER_H
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
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
Reduces the precision of a geom::Geometry according to the supplied geom::PrecisionModel,...
Definition: GeometryPrecisionReducer.h:58
GeometryPrecisionReducer(const geom::GeometryFactory &changeFactory)
Create a reducer that will change the precision model of the new reduced Geometry.
Definition: GeometryPrecisionReducer.h:131
void setPointwise(bool pointwise)
Sets whether the precision reduction will be done in pointwise fashion only.
Definition: GeometryPrecisionReducer.h:187
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:164
static std::unique_ptr< geom::Geometry > reduce(const geom::Geometry &g, const geom::PrecisionModel &precModel)
void setRemoveCollapsedComponents(bool remove)
Definition: GeometryPrecisionReducer.h:148
Basic namespace for all GEOS functionalities.
Definition: Angle.h:26