GEOS  3.6.1
GeometryPrecisionReducer.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2012 Sandro Santilli <strk@keybit.net>
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::unique_ptr
24 #include <memory> // for auto_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 
43 class GEOS_DLL GeometryPrecisionReducer {
44 
45 private:
46 
47  // Externally owned
48  const geom::GeometryFactory *newFactory;
49 
50  const geom::PrecisionModel &targetPM;
51 
52  bool removeCollapsed;
53 
54  bool isPointwise;
55 
56  std::auto_ptr<geom::Geometry> reducePointwise( const geom::Geometry& geom );
57 
58  std::auto_ptr<geom::Geometry> fixPolygonalTopology(
59  const geom::Geometry& geom );
60 
61  geom::GeometryFactory::unique_ptr createFactory(
62  const geom::GeometryFactory& oldGF,
63  const geom::PrecisionModel& newPM );
64 
66  GeometryPrecisionReducer& operator=(GeometryPrecisionReducer const&); /*= delete*/
67 
68 public:
69 
81  static std::auto_ptr<geom::Geometry> reduce(
82  const geom::Geometry &g,
83  const geom::PrecisionModel &precModel )
84  {
85  GeometryPrecisionReducer reducer(precModel);
86  return reducer.reduce(g);
87  }
88 
100  static std::auto_ptr<geom::Geometry> reducePointwise(
101  const geom::Geometry &g,
102  const geom::PrecisionModel &precModel )
103  {
104  GeometryPrecisionReducer reducer(precModel);
105  reducer.setPointwise(true);
106  return reducer.reduce(g);
107  }
108 
110  :
111  newFactory(0),
112  targetPM(pm),
113  removeCollapsed(true),
114  isPointwise(false)
115  {}
116 
127  GeometryPrecisionReducer(const geom::GeometryFactory &gf);
128 
136  void setRemoveCollapsedComponents(bool remove) {
137  removeCollapsed = remove;
138  }
139 
151  void setPointwise(bool pointwise)
152  {
153  isPointwise = pointwise;
154  }
155 
156  std::auto_ptr<geom::Geometry> reduce(const geom::Geometry& geom);
157 
158 };
159 
160 } // namespace geos.precision
161 } // namespace geos
162 
163 #endif // GEOS_PRECISION_GEOMETRYPRECISIONREDUCER_H
static std::auto_ptr< geom::Geometry > reducePointwise(const geom::Geometry &g, const geom::PrecisionModel &precModel)
Definition: GeometryPrecisionReducer.h:100
void setRemoveCollapsedComponents(bool remove)
Definition: GeometryPrecisionReducer.h:136
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
Reduces the precision of a Geometry according to the supplied PrecisionModel, ensuring that the resul...
Definition: GeometryPrecisionReducer.h:43
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
static std::auto_ptr< geom::Geometry > reduce(const geom::Geometry &g, const geom::PrecisionModel &precModel)
Definition: GeometryPrecisionReducer.h:81
void setPointwise(bool pointwise)
Sets whether the precision reduction will be done in pointwise fashion only.
Definition: GeometryPrecisionReducer.h:151