GEOS 3.9.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
27namespace geos {
28namespace geom {
29class PrecisionModel;
30class GeometryFactory;
31class Geometry;
32}
33}
34
35namespace geos {
36namespace precision { // geos.precision
37
59
60private:
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> reducePointwise(const geom::Geometry& geom);
73
74 std::unique_ptr<geom::Geometry> fixPolygonalTopology(const geom::Geometry& geom);
75
76 geom::GeometryFactory::Ptr createFactory(
77 const geom::GeometryFactory& oldGF,
78 const geom::PrecisionModel& newPM);
79
81 GeometryPrecisionReducer& operator=(GeometryPrecisionReducer const&); /*= delete*/
82
83public:
84
96 static std::unique_ptr<geom::Geometry>
98 const geom::Geometry& g,
99 const geom::PrecisionModel& precModel)
100 {
101 GeometryPrecisionReducer reducer(precModel);
102 return reducer.reduce(g);
103 }
104
116 static std::unique_ptr<geom::Geometry>
118 const geom::Geometry& g,
119 const geom::PrecisionModel& precModel)
120 {
121 GeometryPrecisionReducer reducer(precModel);
122 reducer.setPointwise(true);
123 return reducer.reduce(g);
124 }
125
127 : newFactory(nullptr)
128 , targetPM(pm)
129 , removeCollapsed(true)
130 , changePrecisionModel(false)
131 , useAreaReducer(false)
132 , isPointwise(false)
133 {}
134
146 : newFactory(&changeFactory)
147 , targetPM(*(changeFactory.getPrecisionModel()))
148 , removeCollapsed(true)
149 , changePrecisionModel(false)
150 , useAreaReducer(false)
151 , isPointwise(false)
152 {}
153
161 void
163 {
164 removeCollapsed = remove;
165 }
166
177 void
179 {
180 changePrecisionModel = change;
181 }
182
183 void
184 setUseAreaReducer(bool useAR)
185 {
186 useAreaReducer = useAR;
187 }
188
200 void
201 setPointwise(bool pointwise)
202 {
203 isPointwise = pointwise;
204 }
205
206 std::unique_ptr<geom::Geometry> reduce(const geom::Geometry& geom);
207
208};
209
210} // namespace geos.precision
211} // namespace geos
212
213#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
static std::unique_ptr< geom::Geometry > reducePointwise(const geom::Geometry &g, const geom::PrecisionModel &precModel)
Definition: GeometryPrecisionReducer.h:117
GeometryPrecisionReducer(const geom::GeometryFactory &changeFactory)
Create a reducer that will change the precision model of the new reduced Geometry.
Definition: GeometryPrecisionReducer.h:145
void setPointwise(bool pointwise)
Sets whether the precision reduction will be done in pointwise fashion only.
Definition: GeometryPrecisionReducer.h:201
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:178
static std::unique_ptr< geom::Geometry > reduce(const geom::Geometry &g, const geom::PrecisionModel &precModel)
Definition: GeometryPrecisionReducer.h:97
void setRemoveCollapsedComponents(bool remove)
Definition: GeometryPrecisionReducer.h:162
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26