1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
/**********************************************************************
* $Id: Coordinate.cpp,v 1.19 2004/11/29 16:05:33 strk Exp $
*
* GEOS - Geometry Engine Open Source
* http://geos.refractions.net
*
* Copyright (C) 2001-2002 Vivid Solutions Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
#include <geos/geom.h>
#include <stdio.h>
namespace geos {
Coordinate Coordinate::nullCoord=Coordinate(DoubleNotANumber,DoubleNotANumber,DoubleNotANumber);
/**
* Returns a <code>string</code> of the form <I>(x,y,z)</I> .
*
*@return a <code>string</code> of the form <I>(x,y,z)</I>
*/
string Coordinate::toString() const {
string result("");
char buffer[255];
if (ISNAN(z)) {
sprintf(buffer,"(%g,%g)",x,y);
result.append(buffer);
result.append("");
} else {
sprintf(buffer,"(%g,%g,%g)",x,y,z);
result.append(buffer);
result.append("");
}
return result;
}
/*
* Returns <code>true</code> if <code>a</code> and <code>b</code>
* have the same values for x and y.
*
*@param a a <code>Coordinate</code> with which to do the 3D comparison.
*@param b a <code>Coordinate</code> with which to do the 3D comparison.
*@return <code>true</code> if <code>a</code> and <code>b</code>
* have the same values for x, y and z.
*/
bool operator==(const Coordinate& a, const Coordinate& b) {
//return a.equals2D(b);
if ( a.x != b.x ) return false;
if ( a.y != b.y ) return false;
return true;
}
bool operator!=(const Coordinate& a, const Coordinate& b) {
if ( a.x != b.x ) return true;
if ( a.y != b.y ) return true;
return false;
}
} // namespace geos
/**********************************************************************
* $Log: Coordinate.cpp,v $
* Revision 1.19 2004/11/29 16:05:33 strk
* Fixed a bug in LineIntersector::interpolateZ causing NaN values
* to come out.
* Handled dimensional collapses in ElevationMatrix.
* Added ISNAN macro and changed ISNAN/FINITE macros to avoid
* dispendious isnan() and finite() calls.
*
* Revision 1.18 2004/11/01 16:43:04 strk
* Added Profiler code.
* Temporarly patched a bug in DoubleBits (must check drawbacks).
* Various cleanups and speedups.
*
* Revision 1.17 2004/10/21 22:29:54 strk
* Indentation changes and some more COMPUTE_Z rules
*
* Revision 1.16 2004/07/22 07:04:49 strk
* Documented missing geometry functions.
*
* Revision 1.15 2004/07/21 09:55:24 strk
* CoordinateSequence::atLeastNCoordinatesOrNothing definition fix.
* Documentation fixes.
*
* Revision 1.14 2004/07/14 21:17:10 strk
* added inequality operator for Coordinate
*
* Revision 1.13 2004/07/02 13:28:26 strk
* Fixed all #include lines to reflect headers layout change.
* Added client application build tips in README.
*
* Revision 1.12 2004/03/18 10:42:44 ybychkov
* "IO" and "Util" upgraded to JTS 1.4
* "Geometry" partially upgraded.
*
* Revision 1.11 2003/11/07 01:23:42 pramsey
* Add standard CVS headers licence notices and copyrights to all cpp and h
* files.
*
*
**********************************************************************/
|