GEOS: PrecisionModel.h Source File

GEOS 3.3.8

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

PrecisionModel.h
1 /**********************************************************************
2 * $Id: PrecisionModel.h 3292 2011-04-22 13:04:20Z strk $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
8 * Copyright (C) 2006 Refractions Research Inc.
9 *
10 * This is free software; you can redistribute and/or modify it under
11 * the terms of the GNU Lesser General Public Licence as published
12 * by the Free Software Foundation.
13 * See the COPYING file for more information.
14 *
15 **********************************************************************
16 *
17 * Last port: geom/PrecisionModel.java r378 (JTS-1.12)
18 *
19 **********************************************************************/
20
21 #ifndef GEOS_GEOM_PRECISIONMODEL_H
22 #define GEOS_GEOM_PRECISIONMODEL_H
23
24 #include <geos/export.h>
25 #include <geos/inline.h>
26
27
28 #include <string>
29
30 // Forward declarations
31 namespace geos {
32 namespace io {
33 class Unload;
34 }
35 namespace geom {
36 class Coordinate;
37 }
38 }
39
40 namespace geos {
41 namespace geom { // geos::geom
42
88 class GEOS_DLL PrecisionModel {
89 friend class io::Unload;
90
91 public:
92
94 typedef enum {
95
102 FIXED,
103
109 FLOATING,
110
116 FLOATING_SINGLE
117
118 } Type;
119
121 PrecisionModel(void);
122
124 //
129 PrecisionModel(Type nModelType);
130
147 PrecisionModel(double newScale, double newOffsetX, double newOffsetY);
148
160 PrecisionModel(double newScale);
161
162 // copy constructor
163 PrecisionModel(const PrecisionModel &pm);
164
166 ~PrecisionModel(void);
167
168
170 //
175 static const double maximumPreciseValue;
176
187 double makePrecise(double val) const;
188
190 void makePrecise(Coordinate& coord) const;
191
192 void makePrecise(Coordinate* coord) const;
193
195 //
199 bool isFloating() const;
200
204 //
211 int getMaximumSignificantDigits() const;
212
214 //
217 Type getType() const;
218
220 double getScale() const;
221
223 //
228 double getOffsetX() const;
229
231 //
236 double getOffsetY() const;
237
247 //void toInternal(const Coordinate& external, Coordinate* internal) const;
248
249 /*
250 * Returns the precise representation of <code>external</code>.
251 *
252 *@param external the original coordinate
253 *@return
254 * the coordinate whose values will be changed to the precise
255 * representation of <code>external</code>
256 * @deprecated use makePrecise instead
257 */
258 //Coordinate* toInternal(const Coordinate& external) const;
259
260 /*
261 * Returns the external representation of <code>internal</code>.
262 *
263 *@param internal the original coordinate
264 *@return the coordinate whose values will be changed to the
265 * external representation of <code>internal</code>
266 * @deprecated no longer needed, since internal representation is same as external representation
267 */
268 //Coordinate* toExternal(const Coordinate& internal) const;
269
270 /*
271 * Sets <code>external</code> to the external representation of
272 * <code>internal</code>.
273 *
274 * @param internal the original coordinate
275 * @param external
276 * the coordinate whose values will be changed to the
277 * external representation of <code>internal</code>
278 * @deprecated no longer needed, since internal representation is same as external representation
279 */
280 //void toExternal(const Coordinate& internal, Coordinate* external) const;
281
282 std::string toString() const;
283
287 //
303 int compareTo(const PrecisionModel* other) const;
304
305 private:
306
314 void setScale(double newScale);
315 // throw IllegalArgumentException
316
317 Type modelType;
318
319 double scale;
320
321 };
322
323 // Equality operator for PrecisionModel, deprecate it ?
324 //inline bool operator==(const PrecisionModel& a, const PrecisionModel& b);
325
326 } // namespace geos::geom
327 } // namespace geos
328
329 #ifdef GEOS_INLINE
330 # include "geos/geom/PrecisionModel.inl"
331 #endif
332
333 #endif // ndef GEOS_GEOM_PRECISIONMODEL_H
334
335 /**********************************************************************
336 * $Log$
337 * Revision 1.6 2006/04/06 12:34:07 strk
338 * Port info, more debugging lines, doxygen comments
339 *
340 * Revision 1.5 2006/04/03 14:07:32 strk
341 * Commented out obsoleted toInternal() method
342 *
343 * Revision 1.4 2006/03/28 08:57:37 strk
344 * Comments cleanup, system headers included after project headers
345 *
346 * Revision 1.3 2006/03/24 09:52:41 strk
347 * USE_INLINE => GEOS_INLINE
348 *
349 * Revision 1.2 2006/03/22 16:58:35 strk
350 * Removed (almost) all inclusions of geom.h.
351 * Removed obsoleted .cpp files.
352 * Fixed a bug in WKTReader not using the provided CoordinateSequence
353 * implementation, optimized out some memory allocations.
354 *
355 * Revision 1.1 2006/03/09 16:46:49 strk
356 * geos::geom namespace definition, first pass at headers split
357 *
358 **********************************************************************/