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

📄 geometry.h

📁 在Linux下做的QuadTree的程序
💻 H
📖 第 1 页 / 共 2 页
字号:
/********************************************************************** * $Id: Geometry.h 1880 2006-10-27 11:54:17Z strk $ * * GEOS - Geometry Engine Open Source * http://geos.refractions.net * * Copyright (C) 2001-2002 Vivid Solutions Inc. * 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. * ********************************************************************** * * Last port: geom/Geometry.java rev. 1.100 * **********************************************************************/#ifndef GEOS_GEOM_GEOMETRY_H#define GEOS_GEOM_GEOMETRY_H#include <geos/platform.h>#include <geos/inline.h>#include <geos/geom/Envelope.h>#include <geos/geom/Dimension.h> // for Dimension::DimensionType#include <string>#include <iostream>#include <vector>#include <memory>// Forward declarationsnamespace geos {	namespace geom {		class Coordinate;		class CoordinateFilter;		class CoordinateSequence;		class Envelope;		class GeometryComponentFilter;		class GeometryFactory;		class GeometryFilter;		class IntersectionMatrix;		class PrecisionModel;		class Point;	}	namespace io { // geos.io		class Unload;	} // namespace geos.io}namespace geos {namespace geom { // geos::geom/// 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 Geometry geom.h geos.h * * \brief Basic implementation of Geometry, constructed and * destructed by GeometryFactory. * *  <code>clone</code> returns a deep copy of the object. *  Use GeometryFactory to construct. * *  <H3>Binary Predicates</H3> * Because it is not clear at this time * what semantics for spatial *  analysis methods involving <code>GeometryCollection</code>s would be useful, *  <code>GeometryCollection</code>s are not supported as arguments to binary *  predicates (other than <code>convexHull</code>) or the <code>relate</code> *  method. * *  <H3>Set-Theoretic Methods</H3> * *  The spatial analysis methods will *  return the most specific class possible to represent the result. If the *  result is homogeneous, a <code>Point</code>, <code>LineString</code>, or *  <code>Polygon</code> will be returned if the result contains a single *  element; otherwise, a <code>MultiPoint</code>, <code>MultiLineString</code>, *  or <code>MultiPolygon</code> will be returned. If the result is *  heterogeneous a <code>GeometryCollection</code> will be returned. <P> * *  Because it is not clear at this time what semantics for set-theoretic *  methods involving <code>GeometryCollection</code>s would be useful, * <code>GeometryCollections</code> *  are not supported as arguments to the set-theoretic methods. * *  <H4>Representation of Computed Geometries </H4> * *  The SFS states that the result *  of a set-theoretic method is the "point-set" result of the usual *  set-theoretic definition of the operation (SFS 3.2.21.1). However, there are *  sometimes many ways of representing a point set as a <code>Geometry</code>. *  <P> * *  The SFS does not specify an unambiguous representation of a given point set *  returned from a spatial analysis method. One goal of JTS is to make this *  specification precise and unambiguous. JTS will use a canonical form for *  <code>Geometry</code>s returned from spatial analysis methods. The canonical *  form is a <code>Geometry</code> which is simple and noded: *  <UL> *    <LI> Simple means that the Geometry returned will be simple according to *    the JTS definition of <code>isSimple</code>. *    <LI> Noded applies only to overlays involving <code>LineString</code>s. It *    means that all intersection points on <code>LineString</code>s will be *    present as endpoints of <code>LineString</code>s in the result. *  </UL> *  This definition implies that non-simple geometries which are arguments to *  spatial analysis methods must be subjected to a line-dissolve process to *  ensure that the results are simple. * *  <H4> Constructed Points And The Precision Model </H4> * *  The results computed by the set-theoretic methods may *  contain constructed points which are not present in the input Geometry. *  These new points arise from intersections between line segments in the *  edges of the input Geometry. In the general case it is not *  possible to represent constructed points exactly. This is due to the fact *  that the coordinates of an intersection point may contain twice as many bits *  of precision as the coordinates of the input line segments. In order to *  represent these constructed points explicitly, JTS must truncate them to fit *  the PrecisionModel.  * *  Unfortunately, truncating coordinates moves them slightly. Line segments *  which would not be coincident in the exact result may become coincident in *  the truncated representation. This in turn leads to "topology collapses" -- *  situations where a computed element has a lower dimension than it would in *  the exact result.  * *  When JTS detects topology collapses during the computation of spatial *  analysis methods, it will throw an exception. If possible the exception will *  report the location of the collapse.  * *  equals(Object) and hashCode are not overridden, so that when two *  topologically equal Geometries are added to HashMaps and HashSets, they *  remain distinct. This behaviour is desired in many cases. * */class Geometry {public:	friend class GeometryFactory;	friend std::ostream& operator<< (std::ostream& os, const Geometry& geom);	/// A vector of const Geometry pointers	typedef std::vector<const Geometry *> ConstVect;	/// A vector of non-const Geometry pointers	typedef std::vector<Geometry *> NonConstVect;	/// An auto_ptr of Geometry	typedef std::auto_ptr<Geometry> AutoPtr;	/// Make a deep-copy of this Geometry	virtual Geometry* clone() const=0;	/// Destroy Geometry and all components	virtual ~Geometry();	/**	 * \brief	 * Gets the factory which contains the context in which this	 * geometry was created.	 *	 * @return the factory for this geometry	 */	const GeometryFactory* getFactory() const { return factory; }	/**	* \brief	* A simple scheme for applications to add their own custom data to	* a Geometry.	* An example use might be to add an object representing a	* Coordinate Reference System.	* 	* Note that user data objects are not present in geometries created	* by construction methods.	*	* @param newUserData an object, the semantics for which are	* defined by the application using this Geometry	*/	void setUserData(void* newUserData) { userData=newUserData; }	/**	* \brief	* Gets the user data object for this geometry, if any.	*	* @return the user data object, or <code>null</code> if none set	*/	void* getUserData() { return userData; }	/*	 * \brief	 * Returns the ID of the Spatial Reference System used by the	 * <code>Geometry</code>.	 *	 * GEOS supports Spatial Reference System information in the simple way	 * defined in the SFS. A Spatial Reference System ID (SRID) is present	 * in each <code>Geometry</code> object. <code>Geometry</code>	 * provides basic accessor operations for this field, but no others.	 * The SRID is represented as an integer.	 *	 * @return the ID of the coordinate space in which the	 * <code>Geometry</code> is defined.	 *	 */	virtual int getSRID() const { return SRID; }	/*	 * Sets the ID of the Spatial Reference System used by the	 * <code>Geometry</code>.	 */	virtual void setSRID(int newSRID) { SRID=newSRID; }	/**	 * \brief	 * Get the PrecisionModel used to create this Geometry.	 */	const PrecisionModel* getPrecisionModel() const;	/// \brief	/// Returns a vertex of this Geometry,	/// or NULL if this is the empty geometry	///	virtual const Coordinate* getCoordinate() const=0; //Abstract	/**	 * \brief	 * Returns this Geometry vertices.	 * Caller takes ownership of the returned object.	 */	virtual CoordinateSequence* getCoordinates() const=0; //Abstract	/// Returns the count of this Geometrys vertices.	virtual size_t getNumPoints() const=0; //Abstract	/// Returns false if the Geometry not simple.	virtual bool isSimple() const=0; //Abstract	/// Return a string representation of this Geometry type	virtual std::string getGeometryType() const=0; //Abstract	/// Return an integer representation of this Geometry type	virtual GeometryTypeId getGeometryTypeId() const=0; //Abstract	/// Returns the number of geometries in this collection	/// (or 1 if this is not a collection)	virtual size_t getNumGeometries() const { return 1; }	/// Returns a pointer to the nth Geometry int this collection	/// (or self if this is not a collection)	virtual const Geometry* getGeometryN(size_t /*n*/) const { return this; }	/**	 * \brief Tests the validity of this <code>Geometry</code>.	 *	 * Subclasses provide their own definition of "valid".	 *	 * @return <code>true</code> if this <code>Geometry</code> is valid	 *	 * @see IsValidOp	 */	virtual bool isValid() const;	/// Returns whether or not the set of points in this Geometry is empty.	virtual bool isEmpty() const=0; //Abstract	/// Returns the dimension of this Geometry (0=point, 1=line, 2=surface)	virtual Dimension::DimensionType getDimension() const=0; //Abstract	/**	 * \brief	 * Returns the boundary as a newly allocated Geometry object.	 *	 * Returned geometry is empty if this Geometry is empty.	 */	virtual Geometry* getBoundary() const=0; //Abstract	/// Returns the dimension of this Geometrys inherent boundary.	virtual int getBoundaryDimension() const=0; //Abstract	/// Returns this Geometrys bounding box.	virtual Geometry* getEnvelope() const;	/** \brief	 * Returns the minimum and maximum x and y values in this Geometry,	 * or a null Envelope if this Geometry is empty.	 */	virtual const Envelope* getEnvelopeInternal() const;	/**	 * \brief	 * Returns true if the DE-9IM intersection matrix for the	 * two Geometrys is FF*FF****.	 */	virtual bool disjoint(const Geometry *other) const;	/** \brief	 * Returns true if the DE-9IM intersection matrix for the two	 * Geometrys is FT*******, F**T***** or F***T****.	 */	virtual bool touches(const Geometry *other) const;	/// Returns true if disjoint returns false.	virtual bool intersects(const Geometry *g) const;	/**	 * \brief	 * Returns true if the DE-9IM intersection matrix for the two	 * Geometrys is T*T****** (for a point and a curve, a point and	 * an area or a line and an area) 0******** (for two curves).	 */	virtual bool crosses(const Geometry *g) const;	/** \brief	 * Returns true if the DE-9IM intersection matrix for the two	 * Geometrys is T*F**F***.	 */	virtual bool within(const Geometry *g) const;	/// Returns true if other.within(this) returns true.	virtual bool contains(const Geometry *g) const;	/** \brief	 * Returns true if the DE-9IM intersection matrix for the two	 * Geometrys is T*T***T** (for two points or two surfaces)	 * 1*T***T** (for two curves).	 */	virtual bool overlaps(const Geometry *g) const;	/**	 * \brief	 * Returns true if the elements in the DE-9IM intersection matrix	 * for the two Geometrys match the elements in intersectionPattern.	 *	 * IntersectionPattern elements may be: 0 1 2 T ( = 0, 1 or 2)	 * F ( = -1) * ( = -1, 0, 1 or 2).	 *	 * For more information on the DE-9IM, see the OpenGIS Simple	 * Features Specification.	 *	 * @throws util::IllegalArgumentException if either arg is a collection	 *	 */	virtual bool relate(const Geometry *g,			const std::string& intersectionPattern) const;	bool relate(const Geometry& g, const std::string& intersectionPattern) const	{		return relate(&g, intersectionPattern);	}	/// Returns the DE-9IM intersection matrix for the two Geometrys.	virtual IntersectionMatrix* relate(const Geometry *g) const;	IntersectionMatrix* relate(const Geometry &g) const {		return relate(&g);	}	/**	 * \brief	 * Returns true if the DE-9IM intersection matrix for the two	 * Geometrys is T*F**FFF*.	 */	virtual bool equals(const Geometry *g) const;	/** \brief	 * Returns <code>true</code> if this geometry covers the	 * specified geometry.	 * 	 * The <code>covers</code> predicate has the following	 * equivalent definitions:	 * 	 * - Every point of the other geometry is a point of this geometry.	 * - The DE-9IM Intersection Matrix for the two geometries is	 *    <code>T*****FF*</code>	 *    or <code>*T****FF*</code>	 *    or <code>***T**FF*</code>	 *    or <code>****T*FF*</code>	 * - <code>g.coveredBy(this)</code>	 *   (<code>covers</code> is the inverse of <code>coverdBy</code>)	 * 	 * Note the difference between <code>covers</code> and	 * <code>contains</code>	 * - <code>covers</code> is a more inclusive relation.	 * In particular, unlike <code>contains</code> it does not	 * distinguish between points in the boundary and in the interior	 * of geometries.	 * For most situations, <code>covers</code> should be used in	 * preference to <code>contains</code>.

⌨️ 快捷键说明

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