Coordinate.h

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

Generated on Fri Mar 27 04:52:36 2009 for GEOS by  doxygen 1.5.4