GEOS  3.8.0dev
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
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 
87 class GEOS_DLL PrecisionModel {
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 
123  //
128  PrecisionModel(Type nModelType);
129 
146  PrecisionModel(double newScale, double newOffsetX, double newOffsetY);
147 
159  PrecisionModel(double newScale);
160 
161  // copy constructor
162  PrecisionModel(const PrecisionModel& pm);
163 
165  ~PrecisionModel(void);
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  //
210  int getMaximumSignificantDigits() const;
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 
304 private:
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
static const double maximumPreciseValue
The maximum precise value representable in a double.
Definition: PrecisionModel.h:174
Definition: PrecisionModel.h:101
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
Type
The types of Precision Model which GEOS supports.
Definition: PrecisionModel.h:93
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Definition: PrecisionModel.h:108