GEOS: Coordinate.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

# Coordinate.h

    00001 /**********************************************************************
    00002  * $Id: Coordinate.h 3367 2011-05-17 16:50:03Z 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 #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 { // geos.geom
    00035
    00036 struct CoordinateLessThen;
    00037
    00058 // Define the following to make assignments and copy constructions
    00059 // NON-inline (will let profilers report usages)
    00060 //#define PROFILE_COORDINATE_COPIES 1
    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         //void makePrecise(const PrecisionModel *pm);
    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 } // namespace geos.geom
    00154 } // namespace geos
    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