GEOS 3.8.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
123 //
128 PrecisionModel(Type nModelType);
129
145 PrecisionModel(double newScale, double newOffsetX, double newOffsetY);
146
158 PrecisionModel(double newScale);
159
160 // copy constructor
162
165
166
168 //
173 static const double maximumPreciseValue;
174
185 double makePrecise(double val) const;
186
188 void makePrecise(Coordinate& coord) const;
189
190 void makePrecise(Coordinate* coord) const;
191
193 //
197 bool isFloating() const;
198
202 //
210
212 //
215 Type getType() const;
216
218 double getScale() const;
219
221 //
226 double getOffsetX() const;
227
229 //
234 double getOffsetY() const;
235
236 /*
237 * Sets ´internal` to the precise representation of `external`.
238 *
239 * @param external the original coordinate
240 * @param internal the coordinate whose values will be changed to the
241 * precise representation of <code>external</code>
242 * @deprecated use makePrecise instead
243 */
244 //void toInternal(const Coordinate& external, Coordinate* internal) const;
245
246 /*
247 * Returns the precise representation of <code>external</code>.
248 *
249 *@param external the original coordinate
250 *@return
251 * the coordinate whose values will be changed to the precise
252 * representation of <code>external</code>
253 * @deprecated use makePrecise instead
254 */
255 //Coordinate* toInternal(const Coordinate& external) const;
256
257 /*
258 * Returns the external representation of <code>internal</code>.
259 *
260 *@param internal the original coordinate
261 *@return the coordinate whose values will be changed to the
262 * external representation of <code>internal</code>
263 * @deprecated no longer needed, since internal representation is same as external representation
264 */
265 //Coordinate* toExternal(const Coordinate& internal) const;
266
267 /*
268 * Sets <code>external</code> to the external representation of
269 * <code>internal</code>.
270 *
271 * @param internal the original coordinate
272 * @param external
273 * the coordinate whose values will be changed to the
274 * external representation of <code>internal</code>
275 * @deprecated no longer needed, since internal representation is same as external representation
276 */
277 //void toExternal(const Coordinate& internal, Coordinate* external) const;
278
279 std::string toString() const;
280
284 //
300 int compareTo(const PrecisionModel* other) const;
301
302private:
303
311 void setScale(double newScale);
312 // throw IllegalArgumentException
313
314 Type modelType;
315
316 double scale;
317
318};
319
320// Equality operator for PrecisionModel, deprecate it ?
321//inline bool operator==(const PrecisionModel& a, const PrecisionModel& b);
322
323} // namespace geos::geom
324} // namespace geos
325
326#ifdef GEOS_INLINE
327# include "geos/geom/PrecisionModel.inl"
328#endif
329
330#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
double getOffsetY() const
Returns the y-offset used to obtain a precise coordinate.
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.
~PrecisionModel(void)
destructor
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.
double getOffsetX() const
Returns the x-offset used to obtain a precise coordinate.
static const double maximumPreciseValue
The maximum precise value representable in a double.
Definition: PrecisionModel.h:173
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)
Creates a PrecisionModel specifying an explicit precision model type.
double makePrecise(double val) const
Rounds a numeric value to the PrecisionModel grid.
bool isFloating() const
Tests whether the precision model supports floating point.
Type getType() const
Gets the type of this PrecisionModel.
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25