GEOS  3.3.3
Coordinate.h
1 /**********************************************************************
2  * $Id: Coordinate.h 3367 2011-05-17 16:50:03Z strk $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 2006 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************/
15 
16 #ifndef GEOS_GEOM_COORDINATE_H
17 #define GEOS_GEOM_COORDINATE_H
18 
19 #include <geos/export.h>
20 #include <geos/platform.h> // for DoubleNotANumber
21 #include <geos/inline.h>
22 #include <set>
23 #include <stack>
24 #include <vector> // for typedefs
25 #include <string>
26 #include <limits>
27 
28 #ifdef _MSC_VER
29 #pragma warning(push)
30 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
31 #endif
32 
33 namespace geos {
34 namespace geom { // geos.geom
35 
36 struct CoordinateLessThen;
37 
58 // Define the following to make assignments and copy constructions
59 // NON-inline (will let profilers report usages)
60 //#define PROFILE_COORDINATE_COPIES 1
61 class GEOS_DLL Coordinate {
62 
63 private:
64 
65  static Coordinate nullCoord;
66 
67 public:
69  typedef std::set<const Coordinate *, CoordinateLessThen> ConstSet;
70 
72  typedef std::vector<const Coordinate *> ConstVect;
73 
75  typedef std::stack<const Coordinate *> ConstStack;
76 
78  typedef std::vector<Coordinate> Vect;
79 
81  double x;
82 
84  double y;
85 
87  double z;
88 
89  void setNull();
90 
91  static Coordinate& getNull();
92 
93  bool isNull() const;
94 
95  ~Coordinate();
96 
97  Coordinate(double xNew=0.0, double yNew=0.0, double zNew=DoubleNotANumber);
98 
99  bool equals2D(const Coordinate& other) const;
100 
102  bool equals(const Coordinate& other) const;
103 
105  int compareTo(const Coordinate& other) const;
106 
108  bool equals3D(const Coordinate& other) const;
109 
111  std::string toString() const;
112 
115  //void makePrecise(const PrecisionModel *pm);
116 
117  double distance(const Coordinate& p) const;
118 
119  int hashCode() const;
120 
125  static int hashCode(double d);
126 
127 };
128 
130 struct GEOS_DLL CoordinateLessThen {
131 
132  bool operator()(const Coordinate* a, const Coordinate* b) const;
133  bool operator()(const Coordinate& a, const Coordinate& b) const;
134 
135 };
136 
138 inline bool operator<(const Coordinate& a, const Coordinate& b) {
139  return CoordinateLessThen()(a,b);
140 }
141 
143 GEOS_DLL std::ostream& operator<< (std::ostream& os, const Coordinate& c);
144 
146 GEOS_DLL bool operator==(const Coordinate& a, const Coordinate& b);
147 
149 GEOS_DLL bool operator!=(const Coordinate& a, const Coordinate& b);
150 
151 
152 
153 } // namespace geos.geom
154 } // namespace geos
155 
156 #ifdef _MSC_VER
157 #pragma warning(pop)
158 #endif
159 
160 #ifdef GEOS_INLINE
161 # include "geos/geom/Coordinate.inl"
162 #endif
163 
164 #endif // ndef GEOS_GEOM_COORDINATE_H
165