#pragma 
#define CELL_WIDTH 0.3	//格子宽度，单位为米
#define SEND_CELL_INTERVAL 500
#define BRANCH_RANGE 6	//分支确认范围，单位为米
#define LAST_V_POWER 0.7
#define THIS_V_POWER 0.3
#define MAX_CHANGE_DIR_COUNTS 5
#define MAX_CELL_FORWARD_JUMP 15
#define MAX_IDLE_CELL_THRE 2			//怠速单员格阈值
#define FIT_RELIABILITY 0.7				//拟合数据权限
#define MAX_FIT_DATA_COUNTS 5			//最大拟合数据统计数
#define MAX_DIRECTION_COUNTS 5			//最大方向统计数

struct point{
	double x;
	double y;

	point(){
		x = y = 0;
	}

	point& operator=(point& p){
		x = p.x;
		y = p.y;

		return *this;
	}
};

struct ReaderInfo{
	int reader_id;
	double x;
	double y;
	double z;

	ReaderInfo(){
		reader_id = 0;
		x = y = z =0;
	}

	ReaderInfo& operator=(ReaderInfo& v){
		reader_id = v.reader_id;
		x = v.x;
		y = v.y;
		z = v.z;

		return *this;
	}

	bool operator<(ReaderInfo& v) const{
		if (abs(x-v.x) < 1E-2)
		{
			if (y < v.y)
			{
				return true;
			}else{
				return false;
			}
		}else{
			if (x < v.x)
			{
				return true;
			}else{
				return false;
			}
		}
	}
};

//格子信息20170705
class Cell{
public:
	Cell(){
		strSubjectReader = "";
		id = 0;
		nStep = 0;
		minReaderId = maxReaderId = 0;
		dataSource = 0;
		card_stamp_time = 0;
		isHasBranch = false;
		isFit = isOverThre = false;
		isChangePath = false;
		top.x = top.y = bottom.x = bottom.y = left.x = left.y = right.x = right.y = 0;

		::GetLocalTime(&deal_time);
		
		::GetLocalTime(&interval_time);
	}
	~Cell(){}

public:
	int id;				//格子id
	int minReaderId;	//此格子所属的分站路径中的最小分站
	int maxReaderId;	//此格子所属的分站路径中的最大分站
	int nStep;			//距离上一次格子的步进
	int dataSource;	    //数据来源，0为未知，1为定位算法生成,2为定时器内生成

	int card_stamp_time;	//卡的ct号

	std::string strSubjectReader;	//格子所属分站名称

	point top,bottom,left,right;	//格子的4个顶点位置
	
	bool isHasBranch;				//此格子附近是否有分支
	bool isFit;						//此格子是否是拟合出的结果
	bool isOverThre;				//是否越界，或者大跳
	bool isChangePath;				//是否切换分站

	SYSTEMTIME deal_time;			//格子的处理时间
	SYSTEMTIME interval_time;		//格子的0,500ms间隔时间

public:
	double getX(){
		return (this->top.x + this->bottom.x)/2;
	}
	double getY(){
		return (this->top.y + this->bottom.y)/2;
	}

public:
	Cell& operator=(Cell&c){
		id = c.id;
		nStep = c.nStep;
		minReaderId = c.minReaderId;
		maxReaderId = c.maxReaderId;
		strSubjectReader = c.strSubjectReader;
		dataSource = c.dataSource;
		top = c.top;
		bottom = c.bottom;
		left = c.left;
		right = c.right;
		isHasBranch = c.isHasBranch;
		isFit = c.isFit;
		card_stamp_time = c.card_stamp_time;
		isOverThre = c.isOverThre;
		isChangePath = c.isChangePath;
		deal_time = c.deal_time;
		//interval_time = c.interval_time;

		return *this;
	}
};