GEOS  3.9.1dev
PrecisionModel.h
Go to the documentation of this file.
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
30 namespace geos {
31 namespace io {
32 class Unload;
33 }
34 namespace geom {
35 class Coordinate;
36 }
37 }
38 
39 namespace geos {
40 namespace geom { // geos::geom
41 
88  friend class io::Unload;
89 
90 public:
91 
93  typedef enum {
94 
102 
109 
115  FLOATING_SINGLE
116 
117  } Type;
118 
120  PrecisionModel(void);
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 
202  int getMaximumSignificantDigits() const;
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 
295 private:
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
#define GEOS_DLL
Definition: export.h:28
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
static const double maximumPreciseValue
Specifies the precision model of the Coordinate in a Geometry.
Type
The types of Precision Model which GEOS supports.
Basic namespace for all GEOS functionalities.