00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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>
00021 #include <geos/inline.h>
00022 #include <set>
00023 #include <stack>
00024 #include <vector>
00025 #include <string>
00026 #include <limits>
00027
00028 #ifdef _MSC_VER
00029 #pragma warning(push)
00030 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00031 #endif
00032
00033 namespace geos {
00034 namespace geom {
00035
00036 struct CoordinateLessThen;
00037
00058
00059
00060
00061 class GEOS_DLL Coordinate {
00062
00063 private:
00064
00065 static Coordinate nullCoord;
00066
00067 public:
00069 typedef std::set<const Coordinate *, CoordinateLessThen> ConstSet;
00070
00072 typedef std::vector<const Coordinate *> ConstVect;
00073
00075 typedef std::stack<const Coordinate *> ConstStack;
00076
00078 typedef std::vector<Coordinate> Vect;
00079
00081 double x;
00082
00084 double y;
00085
00087 double z;
00088
00089 void setNull();
00090
00091 static Coordinate& getNull();
00092
00093 bool isNull() const;
00094
00095 ~Coordinate();
00096
00097 Coordinate(double xNew=0.0, double yNew=0.0, double zNew=DoubleNotANumber);
00098
00099 bool equals2D(const Coordinate& other) const;
00100
00102 bool equals(const Coordinate& other) const;
00103
00105 int compareTo(const Coordinate& other) const;
00106
00108 bool equals3D(const Coordinate& other) const;
00109
00111 std::string toString() const;
00112
00115
00116
00117 double distance(const Coordinate& p) const;
00118
00119 int hashCode() const;
00120
00125 static int hashCode(double d);
00126
00127 };
00128
00130 struct GEOS_DLL CoordinateLessThen {
00131
00132 bool operator()(const Coordinate* a, const Coordinate* b) const;
00133 bool operator()(const Coordinate& a, const Coordinate& b) const;
00134
00135 };
00136
00138 inline bool operator<(const Coordinate& a, const Coordinate& b) {
00139 return CoordinateLessThen()(a,b);
00140 }
00141
00143 GEOS_DLL std::ostream& operator<< (std::ostream& os, const Coordinate& c);
00144
00146 GEOS_DLL bool operator==(const Coordinate& a, const Coordinate& b);
00147
00149 GEOS_DLL bool operator!=(const Coordinate& a, const Coordinate& b);
00150
00151
00152
00153 }
00154 }
00155
00156 #ifdef _MSC_VER
00157 #pragma warning(pop)
00158 #endif
00159
00160 #ifdef GEOS_INLINE
00161 # include "geos/geom/Coordinate.inl"
00162 #endif
00163
00164 #endif // ndef GEOS_GEOM_COORDINATE_H
00165