17#include <geos/export.h>
18#include <geos/constants.h>
27#pragma warning(disable: 4251)
33struct CoordinateLessThen;
66 typedef std::set<const Coordinate*, CoordinateLessThen>
ConstSet;
75 typedef std::vector<Coordinate>
Vect;
87 GEOS_DLL
friend std::ostream& operator<< (std::ostream& os,
const Coordinate& c);
98 return ! a.equals2D(b);
104 , z(DoubleNotANumber)
107 Coordinate(
double xNew,
double yNew,
double zNew = DoubleNotANumber)
115 x = DoubleNotANumber;
116 y = DoubleNotANumber;
117 z = DoubleNotANumber;
120 static Coordinate& getNull();
124 return (std::isnan(x) && std::isnan(y) && std::isnan(z));
129 return std::isfinite(x) && std::isfinite(y);
132 bool equals2D(
const Coordinate& other)
const
143 bool equals2D(
const Coordinate& other,
double tolerance)
const
145 if (std::abs(x - other.x) > tolerance) {
148 if (std::abs(y - other.y) > tolerance) {
157 return equals2D(other);
181 return (x == other.
x) && (y == other.
y) &&
182 ((z == other.
z) || (std::isnan(z) && std::isnan(other.
z)));
195 return std::sqrt(dx * dx + dy * dy);
198 double distanceSquared(
const Coordinate& p)
const
202 return dx * dx + dy * dy;
205 struct GEOS_DLL HashCode
207 std::size_t operator()(
const Coordinate & c)
const
209 size_t h = std::hash<double>{}(c.x);
210 h ^= std::hash<double>{}(c.y) << 1;
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
bool equals(const Coordinate &other) const
2D only
Definition: Coordinate.h:155
friend bool operator==(const Coordinate &a, const Coordinate &b)
Equality operator for Coordinate. 2D only.
Definition: Coordinate.h:90
std::string toString() const
Returns a string of the form (x,y,z) .
friend bool operator!=(const Coordinate &a, const Coordinate &b)
Inequality operator for Coordinate. 2D only.
Definition: Coordinate.h:96
std::vector< Coordinate > Vect
A vector of Coordinate objects (real object, not pointers)
Definition: Coordinate.h:75
std::vector< const Coordinate * > ConstVect
A vector of const Coordinate pointers.
Definition: Coordinate.h:69
std::set< const Coordinate *, CoordinateLessThen > ConstSet
A set of const Coordinate pointers.
Definition: Coordinate.h:66
std::stack< const Coordinate * > ConstStack
A stack of const Coordinate pointers.
Definition: Coordinate.h:72
double distance(const Coordinate &p) const
Definition: Coordinate.h:191
double y
y-coordinate
Definition: Coordinate.h:81
double x
x-coordinate
Definition: Coordinate.h:78
int compareTo(const Coordinate &other) const
TODO: deprecate this, move logic to CoordinateLessThen instead.
Definition: Coordinate.h:161
bool equals3D(const Coordinate &other) const
3D comparison
Definition: Coordinate.h:179
double z
z-coordinate
Definition: Coordinate.h:84
bool operator<(const Coordinate &a, const Coordinate &b)
Strict weak ordering operator for Coordinate.
Definition: Coordinate.h:245
Basic namespace for all GEOS functionalities.
Definition: geos.h:39
Strict weak ordering Functor for Coordinate.
Definition: Coordinate.h:220