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

📄 geosalgorithm.h

📁 一个很好的vc代码
💻 H
📖 第 1 页 / 共 2 页
字号:
 * Computes the topological relationship (Location) * of a single point to a Geometry. * * The algorithm obeys the SFS boundaryDetermination rule to correctly determine * whether the point lies on the boundary or not. * Note that instances of this class are not reentrant. * @version 1.3 */class PointLocator {public:	PointLocator();	~PointLocator();	int locate(const Coordinate& p,const Geometry *geom);	bool intersects(const Coordinate& p,const Geometry *geom);	int locate(const Coordinate& p,const LineString *l);	int locate(const Coordinate& p,const LinearRing *ring);	int locate(const Coordinate& p,const Polygon *poly);private:	bool isIn;         // true if the point lies in or on any Geometry element	int numBoundaries;    // the number of sub-elements whose boundaries the point lies in	void computeLocation(const Coordinate& p,const Geometry *geom);	void updateLocationInfo(int loc);};class MCPointInRing: public PointInRing {public:	MCPointInRing(LinearRing *newRing);	virtual ~MCPointInRing();	bool isInside(const Coordinate& pt);	void testLineSegment(Coordinate& p,LineSegment *seg);	class MCSelecter: public MonotoneChainSelectAction {	private:		Coordinate p;		MCPointInRing *parent;	public:		MCSelecter(const Coordinate& newP,MCPointInRing *prt);	    void select(LineSegment *ls);	};private:	LinearRing *ring;	BinTreeInterval *interval;	CoordinateSequence *pts;	Bintree *tree;	int crossings;  // number of segment/ray crossings	void buildIndex();	void testMonotoneChain(Envelope *rayEnv,MCSelecter *mcSelecter,indexMonotoneChain *mc);};class SIRtreePointInRing: public PointInRing {private:	LinearRing *ring;	SIRtree *sirTree;	int crossings;  // number of segment/ray crossings	void buildIndex();	void testLineSegment(const Coordinate& p,LineSegment *seg);public:	SIRtreePointInRing(LinearRing *newRing);	bool isInside(const Coordinate& pt);};class CentroidPoint {private:	int ptCount;	Coordinate* centSum;public:	CentroidPoint();	virtual ~CentroidPoint();	void add(const Geometry *geom);	void add(const Coordinate *pt);	Coordinate* getCentroid() const;};class CentroidLine {private:	Coordinate* centSum;	double totalLength;public:	CentroidLine();	virtual ~CentroidLine();	void add(const Geometry *geom);	void add(const CoordinateSequence *pts);	Coordinate* getCentroid() const;};/* * \class CentroidArea geosAlgorithm.h geos/geosAlgorithm.h * * \brief Computes the centroid of an area geometry. * * Algorithm: * * Based on the usual algorithm for calculating * the centroid as a weighted sum of the centroids * of a decomposition of the area into (possibly overlapping) triangles. * The algorithm has been extended to handle holes and multi-polygons. * See <code>http://www.faqs.org/faqs/graphics/algorithms-faq/</code> * for further details of the basic approach. */class CentroidArea {public:	CentroidArea();	virtual ~CentroidArea();	void add(const Geometry *geom);	void add(const CoordinateSequence *ring);	Coordinate* getCentroid() const;private:	CGAlgorithms *cga;	Coordinate* basePt;// the point all triangles are based at	Coordinate* triangleCent3;// temporary variable to hold centroid of triangle	double areasum2;        /* Partial area sum */	Coordinate* cg3; // partial centroid sum	void setBasePoint(const Coordinate *newbasePt);	void add(const Polygon *poly);	void addShell(const CoordinateSequence *pts);	void addHole(const CoordinateSequence *pts);	inline void addTriangle(const Coordinate &p0, const Coordinate &p1, const Coordinate &p2,bool isPositiveArea);	static inline  void centroid3(const Coordinate &p1,const Coordinate &p2,const Coordinate &p3,Coordinate *c);	static inline double area2(const Coordinate &p1,const Coordinate &p2,const Coordinate &p3);};/* * \class InteriorPointPoint geosAlgorithm.h geos/geosAlgorithm.h * \brief * Computes a point in the interior of an point geometry. * * Algorithm: * * Find a point which is closest to the centroid of the geometry. */class InteriorPointPoint {private:	const Coordinate* centroid;	double minDistance;	Coordinate *interiorPoint;	void add(const Geometry *geom);	void add(const Coordinate *point);public:	InteriorPointPoint(const Geometry *g);	virtual	~InteriorPointPoint();	Coordinate* getInteriorPoint() const;};/* * Computes a point in the interior of an linear geometry. * <h2>Algorithm</h2> * <ul> * <li>Find an interior vertex which is closest to * the centroid of the linestring. * <li>If there is no interior vertex, find the endpoint which is * closest to the centroid. * </ul> */class InteriorPointLine {public:	InteriorPointLine(Geometry *g);	virtual ~InteriorPointLine();	Coordinate* getInteriorPoint() const;private:	const Coordinate *centroid;	double minDistance;	Coordinate *interiorPoint;	void addInterior(const Geometry *geom);	void addInterior(const CoordinateSequence *pts);	void addEndpoints(const Geometry *geom);	void addEndpoints(const CoordinateSequence *pts);	void add(const Coordinate *point);};/* * Computes a point in the interior of an area geometry. * * <h2>Algorithm</h2> * <ul> *   <li>Find the intersections between the geometry *       and the horizontal bisector of the area's envelope *   <li>Pick the midpoint of the largest intersection (the intersections *       will be lines and points) * </ul> * * <b> * Note: If a fixed precision model is used, * in some cases this method may return a point * which does not lie in the interior. * </b> */class InteriorPointArea {private:	static double avg(double a, double b);	const GeometryFactory *factory;	Coordinate *interiorPoint;	double maxWidth;	void add(const Geometry *geom);public:	InteriorPointArea(const Geometry *g);	virtual ~InteriorPointArea();	Coordinate* getInteriorPoint() const;	void addPolygon(const Geometry *geometry);	Coordinate* centre(const Envelope *envelope) const;protected:	const Geometry *widestGeometry(const Geometry *geometry);	const Geometry *widestGeometry(const GeometryCollection *gc);	LineString *horizontalBisector(const Geometry *geometry);};class BigQuad {public:	Coordinate northmost;	Coordinate southmost;	Coordinate westmost;	Coordinate eastmost;};class ConvexHull {private:	PointLocator *pointLocator;	//CGAlgorithms *cgAlgorithms;	const Geometry *geometry;	const GeometryFactory *factory;	CoordinateSequence* reduce(const CoordinateSequence *pts);	CoordinateSequence* preSort(CoordinateSequence *pts);	CoordinateSequence* grahamScan(const CoordinateSequence *c);	void radialSort(CoordinateSequence *p);	int polarCompare(Coordinate o, Coordinate p, Coordinate q);	bool isBetween(Coordinate c1, Coordinate c2, Coordinate c3);    BigQuad* makeBigQuad(const CoordinateSequence *pts);	Geometry* lineOrPolygon(CoordinateSequence *newCoordinates);	CoordinateSequence* cleanRing(CoordinateSequence *original);public:	ConvexHull(const Geometry *newGeometry);	~ConvexHull();	Geometry* getConvexHull();};/* * Computes the minimum diameter of a {@link Geometry}. * The minimum diameter is defined to be the * width of the smallest band that * contains the geometry, * where a band is a strip of the plane defined * by two parallel lines. * This can be thought of as the smallest hole that the geometry can be * moved through, with a single rotation. * <p> * The first step in the algorithm is computing the convex hull of the Geometry. * If the input Geometry is known to be convex, a hint can be supplied to * avoid this computation. * * @see ConvexHull * */class MinimumDiameter {private:	const Geometry* inputGeom;	bool isConvex;	LineSegment* minBaseSeg;	Coordinate* minWidthPt;	int minPtIndex;	double minWidth;	void computeMinimumDiameter();	void computeWidthConvex(const Geometry* geom);	/**	* Compute the width information for a ring of {@link Coordinate}s.	* Leaves the width information in the instance variables.	*	* @param pts	* @return	*/	void computeConvexRingMinDiameter(const CoordinateSequence *pts);	int findMaxPerpDistance(const CoordinateSequence* pts, LineSegment* seg, int startIndex);	static int getNextIndex(const CoordinateSequence* pts, int index);public:	~MinimumDiameter();	/**	* Compute a minimum diameter for a giver {@link Geometry}.	*	* @param geom a Geometry	*/	MinimumDiameter(const Geometry* newInputGeom);	/**	* Compute a minimum diameter for a giver {@link Geometry},	* with a hint if	* the Geometry is convex	* (e.g. a convex Polygon or LinearRing,	* or a two-point LineString, or a Point).	*	* @param geom a Geometry which is convex	* @param isConvex <code>true</code> if the input geometry is convex	*/	MinimumDiameter(const Geometry* newInputGeom,const bool newIsConvex);	/**	* Gets the length of the minimum diameter of the input Geometry	*	* @return the length of the minimum diameter	*/	double getLength();	/**	* Gets the {@link Coordinate} forming one end of the minimum diameter	*	* @return a coordinate forming one end of the minimum diameter	*/	Coordinate* getWidthCoordinate();	/**	* Gets the segment forming the base of the minimum diameter	*	* @return the segment forming the base of the minimum diameter	*/	LineString* getSupportingSegment();	/**	* Gets a {@link LineString} which is a minimum diameter	*	* @return a {@link LineString} which is a minimum diameter	*/	LineString* getDiameter();};} // namespace geos#endif/********************************************************************** * $Log: geosAlgorithm.h,v $ * Revision 1.9.2.1  2005/05/23 16:39:05  strk * log lines moved at bottom file, added Refractions copyright * * Revision 1.9  2004/11/23 19:53:07  strk * Had LineIntersector compute Z by interpolation. * * Revision 1.8  2004/11/06 08:16:46  strk * Fixed CGAlgorithms::isCCW from JTS port. * Code cleanup in IsValidOp. * * Revision 1.7  2004/10/21 22:29:54  strk * Indentation changes and some more COMPUTE_Z rules * * Revision 1.6  2004/09/13 10:12:49  strk * Added invalid coordinates checks in IsValidOp. * Cleanups. * **********************************************************************/

⌨️ 快捷键说明

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