GEOS  3.3.2
PrecisionModel.h
00001 /**********************************************************************
00002  * $Id: PrecisionModel.h 3292 2011-04-22 13:04:20Z strk $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
00008  * Copyright (C) 2006 Refractions Research Inc.
00009  *
00010  * This is free software; you can redistribute and/or modify it under
00011  * the terms of the GNU Lesser General Public Licence as published
00012  * by the Free Software Foundation. 
00013  * See the COPYING file for more information.
00014  *
00015  **********************************************************************
00016  *
00017  * Last port: geom/PrecisionModel.java r378 (JTS-1.12)
00018  *
00019  **********************************************************************/
00020 
00021 #ifndef GEOS_GEOM_PRECISIONMODEL_H
00022 #define GEOS_GEOM_PRECISIONMODEL_H
00023 
00024 #include <geos/export.h>
00025 #include <geos/inline.h>
00026 
00027 
00028 #include <string>
00029 
00030 // Forward declarations
00031 namespace geos {
00032         namespace io {
00033                 class Unload;
00034         }
00035         namespace geom {
00036                 class Coordinate;
00037         }
00038 }
00039 
00040 namespace geos {
00041 namespace geom { // geos::geom
00042 
00088 class GEOS_DLL PrecisionModel {
00089 friend class io::Unload;
00090 
00091 public:
00092 
00094         typedef enum {
00095 
00102                 FIXED,
00103 
00109                 FLOATING,
00110 
00116                 FLOATING_SINGLE
00117 
00118         } Type;
00119         
00121         PrecisionModel(void);
00122 
00124         //
00129         PrecisionModel(Type nModelType);
00130 
00147         PrecisionModel(double newScale, double newOffsetX, double newOffsetY);
00148 
00160         PrecisionModel(double newScale);
00161 
00162         // copy constructor
00163         PrecisionModel(const PrecisionModel &pm);
00164 
00166         ~PrecisionModel(void);
00167 
00168 
00170         //
00175         static const double maximumPreciseValue;
00176 
00187         double makePrecise(double val) const;
00188 
00190         void makePrecise(Coordinate& coord) const;
00191 
00192         void makePrecise(Coordinate* coord) const;
00193 
00195         //
00199         bool isFloating() const;
00200 
00204         //
00211         int getMaximumSignificantDigits() const;
00212 
00214         //
00217         Type getType() const;
00218 
00220         double getScale() const;
00221 
00223         //
00228         double getOffsetX() const;
00229 
00231         //
00236         double getOffsetY() const;
00237 
00247         //void toInternal(const Coordinate& external, Coordinate* internal) const;
00248 
00249         /*
00250          *  Returns the precise representation of <code>external</code>.
00251          *
00252          *@param  external  the original coordinate
00253          *@return
00254          *      the coordinate whose values will be changed to the precise
00255          *      representation of <code>external</code>
00256          * @deprecated use makePrecise instead
00257          */
00258         //Coordinate* toInternal(const Coordinate& external) const;
00259 
00260         /*
00261          *  Returns the external representation of <code>internal</code>.
00262          *
00263          *@param  internal  the original coordinate
00264          *@return           the coordinate whose values will be changed to the
00265          *      external representation of <code>internal</code>
00266          * @deprecated no longer needed, since internal representation is same as external representation
00267          */
00268         //Coordinate* toExternal(const Coordinate& internal) const;
00269 
00270         /*
00271          *  Sets <code>external</code> to the external representation of
00272          *  <code>internal</code>.
00273          *
00274          * @param  internal  the original coordinate
00275          * @param  external
00276          *      the coordinate whose values will be changed to the
00277          *      external representation of <code>internal</code>
00278          * @deprecated no longer needed, since internal representation is same as external representation
00279          */
00280         //void toExternal(const Coordinate& internal, Coordinate* external) const;
00281 
00282         std::string toString() const;
00283 
00287         //
00303         int compareTo(const PrecisionModel* other) const;
00304 
00305 private:
00306 
00314         void setScale(double newScale);
00315                         // throw IllegalArgumentException
00316 
00317         Type modelType;
00318 
00319         double scale;
00320 
00321 };
00322 
00323 // Equality operator for PrecisionModel, deprecate it ?
00324 //inline bool operator==(const PrecisionModel& a, const PrecisionModel& b);
00325 
00326 } // namespace geos::geom
00327 } // namespace geos
00328 
00329 #ifdef GEOS_INLINE
00330 # include "geos/geom/PrecisionModel.inl"
00331 #endif
00332 
00333 #endif // ndef GEOS_GEOM_PRECISIONMODEL_H
00334 
00335 /**********************************************************************
00336  * $Log$
00337  * Revision 1.6  2006/04/06 12:34:07  strk
00338  * Port info, more debugging lines, doxygen comments
00339  *
00340  * Revision 1.5  2006/04/03 14:07:32  strk
00341  * Commented out obsoleted toInternal() method
00342  *
00343  * Revision 1.4  2006/03/28 08:57:37  strk
00344  * Comments cleanup, system headers included after project headers
00345  *
00346  * Revision 1.3  2006/03/24 09:52:41  strk
00347  * USE_INLINE => GEOS_INLINE
00348  *
00349  * Revision 1.2  2006/03/22 16:58:35  strk
00350  * Removed (almost) all inclusions of geom.h.
00351  * Removed obsoleted .cpp files.
00352  * Fixed a bug in WKTReader not using the provided CoordinateSequence
00353  * implementation, optimized out some memory allocations.
00354  *
00355  * Revision 1.1  2006/03/09 16:46:49  strk
00356  * geos::geom namespace definition, first pass at headers split
00357  *
00358  **********************************************************************/