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 
145  PrecisionModel(double newScale, double newOffsetX, double newOffsetY);
146 
158  PrecisionModel(double newScale);
159 
160  // copy constructor
161  PrecisionModel(const PrecisionModel& pm);
162 
164  ~PrecisionModel(void);
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  //
209  int getMaximumSignificantDigits() const;
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 
302 private:
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
static const double maximumPreciseValue
The maximum precise value representable in a double.
Definition: PrecisionModel.h:173
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