| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/********************************************************************** |
|
2
|
|
|
|
|
|
|
* |
|
3
|
|
|
|
|
|
|
* GEOS - Geometry Engine Open Source |
|
4
|
|
|
|
|
|
|
* http://geos.osgeo.org |
|
5
|
|
|
|
|
|
|
* |
|
6
|
|
|
|
|
|
|
* Copyright (C) 2012 Sandro Santilli |
|
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 |
|
23
|
|
|
|
|
|
|
#include // for GeometryFactory::Ptr |
|
24
|
|
|
|
|
|
|
#include // 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
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
/** \brief |
|
39
|
|
|
|
|
|
|
* Reduces the precision of a {@link Geometry} |
|
40
|
|
|
|
|
|
|
* according to the supplied {@link PrecisionModel}, |
|
41
|
|
|
|
|
|
|
* ensuring that the result is topologically valid. |
|
42
|
|
|
|
|
|
|
*/ |
|
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::unique_ptr reducePointwise( const geom::Geometry& geom ); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
std::unique_ptr fixPolygonalTopology( |
|
59
|
|
|
|
|
|
|
const geom::Geometry& geom ); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
geom::GeometryFactory::Ptr createFactory( |
|
62
|
|
|
|
|
|
|
const geom::GeometryFactory& oldGF, |
|
63
|
|
|
|
|
|
|
const geom::PrecisionModel& newPM ); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
GeometryPrecisionReducer(GeometryPrecisionReducer const&); /*= delete*/ |
|
66
|
|
|
|
|
|
|
GeometryPrecisionReducer& operator=(GeometryPrecisionReducer const&); /*= delete*/ |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
public: |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
/** |
|
71
|
|
|
|
|
|
|
* Convenience method for doing precision reduction |
|
72
|
|
|
|
|
|
|
* on a single geometry, |
|
73
|
|
|
|
|
|
|
* with collapses removed |
|
74
|
|
|
|
|
|
|
* and keeping the geometry precision model the same, |
|
75
|
|
|
|
|
|
|
* and preserving polygonal topology. |
|
76
|
|
|
|
|
|
|
* |
|
77
|
|
|
|
|
|
|
* @param g the geometry to reduce |
|
78
|
|
|
|
|
|
|
* @param precModel the precision model to use |
|
79
|
|
|
|
|
|
|
* @return the reduced geometry |
|
80
|
|
|
|
|
|
|
*/ |
|
81
|
|
|
|
|
|
|
static std::unique_ptr reduce( |
|
82
|
|
|
|
|
|
|
const geom::Geometry &g, |
|
83
|
|
|
|
|
|
|
const geom::PrecisionModel &precModel ) |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
|
|
|
|
|
|
GeometryPrecisionReducer reducer(precModel); |
|
86
|
|
|
|
|
|
|
return reducer.reduce(g); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
/** |
|
90
|
|
|
|
|
|
|
* Convenience method for doing precision reduction |
|
91
|
|
|
|
|
|
|
* on a single geometry, |
|
92
|
|
|
|
|
|
|
* with collapses removed |
|
93
|
|
|
|
|
|
|
* and keeping the geometry precision model the same, |
|
94
|
|
|
|
|
|
|
* but NOT preserving valid polygonal topology. |
|
95
|
|
|
|
|
|
|
* |
|
96
|
|
|
|
|
|
|
* @param g the geometry to reduce |
|
97
|
|
|
|
|
|
|
* @param precModel the precision model to use |
|
98
|
|
|
|
|
|
|
* @return the reduced geometry |
|
99
|
|
|
|
|
|
|
*/ |
|
100
|
|
|
|
|
|
|
static std::unique_ptr 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
|
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
|
GeometryPrecisionReducer(const geom::PrecisionModel &pm) |
|
110
|
|
|
|
|
|
|
: |
|
111
|
|
|
|
|
|
|
newFactory(nullptr), |
|
112
|
|
|
|
|
|
|
targetPM(pm), |
|
113
|
|
|
|
|
|
|
removeCollapsed(true), |
|
114
|
1
|
|
|
|
|
|
isPointwise(false) |
|
115
|
1
|
|
|
|
|
|
{} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
/** |
|
118
|
|
|
|
|
|
|
* \brief |
|
119
|
|
|
|
|
|
|
* Create a reducer that will change the precision model of the |
|
120
|
|
|
|
|
|
|
* new reduced Geometry |
|
121
|
|
|
|
|
|
|
* |
|
122
|
|
|
|
|
|
|
* @param gf the factory for the created Geometry. |
|
123
|
|
|
|
|
|
|
* Its PrecisionModel will be used for the reduction. |
|
124
|
|
|
|
|
|
|
* NOTE: ownership left to caller must be kept alive for |
|
125
|
|
|
|
|
|
|
* the whole lifetime of the returned Geometry. |
|
126
|
|
|
|
|
|
|
*/ |
|
127
|
|
|
|
|
|
|
GeometryPrecisionReducer(const geom::GeometryFactory &gf); |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
/** |
|
130
|
|
|
|
|
|
|
* Sets whether the reduction will result in collapsed components |
|
131
|
|
|
|
|
|
|
* being removed completely, or simply being collapsed to an (invalid) |
|
132
|
|
|
|
|
|
|
* Geometry of the same type. |
|
133
|
|
|
|
|
|
|
* |
|
134
|
|
|
|
|
|
|
* @param remove if true collapsed components will be removed |
|
135
|
|
|
|
|
|
|
*/ |
|
136
|
1
|
|
|
|
|
|
void setRemoveCollapsedComponents(bool remove) { |
|
137
|
1
|
|
|
|
|
|
removeCollapsed = remove; |
|
138
|
1
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
/** \brief |
|
141
|
|
|
|
|
|
|
* Sets whether the precision reduction will be done |
|
142
|
|
|
|
|
|
|
* in pointwise fashion only. |
|
143
|
|
|
|
|
|
|
* |
|
144
|
|
|
|
|
|
|
* Pointwise precision reduction reduces the precision |
|
145
|
|
|
|
|
|
|
* of the individual coordinates only, but does |
|
146
|
|
|
|
|
|
|
* not attempt to recreate valid topology. |
|
147
|
|
|
|
|
|
|
* This is only relevant for geometries containing polygonal components. |
|
148
|
|
|
|
|
|
|
* |
|
149
|
|
|
|
|
|
|
* @param pointwise if reduction should be done pointwise only |
|
150
|
|
|
|
|
|
|
*/ |
|
151
|
1
|
|
|
|
|
|
void setPointwise(bool pointwise) |
|
152
|
|
|
|
|
|
|
{ |
|
153
|
1
|
|
|
|
|
|
isPointwise = pointwise; |
|
154
|
1
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
std::unique_ptr reduce(const geom::Geometry& geom); |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
}; |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
} // namespace geos.precision |
|
161
|
|
|
|
|
|
|
} // namespace geos |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
#endif // GEOS_PRECISION_GEOMETRYPRECISIONREDUCER_H |