GEOS
3.6.2
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.osgeo.org 00005 * 00006 * Copyright (C) 2006 Refractions Research Inc. 00007 * 00008 * This is free software; you can redistribute and/or modify it under 00009 * the terms of the GNU Lesser General Public Licence as published 00010 * by the Free Software Foundation. 00011 * See the COPYING file for more information. 00012 * 00013 **********************************************************************/ 00014 00015 #ifndef GEOS_GEOM_COORDINATE_H 00016 #define GEOS_GEOM_COORDINATE_H 00017 00018 #include <geos/export.h> 00019 #include <geos/platform.h> // for DoubleNotANumber 00020 #include <geos/inline.h> 00021 #include <set> 00022 #include <stack> 00023 #include <vector> // for typedefs 00024 #include <string> 00025 #include <limits> 00026 00027 #ifdef _MSC_VER 00028 #pragma warning(push) 00029 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class 00030 #endif 00031 00032 namespace geos { 00033 namespace geom { // geos.geom 00034 00035 struct CoordinateLessThen; 00036 00057 // Define the following to make assignments and copy constructions 00058 // NON-inline (will let profilers report usages) 00059 //#define PROFILE_COORDINATE_COPIES 1 00060 class GEOS_DLL Coordinate { 00061 00062 private: 00063 00064 static Coordinate _nullCoord; 00065 00066 public: 00068 typedef std::set<const Coordinate *, CoordinateLessThen> ConstSet; 00069 00071 typedef std::vector<const Coordinate *> ConstVect; 00072 00074 typedef std::stack<const Coordinate *> ConstStack; 00075 00077 typedef std::vector<Coordinate> Vect; 00078 00080 double x; 00081 00083 double y; 00084 00086 double z; 00087 00088 void setNull(); 00089 00090 static Coordinate& getNull(); 00091 00092 bool isNull() const; 00093 00094 Coordinate(double xNew=0.0, double yNew=0.0, double zNew=DoubleNotANumber); 00095 00096 bool equals2D(const Coordinate& other) const; 00097 00099 bool equals(const Coordinate& other) const; 00100 00102 int compareTo(const Coordinate& other) const; 00103 00105 bool equals3D(const Coordinate& other) const; 00106 00108 std::string toString() const; 00109 00112 //void makePrecise(const PrecisionModel *pm); 00113 00114 double distance(const Coordinate& p) const; 00115 00116 int hashCode() const; 00117 00122 static int hashCode(double d); 00123 00124 }; 00125 00127 struct GEOS_DLL CoordinateLessThen { 00128 00129 bool operator()(const Coordinate* a, const Coordinate* b) const; 00130 bool operator()(const Coordinate& a, const Coordinate& b) const; 00131 00132 }; 00133 00135 inline bool operator<(const Coordinate& a, const Coordinate& b) { 00136 return CoordinateLessThen()(a,b); 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 _MSC_VER 00154 #pragma warning(pop) 00155 #endif 00156 00157 #ifdef GEOS_INLINE 00158 # include "geos/geom/Coordinate.inl" 00159 #endif 00160 00161 #endif // ndef GEOS_GEOM_COORDINATE_H 00162