clsStruct.h 2.5 KB
#ifndef _clsStruct_H_
#define _clsStruct_H_
#include<vector>
namespace DmapCore_30
{
	class clsMalloc;
	class Rect;
	class clsStruct
	{
	public:
		clsStruct();
		~clsStruct();
		 enum StructType
		{
			Struct_Point = 0,
			Struct_Line = 1,
			Struct_MLine = 2,
			Struct_Polygon = 3,
			Struct_MPolygon = 4,
			Struct_Heat = 4
		};
		struct POINT
		{
			double x;
			double y;
		};
		struct POLY_STRUCT
		{
			int nPoint;
			POINT* pPoint;
			int nPartCount;
			clsMalloc* pPartStart;
			clsMalloc* pAllFieldName;
			clsMalloc* pAllFields;  //除shape之外的所有字段
		};
		
		struct LINE
		{
			int nPoint;
			POINT* p;
		};
		struct MLINE
		{
			int nLine;
			LINE* p;
		};
		struct POLYGON
		{
			int nRing;
			LINE* p;
		};
		struct MPOLYGON
		{
			int nPolygon;
			POLYGON* p;
		};

		static bool GetCenter(double& x, double& y, LINE* pLine);
		static bool GetCenter(double & x, double & y, MLINE* pMLine);
		static bool GetCenter(double& x, double& y, POLYGON* pPolygon);
		static bool GetCenter(double& x, double &y, MPOLYGON* pMPolygon);
		static bool GetGravity(double& x, double&y, LINE* pLine);
		static bool GetGravity(double&x, double&y, int& iIndex, LINE*pLine);
		static bool GetGravity(double& x, double&y, MLINE* pMLine);
		static bool GetGravity(double& x, double&y, int& iIndex, MLINE* pMLine);
		static bool GetGravity(double& x, double&y, POLYGON* pPolygon);
		static bool GetGravity(double& x, double&y, MPOLYGON* pMPolygon);
		static bool GetRingGravity(double& x, double & y, LINE* pRing);

		//获取起点线段,终点线段,中心点线段
		//不考虑一个multilinestring 有多条line
		static bool GetStart(MLINE*pMLine, double& x1, double&y1, double&x2, double&y2);
		static bool GetEnd(MLINE* pMLine, double&x1, double&y1, double&x2, double&y2);
		static bool GetCenter(MLINE* pMLine, double &x1, double&y1, double&x2, double&y2);
		static double GetLength(LINE* pLine);  //计算长度
		static double GetLength5(LINE* pLine, int & iPointIndex, double& beginX, double &beginY, double& dRadia,  int w, int h, double dw); //简单计算长度

		static double GetMaxRing(MPOLYGON* pMPolygon, int& iPolygonIndex, int& iRingIndex);
		static bool GetConvexRing(LINE* pRing, std::vector<double>&vX, std::vector<double>& vY);  //计算多边形凸壳
		static int GetNextConvexPointMin(LINE* pRing, int iPointIndexNow);
		static int GetNextConvexPointRotate(LINE* pRing, int iPointIndexNow, int iPointIndexLast);


		static bool GetIsInRing(LINE* pRing, double x, double y);
	};

}

#endif