⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 geom.h

📁 一个很好的vc代码
💻 H
📖 第 1 页 / 共 5 页
字号:
/********************************************************************** * $Id: geom.h,v 1.34.2.1 2005/05/23 18:16:40 strk Exp $ * * GEOS - Geometry Engine Open Source * http://geos.refractions.net * * Copyright (C) 2001-2002 Vivid Solutions Inc. * Copyright (C) 2005 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_H#define GEOS_GEOM_H#include <memory>#include <iostream>#include <string>#include <vector>#include <algorithm>#include <map>#include <cmath>#include <geos/platform.h>using namespace std;/** * \brief Basic namespace for all GEOS functionalities. */namespace geos {/// Return current GEOS versionstring geosversion();/** * \brief * Return the version of JTS this GEOS * release has been ported from. */string jtsport();/// Geometry typesenum GeometryTypeId {	/// a point	GEOS_POINT,	/// a linestring	GEOS_LINESTRING,	/// a linear ring (linestring with 1st point == last point)	GEOS_LINEARRING,	/// a polygon	GEOS_POLYGON,	/// a collection of points	GEOS_MULTIPOINT,	/// a collection of linestrings	GEOS_MULTILINESTRING,	/// a collection of polygons	GEOS_MULTIPOLYGON,	/// a collection of heterogeneus geometries	GEOS_GEOMETRYCOLLECTION};class Coordinate;/** * \class PrecisionModel geom.h geos.h * * \brief Specifies the precision model of the Coordinate in a Geometry. * * In other words, specifies the grid of allowable * points for all <code>Geometry</code>s. *  * The makePrecise method allows rounding a coordinate to * a "precise" value; that is, one whose * precision is known exactly. * * Coordinates are assumed to be precise in geometries. * That is, the coordinates are assumed to be rounded to the * precision model given for the geometry. * JTS input routines automatically round coordinates to the precision model * before creating Geometries. * All internal operations * assume that coordinates are rounded to the precision model. * Constructive methods (such as boolean operations) always round computed * coordinates to the appropriate precision model. * * Currently three types of precision model are supported: * - FLOATING - represents full double precision floating point. *   This is the default precision model used in JTS * - FLOATING_SINGLE - represents single precision floating point. * - FIXED - represents a model with a fixed number of decimal places. *   A Fixed Precision Model is specified by a scale factor. *   The scale factor specifies the grid which numbers are rounded to. *   Input coordinates are mapped to fixed coordinates according to the *   following equations: *   - jtsPt.x = round( (inputPt.x * scale ) / scale *   - jtsPt.y = round( (inputPt.y * scale ) / scale * * Coordinates are represented internally as Java double-precision values. * Since Java uses the IEEE-394 floating point standard, this * provides 53 bits of precision. (Thus the maximum precisely representable * integer is 9,007,199,254,740,992). * * JTS methods currently do not handle inputs with different precision models. */class PrecisionModel {friend class Unload;public:	/// The types of Precision Model which GEOS supports.	/*	* This class is only for use to support the "enums"	* for the types of precision model.	*/	typedef enum {		/**		* Fixed Precision indicates that coordinates have a fixed		* number of decimal places.		* The number of decimal places is determined by the log10		* of the scale factor.		*/		FIXED,		/**		* Floating precision corresponds to the standard Java		* double-precision floating-point representation, which is		* based on the IEEE-754 standard		*/		FLOATING,		/**		* Floating single precision corresponds to the standard Java		* single-precision floating-point representation, which is		* based on the IEEE-754 standard		*/		FLOATING_SINGLE	} Type;		/// Creates a PrecisionModel with a default precision of FLOATING.	PrecisionModel(void);	/// Creates a PrecisionModel specifying an explicit precision model type.	/**	* If the model type is FIXED the scale factor will default to 1.	*	* @param nModelType the type of the precision model	*/	PrecisionModel(Type nModelType);	/*	 * Creates a <code>PrecisionModel</code> with Fixed precision.	 *	 * Fixed-precision coordinates are represented as precise internal	 * coordinates, which are rounded to the grid defined by the	 * scale factor.	 *	 * @param  scale	 *	amount by which to multiply a coordinate after subtracting	 *	the offset, to obtain a precise coordinate	 * @param  offsetX  not used.	 * @param  offsetY  not used.	 *	 * @deprecated offsets are no longer supported, since internal	 * representation is rounded floating point	 */	PrecisionModel(double newScale, double newOffsetX, double newOffsetY);	/**	 * \brief 	 * Creates a PrecisionModel with Fixed precision.	 *	 * Fixed-precision coordinates are represented as precise	 * internal coordinates which are rounded to the grid defined	 * by the scale factor.	 *	 * @param newScale amount by which to multiply a coordinate	 * after subtracting the offset, to obtain a precise coordinate	 */	PrecisionModel(double newScale);	// copy constructor	PrecisionModel(const PrecisionModel &pm);	/// destructor	virtual ~PrecisionModel(void);	/// The maximum precise value representable in a double.	/**	 * Since IEE754 double-precision numbers allow 53 bits of mantissa,	 * the value is equal to 2^53 - 1.	 * This provides <i>almost</i> 16 decimal digits of precision.	 */	static const double maximumPreciseValue;	/// Rounds a numeric value to the PrecisionModel grid.	double makePrecise(double val) const;	/// Rounds the given Coordinate to the PrecisionModel grid.	void makePrecise(Coordinate *coord) const;	/// Tests whether the precision model supports floating point	/**	* @return <code>true</code> if the precision model supports	* floating point	*/	bool isFloating() const;	/// Returns the maximum number of significant digits provided by this precision model.	/**	* Intended for use by routines which need to print out precise values.	*	* @return the maximum number of decimal places provided by this precision model	*/	int getMaximumSignificantDigits() const;	/// Gets the type of this PrecisionModel	/**	* @return the type of this PrecisionModel	*/	Type getType() const;	/// Returns the multiplying factor used to obtain a precise coordinate.	double getScale() const;	/*	* Returns the x-offset used to obtain a precise coordinate.	*	* @return the amount by which to subtract the x-coordinate before	*         multiplying by the scale	* @deprecated Offsets are no longer used	*/	double getOffsetX() const;	/*	* Returns the y-offset used to obtain a precise coordinate.	*	* @return the amount by which to subtract the y-coordinate before	*         multiplying by the scale	* @deprecated Offsets are no longer used	*/	double getOffsetY() const;	/*	 *  Sets <code>internal</code> to the precise representation of <code>external</code>.	 *	 * @param external the original coordinate	 * @param internal the coordinate whose values will be changed to the	 *                 precise representation of <code>external</code>	 * @deprecated use makePrecise instead	 */	void toInternal(const Coordinate& external, Coordinate* internal) const;	/*	*  Returns the precise representation of <code>external</code>.	*	*@param  external  the original coordinate	*@return	*	the coordinate whose values will be changed to the precise	*	representation of <code>external</code>	* @deprecated use makePrecise instead	*/	Coordinate* toInternal(const Coordinate& external) const;	/*	*  Returns the external representation of <code>internal</code>.	*	*@param  internal  the original coordinate	*@return           the coordinate whose values will be changed to the	*      external representation of <code>internal</code>	* @deprecated no longer needed, since internal representation is same as external representation	*/	Coordinate* toExternal(const Coordinate& internal) const;	/*	*  Sets <code>external</code> to the external representation of	*  <code>internal</code>.	*	* @param  internal  the original coordinate	* @param  external	*	the coordinate whose values will be changed to the	*	external representation of <code>internal</code>	* @deprecated no longer needed, since internal representation is same as external representation	*/	void toExternal(const Coordinate& internal, Coordinate* external) const;	string toString() const;	/// Compares this PrecisionModel object with the specified object for order.	/**	* A PrecisionModel is greater than another if it provides greater precision.	* The comparison is based on the value returned by the	* getMaximumSignificantDigits method.	* This comparison is not strictly accurate when comparing floating	* precision models to fixed models;	* however, it is correct when both models are either floating or fixed.	*	* @param other the PrecisionModel with which this PrecisionModel	*      is being compared	* @return a negative integer, zero, or a positive integer as this	*      PrecisionModel is less than, equal to, or greater than the	*      specified PrecisionModel.	*/	int compareTo(const PrecisionModel* other) const;private:	void setScale(double newScale);	Type modelType;	double scale;#ifdef INT64_CONST_IS_I64	static const int64 serialVersionUID = 7777263578777803835I64;#else        	static const int64 serialVersionUID = 7777263578777803835LL;#endif        };/** * \class Coordinate geom.h geos.h * * \brief * Coordinate is the lightweight class used to store coordinates. * * It is distinct from Point, which is a subclass of Geometry. * Unlike objects of type Point (which contain additional * information such as an envelope, a precision model, and spatial * reference system information), a Coordinate only contains * ordinate values and accessor methods.  * * Coordinate objects are two-dimensional points, with an additional * z-ordinate. JTS does not support any operations on the z-ordinate except * the basic accessor functions. * * Constructed coordinates will have a z-ordinate of DoubleNotANumber. * The standard comparison functions will ignore the z-ordinate. * */class Coordinate {public:	//void setNull(void);	//static Coordinate& getNull(void);	virtual ~Coordinate(){};	//Coordinate(double xNew, double yNew, double zNew);	//Coordinate(const Coordinate& c);	//Coordinate(double xNew, double yNew);	//void setCoordinate(Coordinate& other);	//bool equals2D(Coordinate& other);	//int compareTo(Coordinate& other);	//bool equals3D(Coordinate& other);	string toString() const;	//void makePrecise();	//double distance(Coordinate& p);	static Coordinate nullCoord;	void Coordinate::setNull() {		x=DoubleNotANumber;		y=DoubleNotANumber;		z=DoubleNotANumber;	}	static Coordinate& Coordinate::getNull() {		return nullCoord;	}	Coordinate::Coordinate() {		x=0.0;		y=0.0;		z=DoubleNotANumber;	}	Coordinate::Coordinate(double xNew, double yNew, double zNew) {		x=xNew;		y=yNew;		z=zNew;	}	Coordinate::Coordinate(const Coordinate& c){		x=c.x;		y=c.y;		z=c.z;	}	Coordinate::Coordinate(double xNew, double yNew){		x=xNew;		y=yNew;		z=DoubleNotANumber;	}	void Coordinate::setCoordinate(const Coordinate& other) {		x = other.x;		y = other.y;		z = other.z;	}	bool Coordinate::equals2D(const Coordinate& other) const {		if (x != other.x) {		return false;		}		if (y != other.y) {		return false;		}		return true;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -