GEOS 3.4.2

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

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 <memory> // for auto_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
42 class GEOS_DLL GeometryPrecisionReducer {
43
44 private:
45
46 // Externally owned
47 const geom::GeometryFactory *newFactory;
48
49 const geom::PrecisionModel &targetPM;
50
51 bool removeCollapsed;
52
53 bool isPointwise;
54
55 std::auto_ptr<geom::Geometry> reducePointwise( const geom::Geometry& geom );
56
57 std::auto_ptr<geom::Geometry> fixPolygonalTopology(
58 const geom::Geometry& geom );
59
60 std::auto_ptr<geom::GeometryFactory> createFactory(
61 const geom::GeometryFactory& oldGF,
62 const geom::PrecisionModel& newPM );
63
64 GeometryPrecisionReducer(GeometryPrecisionReducer const&); /*= delete*/
65 GeometryPrecisionReducer& operator=(GeometryPrecisionReducer const&); /*= delete*/
66
67 public:
68
80 static std::auto_ptr<geom::Geometry> reduce(
81 const geom::Geometry &g,
82 const geom::PrecisionModel &precModel )
83 {
84 GeometryPrecisionReducer reducer(precModel);
85 return reducer.reduce(g);
86 }
87
99 static std::auto_ptr<geom::Geometry> reducePointwise(
100 const geom::Geometry &g,
101 const geom::PrecisionModel &precModel )
102 {
103 GeometryPrecisionReducer reducer(precModel);
104 reducer.setPointwise(true);
105 return reducer.reduce(g);
106 }
107
108 GeometryPrecisionReducer(const geom::PrecisionModel &pm)
109 :
110 newFactory(0),
111 targetPM(pm),
112 removeCollapsed(true),
113 isPointwise(false)
114 {}
115
126 GeometryPrecisionReducer(const geom::GeometryFactory &gf);
127
135 void setRemoveCollapsedComponents(bool remove) {
136 removeCollapsed = remove;
137 }
138
150 void setPointwise(bool pointwise)
151 {
152 isPointwise = pointwise;
153 }
154
155 std::auto_ptr<geom::Geometry> reduce(const geom::Geometry& geom);
156
157 };
158
159 } // namespace geos.precision
160 } // namespace geos
161
162 #endif // GEOS_PRECISION_GEOMETRYPRECISIONREDUCER_H