GEOS
3.2.3
|
00001 /********************************************************************** 00002 * $Id: Coordinate.h 2556 2009-06-06 22:22:28Z strk $ 00003 * 00004 * GEOS - Geometry Engine Open Source 00005 * http://geos.refractions.net 00006 * 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 #ifndef GEOS_GEOM_COORDINATE_H 00017 #define GEOS_GEOM_COORDINATE_H 00018 00019 #include <geos/export.h> 00020 #include <geos/platform.h> // for DoubleNotANumber 00021 #include <geos/inline.h> 00022 #include <set> 00023 #include <stack> 00024 #include <vector> // for typedefs 00025 #include <string> 00026 #include <limits> 00027 00028 namespace geos { 00029 namespace geom { // geos.geom 00030 00031 struct CoordinateLessThen; 00032 00053 // Define the following to make assignments and copy constructions 00054 // NON-inline (will let profilers report usages) 00055 //#define PROFILE_COORDINATE_COPIES 1 00056 class GEOS_DLL Coordinate { 00057 00058 private: 00059 00060 static Coordinate nullCoord; 00061 00062 public: 00064 typedef std::set<const Coordinate *, CoordinateLessThen> ConstSet; 00065 00067 typedef std::vector<const Coordinate *> ConstVect; 00068 00070 typedef std::stack<const Coordinate *> ConstStack; 00071 00073 typedef std::vector<Coordinate> Vect; 00074 00076 double x; 00077 00079 double y; 00080 00082 double z; 00083 00084 void setNull(); 00085 00086 static Coordinate& getNull(); 00087 00088 bool isNull() const; 00089 00090 ~Coordinate(); 00091 00092 Coordinate(double xNew=0.0, double yNew=0.0, double zNew=DoubleNotANumber); 00093 00094 // Letting the compiler synthetize these gives us more numerical stability 00095 #if 0 00096 Coordinate(const Coordinate& c); 00097 00098 Coordinate &operator=(const Coordinate &c); 00099 #endif 00100 00101 bool equals2D(const Coordinate& other) const; 00102 00104 bool equals(const Coordinate& other) const; 00105 00107 int compareTo(const Coordinate& other) const; 00108 00110 bool equals3D(const Coordinate& other) const; 00111 00113 std::string toString() const; 00114 00117 //void makePrecise(const PrecisionModel *pm); 00118 00119 double distance(const Coordinate& p) const; 00120 00121 int hashCode() const; 00122 00127 static int hashCode(double d); 00128 00129 }; 00130 00132 struct GEOS_DLL CoordinateLessThen { 00133 00134 bool operator()(const Coordinate* a, const Coordinate* b) const; 00135 bool operator()(const Coordinate& a, const Coordinate& b) const; 00136 00137 }; 00138 00140 GEOS_DLL std::ostream& operator<< (std::ostream& os, const Coordinate& c); 00141 00143 GEOS_DLL bool operator==(const Coordinate& a, const Coordinate& b); 00144 00146 GEOS_DLL bool operator!=(const Coordinate& a, const Coordinate& b); 00147 00148 00149 00150 } // namespace geos.geom 00151 } // namespace geos 00152 00153 #ifdef GEOS_INLINE 00154 # include "geos/geom/Coordinate.inl" 00155 #endif 00156 00157 #endif // ndef GEOS_GEOM_COORDINATE_H 00158 00159 /********************************************************************** 00160 * $Log$ 00161 * Revision 1.6 2006/06/14 19:27:02 strk 00162 * Let the compiler synthetize copy ctor and assignment op for Coordinate class to obtain better numerical stability. 00163 * 00164 * Revision 1.5 2006/05/23 15:06:07 strk 00165 * * source/headers/geos/geom/Coordinate.h: added missing <string> include. 00166 * 00167 * Revision 1.4 2006/03/27 15:57:39 strk 00168 * Commented need for platform.h include 00169 * 00170 * Revision 1.3 2006/03/24 09:52:41 strk 00171 * USE_INLINE => GEOS_INLINE 00172 * 00173 * Revision 1.2 2006/03/20 10:12:45 strk 00174 * Bug #70 - Small fix in fwd decl. of CoordinateLessThen 00175 * 00176 * Revision 1.1 2006/03/09 16:46:49 strk 00177 * geos::geom namespace definition, first pass at headers split 00178 * 00179 **********************************************************************/