GEOS
3.4.2
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.osgeo.org 00005 * 00006 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net> 00007 * Copyright (C) 2006 Refractions Research Inc. 00008 * 00009 * This is free software; you can redistribute and/or modify it under 00010 * the terms of the GNU Lesser General Public Licence as published 00011 * by the Free Software Foundation. 00012 * See the COPYING file for more information. 00013 * 00014 ********************************************************************** 00015 * 00016 * Last port: geom/PrecisionModel.java r378 (JTS-1.12) 00017 * 00018 **********************************************************************/ 00019 00020 #ifndef GEOS_GEOM_PRECISIONMODEL_H 00021 #define GEOS_GEOM_PRECISIONMODEL_H 00022 00023 #include <geos/export.h> 00024 #include <geos/inline.h> 00025 00026 00027 #include <string> 00028 00029 // Forward declarations 00030 namespace geos { 00031 namespace io { 00032 class Unload; 00033 } 00034 namespace geom { 00035 class Coordinate; 00036 } 00037 } 00038 00039 namespace geos { 00040 namespace geom { // geos::geom 00041 00087 class GEOS_DLL PrecisionModel { 00088 friend class io::Unload; 00089 00090 public: 00091 00093 typedef enum { 00094 00101 FIXED, 00102 00108 FLOATING, 00109 00115 FLOATING_SINGLE 00116 00117 } Type; 00118 00120 PrecisionModel(void); 00121 00123 // 00128 PrecisionModel(Type nModelType); 00129 00146 PrecisionModel(double newScale, double newOffsetX, double newOffsetY); 00147 00159 PrecisionModel(double newScale); 00160 00161 // copy constructor 00162 PrecisionModel(const PrecisionModel &pm); 00163 00165 ~PrecisionModel(void); 00166 00167 00169 // 00174 static const double maximumPreciseValue; 00175 00186 double makePrecise(double val) const; 00187 00189 void makePrecise(Coordinate& coord) const; 00190 00191 void makePrecise(Coordinate* coord) const; 00192 00194 // 00198 bool isFloating() const; 00199 00203 // 00210 int getMaximumSignificantDigits() const; 00211 00213 // 00216 Type getType() const; 00217 00219 double getScale() const; 00220 00222 // 00227 double getOffsetX() const; 00228 00230 // 00235 double getOffsetY() const; 00236 00246 //void toInternal(const Coordinate& external, Coordinate* internal) const; 00247 00248 /* 00249 * Returns the precise representation of <code>external</code>. 00250 * 00251 *@param external the original coordinate 00252 *@return 00253 * the coordinate whose values will be changed to the precise 00254 * representation of <code>external</code> 00255 * @deprecated use makePrecise instead 00256 */ 00257 //Coordinate* toInternal(const Coordinate& external) const; 00258 00259 /* 00260 * Returns the external representation of <code>internal</code>. 00261 * 00262 *@param internal the original coordinate 00263 *@return the coordinate whose values will be changed to the 00264 * external representation of <code>internal</code> 00265 * @deprecated no longer needed, since internal representation is same as external representation 00266 */ 00267 //Coordinate* toExternal(const Coordinate& internal) const; 00268 00269 /* 00270 * Sets <code>external</code> to the external representation of 00271 * <code>internal</code>. 00272 * 00273 * @param internal the original coordinate 00274 * @param external 00275 * the coordinate whose values will be changed to the 00276 * external representation of <code>internal</code> 00277 * @deprecated no longer needed, since internal representation is same as external representation 00278 */ 00279 //void toExternal(const Coordinate& internal, Coordinate* external) const; 00280 00281 std::string toString() const; 00282 00286 // 00302 int compareTo(const PrecisionModel* other) const; 00303 00304 private: 00305 00313 void setScale(double newScale); 00314 // throw IllegalArgumentException 00315 00316 Type modelType; 00317 00318 double scale; 00319 00320 }; 00321 00322 // Equality operator for PrecisionModel, deprecate it ? 00323 //inline bool operator==(const PrecisionModel& a, const PrecisionModel& b); 00324 00325 } // namespace geos::geom 00326 } // namespace geos 00327 00328 #ifdef GEOS_INLINE 00329 # include "geos/geom/PrecisionModel.inl" 00330 #endif 00331 00332 #endif // ndef GEOS_GEOM_PRECISIONMODEL_H