coordinate.inl
来自「在Linux下做的QuadTree的程序」· INL 代码 · 共 174 行
INL
174 行
/********************************************************************** * $Id: Coordinate.inl 1820 2006-09-06 16:54:23Z mloskot $ * * GEOS - Geometry Engine Open Source * http://geos.refractions.net * * Copyright (C) 2005-2006 Refractions Research 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. * **********************************************************************/#ifndef GEOS_GEOM_COORDINATE_INL#define GEOS_GEOM_COORDINATE_INL#include <geos/geom/Coordinate.h>//#include <geos/geom/PrecisionModel.h> // we need it for makePrecise, possibly to be obsoleted#include <geos/platform.h> // for DoubleNotANumber#include <cassert>#include <cmath>namespace geos {namespace geom { // geos::geomINLINE voidCoordinate::setNull(){ x=DoubleNotANumber; y=DoubleNotANumber; z=DoubleNotANumber;}INLINE Coordinate&Coordinate::getNull(){ return nullCoord;}INLINECoordinate::~Coordinate(){}INLINECoordinate::Coordinate(double xNew, double yNew, double zNew) : x(xNew), y(yNew), z(zNew){}#if 0INLINECoordinate::Coordinate(const Coordinate& c) : x(c.x), y(c.y), z(c.z){}INLINE Coordinate&Coordinate::operator=(const Coordinate &c){ if ( this == &c ) return *this; x=c.x; y=c.y; z=c.z; return *this;}#endifINLINE boolCoordinate::equals2D(const Coordinate& other) const{ if (x != other.x) return false; if (y != other.y) return false; return true;}INLINE boolCoordinate::equals(const Coordinate& other) const{ return equals2D(other);}INLINE intCoordinate::compareTo(const Coordinate& other) const{ if (x < other.x) return -1; if (x > other.x) return 1; if (y < other.y) return -1; if (y > other.y) return 1; return 0;}INLINE boolCoordinate::equals3D(const Coordinate& other) const{ return (x == other.x) && ( y == other.y) && ((z == other.z)||(ISNAN(z) && ISNAN(other.z)));}#if 0INLINE voidCoordinate::makePrecise(const PrecisionModel *pm){ x = pm->makePrecise(x); y = pm->makePrecise(y);}#endifINLINE doubleCoordinate::distance(const Coordinate& p) const{ double dx = x - p.x; double dy = y - p.y; return sqrt(dx * dx + dy * dy);}INLINE intCoordinate::hashCode() const{ //Algorithm from Effective Java by Joshua Bloch [Jon Aquino] int result = 17; result = 37 * result + hashCode(x); result = 37 * result + hashCode(y); return result;}/*static*/INLINE intCoordinate::hashCode(double d){ int64 f = (int64)(d); return (int)(f^(f>>32));}INLINE boolCoordinateLessThen::operator()(const Coordinate* a, const Coordinate* b) const{ if (a->compareTo(*b)<0) return true; else return false;}INLINE boolCoordinateLessThen::operator()(const Coordinate& a, const Coordinate& b) const{ if (a.compareTo(b)<0) return true; else return false;}INLINE booloperator==(const Coordinate& a, const Coordinate& b){ return a.equals2D(b);}INLINE booloperator!=(const Coordinate& a, const Coordinate& b){ return ! a.equals2D(b);}} // namespace geos::geom} // namespace geos#endif // GEOS_GEOM_COORDINATE_INL
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?