GEOS 3.9.1
PrecisionModel.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
7 * Copyright (C) 2006 Refractions Research Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: geom/PrecisionModel.java r378 (JTS-1.12)
17 *
18 **********************************************************************/
19
20#ifndef GEOS_GEOM_PRECISIONMODEL_H
21#define GEOS_GEOM_PRECISIONMODEL_H
22
23#include <geos/export.h>
24#include <geos/inline.h>
25
26
27#include <string>
28
29// Forward declarations
30namespace geos {
31namespace io {
32class Unload;
33}
34namespace geom {
35class Coordinate;
36}
37}
38
39namespace geos {
40namespace geom { // geos::geom
41
87class GEOS_DLL PrecisionModel {
88 friend class io::Unload;
89
90public:
91
93 typedef enum {
94
102
109
115 FLOATING_SINGLE
116
117 } Type;
118
121
128 PrecisionModel(Type nModelType);
129
145 PrecisionModel(double newScale, double newOffsetX, double newOffsetY);
146
158 PrecisionModel(double newScale);
159
166 static const double maximumPreciseValue;
167
178 double makePrecise(double val) const;
179
181 void makePrecise(Coordinate& coord) const;
182
183 void makePrecise(Coordinate* coord) const;
184
190 bool isFloating() const;
191
203
208 Type getType() const;
209
211 double getScale() const;
212
219 double getOffsetX() const;
220
227 double getOffsetY() const;
228
229 /*
230 * Sets ´internal` to the precise representation of `external`.
231 *
232 * @param external the original coordinate
233 * @param internal the coordinate whose values will be changed to the
234 * precise representation of <code>external</code>
235 * @deprecated use makePrecise instead
236 */
237 //void toInternal(const Coordinate& external, Coordinate* internal) const;
238
239 /*
240 * Returns the precise representation of <code>external</code>.
241 *
242 *@param external the original coordinate
243 *@return
244 * the coordinate whose values will be changed to the precise
245 * representation of <code>external</code>
246 * @deprecated use makePrecise instead
247 */
248 //Coordinate* toInternal(const Coordinate& external) const;
249
250 /*
251 * Returns the external representation of <code>internal</code>.
252 *
253 *@param internal the original coordinate
254 *@return the coordinate whose values will be changed to the
255 * external representation of <code>internal</code>
256 * @deprecated no longer needed, since internal representation is same as external representation
257 */
258 //Coordinate* toExternal(const Coordinate& internal) const;
259
260 /*
261 * Sets <code>external</code> to the external representation of
262 * <code>internal</code>.
263 *
264 * @param internal the original coordinate
265 * @param external
266 * the coordinate whose values will be changed to the
267 * external representation of <code>internal</code>
268 * @deprecated no longer needed, since internal representation is same as external representation
269 */
270 //void toExternal(const Coordinate& internal, Coordinate* external) const;
271
272 std::string toString() const;
273
293 int compareTo(const PrecisionModel* other) const;
294
295private:
296
304 void setScale(double newScale);
305 // throw IllegalArgumentException
306
307 Type modelType;
308
309 double scale;
310
311};
312
313// Equality operator for PrecisionModel, deprecate it ?
314//inline bool operator==(const PrecisionModel& a, const PrecisionModel& b);
315
316} // namespace geos::geom
317} // namespace geos
318
319#ifdef GEOS_INLINE
320# include "geos/geom/PrecisionModel.inl"
321#endif
322
323#endif // ndef GEOS_GEOM_PRECISIONMODEL_H
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:87
int compareTo(const PrecisionModel *other) const
Compares this PrecisionModel object with the specified object for order.
PrecisionModel(double newScale, double newOffsetX, double newOffsetY)
Creates a PrecisionModel with Fixed precision.
double getScale() const
Returns the multiplying factor used to obtain a precise coordinate.
int getMaximumSignificantDigits() const
Returns the maximum number of significant digits provided by this precision model.
static const double maximumPreciseValue
Definition PrecisionModel.h:166
void makePrecise(Coordinate &coord) const
Rounds the given Coordinate to the PrecisionModel grid.
PrecisionModel(void)
Creates a PrecisionModel with a default precision of FLOATING.
Type
The types of Precision Model which GEOS supports.
Definition PrecisionModel.h:93
@ FIXED
Definition PrecisionModel.h:101
@ FLOATING
Definition PrecisionModel.h:108
PrecisionModel(double newScale)
Creates a PrecisionModel with Fixed precision.
PrecisionModel(Type nModelType)
double makePrecise(double val) const
Rounds a numeric value to the PrecisionModel grid.
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26