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

📄 geom.h

📁 一个很好的vc代码
💻 H
📖 第 1 页 / 共 5 页
字号:
	}	int Coordinate::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;	}	bool Coordinate::equals3D(const Coordinate& other) const {		return (x == other.x) && ( y == other.y) && ((z == other.z)||(ISNAN(z) && ISNAN(other.z)));	}	void Coordinate::makePrecise(const PrecisionModel *precisionModel) {		x = precisionModel->makePrecise(x);		y = precisionModel->makePrecise(y);	}	double Coordinate::distance(const Coordinate& p) const {		double dx = x - p.x;		double dy = y - p.y;		return sqrt(dx * dx + dy * dy);	}	int Coordinate::hashCode() {		//Algorithm from Effective Java by Joshua Bloch [Jon Aquino]		int result = 17;		result = 37 * result + hashCode(x);		result = 37 * result + hashCode(y);		return result;	}	/**	* Returns a hash code for a double value, using the algorithm from	* Joshua Bloch's book <i>Effective Java</i>	*/	static int Coordinate::hashCode(double x) {		int64 f = (int64)(x);		return (int)(f^(f>>32));	}	/// x-coordinate	double x;	/// y-coordinate	double y;	/// z-coordinate	double z;private:#ifdef INT64_CONST_IS_I64	static const int64 serialVersionUID=6683108902428366910I64;#else	static const int64 serialVersionUID=6683108902428366910LL;#endif};//* class CoordinateList geom.h geos.h//*//* brief A list of Coordinates, which may be set to prevent//* repeated coordinates from occuring in the list.////class CoordinateList {//public://	~CoordinateList(){};////	// copy constructor//	CoordinateList(const CoordinateList &cl);////	// constructor an empty CoordinateList//	CoordinateList();////	/*//	 * Constructs a new list from a vector of Coordinates.//	 * Caller can specify if repeated points are to be removed.//	 * Default is allowing repeated points.//	 * Will take ownership of coords.//	 *///	CoordinateList(vector<Coordinate> *coords, bool allowRepeted=false);////	// Get a reference to the nth Coordinate //	const Coordinate& getCoordinate(int n) const;////	/*//	 * \brief Add an array of coordinates //	 * @param vc The coordinates//	 * @param allowRepeated if set to false, repeated coordinates//	 * 	are collapsed//	 * @return true (as by general collection contract)//	 *///	void add(vector<Coordinate>* vc, bool allowRepeated);////	/*//	 * \brief Add an array of coordinates //	 * @param cl The coordinates//	 * @param allowRepeated if set to false, repeated coordinates//	 * are collapsed//	 * @param direction if false, the array is added in reverse order//	 * @return true (as by general collection contract)//	 *///	void add(CoordinateList *cl,bool allowRepeated,bool direction);////	/*//	 * \brief Add a coordinate//	 * @param c The coordinate to add//	 * @param allowRepeated if set to false, repeated coordinates//	 * are collapsed//	 * @return true (as by general collection contract)//	 *///	void add(const Coordinate& c,bool allowRepeated);////	// Add a Coordinate to the list//	void add(const Coordinate& c);////	// Get vector//	const vector<Coordinate>* toCoordinateArray() const;////private:////	vector<Coordinate> *vect;//};/** * \class CoordinateSequence geom.h geos.h * * \brief * The internal representation of a list of coordinates inside a Geometry. * * There are some cases in which you might want Geometries to store their * points using something other than the GEOS Coordinate class. For example, you * may want to experiment with another implementation, such as an array of Xs * and an array of Ys. or you might want to use your own coordinate class, one * that supports extra attributes like M-values. *  * You can do this by implementing the CoordinateSequence and * CoordinateSequenceFactory interfaces. You would then create a * GeometryFactory parameterized by your CoordinateSequenceFactory, and use * this GeometryFactory to create new Geometries. All of these new Geometries * will use your CoordinateSequence implementation. *  */class CoordinateSequence {public:	virtual ~CoordinateSequence(){};	/** \brief	 * Returns a deep copy of this collection.	 */	virtual CoordinateSequence *clone() const=0;	/** \brief	 * Returns a read-only reference to Coordinate at position i.	 *	 * Whether or not the Coordinate returned is the actual underlying	 * Coordinate or merely a copy depends on the implementation.	 */	//virtual const Coordinate& getCoordinate(int i) const=0;	virtual const Coordinate& getAt(int i) const=0;	/** \brief	 * Returns the number of Coordinates (actual or otherwise, as	 * this implementation may not store its data in Coordinate objects).	 */	//virtual int size() const=0;	virtual int getSize() const=0;	/** \brief	 * Returns a read-only vector with the Coordinates in this collection.	 *	 * Whether or not the Coordinates returned are the actual underlying	 * Coordinates or merely copies depends on the implementation.	 * Note that if this implementation does not store its data as an	 * array of Coordinates, this method will incur a performance penalty	 * because the array needs to be built from scratch.	 */	virtual	const vector<Coordinate>* toVector() const=0;	/**	 * \brief Add an array of coordinates 	 * @param vc The coordinates	 * @param allowRepeated if set to false, repeated coordinates	 * 	are collapsed	 * @return true (as by general collection contract)	 */	void add(const vector<Coordinate>* vc, bool allowRepeated);	/* This is here for backward compatibility.. */	void add(CoordinateSequence *cl,bool allowRepeated,bool direction);	/**	 * \brief Add an array of coordinates 	 * @param cl The coordinates	 * @param allowRepeated if set to false, repeated coordinates	 * are collapsed	 * @param direction if false, the array is added in reverse order	 * @return true (as by general collection contract)	 */	void add(const CoordinateSequence *cl,bool allowRepeated,bool direction);	/**	 * \brief Add a coordinate	 * @param c The coordinate to add	 * @param allowRepeated if set to false, repeated coordinates	 * are collapsed	 * @return true (as by general collection contract)	 */	void add(const Coordinate& c,bool allowRepeated);	/// Returns <code>true</code> it list contains no coordinates.	virtual	bool isEmpty() const=0;	/// Add a Coordinate to the list	virtual	void add(const Coordinate& c)=0;	// Get number of coordinates	//virtual int getSize() const=0;	/// Get a reference to Coordinate at position pos	//virtual	const Coordinate& getAt(int pos) const=0;	/// Copy Coordinate c to position pos	virtual	void setAt(const Coordinate& c, int pos)=0;	/// Delete Coordinate at position pos (list will shrink).	virtual	void deleteAt(int pos)=0;	/// Get a string rapresentation of CoordinateSequence	virtual	string toString() const=0;	/// Substitute Coordinate list with a copy of the given vector	virtual	void setPoints(const vector<Coordinate> &v)=0;		/// Returns true if contains any two consecutive points 	bool hasRepeatedPoints() const;	/// Returns lower-left Coordinate in list	const Coordinate* minCoordinate() const;	/// Returns a new CoordinateSequence being a copy of the input with any consecutive equal Coordinate removed.	static CoordinateSequence* removeRepeatedPoints(const CoordinateSequence *cl);	/**	* \brief Returns true if given CoordinateSequence contains	* any two consecutive Coordinate 	*/	static bool hasRepeatedPoints(const CoordinateSequence *cl);	/**	* \brief Returns either the given CoordinateSequence if its length	* is greater than the given amount, or an empty CoordinateSequence.	*/	static CoordinateSequence* atLeastNCoordinatesOrNothing(int n, CoordinateSequence *c);	/**	 * \brief Returns lower-left Coordinate in given CoordinateSequence.	 * This is actually the Coordinate with lower X (and Y if needed)	 * ordinate.	 */	static const Coordinate* minCoordinate(CoordinateSequence *cl);	/// Return position of a Coordinate, or -1 if not found	static int indexOf(const Coordinate *coordinate, const CoordinateSequence *cl);	/**	* \brief	* Returns true if the two arrays are identical, both null,	* or pointwise equal 	*/	static bool equals(CoordinateSequence *cl1, CoordinateSequence *cl2);	/// Scroll given CoordinateSequence so to start with given Coordinate.	static void scroll(CoordinateSequence *cl, const Coordinate *firstCoordinate);	/// Reverse Coordinate order in given CoordinateSequence	static void reverse(CoordinateSequence *cl);};/** * \class DefaultCoordinateSequence geom.h geos.h * * \brief The default implementation of CoordinateSequence */class DefaultCoordinateSequence : public CoordinateSequence {public:	DefaultCoordinateSequence(const DefaultCoordinateSequence &cl);	CoordinateSequence *clone() const;	//const Coordinate& getCoordinate(int pos) const;	const Coordinate& getAt(int pos) const;	//int size() const;	int getSize() const;	const vector<Coordinate>* toVector() const;	/// Construct an empty sequence	DefaultCoordinateSequence();	/// Construct sequence taking ownership of given Coordinate vector	DefaultCoordinateSequence(vector<Coordinate> *coords);	/// Construct sequence allocating space for n coordinates	DefaultCoordinateSequence(int n);	virtual ~DefaultCoordinateSequence();	bool isEmpty() const;	void add(const Coordinate& c);	void setAt(const Coordinate& c, int pos);	void deleteAt(int pos);	string toString() const;	void setPoints(const vector<Coordinate> &v);private:	vector<Coordinate> *vect;};struct point_3d {	double x;	double y;	double z;};class PointCoordinateSequence : public CoordinateSequence {public:	PointCoordinateSequence();	PointCoordinateSequence(int n);	PointCoordinateSequence(const Coordinate& c);	PointCoordinateSequence(const PointCoordinateSequence &cl);	PointCoordinateSequence(const CoordinateSequence *c);	virtual ~PointCoordinateSequence();	CoordinateSequence *clone() const;	bool isEmpty() const;	void add(const Coordinate& c);	void add(point_3d p);	int getSize() const;	const Coordinate& getAt(int pos) const;	point_3d getPointAt(int pos);	void setAt(const Coordinate& c, int pos);	void setAt(point_3d p, int pos);	void deleteAt(int pos);	const vector<Coordinate>* toVector() const;	vector<point_3d>* toPointVector();	string toString() const;	void setPoints(const vector<Coordinate> &v);	void setPoints(vector<point_3d> &v);private:	vector<point_3d> *vect;	mutable vector<Coordinate>*cached_vector;};/** * \class CoordinateSequenceFactory geom.h geos.h * * \brief * An object that knows how to build a particular implementation of * CoordinateSequence from an array of Coordinates. */class CoordinateSequenceFactory {public:	// create an empty CoordinateSequence	//virtual CoordinateSequence* createCoordinateSequence()=0;	// create an empty CoordinateSequence with 'size' Coordinate slots	//virtual CoordinateSequence* createCoordinateSequence(int size)=0;	//virtual CoordinateSequence* createCoordinateSequence(const Coordinate& c)=0;	// create an CoordinateSequence containing the given Coordinate 	//virtual CoordinateSequence* createCoordinateSequence(const CoordinateSequence *c)=0;	/** \brief	 * Returns a CoordinateSequence based on the given array.	 * Whether or not the vector is copied is implementation-dependent,	 * for this reason caller does give up ownership of it.	 * Implementations that will not copy it will need take care	 * of deleting it.	 * Note that a NULL value is allowed as coordinates, and will	 * create an empty CoordinateSequence.	 */	virtual CoordinateSequence *create(vector<Coordinate> *coordinates) const=0;};/** * \class DefaultCoordinateSequenceFactory geom.h geos.h * * \brief * Creates CoordinateSequences internally represented as an array of * Coordinates. */class DefaultCoordinateSequenceFactory: public CoordinateSequenceFactory {public:	// create an empty DefaultCoordinateSequence

⌨️ 快捷键说明

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