GEOS 3.6.2
PrecisionModel.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
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 {
31 namespace io {
32 class Unload;
33 }
34 namespace geom {
35 class Coordinate;
36 }
37}
38
39namespace geos {
40namespace geom { // geos::geom
41
87class GEOS_DLL PrecisionModel {
88friend class io::Unload;
89
90public:
91
93 typedef enum {
94
102
109
116
117 } Type;
118
121
123 //
128 PrecisionModel(Type nModelType);
129
146 PrecisionModel(double newScale, double newOffsetX, double newOffsetY);
147
159 PrecisionModel(double newScale);
160
161 // copy constructor
163
166
167
169 //
174 static const double maximumPreciseValue;
175
186 double makePrecise(double val) const;
187
189 void makePrecise(Coordinate& coord) const;
190
191 void makePrecise(Coordinate* coord) const;
192
194 //
198 bool isFloating() const;
199
203 //
211
213 //
216 Type getType() const;
217
219 double getScale() const;
220
222 //
227 double getOffsetX() const;
228
230 //
235 double getOffsetY() const;
236
246 //void toInternal(const Coordinate& external, Coordinate* internal) const;
247
248 /*
249 * Returns the precise representation of <code>external</code>.
250 *
251 *@param external the original coordinate
252 *@return
253 * the coordinate whose values will be changed to the precise
254 * representation of <code>external</code>
255 * @deprecated use makePrecise instead
256 */
257 //Coordinate* toInternal(const Coordinate& external) const;
258
259 /*
260 * Returns the external representation of <code>internal</code>.
261 *
262 *@param internal the original coordinate
263 *@return the coordinate whose values will be changed to the
264 * external representation of <code>internal</code>
265 * @deprecated no longer needed, since internal representation is same as external representation
266 */
267 //Coordinate* toExternal(const Coordinate& internal) const;
268
269 /*
270 * Sets <code>external</code> to the external representation of
271 * <code>internal</code>.
272 *
273 * @param internal the original coordinate
274 * @param external
275 * the coordinate whose values will be changed to the
276 * external representation of <code>internal</code>
277 * @deprecated no longer needed, since internal representation is same as external representation
278 */
279 //void toExternal(const Coordinate& internal, Coordinate* external) const;
280
281 std::string toString() const;
282
286 //
302 int compareTo(const PrecisionModel* other) const;
303
304private:
305
313 void setScale(double newScale);
314 // throw IllegalArgumentException
315
316 Type modelType;
317
318 double scale;
319
320};
321
322// Equality operator for PrecisionModel, deprecate it ?
323//inline bool operator==(const PrecisionModel& a, const PrecisionModel& b);
324
325} // namespace geos::geom
326} // namespace geos
327
328#ifdef GEOS_INLINE
329# include "geos/geom/PrecisionModel.inl"
330#endif
331
332#endif // ndef GEOS_GEOM_PRECISIONMODEL_H
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
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
std::string toString() const
Sets internal to the precise representation of external.
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:174
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
@ FLOATING_SINGLE
Definition PrecisionModel.h:115
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.
Contains the Geometry interface hierarchy and supporting classes.
Definition IndexedNestedRingTester.h:26
Contains the interfaces for converting JTS objects to and from other formats.
Definition Geometry.h:56
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:25