#include "StdAfx.h"
#include "DrawRoad.h"

int tarray_BX;  //平面线元数
double array_BX[150][10]; //平面线元
double JDarray_BX[100][7];  // 1->N,2->E,7.超高
int ShowLWRMes = 1;//显示路网半径信息
int ShowLWZXMes = 1;//显示路网中线信息

vector<DPoint3d>Road_BX1_ForStarEnd;
vector<DPoint3d>Road_BX2_ForStarEnd;

CDrawRoad::CDrawRoad() {
}

CDrawRoad::CDrawRoad(Road RoadData)
{
	RoadData.isshowBJ = ShowLWRMes;
	RoadData.isshowZX = ShowLWZXMes;
	isDrawPDB = 1;
	isIniRdaious = 1;
	m_RoadData.push_back(RoadData);
}

CDrawRoad::CDrawRoad(vector<Road> RoadData)
{
	m_RoadData.clear();
	m_RoadData = RoadData;
	isIniRdaious = 1;
	//for(int i=0;i<(int)m_RoadData.size();i++)
	//{
	//	m_RoadData[i].isshowBJ = ShowLWRMes;
	//	m_RoadData[i].isshowZX = ShowLWZXMes;
	//}
}

CDrawRoad::~CDrawRoad()
{
	//m_RoadDataCheck.clear();
}

void CDrawRoad::CheckRD(Road rd1, vector<vector<Road>>& RD)
{
	vector<Road>RDCheck;
	for (int i = 0; i < (int)RD.size(); i++)
	{
		for (int j = 0; j < (int)RD[i].size(); j++)
		{
			if (_tcscmp(RD[i][j].BianHaoIn, rd1.BianHaoIn) == 0)
			{
				RD[i].push_back(rd1);
				return;
			}
		}

	}
	RDCheck.push_back(rd1);
	RD.push_back(RDCheck);
}

double CDrawRoad::cal_T_ang(vector<JDdata> JDARRAY, int j, double& ANG)
{
	ANG = 0;
	if (JDARRAY.size() == 0)
		return 0;

	if (j == 0 || j == JDARRAY.size() - 1)
		return 0;


	double fb, fe;
	xyddaa(JDARRAY[j - 1].y, JDARRAY[j - 1].x, JDARRAY[j].y, JDARRAY[j].x, &fb);
	xyddaa(JDARRAY[j].y, JDARRAY[j].x, JDARRAY[j + 1].y, JDARRAY[j + 1].x, &fe);
	double aa = ZXJ(fe, fb);

	//切线长
	ANG = PI - fabs(aa);
	double T;
	T = JDARRAY[j].R / tan(ANG / 2.0);
	return T;
}

//检测道路边线数据
void CDrawRoad::CheckRDBX(vector<JDdata>& JDARRAY, int isZX)
{
	if (JDARRAY.size() <= 2)
		return;

	double fb, fe, dis;
	//三点共线则删除中间点（角度误差取0.01合适否？）
	DVec3d vec1, vec2;
	for (int j = 1; j < (int)JDARRAY.size() - 1; j++)
	{
		if (isZX == 1)
		{
			if (fabs(JDARRAY[j].kuandu_left - JDARRAY[j - 1].kuandu_left) > 0.01 ||
				fabs(JDARRAY[j].kuandu_right - JDARRAY[j - 1].kuandu_right) > 0.01)
				continue;
		}
		vec1 = DVec3d::From(JDARRAY[j].x - JDARRAY[j - 1].x, JDARRAY[j].y - JDARRAY[j - 1].y, 0);
		vec1.Normalize();
		vec2 = DVec3d::From(JDARRAY[j + 1].x - JDARRAY[j].x, JDARRAY[j + 1].y - JDARRAY[j].y, 0);
		vec2.Normalize();
		double  ANG = vec1.AngleTo(vec2);

		if (fabs(ANG) < 0.01 || fabs(ANG - PI) < 0.01)
		{
			JDARRAY.erase(JDARRAY.begin() + j);
			j--;
		}
	}

	if (JDARRAY.size() <= 2)
		return;
	//两点间距过小视为重复，剔除中间点
	double len;
	for (int j = 0; j < (int)JDARRAY.size() - 1; j++)
	{
		len = sqrt(pow(JDARRAY[j].x - JDARRAY[j + 1].x, 2)
			+ pow(JDARRAY[j].y - JDARRAY[j + 1].y, 2));
		if (fabs(len) < 0.1)
		{
			JDARRAY.erase(JDARRAY.begin() + j + 1);
			j--;
		}
	}

	//检测半径是否过大
	double len1, len2;
	double T1, T2;
	double ANG1, ANG2;
	if (JDARRAY.size() <= 3) // 三点以内无需修正（三点道路需比较直线段与切线长）
	{
		if (JDARRAY.size() == 3)
		{
			//两条边的长度
			len1 = sqrt(pow(JDARRAY[0].x - JDARRAY[1].x, 2)
				+ pow(JDARRAY[0].y - JDARRAY[1].y, 2));
			len2 = sqrt(pow(JDARRAY[1].x - JDARRAY[2].x, 2)
				+ pow(JDARRAY[1].y - JDARRAY[2].y, 2));

			//如果切线长>边线长 修正半径
			T1 = cal_T_ang(JDARRAY, 1, ANG1);

			if (len1 > len2)
			{
				if (T1 > len2)
					JDARRAY[1].R = tan(ANG1 / 2.0) * len2;
			}
			else
			{
				if (T1 > len1)
					JDARRAY[1].R = tan(ANG1 / 2.0) * len1;
			}
		}
		return;
	}

	if (JDARRAY.size() <= 5) // 4,5点数为何不考虑？？？？？
		return;
	// 起终点间距
	dis = sqrt(pow(JDARRAY[0].x - JDARRAY[(int)JDARRAY.size() - 1].x, 2.0)
		+ pow(JDARRAY[0].y - JDARRAY[(int)JDARRAY.size() - 1].y, 2.0));

	xyddaa(JDARRAY[0].y, JDARRAY[0].x, JDARRAY[1].y, JDARRAY[1].x, &fb);
	xyddaa(JDARRAY[(int)JDARRAY.size() - 2].y, JDARRAY[(int)JDARRAY.size() - 2].x, JDARRAY[(int)JDARRAY.size() - 1].y, JDARRAY[(int)JDARRAY.size() - 1].x, &fe);

	//如果首尾相连 并且方位角相同 为保险起见 调整首尾位置
	if (fabs(dis) < 0.01 && fabs(fe - fb) < 0.01)
	{
		double xtmp, ytmp;
		xtmp = (JDARRAY[1].x + JDARRAY[(int)JDARRAY.size() - 2].x) / 2.0;
		ytmp = (JDARRAY[1].y + JDARRAY[(int)JDARRAY.size() - 2].y) / 2.0;
		JDARRAY[0].x = xtmp;
		JDARRAY[0].y = ytmp;
		JDARRAY[(int)JDARRAY.size() - 1].x = xtmp;
		JDARRAY[(int)JDARRAY.size() - 1].y = ytmp;
	}

	//检测边线转角处的半径切点是否会超出该边线
	for (int j = 1; j < (int)JDARRAY.size() - 1; j++)
	{
		//两条边的长度
		len1 = sqrt(pow(JDARRAY[j].x - JDARRAY[j - 1].x, 2)
			+ pow(JDARRAY[j].y - JDARRAY[j - 1].y, 2));
		len2 = sqrt(pow(JDARRAY[j + 1].x - JDARRAY[j].x, 2)
			+ pow(JDARRAY[j + 1].y - JDARRAY[j].y, 2));


		//如果切线长>边线长 删除该交点
		double inx, iny;
		if (len1 > len2)
		{
			T1 = cal_T_ang(JDARRAY, j, ANG1);
			T2 = cal_T_ang(JDARRAY, j + 1, ANG2);
			if (T1 > len2 || T2 > len2)
			{
				if (j + 2 < JDARRAY.size())
				{
					//重新计算交点坐标
					INTERS(&inx, &iny, JDARRAY[j - 1].x, JDARRAY[j - 1].y,
						JDARRAY[j].x, JDARRAY[j].y,
						JDARRAY[j + 1].x, JDARRAY[j + 1].y,
						JDARRAY[j + 2].x, JDARRAY[j + 2].y);

					JDARRAY[j].x = inx;
					JDARRAY[j].y = iny;

					JDARRAY.erase(JDARRAY.begin() + j + 1);
					j--;
				}
				else
				{
					JDARRAY[(int)JDARRAY.size() - 2].R = tan(ANG1 / 2.0) * len2;
				}
			}
			//调整小者
			else if (T1 + T2 > len2)
			{
				double xleft = 0;
				if (T1 > T2)
				{
					xleft = len2 - T1;
					JDARRAY[j + 1].R = tan(ANG2 / 2.0) * xleft;
				}
				else
				{
					xleft = len2 - T2;
					JDARRAY[j].R = tan(ANG1 / 2.0) * xleft;
				}
			}
		}
		else
		{
			T1 = cal_T_ang(JDARRAY, j - 1, ANG1);
			T2 = cal_T_ang(JDARRAY, j, ANG2);
			if (T1 > len1 || T2 > len1)
			{
				if (j > 2)
				{
					//重新计算交点坐标
					INTERS(&inx, &iny, JDARRAY[j - 2].x, JDARRAY[j - 2].y,
						JDARRAY[j - 1].x, JDARRAY[j - 1].y,
						JDARRAY[j].x, JDARRAY[j].y,
						JDARRAY[j + 1].x, JDARRAY[j + 1].y);

					JDARRAY[j - 1].x = inx;
					JDARRAY[j - 1].y = iny;

					JDARRAY.erase(JDARRAY.begin() + j);
					j--;
				}
				else
				{
					JDARRAY[j].R = tan(ANG2 / 2.0) * len1;
				}
			}
			//调整小者
			else if (T1 + T2 > len1)
			{
				double xleft = 0;
				if (T1 > T2)
				{
					xleft = len2 - T1;
					JDARRAY[j].R = tan(ANG2 / 2.0) * xleft;
				}
				else
				{
					xleft = len2 - T2;
					JDARRAY[j - 1].R = tan(ANG1 / 2.0) * xleft;
				}
			}
		}
	}
}

int CDrawRoad::CheckZiJiao(vector <JDdata> JD)
{
	int res;
	double x, y;
	if (JD.size() <= 2)
		return -1;
	//闭合
	if (fabs(JD[0].x - JD[(int)JD.size() - 1].x) < 0.001 && fabs(JD[0].y - JD[(int)JD.size() - 1].y) < 0.001)
	{
		double f1, f2;
		//判断起始点位于何处，若首尾不平行，移动虚拟交点
		xyddaa(JD[0].x, JD[0].y, JD[1].x, JD[1].y, f1);
		xyddaa(JD[(int)JD.size() - 2].x, JD[(int)JD.size() - 2].y, JD[(int)JD.size() - 1].x, JD[(int)JD.size() - 1].y, f2);
		if (fabs(f1 - f2) < 0.001)
			return -1;
		else
			return (int)JD.size() - 1;
	}

	if (JD.size() <= 3)
		return -1;
	for (int i = 0; i < (int)JD.size() - 3; i++)
	{
		for (int j = i + 2; j < (int)JD.size() - 1; j++)
		{
			res = INTERS(&x, &y, JD[i].x, JD[i].y, JD[i + 1].x, JD[i + 1].y, JD[j].x, JD[j].y, JD[j + 1].x, JD[j + 1].y);
			if (res == 0)
				return i;
		}
	}
	return -1;
}

int CDrawRoad::getBPMTL(double a, double R, double L1, double L2, double* BPMTL) const
{
	// BPTL[9]=B1,B2,P1,P2,M1,M2,T1,T2,L
	double A1, A2, aa, B1, B2, P1, P2, M1, M2, T1, T2, LS;
	A1 = sqrt(R * L1); A2 = sqrt(R * L2);
	aa = rad(a);

	if (R > 1.0e-6)
	{
		B1 = L1 * 0.5 / R;
		B2 = L2 * 0.5 / R;
	}
	else
	{
		B1 = 0;
		B2 = 0;
	}


	if (L1 < 0.0001) { P1 = 0.0; M1 = 0.0; }
	else { P1 = spiral_p(A1, L1); M1 = spiral_xm(A1, L1); };
	if (L2 < 0.0001) { P2 = 0.0; M2 = 0.0; }
	else { P2 = spiral_p(A2, L2); M2 = spiral_xm(A2, L2); };
	// P1=spiral_p(A1,L1);P2=spiral_p(A2,L2);//P1,P2
	// M1=spiral_xm(A1,L1);M2=spiral_xm(A2,L2);// M1,M2

	if (fabs(aa) > 1.0e-6)
	{
		T1 = (R + P1) * tan(aa * 0.5) + M1 - (P1 - P2) / sin(aa);
		T2 = (R + P2) * tan(aa * 0.5) + M2 + (P1 - P2) / sin(aa);
	}
	else
	{
		T1 = 0;
		T2 = 0;
	}

	LS = (aa - B1 - B2) * R + L1 + L2;
	*(BPMTL + 0) = B1;
	*(BPMTL + 1) = B2;
	*(BPMTL + 2) = P1;
	*(BPMTL + 3) = P2;
	*(BPMTL + 4) = M1;
	*(BPMTL + 5) = M2;
	*(BPMTL + 6) = T1;
	*(BPMTL + 7) = T2;
	*(BPMTL + 8) = LS;
	return(1);
}

bool CDrawRoad::TrsCmltoNE(double Cml, xlpoint& PZ, Road m_road)
{
	PZ.lc = Cml;
	xlpoint_pz(m_road.array, m_road.tarray, &PZ);
	return true;
}

bool CDrawRoad::TrsCmltoNE(double Cml, xlpoint& PZ, Road_BX m_road)
{
	PZ.lc = Cml;
	xlpoint_pz(array_BX, tarray_BX, &PZ);
	return true;
}

void CDrawRoad::InitJDdata(JDdata& tpJD)
{
	_tcscpy(tpJD.BIANHAO, L"");
	tpJD.dist = 0;
	tpJD.gc = 0;
	_tcscpy(tpJD.JXLC, L"");
	tpJD.kuandu = 0;
	tpJD.shunjieAngle = 0;
	tpJD.kuandu_left = 0;
	tpJD.kuandu_right = 0;
	tpJD.l1 = 0;
	tpJD.l2 = 0;
	tpJD.lc = 0;
	tpJD.R = 0;
	tpJD.x = 0;
	tpJD.x = 0;
	tpJD.y = 0;
}

BOOL CDrawRoad::Cal_xianyuan(Road& m_RoadData1) const
{
	double fb, fe, db, de, aa, c, lcb, lce, T0 = 0.0, interal = 18;
	ACHAR zy[STR_MIN];
	//ACHAR GH[STR_SHORT];
	int i = 0, j = 0, k, color = 2, iq = 2;
	double BPMTL[10], T1, T2, L;
	double LCB, DDlength;
	int iDL = 0, NJD;
	//double array_pxy[50][4][5];
	vector<double> array_pxy;//array_pxy[NJD][4][5] 临时线元数组//改成一维，方便释放

	//double QXB[50][9];

	int tarray = 0;

	NJD = (int)m_RoadData1.JDARRAY.size();
	if (NJD == 1)
		return FALSE;

	vector<vector<double>> QXB;
	QXB.resize(NJD);
	for (int mm = 0; mm < QXB.size(); mm++)
		QXB[mm].resize(9);

	for (j = 0; j < NJD; j++)
	{
		m_RoadData1.JDarray[j][0] = j;
		m_RoadData1.JDarray[j][1] = m_RoadData1.JDARRAY[j].y;
		m_RoadData1.JDarray[j][2] = m_RoadData1.JDARRAY[j].x;
		m_RoadData1.JDarray[j][3] = 0.0;
		m_RoadData1.JDarray[j][4] = m_RoadData1.JDARRAY[j].R;
		m_RoadData1.JDarray[j][5] = 0.0;
		m_RoadData1.JDarray[j][6] = 0.0;
	}
	//ADS
	// 导线法由导线数据文件求线位 L.SC.S.L.S.C.S.L...  得到线元文件


	for (i = 0; i < 10; i++)
		BPMTL[i] = 0.0;
	//for (i = 0; i < 50; i++)
	//{
	//	for (k = 0; k < 4; k++)
	//	{
	//		for (j = 0; j < 5; j++)
	//			array_pxy[i][k][j] = 0.0;
	//	}
	//}

	for (i = 0; i < 50; i++)
	{
		for (j = 0; j < 10; j++)
		{
			m_RoadData1.array[i][j] = 0;
		}
	}

	array_pxy.clear();
	array_pxy.resize(20 * (int)m_RoadData1.JDARRAY.size());

	//起终点半径应为0    
	m_RoadData1.JDarray[0][4] = m_RoadData1.JDarray[NJD - 1][4] = m_RoadData1.JDarray[0][5] = m_RoadData1.JDarray[NJD - 1][5] = 0.0;

	db = xyddaa(m_RoadData1.JDarray[0][1], m_RoadData1.JDarray[0][2], m_RoadData1.JDarray[1][1], m_RoadData1.JDarray[1][2], &fb);
	//   JDarray[0][6]=fb;  
	lcb = m_RoadData1.JDarray[0][3];
	lce = lcb;
	fb = dms_rad(fb);
	//array_pxy[0][0][0] = 10.0;
	// N(X)=ACAD_Y
	//array_pxy[0][0][1] = m_RoadData1.JDarray[0][1];
	//E(Y)=ACAD_X
	//array_pxy[0][0][2] = m_RoadData1.JDarray[0][2];
	// FA
	//array_pxy[0][0][3] = fb;
	// LC
	//array_pxy[0][0][4] = m_RoadData1.JDarray[0][3];


	array_pxy[0] = 10.0;// 起点属性
	array_pxy[1] = m_RoadData1.JDarray[0][1]; //坐标
	array_pxy[2] = m_RoadData1.JDarray[0][2]; //坐标
	array_pxy[3] = fb;  //方位角 FA
	array_pxy[4] = m_RoadData1.JDarray[0][3]; //里程 LC




	//  DLB[0].BLC=JDarray[0][3];   DLB[0].DL=0.0;  NDL=1;   // 起点 作为一特殊断链点

	QXB[0][0] = m_RoadData1.JDarray[0][3];  // 起点里程
	QXB[0][1] = QXB[0][0];
	QXB[0][2] = QXB[0][0];
	QXB[0][3] = QXB[0][0];
	QXB[0][4] = QXB[0][5] = QXB[0][6] = QXB[0][7] = QXB[0][8] = 0.0;
	T0 = 0.0;
	if (NJD == 2) // 仅有两个交点,即一条直线时
	{
		//array_pxy[1][0][0] = 1.0;
		//array_pxy[1][0][1] = db;
		array_pxy[1 * 20] = 1.0; //
		array_pxy[1 * 20 + 1] = db;
	};

	LCB = QXB[0][0]; // 起点里程
	DDlength = LCB;
	iDL = 1;

	for (i = 1; i < NJD - 1; i++)
	{
		de = xyddaa(m_RoadData1.JDarray[i][1], m_RoadData1.JDarray[i][2], m_RoadData1.JDarray[i + 1][1], m_RoadData1.JDarray[i + 1][2], &fe);
		fe = dms_rad(fe);
		aa = rad(fe) - rad(fb);
		if (aa < -PI)
			aa = aa + 2 * PI;
		if (aa > PI)
			aa = aa - 2 * PI;
		if (aa > 0)
		{
			c = 1;
			_tcscpy(zy, L"y");
		}  //右偏
		else
		{
			c = -1;
			_tcscpy(zy, L"z");
		}//左偏
		aa = fabs(aa);
		aa = dms_rad(aa);
		//if (JDarray[i][4]<=0)
		//	break;
		getBPMTL(aa, m_RoadData1.JDarray[i][4], m_RoadData1.JDarray[i][3], m_RoadData1.JDarray[i][5], &BPMTL[0]);
		T1 = BPMTL[6];
		T2 = BPMTL[7];
		L = BPMTL[8];

		if (L < (m_RoadData1.JDarray[i][3] + m_RoadData1.JDarray[i][5]))
		{
			//return 0;
			//ads_printf(L"\n%d号曲线 前后缓和曲线重叠：缓长L1+L2=%10.3f>大于曲线长L=%10.3f ",i,JDarray[i][3]+JDarray[i][5],L);
		}
		else if ((L - m_RoadData1.JDarray[i][3] - m_RoadData1.JDarray[i][5]) < 20.0)
		{
			//return 0;
			//ads_printf(L"\n %d号曲线的(R=%8.1f)圆曲线长L=%10.3f 不足20m ",i,JDarray[i][4],L-JDarray[i][3]-JDarray[i][5]);
		}

		//曲线要数 角度为度.分秒
		QXB[i][4] = aa;
		QXB[i][5] = T1;
		QXB[i][6] = T2;
		QXB[i][7] = L;
		QXB[i][8] = c;
		//  line
		//array_pxy[i][0][0] = 1.0;
		//array_pxy[i][0][1] = db - T1 - T0;
		array_pxy[i * 20] = 1.0;
		array_pxy[i * 20 + 1] = db - T1 - T0;

		//ZH (zy)
		QXB[i][0] = QXB[i - 1][3] + (db - T1 - T0);
		if ((db - T1 - T0) < 20.0)
		{
			//	ads_printf(L"\n %d号曲线起点ZH/ZY距前一曲线HZ/ZY距离=%-10.3f ",i+JD0-1,db-T1-T0);
			if ((db - T1 - T0) < 0)
			{
				//return 0;
				//ads_printf(L"超过前一曲线HZ/YZ不合法 ");
			}

		}
		aa = sqrt(m_RoadData1.JDarray[i][3] * m_RoadData1.JDarray[i][4]);
		if (aa > 0.000000001)
		{
			//array_pxy[i][1][0] = 3.0;
			//array_pxy[i][1][1] = aa;
			////array_pxy[i][1][2]=QXLRL[i][1];
			//array_pxy[i][1][2] = m_RoadData1.JDarray[i][4];
			//array_pxy[i][1][3] = 0.0;
			//array_pxy[i][1][4] = c;

			array_pxy[i * 20 + 1 * 5] = 3.0;
			array_pxy[i * 20 + 1 * 5 + 1] = aa; //A
			array_pxy[i * 20 + 1 * 5 + 2] = m_RoadData1.JDarray[i][4];  //R
			array_pxy[i * 20 + 1 * 5 + 3] = 0.0;
			array_pxy[i * 20 + 1 * 5 + 4] = c;  //z y pian
		}
		// HY
		QXB[i][1] = QXB[i][0] + m_RoadData1.JDarray[i][3];
		//  circle 
		aa = L - m_RoadData1.JDarray[i][3] - m_RoadData1.JDarray[i][5];
		if (aa > 0.000000001)
		{
			//array_pxy[i][2][0] = 2.0;
			//array_pxy[i][2][1] = m_RoadData1.JDarray[i][4];
			//array_pxy[i][2][2] = aa;
			//array_pxy[i][2][3] = 0.0;
			//array_pxy[i][2][4] = c;
			array_pxy[i * 20 + 2 * 5] = 2.0;  //性质
			array_pxy[i * 20 + 2 * 5 + 1] = m_RoadData1.JDarray[i][4]; //R
			array_pxy[i * 20 + 2 * 5 + 2] = aa; //yuan  chang 
			array_pxy[i * 20 + 2 * 5 + 3] = 0.0;
			array_pxy[i * 20 + 2 * 5 + 4] = c;

		}
		else//半径为0 转角要传递
		{
			//array_pxy[i][2][0] = 2.0;  //性质
			//array_pxy[i][2][1] = m_RoadData1.JDarray[i][4]; //R
			//array_pxy[i][2][2] = aa; //yuan  chang 
			//array_pxy[i][2][3] = rad(fe);
			//array_pxy[i][2][4] = c;

			array_pxy[i * 20 + 2 * 5] = 2.0;  //性质
			array_pxy[i * 20 + 2 * 5 + 1] = m_RoadData1.JDarray[i][4]; //R
			array_pxy[i * 20 + 2 * 5 + 2] = aa; //yuan  chang 
			array_pxy[i * 20 + 2 * 5 + 3] = rad(fe);
			array_pxy[i * 20 + 2 * 5 + 4] = c;
		}
		// YH
		QXB[i][2] = QXB[i][1] + aa;
		//2-spiral
		aa = sqrt(m_RoadData1.JDarray[i][5] * m_RoadData1.JDarray[i][4]);
		if (aa > 0.000000001)
		{
			//array_pxy[i][3][0] = 4.0;
			//array_pxy[i][3][1] = aa;
			//array_pxy[i][3][2] = m_RoadData1.JDarray[i][4];
			//array_pxy[i][3][3] = 0.0;
			//array_pxy[i][3][4] = c;
			array_pxy[i * 20 + 3 * 5 + 0] = 4.0; //A
			array_pxy[i * 20 + 3 * 5 + 1] = aa; //A
			array_pxy[i * 20 + 3 * 5 + 2] = m_RoadData1.JDarray[i][4];  //R
			array_pxy[i * 20 + 3 * 5 + 3] = 0.0;
			array_pxy[i * 20 + 3 * 5 + 4] = c;  //z y pian

		}
		// HZ
		QXB[i][3] = QXB[i][2] + m_RoadData1.JDarray[i][5];
		db = de;
		lcb = lce;
		fb = fe;
		T0 = T2;
	}
	//  line
	db = db - T0;
	if (db > 0.0000000001)
	{
		//array_pxy[NJD-1][0][0] = 1.0;
		//array_pxy[NJD-1][0][1] = db;
		array_pxy[(NJD - 1) * 20] = 1.0;
		array_pxy[(NJD - 1) * 20 + 1] = db;
	}

	// 终点里程
	QXB[NJD - 1][0] = QXB[NJD - 2][3] + db;
	m_RoadData1.RoadL = QXB[NJD - 1][0] - QXB[0][0];
	QXB[NJD - 1][1] = QXB[NJD - 1][0];
	QXB[NJD - 1][2] = QXB[NJD - 1][0];
	QXB[NJD - 1][3] = QXB[NJD - 1][0];
	QXB[NJD - 1][4] = QXB[NJD - 1][5] = QXB[NJD - 1][6] = QXB[NJD - 1][7] = QXB[NJD - 1][8] = 0.0;
	// 修改终点特殊断链点里程 (终点 作为一特殊断链点) 
	//  起点
	double INDATA[5], l, L0;
	struct xlpoint PB0, PEZ;
	for (j = 0; j < 5; j++)
		m_RoadData1.array[0][j] = array_pxy[j];

	tarray = 1;
	///////除去起终交点 每个交点四个线元  ( 在只有圆曲线 没有 缓和曲线时  只有两个线元)
	for (i = 1; i < NJD - 1; i++)
	{
		for (k = 0; k < 4; k++)
		{
			for (j = 0; j < 5; j++)
				//INDATA[j] = array_pxy[i][k][j];
				INDATA[j] = array_pxy[i * 20 + k * 5 + j];
			j = (int)(INDATA[0] + 0.01);
			l = 0.0;
			if (j == 1)
				l = INDATA[1];
			else if (j == 2)
				l = INDATA[2];
			else if (j == 3 || j == 4)
			{
				if (fabs(INDATA[2]) > 0.000001)
					l = INDATA[1] * INDATA[1] / INDATA[2];
				else
					l = 0.0;
			}
			else if (j == 5)
			{
				if (fabs(INDATA[2] * INDATA[3]) > 0.000001)
					l = INDATA[1] * INDATA[1] * (INDATA[2] - INDATA[3]) / (INDATA[2] * INDATA[3]);
				else
					l = 0.0;
			}
			else if (j == 6)
			{
				if (fabs(INDATA[2] * INDATA[3]) > 0.000001)
					l = INDATA[1] * INDATA[1] * (INDATA[3] - INDATA[2]) / (INDATA[2] * INDATA[3]);
				else
					l = 0.0;
			}
			// 求L0=？
			L0 = l;
			if (j == 2)
				L0 = INDATA[1];
			//		   ads_printf(L"l=%lf\n",l);
			if (L0 > 0.001)
			{
				for (int kk = 0; kk < 5; kk++)
					//m_RoadData1.array[tarray][kk] = array_pxy[i][k][kk];
					m_RoadData1.array[tarray][kk] = array_pxy[i * 20 + k * 5 + kk];
				if (j == 1)//直线
				{
					db = xyddaa(m_RoadData1.JDarray[i - 1][1], m_RoadData1.JDarray[i - 1][2], m_RoadData1.JDarray[i][1], m_RoadData1.JDarray[i][2], &fb);
					m_RoadData1.array[tarray][5] = fb;
					m_RoadData1.array[tarray][6] = QXB[i - 1][3];
					m_RoadData1.array[tarray][7] = 1e40;
					m_RoadData1.array[tarray][8] = m_RoadData1.JDarray[i - 1][1] + QXB[i - 1][6] * cos(fb);
					m_RoadData1.array[tarray][9] = m_RoadData1.JDarray[i - 1][2] + QXB[i - 1][6] * sin(fb);
				}
				// ads_printf(L"\n %1.0f %10.3f %10.3f %1.0f",array[trow][0],array[trow][1],array[trow][2],array[trow][4]);
				tarray = tarray + 1;
			};
		};
	};
	//  终点
	for (j = 0; j < 5; j++)
		//m_RoadData1.array[tarray][j] = array_pxy[NJD-1][0][j];
		m_RoadData1.array[tarray][j] = array_pxy[(NJD - 1) * 20 + j];
	if (NJD > 2)
	{
		i = NJD - 1;
		db = xyddaa(m_RoadData1.JDarray[i - 1][1], m_RoadData1.JDarray[i - 1][2], m_RoadData1.JDarray[i][1], m_RoadData1.JDarray[i][2], &fb);
		m_RoadData1.array[tarray][5] = fb;
		m_RoadData1.array[tarray][6] = QXB[i - 1][3];
		m_RoadData1.array[tarray][7] = 1e40;
		m_RoadData1.array[tarray][8] = m_RoadData1.JDarray[i - 1][1] + QXB[i - 1][6] * cos(fb);
		m_RoadData1.array[tarray][9] = m_RoadData1.JDarray[i - 1][2] + QXB[i - 1][6] * sin(fb);
	}

	tarray = tarray + 1;
	i = 0;
	PB0.lc = m_RoadData1.array[0][4];
	PB0.x = m_RoadData1.array[0][1];
	PB0.y = m_RoadData1.array[0][2];
	PB0.a = rad(m_RoadData1.array[0][3]);
	PB0.r = 1e40;
	m_RoadData1.array[1][5] = PB0.a;
	m_RoadData1.array[1][6] = PB0.lc;
	m_RoadData1.array[1][7] = PB0.r;
	m_RoadData1.array[1][8] = PB0.x;
	m_RoadData1.array[1][9] = PB0.y;
	for (i = 1; i < tarray; i++)
	{
		// 第 i 线元
		for (k = 0; k < 5; k++)
			INDATA[k] = m_RoadData1.array[i][k];

		j = (int)(m_RoadData1.array[i + 1][0] + 0.0001);
		if (j == 1)//下一单元是直线 
		{
			PB0.a = m_RoadData1.array[i + 1][5];
			PB0.lc = m_RoadData1.array[i + 1][6];
			PB0.r = m_RoadData1.array[i + 1][7];
			PB0.x = m_RoadData1.array[i + 1][8];
			PB0.y = m_RoadData1.array[i + 1][9];
		}
		else
		{
			l = Get_INDATA_L(INDATA, &j);
			xlzbxy(&PB0, &PEZ, l, INDATA, 0);
			m_RoadData1.array[i + 1][5] = PEZ.a;
			//if( fabs(array_pxy[i][2][0]-2)<0.00001 && l<0.00000001 ) array[i+1][5] = INDATA[3];
			m_RoadData1.array[i + 1][6] = PEZ.lc;
			m_RoadData1.array[i + 1][7] = PEZ.r;//线元起点的半径,直圆\圆直为无穷大
			m_RoadData1.array[i + 1][8] = PEZ.x;
			m_RoadData1.array[i + 1][9] = PEZ.y;
			PB0 = PEZ;
		}
	}
	xlpoint PZ1;
	PZ1.lc = QXB[NJD - 1][0];
	xlpoint_pz(m_RoadData1.array, tarray, &PZ1);

	/////////////////////////////线路终点线元属性 为10时  有可能投影函数投影不到
	m_RoadData1.array[tarray][0] = 10;
	m_RoadData1.array[tarray][1] = PZ1.x;
	m_RoadData1.array[tarray][2] = PZ1.y;
	m_RoadData1.array[tarray][3] = PZ1.a;
	m_RoadData1.array[tarray][4] = PZ1.lc;
	m_RoadData1.tarray = tarray;

	array_pxy.clear();
	QXB.clear();
	return 1;
}

BOOL CDrawRoad::Cal_xianyuan(Road_BX& m_RoadData2) const
{
	//double array_pxy_BX[100][4][5];
	vector<double> array_pxy_BX;//array_pxy[NJD][4][5] 临时线元数组//改成一维，方便释放

	double fb, fe, db, de, aa, c, lcb, lce, T0 = 0.0, interal = 18;
	ACHAR zy[STR_MIN];
	//ACHAR GH[STR_SHORT];
	int i = 0, j = 0, k, color = 2, iq = 2;
	double BPMTL[10], T1, T2, L;
	double LCB, DDlength;
	int iDL = 0, NJD;
	//double QXB[50][9];

	NJD = (int)m_RoadData2.JDARRAY.size();
	if (NJD < 2)
		return FALSE;
	vector<vector<double>> QXB;
	QXB.resize(NJD);
	for (int mm = 0; mm < QXB.size(); mm++)
		QXB[mm].resize(9);

	for (j = 0; j < NJD; j++)
	{
		JDarray_BX[j][0] = j;
		JDarray_BX[j][1] = m_RoadData2.JDARRAY[j].y;
		JDarray_BX[j][2] = m_RoadData2.JDARRAY[j].x;
		JDarray_BX[j][3] = m_RoadData2.JDARRAY[j].l1;
		JDarray_BX[j][4] = m_RoadData2.JDARRAY[j].R;
		JDarray_BX[j][5] = m_RoadData2.JDARRAY[j].l2;
		JDarray_BX[j][6] = 0.0;
	}
	//ADS
	// 导线法由导线数据文件求线位 L.SC.S.L.S.C.S.L...  得到线元文件

	for (i = 0; i < 10; i++)
		BPMTL[i] = 0.0;
	//for (i = 0; i < 100; i++)
	//{
	//	for (k = 0; k < 4; k++)
	//	{
	//		for (j = 0; j < 5; j++)
	//			array_pxy_BX[i][k][j] = 0.0;
	//	}
	//}

	for (i = 0; i < 50; i++)
	{
		for (j = 0; j < 10; j++)
		{
			array_BX[i][j] = 0;
		}
	}

	array_pxy_BX.clear();
	array_pxy_BX.resize(20 * NJD);

	for (i = 0; i < array_pxy_BX.size(); i++)
		array_pxy_BX[i] = 0.0;
	//起终点半径应为0    
	JDarray_BX[0][4] = JDarray_BX[NJD - 1][4] = JDarray_BX[0][5] = JDarray_BX[NJD - 1][5] = 0.0;

	db = xyddaa(JDarray_BX[0][1], JDarray_BX[0][2], JDarray_BX[1][1], JDarray_BX[1][2], &fb);
	//   JDarray[0][6]=fb;  
	lcb = JDarray_BX[0][3];
	lce = lcb;
	fb = dms_rad(fb);
	//array_pxy_BX[0][0][0] = 10.0;
	//// N(X)=ACAD_Y
	//array_pxy_BX[0][0][1] = JDarray_BX[0][1];
	////E(Y)=ACAD_X
	//array_pxy_BX[0][0][2] = JDarray_BX[0][2];
	//// FA
	//array_pxy_BX[0][0][3] = fb;
	//// LC
	//array_pxy_BX[0][0][4] = JDarray_BX[0][3];

	array_pxy_BX[0] = 10.0;// 起点属性
	array_pxy_BX[1] = JDarray_BX[0][1]; //坐标
	array_pxy_BX[2] = JDarray_BX[0][2]; //坐标
	array_pxy_BX[3] = fb;  //方位角 FA
	array_pxy_BX[4] = JDarray_BX[0][3]; //里程 LC

	//  DLB[0].BLC=JDarray[0][3];   DLB[0].DL=0.0;  NDL=1;   // 起点 作为一特殊断链点

	QXB[0][0] = JDarray_BX[0][3];  // 起点里程
	QXB[0][1] = QXB[0][0];
	QXB[0][2] = QXB[0][0];
	QXB[0][3] = QXB[0][0];
	QXB[0][4] = QXB[0][5] = QXB[0][6] = QXB[0][7] = QXB[0][8] = 0.0;
	T0 = 0.0;
	if (NJD == 2) // 仅有两个交点,即一条直线时
	{
		//array_pxy_BX[1][0][0] = 1.0;
		//array_pxy_BX[1][0][1] = db;
		array_pxy_BX[1 * 20] = 1.0; //
		array_pxy_BX[1 * 20 + 1] = db;
	};

	LCB = QXB[0][0]; // 起点里程
	DDlength = LCB;
	iDL = 1;

	for (i = 1; i < NJD - 1; i++)
	{
		de = xyddaa(JDarray_BX[i][1], JDarray_BX[i][2], JDarray_BX[i + 1][1], JDarray_BX[i + 1][2], &fe);
		fe = dms_rad(fe);
		aa = rad(fe) - rad(fb);
		if (aa < -PI)
			aa = aa + 2 * PI;
		if (aa > PI)
			aa = aa - 2 * PI;
		if (aa > 0)
		{
			c = 1;
			_tcscpy(zy, L"y");
		}  //右偏
		else
		{
			c = -1;
			_tcscpy(zy, L"z");
		}//左偏
		aa = fabs(aa);
		aa = dms_rad(aa);
		//if (JDarray[i][4]<=0)
		//	break;
		getBPMTL(aa, JDarray_BX[i][4], JDarray_BX[i][3], JDarray_BX[i][5], &BPMTL[0]);
		T1 = BPMTL[6];
		T2 = BPMTL[7];
		L = BPMTL[8];

		if (L < (JDarray_BX[i][3] + JDarray_BX[i][5]))
		{
			//return 0;
			//ads_printf(L"\n%d号曲线 前后缓和曲线重叠：缓长L1+L2=%10.3f>大于曲线长L=%10.3f ",i,JDarray[i][3]+JDarray[i][5],L);
		}
		else if ((L - JDarray_BX[i][3] - JDarray_BX[i][5]) < 20.0)
		{
			//return 0;
			//ads_printf(L"\n %d号曲线的(R=%8.1f)圆曲线长L=%10.3f 不足20m ",i,JDarray[i][4],L-JDarray[i][3]-JDarray[i][5]);
		}

		//曲线要数 角度为度.分秒
		QXB[i][4] = aa;
		QXB[i][5] = T1;
		QXB[i][6] = T2;
		QXB[i][7] = L;
		QXB[i][8] = c;
		//  line
		//array_pxy_BX[i][0][0] = 1.0;
		//array_pxy_BX[i][0][1] = db - T1 - T0;
		array_pxy_BX[i * 20] = 1.0;
		array_pxy_BX[i * 20 + 1] = db - T1 - T0;
		//ZH (zy)
		QXB[i][0] = QXB[i - 1][3] + (db - T1 - T0);
		if ((db - T1 - T0) < 20.0)
		{
			//	ads_printf(L"\n %d号曲线起点ZH/ZY距前一曲线HZ/ZY距离=%-10.3f ",i+JD0-1,db-T1-T0);
			if ((db - T1 - T0) < 0)
			{
				//return 0;
				//ads_printf(L"超过前一曲线HZ/YZ不合法 ");
			}

		}
		aa = sqrt(JDarray_BX[i][3] * JDarray_BX[i][4]);
		if (aa > 0.000000001)
		{
			//array_pxy_BX[i][1][0] = 3.0;
			//array_pxy_BX[i][1][1] = aa;
			////array_pxy[i][1][2]=QXLRL[i][1];
			//array_pxy_BX[i][1][2] = JDarray_BX[i][4];
			//array_pxy_BX[i][1][3] = 0.0;
			//array_pxy_BX[i][1][4] = c;

			array_pxy_BX[i * 20 + 1 * 5] = 3.0;
			array_pxy_BX[i * 20 + 1 * 5 + 1] = aa; //A
			array_pxy_BX[i * 20 + 1 * 5 + 2] = JDarray_BX[i][4];  //R
			array_pxy_BX[i * 20 + 1 * 5 + 3] = 0.0;
			array_pxy_BX[i * 20 + 1 * 5 + 4] = c;  //z y pian
		}
		// HY
		QXB[i][1] = QXB[i][0] + JDarray_BX[i][3];
		//  circle 
		aa = L - JDarray_BX[i][3] - JDarray_BX[i][5];
		if (aa > 0.000000001)
		{
			//array_pxy_BX[i][2][0] = 2.0;
			//array_pxy_BX[i][2][1] = JDarray_BX[i][4];
			//array_pxy_BX[i][2][2] = aa;
			//array_pxy_BX[i][2][3] = 0.0;
			//array_pxy_BX[i][2][4] = c;

			array_pxy_BX[i * 20 + 2 * 5] = 2.0;  //性质
			array_pxy_BX[i * 20 + 2 * 5 + 1] = JDarray_BX[i][4]; //R
			array_pxy_BX[i * 20 + 2 * 5 + 2] = aa; //yuan  chang 
			array_pxy_BX[i * 20 + 2 * 5 + 3] = 0.0;
			array_pxy_BX[i * 20 + 2 * 5 + 4] = c;
		}
		else//半径为0 转角要传递
		{
			//array_pxy_BX[i][2][0] = 2.0;  //性质
			//array_pxy_BX[i][2][1] = JDarray_BX[i][4]; //R
			//array_pxy_BX[i][2][2] = aa; //yuan  chang 
			//array_pxy_BX[i][2][3] = rad(fe);
			//array_pxy_BX[i][2][4] = c;

			array_pxy_BX[i * 20 + 2 * 5] = 2.0;  //性质
			array_pxy_BX[i * 20 + 2 * 5 + 1] = JDarray_BX[i][4]; //R
			array_pxy_BX[i * 20 + 2 * 5 + 2] = aa; //yuan  chang 
			array_pxy_BX[i * 20 + 2 * 5 + 3] = rad(fe);
			array_pxy_BX[i * 20 + 2 * 5 + 4] = c;
		}
		// YH
		QXB[i][2] = QXB[i][1] + aa;
		//2-spiral
		aa = sqrt(JDarray_BX[i][5] * JDarray_BX[i][4]);
		if (aa > 0.000000001)
		{
			//array_pxy_BX[i][3][0] = 4.0;
			//array_pxy_BX[i][3][1] = aa;
			//array_pxy_BX[i][3][2] = JDarray_BX[i][4];
			//array_pxy_BX[i][3][3] = 0.0;
			//array_pxy_BX[i][3][4] = c;

			array_pxy_BX[i * 20 + 3 * 5 + 0] = 4.0; //A
			array_pxy_BX[i * 20 + 3 * 5 + 1] = aa; //A
			array_pxy_BX[i * 20 + 3 * 5 + 2] = JDarray_BX[i][4];  //R
			array_pxy_BX[i * 20 + 3 * 5 + 3] = 0.0;
			array_pxy_BX[i * 20 + 3 * 5 + 4] = c;  //z y pian
		}
		// HZ
		QXB[i][3] = QXB[i][2] + JDarray_BX[i][5];
		db = de;
		lcb = lce;
		fb = fe;
		T0 = T2;
	}
	//  line
	db = db - T0;
	if (db > 0.0000000001)
	{
		//array_pxy_BX[NJD-1][0][0] = 1.0;
		//array_pxy_BX[NJD-1][0][1] = db;
		array_pxy_BX[(NJD - 1) * 20] = 1.0;
		array_pxy_BX[(NJD - 1) * 20 + 1] = db;
	}

	// 终点里程
	QXB[NJD - 1][0] = QXB[NJD - 2][3] + db;
	m_RoadData2.RoadL = QXB[NJD - 1][0] - QXB[0][0];
	QXB[NJD - 1][1] = QXB[NJD - 1][0];
	QXB[NJD - 1][2] = QXB[NJD - 1][0];
	QXB[NJD - 1][3] = QXB[NJD - 1][0];
	QXB[NJD - 1][4] = QXB[NJD - 1][5] = QXB[NJD - 1][6] = QXB[NJD - 1][7] = QXB[NJD - 1][8] = 0.0;
	// 修改终点特殊断链点里程 (终点 作为一特殊断链点)

	//_tcscpy(Sgh,DLB[NDL-1].BGH);
	//_tcscpy(Egh,DLB[NDL-1].EGH);//修改终点断链冠号  2004.7.16
	//lcb = XLC(QXB[NJD-1][0],DLB[NDL-1].BGH,NDL-1);//2005-12-16
	//if (_tcscmp(DLB[NDL-1].BGH,DLB[NDL-1].EGH) != 0 || fabs(DLB[NDL-1].DL) > 0.00001)
	//	lce = DLB[NDL-1].BLC + DLB[NDL-1].DL;//2005-12-16
	//else
	//	lce = lcb;		
	//setDLM(NDL-1,lcb,lce-lcb,Sgh,Egh); 	 
	//  起点
	double INDATA[5], l, L0;
	struct xlpoint PB0, PEZ;
	for (j = 0; j < 5; j++)
		//array_BX[0][j] = array_pxy_BX[0][0][j];
		array_BX[0][j] = array_pxy_BX[j];
	tarray_BX = 1;
	///////除去起终交点 每个交点四个线元  ( 在只有圆曲线 没有 缓和曲线时  只有两个线元)
	for (i = 1; i < NJD - 1; i++)
	{
		for (k = 0; k < 4; k++)
		{
			for (j = 0; j < 5; j++)
				//INDATA[j] = array_pxy_BX[i][k][j];
				INDATA[j] = array_pxy_BX[i * 20 + k * 5 + j];
			j = (int)(INDATA[0] + 0.01);
			l = 0.0;
			if (j == 1)
				l = INDATA[1];
			else if (j == 2)
				l = INDATA[2];
			else if (j == 3 || j == 4)
			{
				if (fabs(INDATA[2]) > 0.000001)
					l = INDATA[1] * INDATA[1] / INDATA[2];
				else
					l = 0.0;
			}
			else if (j == 5)
			{
				if (fabs(INDATA[2] * INDATA[3]) > 0.000001)
					l = INDATA[1] * INDATA[1] * (INDATA[2] - INDATA[3]) / (INDATA[2] * INDATA[3]);
				else
					l = 0.0;
			}
			else if (j == 6)
			{
				if (fabs(INDATA[2] * INDATA[3]) > 0.000001)
					l = INDATA[1] * INDATA[1] * (INDATA[3] - INDATA[2]) / (INDATA[2] * INDATA[3]);
				else
					l = 0.0;
			}
			// 求L0=？
			L0 = l;
			if (j == 2)
				L0 = INDATA[1];
			//		   ads_printf(L"l=%lf\n",l);
			if (L0 > 0.001)
			{
				for (int kk = 0; kk < 5; kk++)
					//array_BX[tarray_BX][kk] = array_pxy_BX[i][k][kk];
					array_BX[tarray_BX][kk] = array_pxy_BX[i * 20 + k * 5 + kk];
				if (j == 1)//直线
				{
					db = xyddaa(JDarray_BX[i - 1][1], JDarray_BX[i - 1][2], JDarray_BX[i][1], JDarray_BX[i][2], &fb);
					array_BX[tarray_BX][5] = fb;
					array_BX[tarray_BX][6] = QXB[i - 1][3];
					array_BX[tarray_BX][7] = 1e40;
					array_BX[tarray_BX][8] = JDarray_BX[i - 1][1] + QXB[i - 1][6] * cos(fb);
					array_BX[tarray_BX][9] = JDarray_BX[i - 1][2] + QXB[i - 1][6] * sin(fb);
				}
				// ads_printf(L"\n %1.0f %10.3f %10.3f %1.0f",array[trow][0],array[trow][1],array[trow][2],array[trow][4]);
				tarray_BX = tarray_BX + 1;
			};
		};
	};
	//  终点
	for (j = 0; j < 5; j++)
		//array_BX[tarray_BX][j] = array_pxy_BX[NJD-1][0][j];
		array_BX[tarray_BX][j] = array_pxy_BX[(NJD - 1) * 20 + j];
	if (NJD > 2)
	{
		i = NJD - 1;
		db = xyddaa(JDarray_BX[i - 1][1], JDarray_BX[i - 1][2], JDarray_BX[i][1], JDarray_BX[i][2], &fb);
		array_BX[tarray_BX][5] = fb;
		array_BX[tarray_BX][6] = QXB[i - 1][3];
		array_BX[tarray_BX][7] = 1e40;
		array_BX[tarray_BX][8] = JDarray_BX[i - 1][1] + QXB[i - 1][6] * cos(fb);
		array_BX[tarray_BX][9] = JDarray_BX[i - 1][2] + QXB[i - 1][6] * sin(fb);
	}

	tarray_BX = tarray_BX + 1;
	i = 0;
	PB0.lc = array_BX[0][4];
	PB0.x = array_BX[0][1];
	PB0.y = array_BX[0][2];
	PB0.a = rad(array_BX[0][3]);
	PB0.r = 1e40;
	array_BX[1][5] = PB0.a;
	array_BX[1][6] = PB0.lc;
	array_BX[1][7] = PB0.r;
	array_BX[1][8] = PB0.x;
	array_BX[1][9] = PB0.y;
	for (i = 1; i < tarray_BX; i++)
	{
		// 第 i 线元
		for (k = 0; k < 5; k++)
			INDATA[k] = array_BX[i][k];

		j = (int)(array_BX[i + 1][0] + 0.0001);
		if (j == 1)//下一单元是直线 
		{
			PB0.a = array_BX[i + 1][5];
			PB0.lc = array_BX[i + 1][6];
			PB0.r = array_BX[i + 1][7];
			PB0.x = array_BX[i + 1][8];
			PB0.y = array_BX[i + 1][9];
		}
		else
		{
			l = Get_INDATA_L(INDATA, &j);
			xlzbxy(&PB0, &PEZ, l, INDATA, 0);
			array_BX[i + 1][5] = PEZ.a;
			//if( fabs(array_pxy[i][2][0]-2)<0.00001 && l<0.00000001 ) array[i+1][5] = INDATA[3];
			array_BX[i + 1][6] = PEZ.lc;
			array_BX[i + 1][7] = PEZ.r;//线元起点的半径,直圆\圆直为无穷大
			array_BX[i + 1][8] = PEZ.x;
			array_BX[i + 1][9] = PEZ.y;
			PB0 = PEZ;
		}
	}
	xlpoint PZ1;
	PZ1.lc = QXB[NJD - 1][0];
	xlpoint_pz(array_BX, tarray_BX, &PZ1);

	/////////////////////////////线路终点线元属性 为10时  有可能投影函数投影不到
	array_BX[tarray_BX][0] = 10;
	array_BX[tarray_BX][1] = PZ1.x;
	array_BX[tarray_BX][2] = PZ1.y;
	array_BX[tarray_BX][3] = PZ1.a;
	array_BX[tarray_BX][4] = PZ1.lc;
	array_pxy_BX.clear();
	QXB.clear();
	return 1;
}

BOOL CDrawRoad::Cal_xianyuan(vector<JDdata> JDARRAY) const
{
	//double array_pxy_BX[100][4][5];
	vector<double> array_pxy_BX;//array_pxy[NJD][4][5] 临时线元数组//改成一维，方便释放

	double fb, fe, db, de, aa, c, lcb, lce, T0 = 0.0, interal = 18;
	ACHAR zy[STR_MIN];
	//ACHAR GH[STR_SHORT];
	int i = 0, j = 0, k, color = 2, iq = 2;
	double BPMTL[10], T1, T2, L;
	double LCB, DDlength;
	int iDL = 0, NJD;
	//double QXB[50][9];
	tarray_BX = 0;

	NJD = (int)JDARRAY.size();
	if (NJD < 2)
		return FALSE;
	vector<vector<double>> QXB;
	QXB.resize(NJD);
	for (int mm = 0; mm < QXB.size(); mm++)
		QXB[mm].resize(9);
	for (j = 0; j < NJD; j++)
	{
		JDarray_BX[j][0] = j;
		JDarray_BX[j][1] = JDARRAY[j].y;
		JDarray_BX[j][2] = JDARRAY[j].x;
		JDarray_BX[j][3] = JDARRAY[j].l1;
		JDarray_BX[j][4] = JDARRAY[j].R;
		JDarray_BX[j][5] = JDARRAY[j].l2;
		JDarray_BX[j][6] = 0.0;
	}
	//ADS
	// 导线法由导线数据文件求线位 L.SC.S.L.S.C.S.L...  得到线元文件

	for (i = 0; i < 10; i++)
		BPMTL[i] = 0.0;
	//for (i = 0; i < 100; i++)
	//{
	//	for (k = 0; k < 4; k++)
	//	{
	//		for (j = 0; j < 5; j++)
	//			array_pxy_BX[i][k][j] = 0.0;
	//	}
	//}
	for (i = 0; i < 50; i++)
	{
		for (j = 0; j < 10; j++)
		{
			array_BX[i][j] = 0;
		}
	}

	array_pxy_BX.clear();
	array_pxy_BX.resize(20 * NJD);

	for (i = 0; i < array_pxy_BX.size(); i++)
		array_pxy_BX[i] = 0.0;

	//起终点半径应为0    
	JDarray_BX[0][4] = JDarray_BX[NJD - 1][4] = JDarray_BX[0][5] = JDarray_BX[NJD - 1][5] = 0.0;

	db = xyddaa(JDarray_BX[0][1], JDarray_BX[0][2], JDarray_BX[1][1], JDarray_BX[1][2], &fb);
	//   JDarray[0][6]=fb;  
	lcb = JDarray_BX[0][3];
	lce = lcb;
	fb = dms_rad(fb);

	//array_pxy_BX[0][0][0] = 10.0;
	//// N(X)=ACAD_Y
	//array_pxy_BX[0][0][1] = JDarray_BX[0][1];
	////E(Y)=ACAD_X
	//array_pxy_BX[0][0][2] = JDarray_BX[0][2];
	//// FA
	//array_pxy_BX[0][0][3] = fb;
	//// LC
	//array_pxy_BX[0][0][4] = JDarray_BX[0][3];

	array_pxy_BX[0] = 10.0;// 起点属性
	array_pxy_BX[1] = JDarray_BX[0][1]; //坐标
	array_pxy_BX[2] = JDarray_BX[0][2]; //坐标
	array_pxy_BX[3] = fb;  //方位角 FA
	array_pxy_BX[4] = JDarray_BX[0][3]; //里程 LC

	//  DLB[0].BLC=JDarray[0][3];   DLB[0].DL=0.0;  NDL=1;   // 起点 作为一特殊断链点

	QXB[0][0] = JDarray_BX[0][3];  // 起点里程
	QXB[0][1] = QXB[0][0];
	QXB[0][2] = QXB[0][0];
	QXB[0][3] = QXB[0][0];
	QXB[0][4] = QXB[0][5] = QXB[0][6] = QXB[0][7] = QXB[0][8] = 0.0;
	T0 = 0.0;
	if (NJD == 2) // 仅有两个交点,即一条直线时
	{
		//array_pxy_BX[1][0][0] = 1.0;
		//array_pxy_BX[1][0][1] = db;
		array_pxy_BX[1 * 20] = 1.0; //
		array_pxy_BX[1 * 20 + 1] = db;
	};

	LCB = QXB[0][0]; // 起点里程
	DDlength = LCB;
	iDL = 1;

	for (i = 1; i < NJD - 1; i++)
	{
		de = xyddaa(JDarray_BX[i][1], JDarray_BX[i][2], JDarray_BX[i + 1][1], JDarray_BX[i + 1][2], &fe);
		fe = dms_rad(fe);
		aa = rad(fe) - rad(fb);
		if (aa < -PI)
			aa = aa + 2 * PI;
		if (aa > PI)
			aa = aa - 2 * PI;
		if (aa > 0)
		{
			c = 1;
			_tcscpy(zy, L"y");
		}  //右偏
		else
		{
			c = -1;
			_tcscpy(zy, L"z");
		}//左偏
		aa = fabs(aa);
		aa = dms_rad(aa);
		//if (JDarray[i][4]<=0)
		//	break;
		getBPMTL(aa, JDarray_BX[i][4], JDarray_BX[i][3], JDarray_BX[i][5], &BPMTL[0]);
		T1 = BPMTL[6];
		T2 = BPMTL[7];
		L = BPMTL[8];

		if (L < (JDarray_BX[i][3] + JDarray_BX[i][5]))
		{
			//return 0;
			//ads_printf(L"\n%d号曲线 前后缓和曲线重叠：缓长L1+L2=%10.3f>大于曲线长L=%10.3f ",i,JDarray[i][3]+JDarray[i][5],L);
		}
		else if ((L - JDarray_BX[i][3] - JDarray_BX[i][5]) < 20.0)
		{
			//return 0;
			//ads_printf(L"\n %d号曲线的(R=%8.1f)圆曲线长L=%10.3f 不足20m ",i,JDarray[i][4],L-JDarray[i][3]-JDarray[i][5]);
		}

		//曲线要数 角度为度.分秒
		QXB[i][4] = aa;
		QXB[i][5] = T1;
		QXB[i][6] = T2;
		QXB[i][7] = L;
		QXB[i][8] = c;
		//  line
		//array_pxy_BX[i][0][0] = 1.0;
		//array_pxy_BX[i][0][1] = db - T1 - T0;
		array_pxy_BX[i * 20] = 1.0;
		array_pxy_BX[i * 20 + 1] = db - T1 - T0;
		//ZH (zy)
		QXB[i][0] = QXB[i - 1][3] + (db - T1 - T0);
		//if( (db-T1-T0)<20.0) 
		//{
			//	ads_printf(L"\n %d号曲线起点ZH/ZY距前一曲线HZ/ZY距离=%-10.3f ",i+JD0-1,db-T1-T0);
		if ((db - T1 - T0) < 0)
		{
			//return 0;
			//ads_printf(L"超过前一曲线HZ/YZ不合法 ");
		}

		//}
		aa = sqrt(JDarray_BX[i][3] * JDarray_BX[i][4]);
		if (aa > 0.000000001)
		{
			//array_pxy_BX[i][1][0] = 3.0;
			//array_pxy_BX[i][1][1] = aa;
			////array_pxy[i][1][2]=QXLRL[i][1];
			//array_pxy_BX[i][1][2] = JDarray_BX[i][4];
			//array_pxy_BX[i][1][3] = 0.0;
			//array_pxy_BX[i][1][4] = c;
			array_pxy_BX[i * 20 + 1 * 5] = 3.0;
			array_pxy_BX[i * 20 + 1 * 5 + 1] = aa; //A
			array_pxy_BX[i * 20 + 1 * 5 + 2] = JDarray_BX[i][4];  //R
			array_pxy_BX[i * 20 + 1 * 5 + 3] = 0.0;
			array_pxy_BX[i * 20 + 1 * 5 + 4] = c;  //z y pian
		}
		// HY
		QXB[i][1] = QXB[i][0] + JDarray_BX[i][3];
		//  circle 
		aa = L - JDarray_BX[i][3] - JDarray_BX[i][5];
		if (aa > 0.000000001)
		{
			//array_pxy_BX[i][2][0] = 2.0;
			//array_pxy_BX[i][2][1] = JDarray_BX[i][4];
			//array_pxy_BX[i][2][2] = aa;
			//array_pxy_BX[i][2][3] = 0.0;
			//array_pxy_BX[i][2][4] = c;

			array_pxy_BX[i * 20 + 2 * 5] = 2.0;  //性质
			array_pxy_BX[i * 20 + 2 * 5 + 1] = JDarray_BX[i][4]; //R
			array_pxy_BX[i * 20 + 2 * 5 + 2] = aa; //yuan  chang 
			array_pxy_BX[i * 20 + 2 * 5 + 3] = 0.0;
			array_pxy_BX[i * 20 + 2 * 5 + 4] = c;
		}
		else//半径为0 转角要传递
		{
			//array_pxy_BX[i][2][0] = 2.0;  //性质
			//array_pxy_BX[i][2][1] = JDarray_BX[i][4]; //R
			//array_pxy_BX[i][2][2] = aa; //yuan  chang 
			//array_pxy_BX[i][2][3] = rad(fe);
			//array_pxy_BX[i][2][4] = c;

			array_pxy_BX[i * 20 + 2 * 5] = 2.0;  //性质
			array_pxy_BX[i * 20 + 2 * 5 + 1] = JDarray_BX[i][4]; //R
			array_pxy_BX[i * 20 + 2 * 5 + 2] = aa; //yuan  chang 
			array_pxy_BX[i * 20 + 2 * 5 + 3] = rad(fe);
			array_pxy_BX[i * 20 + 2 * 5 + 4] = c;
		}
		// YH
		QXB[i][2] = QXB[i][1] + aa;
		//2-spiral
		aa = sqrt(JDarray_BX[i][5] * JDarray_BX[i][4]);
		if (aa > 0.000000001)
		{
			//array_pxy_BX[i][3][0] = 4.0;
			//array_pxy_BX[i][3][1] = aa;
			//array_pxy_BX[i][3][2] = JDarray_BX[i][4];
			//array_pxy_BX[i][3][3] = 0.0;
			//array_pxy_BX[i][3][4] = c;

			array_pxy_BX[i * 20 + 3 * 5 + 0] = 4.0; //A
			array_pxy_BX[i * 20 + 3 * 5 + 1] = aa; //A
			array_pxy_BX[i * 20 + 3 * 5 + 2] = JDarray_BX[i][4];  //R
			array_pxy_BX[i * 20 + 3 * 5 + 3] = 0.0;
			array_pxy_BX[i * 20 + 3 * 5 + 4] = c;  //z y pian
		}
		// HZ
		QXB[i][3] = QXB[i][2] + JDarray_BX[i][5];
		db = de;
		lcb = lce;
		fb = fe;
		T0 = T2;
	}
	//  line
	db = db - T0;
	if (db > 0.0000000001)
	{
		//array_pxy_BX[NJD-1][0][0] = 1.0;
		//array_pxy_BX[NJD-1][0][1] = db;
		array_pxy_BX[(NJD - 1) * 20] = 1.0;
		array_pxy_BX[(NJD - 1) * 20 + 1] = db;
	}

	// 终点里程
	QXB[NJD - 1][0] = QXB[NJD - 2][3] + db;
	QXB[NJD - 1][1] = QXB[NJD - 1][0];
	QXB[NJD - 1][2] = QXB[NJD - 1][0];
	QXB[NJD - 1][3] = QXB[NJD - 1][0];
	QXB[NJD - 1][4] = QXB[NJD - 1][5] = QXB[NJD - 1][6] = QXB[NJD - 1][7] = QXB[NJD - 1][8] = 0.0;
	// 修改终点特殊断链点里程 (终点 作为一特殊断链点)

	//_tcscpy(Sgh,DLB[NDL-1].BGH);
	//_tcscpy(Egh,DLB[NDL-1].EGH);//修改终点断链冠号  2004.7.16
	//lcb = XLC(QXB[NJD-1][0],DLB[NDL-1].BGH,NDL-1);//2005-12-16
	//if (_tcscmp(DLB[NDL-1].BGH,DLB[NDL-1].EGH) != 0 || fabs(DLB[NDL-1].DL) > 0.00001)
	//	lce = DLB[NDL-1].BLC + DLB[NDL-1].DL;//2005-12-16
	//else
	//	lce = lcb;		
	//setDLM(NDL-1,lcb,lce-lcb,Sgh,Egh); 	 
	//  起点
	double INDATA[5], l, L0;
	struct xlpoint PB0, PEZ;
	for (j = 0; j < 5; j++)
		array_BX[0][j] = array_pxy_BX[j];
	tarray_BX = 1;
	///////除去起终交点 每个交点四个线元  ( 在只有圆曲线 没有 缓和曲线时  只有两个线元)
	for (i = 1; i < NJD - 1; i++)
	{
		for (k = 0; k < 4; k++)
		{
			for (j = 0; j < 5; j++)
				//INDATA[j] = array_pxy_BX[i][k][j];
				INDATA[j] = array_pxy_BX[i * 20 + k * 5 + j];
			j = (int)(INDATA[0] + 0.01);
			l = 0.0;
			if (j == 1)
				l = INDATA[1];
			else if (j == 2)
				l = INDATA[2];
			else if (j == 3 || j == 4)
			{
				if (fabs(INDATA[2]) > 0.000001)
					l = INDATA[1] * INDATA[1] / INDATA[2];
				else
					l = 0.0;
			}
			else if (j == 5)
			{
				if (fabs(INDATA[2] * INDATA[3]) > 0.000001)
					l = INDATA[1] * INDATA[1] * (INDATA[2] - INDATA[3]) / (INDATA[2] * INDATA[3]);
				else
					l = 0.0;
			}
			else if (j == 6)
			{
				if (fabs(INDATA[2] * INDATA[3]) > 0.000001)
					l = INDATA[1] * INDATA[1] * (INDATA[3] - INDATA[2]) / (INDATA[2] * INDATA[3]);
				else
					l = 0.0;
			}
			// 求L0=？
			L0 = l;
			if (j == 2)
				L0 = INDATA[1];
			//		   ads_printf(L"l=%lf\n",l);
			if (L0 > 0.001)
			{
				for (int kk = 0; kk < 5; kk++)
					//array_BX[tarray_BX][kk] = array_pxy_BX[i][k][kk];
					array_BX[tarray_BX][kk] = array_pxy_BX[i * 20 + k * 5 + kk];
				if (j == 1)//直线
				{
					db = xyddaa(JDarray_BX[i - 1][1], JDarray_BX[i - 1][2], JDarray_BX[i][1], JDarray_BX[i][2], &fb);
					array_BX[tarray_BX][5] = fb;
					array_BX[tarray_BX][6] = QXB[i - 1][3];
					array_BX[tarray_BX][7] = 1e40;
					array_BX[tarray_BX][8] = JDarray_BX[i - 1][1] + QXB[i - 1][6] * cos(fb);
					array_BX[tarray_BX][9] = JDarray_BX[i - 1][2] + QXB[i - 1][6] * sin(fb);
				}
				// ads_printf(L"\n %1.0f %10.3f %10.3f %1.0f",array[trow][0],array[trow][1],array[trow][2],array[trow][4]);
				tarray_BX = tarray_BX + 1;
			};
		};
	};
	//  终点
	for (j = 0; j < 5; j++)
		//array_BX[tarray_BX][j] = array_pxy_BX[NJD-1][0][j];
		array_BX[tarray_BX][j] = array_pxy_BX[(NJD - 1) * 20 + j];
	if (NJD > 2)
	{
		i = NJD - 1;
		db = xyddaa(JDarray_BX[i - 1][1], JDarray_BX[i - 1][2], JDarray_BX[i][1], JDarray_BX[i][2], &fb);
		array_BX[tarray_BX][5] = fb;
		array_BX[tarray_BX][6] = QXB[i - 1][3];
		array_BX[tarray_BX][7] = 1e40;
		array_BX[tarray_BX][8] = JDarray_BX[i - 1][1] + QXB[i - 1][6] * cos(fb);
		array_BX[tarray_BX][9] = JDarray_BX[i - 1][2] + QXB[i - 1][6] * sin(fb);
	}

	tarray_BX = tarray_BX + 1;
	i = 0;
	PB0.lc = array_BX[0][4];
	PB0.x = array_BX[0][1];
	PB0.y = array_BX[0][2];
	PB0.a = rad(array_BX[0][3]);
	PB0.r = 1e40;
	array_BX[1][5] = PB0.a;
	array_BX[1][6] = PB0.lc;
	array_BX[1][7] = PB0.r;
	array_BX[1][8] = PB0.x;
	array_BX[1][9] = PB0.y;
	for (i = 1; i < tarray_BX; i++)
	{
		// 第 i 线元
		for (k = 0; k < 5; k++)
			INDATA[k] = array_BX[i][k];

		j = (int)(array_BX[i + 1][0] + 0.0001);
		if (j == 1)//下一单元是直线 
		{
			PB0.a = array_BX[i + 1][5];
			PB0.lc = array_BX[i + 1][6];
			PB0.r = array_BX[i + 1][7];
			PB0.x = array_BX[i + 1][8];
			PB0.y = array_BX[i + 1][9];
		}
		else
		{
			l = Get_INDATA_L(INDATA, &j);
			xlzbxy(&PB0, &PEZ, l, INDATA, 0);
			array_BX[i + 1][5] = PEZ.a;
			//if( fabs(array_pxy[i][2][0]-2)<0.00001 && l<0.00000001 ) array[i+1][5] = INDATA[3];
			array_BX[i + 1][6] = PEZ.lc;
			array_BX[i + 1][7] = PEZ.r;//线元起点的半径,直圆\圆直为无穷大
			array_BX[i + 1][8] = PEZ.x;
			array_BX[i + 1][9] = PEZ.y;
			PB0 = PEZ;
		}
	}
	xlpoint PZ1;
	PZ1.lc = QXB[NJD - 1][0];
	xlpoint_pz(array_BX, tarray_BX, &PZ1);

	/////////////////////////////线路终点线元属性 为10时  有可能投影函数投影不到
	array_BX[tarray_BX][0] = 10;
	array_BX[tarray_BX][1] = PZ1.x;
	array_BX[tarray_BX][2] = PZ1.y;
	array_BX[tarray_BX][3] = PZ1.a;
	array_BX[tarray_BX][4] = PZ1.lc;

	array_pxy_BX.clear();
	QXB.clear();
	return 1;
}

void CDrawRoad::CheckQiuJiaoPushback(QiuJiao_inf TMP, vector<QiuJiao_inf>& resJD) const
{
	for (int i = 0; i < (int)resJD.size(); i++)
	{
		if (fabs(resJD[i].x - TMP.x) < 0.001 && fabs(resJD[i].y - TMP.y) < 0.001
			&& resJD[i].JIAOxuhao != TMP.RDcankao && resJD[i].RDcankao != TMP.JIAOxuhao)
			return;
	}
	resJD.push_back(TMP);
}

bool CDrawRoad::TrsNEtoCml(Road RD, double N, double E, double& Cml) const
 {
	Cml = PROJ_ML(RD.array, RD.tarray, N, E, N, E);
	return true;
}

bool CDrawRoad::TrsNEtoCml(Road_BX RD, double N, double E, double& Cml) const
{
	Cml = PROJ_ML(array_BX, tarray_BX, N, E, N, E);
	return true;
}

bool CDrawRoad::TrsNEtoCml(Rd_BX RD, double N, double E, double& Cml) const
{
	Cml = PROJ_ML(array_BX, tarray_BX, N, E, N, E);
	return true;
}

bool CDrawRoad::TrsCmltoGC(Road RD, double Cml, double& GC) const
{
	int BPDSize =(int)RD.m_BPDArray.size();
	GC = 0;
	if (BPDSize > 0)
	{
		for (int i = 0; i < BPDSize - 1; i++)
		{
			if (Cml >= RD.m_BPDArray[i].lc && Cml <= RD.m_BPDArray[i + 1].lc)
			{
				GC = RD.m_BPDArray[i].gc + RD.m_BPDArray[i].pd * (Cml - RD.m_BPDArray[i].lc) * 0.01;
				break;
			}
		}
	}
	if (GC != 0)
		return true;
	else
		return false;
}

bool CDrawRoad::TrsCmltoGC(Road_BX RD, double Cml, double& GC) const
{
	int BPDSize = (int)RD.m_BPDArray.size();
	GC = 0;
	if (BPDSize > 0)
	{
		for (int i = 0; i < BPDSize - 1; i++)
		{
			if (Cml >= (RD.m_BPDArray[i].lc - 2.5) && (Cml <= RD.m_BPDArray[i + 1].lc + 2.5))
			{
				GC = RD.m_BPDArray[i].gc + RD.m_BPDArray[i].pd * (Cml - RD.m_BPDArray[i].lc)*0.01;
				break;
			}
		}
	}
	if (GC != 0)
		return true;
	else
		return false;
}

bool CDrawRoad::CalGCFromRoadGC(Road RD, double X, double Y, double& GC) const
{
	vector<DPoint3d>PointArraytmp;
	PointArraytmp.clear();
	for (int i = 0; i < RD.JDARRAY.size(); i++)
	{
		DPoint3d Point3dtmp = DPoint3d::FromZero();
		Point3dtmp.x = RD.JDARRAY[i].x;
		Point3dtmp.y = RD.JDARRAY[i].y;
		Point3dtmp.z = RD.JDARRAY[i].gc;
		PointArraytmp.push_back(Point3dtmp);
	}
	for (int i = 0; i < PointArraytmp.size() - 1; i++)
	{
		bool IsInLine;
		DPoint3d TargetPoint = DPoint3d::FromZero();
		TargetPoint.x = X;
		TargetPoint.y = Y;
		IsInLine = GetPointIsInLine(TargetPoint, PointArraytmp[i], PointArraytmp[i + 1]);
		if (IsInLine)
		{
			double Distancetmp = sqrt(pow((PointArraytmp[i].x - PointArraytmp[i + 1].x), 2) + pow((PointArraytmp[i].y - PointArraytmp[i + 1].y), 2));
			double Distancetmp1 = sqrt(pow((PointArraytmp[i].x - TargetPoint.x), 2) + pow((PointArraytmp[i].y - TargetPoint.y), 2));
			if (Distancetmp1 == 0)
			{
				GC = PointArraytmp[i].z;
				break;
			}
			else
			{
				double GCValue = 0.0;
				GCValue = PointArraytmp[i + 1].z - PointArraytmp[i].z;
				GC = PointArraytmp[i].z + GCValue * Distancetmp1 / Distancetmp;
				break;
			}
		}
	}

	if (GC != 0)
		return true;
	else
		return false;
}

bool CDrawRoad::CalGCFromRoadGC(Road_BX RD, double X, double Y, double& GC) const
{
	vector<DPoint3d>PointArraytmp;
	PointArraytmp.clear();
	for (int i = 0; i < RD.JDARRAY.size(); i++)
	{
		DPoint3d Point3dtmp = DPoint3d::FromZero();
		Point3dtmp.x = RD.JDARRAY[i].x;
		Point3dtmp.y = RD.JDARRAY[i].y;
		Point3dtmp.z = RD.JDARRAY[i].gc;
		PointArraytmp.push_back(Point3dtmp);
	}
	for (int i = 0; i < PointArraytmp.size() - 1; i++)
	{
		bool IsInLine;
		DPoint3d TargetPoint = DPoint3d::FromZero();
		TargetPoint.x = X;
		TargetPoint.y = Y;
		IsInLine = GetPointIsInLine(TargetPoint, PointArraytmp[i], PointArraytmp[i + 1]);
		if (IsInLine)
		{
			double Distancetmp = sqrt(pow((PointArraytmp[i].x- PointArraytmp[i+1].x),2)+ pow((PointArraytmp[i].y - PointArraytmp[i + 1].y), 2));
			double Distancetmp1 = sqrt(pow((PointArraytmp[i].x - TargetPoint.x), 2) + pow((PointArraytmp[i].y - TargetPoint.y), 2));
			if (Distancetmp1 == 0)
			{
				GC = PointArraytmp[i].z;
				break;
			}
			else
			{
				double GCValue = 0.0;
				GCValue = PointArraytmp[i + 1].z - PointArraytmp[i].z;
				GC = PointArraytmp[i].z + GCValue * Distancetmp1 / Distancetmp;
				break;
			}
		}
	}

	if (GC != 0)
		return true;
	else
		return false;
}

bool CDrawRoad::GetGCFromRoadGCForHHQX(double cml, double length1, double GCC,double GC1, double& GC) const //gcc表示高程差
{
	GC = GC1 + GCC * cml / length1;
	if (GC != 0)
		return true;
	else
		return false;
}

//判断点是否在直线上
bool CDrawRoad::GetPointIsInLine(DPoint3d pf, DPoint3d p1, DPoint3d p2, double range)
{

	//range 判断的的误差，不需要误差则赋值0
	//点在线段首尾两端之外则return false
	if (fabs(pf.x - p1.x) < range && fabs(pf.y - p1.y) < range)
		return true;
	if (fabs(pf.x - p2.x) < range && fabs(pf.y - p2.y) < range)
		return true;

	double cross = (p2.x - p1.x) * (pf.x - p1.x) + (p2.y - p1.y) * (pf.y - p1.y);
	if (cross <= 0) return false;
	double d2 = (p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y);
	if (cross >= d2) return false;

	double r = cross / d2;
	double px = p1.x + (p2.x - p1.x) * r;
	double py = p1.y + (p2.y - p1.y) * r;

	//判断距离是否小于误差
	return sqrt((pf.x - px) * (pf.x - px) + (py - pf.y) * (py - pf.y)) <= range;
}

void CDrawRoad::InterSectRDSelf(vector<JDdata> JDARRAY, double R, vector<QiuJiao_inf>& resJD) const
{
	//小于3点直接返回
	if (JDARRAY.size() <= 3)
		return;
	resJD.clear();
	QiuJiao_inf TMP;
	double x, y;
	int res;
	double dis = 0;
	double f1, f2;
	for (int i = 0; i < (int)JDARRAY.size() - 1; i++)
	{
		if (i > 1)
		{
			//前线段
			for (int j = 0; j < i - 1; j++)
			{
				res = INTERS(&x, &y, JDARRAY[i].x, JDARRAY[i].y, JDARRAY[i + 1].x, JDARRAY[i + 1].y, JDARRAY[j].x, JDARRAY[j].y, JDARRAY[j + 1].x, JDARRAY[j + 1].y);
				xyddaa(JDARRAY[i].x, JDARRAY[i].y, JDARRAY[i + 1].x, JDARRAY[i + 1].y, f1);
				xyddaa(JDARRAY[j].x, JDARRAY[j].y, JDARRAY[j + 1].x, JDARRAY[j + 1].y, f2);
				if (res == 0 && fabs(f1 - f2) > 0.001)
				{
					TMP.x = x;
					TMP.y = y;
					TMP.RDcankao = i;
					TMP.JIAOxuhao = j;
					TMP.kuandu = JDARRAY[i].kuandu;
					TMP.R = R;
					TMP.f = f1;
					CheckQiuJiaoPushback(TMP, resJD);
				}
			}
		}
		if (i < JDARRAY.size() - 3)
		{
			//后线段
			for (int j = i + 2; j < (int)JDARRAY.size() - 1; j++)
			{
				res = INTERS(&x, &y, JDARRAY[i].x, JDARRAY[i].y, JDARRAY[i + 1].x, JDARRAY[i + 1].y, JDARRAY[j].x, JDARRAY[j].y, JDARRAY[j + 1].x, JDARRAY[j + 1].y);
				xyddaa(JDARRAY[i].x, JDARRAY[i].y, JDARRAY[i + 1].x, JDARRAY[i + 1].y, f1);
				xyddaa(JDARRAY[j].x, JDARRAY[j].y, JDARRAY[j + 1].x, JDARRAY[j + 1].y, f2);
				if (res == 0 && fabs(f1 - f2) > 0.001)
				{
					TMP.x = x;
					TMP.y = y;
					TMP.RDcankao = i;
					TMP.JIAOxuhao = j;
					TMP.kuandu = JDARRAY[i].kuandu;
					TMP.R = R;
					TMP.f = f1;
					CheckQiuJiaoPushback(TMP, resJD);
				}
			}
		}
	}
}

void CDrawRoad::InterSectRD(vector<JDdata> JDARRAY1, vector<JDdata> JDARRAY2, double R1, double R2, vector<QiuJiao_inf>& resJD) const
{
	QiuJiao_inf TMP;
	double x, y;
	int res;
	resJD.clear();
	double dis = 0;
	double f1, f2;
	DVec3d vec1, vec2;
	DPoint3d x1, x1change, y1, y1change;
	DPoint3d x2, x2change, y2, y2change;
	int inorout;
	DPoint3d ptchui;
	for (int i = 0; i < (int)JDARRAY1.size() - 1; i++)
	{
		for (int j = 0; j < (int)JDARRAY2.size() - 1; j++)
		{
			//JDARRAY1方向的矢量
			vec1 = DVec3d::From(JDARRAY1[i + 1].x - JDARRAY1[i].x, JDARRAY1[i + 1].y - JDARRAY1[i].y, 0);
			vec1.Normalize();
			x1.Init(JDARRAY1[i].x, JDARRAY1[i].y, 0);
			y1.Init(JDARRAY1[i + 1].x, JDARRAY1[i + 1].y, 0);
			//JDARRAY2方向的矢量
			vec2 = DVec3d::From(JDARRAY2[j + 1].x - JDARRAY2[j].x, JDARRAY2[j + 1].y - JDARRAY2[j].y, 0);
			vec2.Normalize();
			x2.Init(JDARRAY2[j].x, JDARRAY2[j].y, 0);
			y2.Init(JDARRAY2[j + 1].x, JDARRAY2[j + 1].y, 0);

			//判断y2是否在x1 y1的线段上，若刚好在线段上，则交点沿道路向量缩减0.1长度；
			ptchui.Init(0, 0, 0);
			ChuizuToZx(inorout, ptchui.x, ptchui.y, y2.x, y2.y, x1.x, x1.y, y1.x, y1.y);
			if (y2.Distance(ptchui) < 0.001)
				y2 -= 0.1 * vec2;
			//判断x2是否在x1 y1的线段上，若刚好在线段上，则交点沿道路向量缩减0.1长度；
			ChuizuToZx(inorout, ptchui.x, ptchui.y, x2.x, x2.y, x1.x, x1.y, y1.x, y1.y);
			if (x2.Distance(ptchui) < 0.001)
				x2 -= 0.1 * vec2;

			if (i == 0) // 若x1是起点，则沿所在直线延长半路宽（是否应用JDARRAY2的路宽？）
				x1change = x1 - (JDARRAY1[i].kuandu_left + JDARRAY1[i].kuandu_right) / 2.0 * vec1;
			else
				x1change = x1;
			if (i == JDARRAY1.size() - 2)// 若y1是终点，则沿所在直线延长半路宽（是否应用JDARRAY2的路宽？）
				y1change = y1 + (JDARRAY1[i].kuandu_left + JDARRAY1[i].kuandu_right) / 2.0 * vec1;
			else
				y1change = y1;

			if (j == 0) // 同上
				x2change = x2 - (JDARRAY2[j].kuandu_left + JDARRAY2[j].kuandu_right) / 2.0 * vec2;
			else
				x2change = x2;
			if (j == JDARRAY2.size() - 2)
				y2change = y2 + (JDARRAY2[j].kuandu_left + JDARRAY2[j].kuandu_right) / 2.0 * vec2;
			else
				y2change = y2;

			res = INTERS(&x, &y, x1change.x, x1change.y, y1change.x, y1change.y,
				x2change.x, x2change.y, y2change.x, y2change.y); // 判断是否直接相交，并返回交点坐标
			//res=INTERS(&x,&y,JDARRAY1[i].x,JDARRAY1[i].y,JDARRAY1[i+1].x,JDARRAY1[i+1].y,
			//	JDARRAY2[j].x,JDARRAY2[j].y,JDARRAY2[j+1].x,JDARRAY2[j+1].y);
			// 计算两条相交直线段各自的转角
			xyddaa(JDARRAY1[i].x, JDARRAY1[i].y, JDARRAY1[i + 1].x, JDARRAY1[i + 1].y, f1);
			xyddaa(JDARRAY2[j].x, JDARRAY2[j].y, JDARRAY2[j + 1].x, JDARRAY2[j + 1].y, f2);
			if (res == 0 && fabs(f1 - f2) > 0.001) // 得到相交信息
			{
				TMP.x = x;
				TMP.y = y;
				TMP.RDcankao = i; //此处i j需修正
				TMP.JIAOxuhao = j;
				TMP.kuandu = JDARRAY1[i].kuandu;
				TMP.R = max(R1, R2);
				TMP.f = f1;
				resJD.push_back(TMP);
			}
		}
	}
	//剔除重复
	if (resJD.size() > 1)
	{
		for (int i = 0; i < (int)resJD.size() - 1; i++)
		{
			if (fabs(resJD[i].x - resJD[i + 1].x) < 0.001 && fabs(resJD[i].y - resJD[i + 1].y) < 0.001)
			{
				resJD.erase(resJD.begin() + i);
				i--;
			}
		}
	}
}

bool CDrawRoad::TrsCmltoI(Road RD, double CML, int& num) const
{
	vector<int>I_SUM;
	num = 0;
	xlpoint PZ;
	TrsCmltoNE(CML, PZ, RD);
	DPoint3d PT;
	PT.Init(PZ.y, PZ.x, 0);
	double dXchuizu1, dYchuizu1;
	for (int i = 0; i < (int)RD.JDARRAY.size() - 1; i++) //
	{
		int inorout;
		ChuizuToZx(inorout, dXchuizu1, dYchuizu1, PT.x, PT.y, RD.JDARRAY[i].x, RD.JDARRAY[i].y, RD.JDARRAY[i + 1].x, RD.JDARRAY[i + 1].y);
		if (inorout == 1) //如果垂足在直线上
		{
			I_SUM.push_back(i);
		}
	}

	if (I_SUM.size() == 1)
	{
		num = I_SUM[0];
		return true;
	}
	else
	{
		double cml1, cml2;
		for (int i = 0; i < (int)I_SUM.size(); i++)
		{
			TrsNEtoCml(RD, RD.JDARRAY[I_SUM[i]].y, RD.JDARRAY[I_SUM[i]].x, cml1);
			TrsNEtoCml(RD, RD.JDARRAY[I_SUM[i] + 1].y, RD.JDARRAY[I_SUM[i] + 1].x, cml2);
			if (CML - cml1 >= -0.001 && cml2 - CML >= -0.001)
			{
				num = I_SUM[i];
				return true;
			}
		}
	}
	return false;
}

// 求交点信息
void CDrawRoad::RD_QiuJiao(vector<Road>& m_RoadData3) const
{
	vector<QiuJiao_inf> pTemp; // 相交信息临时数组
	int  m_RoadNum1 = (int)m_RoadData3.size();
	for (int i = 0; i < m_RoadNum1; i++)
	{
		m_RoadData3[i].ConRD.clear();
		for (int ii = 0; ii < m_RoadNum1; ii++)
		{
			pTemp.clear();
			if (ii == i) // 自相交信息
				InterSectRDSelf(m_RoadData3[i].JDARRAY,/*m_RoadData3[i].minR*/6, pTemp);
			else         // 其他相交信息
				InterSectRD(m_RoadData3[i].JDARRAY, m_RoadData3[ii].JDARRAY,/*m_RoadData3[i].minR*/6.0, 6.0 /*m_RoadData3[ii].minR*/, pTemp);
			//记录交点信息
			//m_RoadData3[i].ConRD_num=(int)m_RoadData3[i].ConRD.size();
			if (pTemp.size() > 0)
			{
				ConnectRoad ptemp_RD_Detail;
				_tcscpy(ptemp_RD_Detail.DLBiaoHao, L"");
				_tcscpy(ptemp_RD_Detail.MyBiaoHao, L"");
				ptemp_RD_Detail.ConnectStyle = 0;

				double dist1 = 0.0;
				double dist2 = 0.0;
				double dist3 = 0.0;
				double dist4 = 0.0;
				double f = 0;
				int style;
				//	ptemp_RD_Detail.resize((int)pTemp.size());
				for (int kk = 0; kk < (int)pTemp.size(); kk++)
				{
					ptemp_RD_Detail.ConJD.x = pTemp[kk].x;
					ptemp_RD_Detail.ConJD.y = pTemp[kk].y;
					ptemp_RD_Detail.RDcankao = pTemp[kk].RDcankao;
					_tcscpy(ptemp_RD_Detail.MyBiaoHao, m_RoadData3[i].DLBiaoHao);
					ptemp_RD_Detail.JIAOxuhao = pTemp[kk].JIAOxuhao;
					if (ii == i)
					{
						vector<double> ml;
						ml.clear();
						PROJ_ML_all(m_RoadData3[i].array, m_RoadData3[i].tarray,
							pTemp[kk].y, pTemp[kk].x, pTemp[kk].y, pTemp[kk].x, ml);
						ptemp_RD_Detail.ConJD.lc = ml[0];
						for (int kkk = 0; kkk < (int)ml.size(); kkk++)
						{
							int searchnum = 0;
							TrsCmltoI(m_RoadData3[i], ml[kkk], searchnum);
							if (searchnum == pTemp[kk].RDcankao)
							{
								ptemp_RD_Detail.ConJD.lc = ml[kkk];
								break;
							}
						}

					}
					else
					{
						ptemp_RD_Detail.ConJD.lc = PROJ_ML(m_RoadData3[i].array, m_RoadData3[i].tarray,
							pTemp[kk].y, pTemp[kk].x, pTemp[kk].y, pTemp[kk].x);
					}

					ptemp_RD_Detail.ConJD.R = pTemp[kk].R;
					//ads_printf(L"投影里程%lf     %lf     %lf\n",pTemp[kk].x, pTemp[kk].y, ptemp_RD_Detail.ConJD.lc);
					//与该线的第一个点比较确定其为T字开头
					dist1 = pow(pTemp[kk].x - m_RoadData3[i].JDARRAY[0].x, 2) + pow(pTemp[kk].y - m_RoadData3[i].JDARRAY[0].y, 2);
					dist1 = sqrt(dist1);
					xyddaa(m_RoadData3[i].JDARRAY[0].x, m_RoadData3[i].JDARRAY[0].y, m_RoadData3[i].JDARRAY[1].x, m_RoadData3[i].JDARRAY[1].y, f);
					if (dist1 < m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].kuandu /*/ 2.0*/ + 0.0001 && (fabs(f - pTemp[kk].f) < 0.001 || fabs(fabs(f - pTemp[kk].f) - 2 * PI) < 0.001))
					{
						//此处需增加判断区分T字连接，Y连接
						//与相交路段两端比较，若与路段起点距离小于半路宽，记为T前左 ，若与路段终点距离小于路宽，记为T前右
						double disttmp1 = 0, disttmp2 = 0;
						if (m_RoadData3[ii].JDARRAY.size() > 2)//首先判断此路顶点大于两个
						{
							//与路段起点距离小于当前路宽，记为T前左，约束条件交点序号大于0
							disttmp1 = pow(pTemp[kk].x - m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].x, 2) + pow(pTemp[kk].y - m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].y, 2);
							disttmp1 = sqrt(disttmp1);
							if (disttmp1 < m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].kuandu/* / 2.0 */ + 0.0001/*+ m_RoadData3[i].minR*/ && pTemp[kk].JIAOxuhao>0)
							{
								style = 5;//T前左
								ptemp_RD_Detail.ConnectStyle = style;
								ptemp_RD_Detail.RDcankao = -1;
								_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
								m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
								continue;
							}

							//与路段终点距离小于当前路宽，记为T前右，约束条件交点序号小于最后两点
							disttmp2 = pow(pTemp[kk].x - m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao + 1].x, 2) + pow(pTemp[kk].y - m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao + 1].y, 2);
							disttmp2 = sqrt(disttmp2);
							if (disttmp2 < m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].kuandu/* / 2.0*/ + 0.0001/*+m_RoadData3[i].minR*/ && pTemp[kk].JIAOxuhao < m_RoadData3[ii].JDARRAY.size() - 2)
							{
								style = 6;//T前右
								ptemp_RD_Detail.ConnectStyle = style;
								ptemp_RD_Detail.RDcankao = -1;
								_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
								m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
								continue;
							}
						}
						//T前
						style = 0;
						ptemp_RD_Detail.ConnectStyle = style;
						ptemp_RD_Detail.RDcankao = -1;
						_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
						m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
						continue;
					}

					//与该线的最后一个点比较
					dist2 = pow(pTemp[kk].x - m_RoadData3[i].JDARRAY[m_RoadData3[i].JDARRAY.size() - 1].x, 2) + pow(pTemp[kk].y - m_RoadData3[i].JDARRAY[m_RoadData3[i].JDARRAY.size() - 1].y, 2);
					dist2 = sqrt(dist2);
					xyddaa(m_RoadData3[i].JDARRAY[m_RoadData3[i].JDARRAY.size() - 2].x, m_RoadData3[i].JDARRAY[m_RoadData3[i].JDARRAY.size() - 2].y, m_RoadData3[i].JDARRAY[m_RoadData3[i].JDARRAY.size() - 1].x, m_RoadData3[i].JDARRAY[m_RoadData3[i].JDARRAY.size() - 1].y, f);
					//if (dist2<m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].kuandu/2.0)
					if (dist2 < m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].kuandu/* / 2.0*/ + 0.0001 && (fabs(f - pTemp[kk].f) < 0.001 || fabs(fabs(f - pTemp[kk].f) - 2 * PI) < 0.001))
					{
						//此处需增加判断区分T字连接，Y连接
						//与相交路段两端比较，若与路段起点距离小于路宽，记为T后左 ，若与路段终点距离小于路宽，记为T后右
						double disttmp1 = 0, disttmp2 = 0;
						if (m_RoadData3[ii].JDARRAY.size() > 2)//首先判断此路顶点大于两个
						{
							//与路段起点距离小于当前路宽，记为T前左，约束条件交点序号大于0
							disttmp1 = pow(pTemp[kk].x - m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].x, 2) + pow(pTemp[kk].y - m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].y, 2);
							disttmp1 = sqrt(disttmp1);
							if (disttmp1 < m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].kuandu/* / 2.0*/ + 0.0001 /*+m_RoadData3[i].minR */ && pTemp[kk].JIAOxuhao>0)
							{
								style = 7;//T后左
								ptemp_RD_Detail.ConnectStyle = style;
								ptemp_RD_Detail.RDcankao = 10000;
								_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
								m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
								continue;
							}

							//与路段终点距离小于当前路宽，记为T前右，约束条件交点序号小于最后两点
							disttmp2 = pow(pTemp[kk].x - m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao + 1].x, 2) + pow(pTemp[kk].y - m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao + 1].y, 2);
							disttmp2 = sqrt(disttmp2);
							if (disttmp2 < m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].kuandu/* / 2.0*/ + 0.0001/*+m_RoadData3[i].minR */ && pTemp[kk].JIAOxuhao < m_RoadData3[ii].JDARRAY.size() - 2)
							{
								style = 8;//T后右
								ptemp_RD_Detail.ConnectStyle = style;
								ptemp_RD_Detail.RDcankao = 10000;
								_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
								m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
								continue;
							}
						}

						//T后
						style = 1;
						ptemp_RD_Detail.ConnectStyle = style;
						ptemp_RD_Detail.RDcankao = 10000;
						_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
						m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
						//break;
						continue;
					}

					//与相交线的第一个点比较
					dist3 = pow(pTemp[kk].x - m_RoadData3[ii].JDARRAY[0].x, 2) + pow(pTemp[kk].y - m_RoadData3[ii].JDARRAY[0].y, 2);
					dist3 = sqrt(dist3);
					if (dist3 < m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].kuandu /*/ 2.0*/ + 0.0001)
					{
						int ci = ptemp_RD_Detail.RDcankao;
						double zory;
						zory = CCW2(m_RoadData3[i].JDARRAY[ci].x, m_RoadData3[i].JDARRAY[ci].y,
							m_RoadData3[i].JDARRAY[ci + 1].x, m_RoadData3[i].JDARRAY[ci + 1].y,
							m_RoadData3[ii].JDARRAY[1].x, m_RoadData3[ii].JDARRAY[1].y);

						//与相交路段两端比较，若与路段起点距离小于路宽，记为T后左 ，若与路段终点距离小于路宽，记为T后右
						double disttmp1 = 0, disttmp2 = 0;
						if (m_RoadData3[i].JDARRAY.size() > 2)//首先判断此路顶点大于两个
						{
							//与路段起点距离小于当前路宽，记为T左，约束条件交点序号大于0
							disttmp1 = pow(pTemp[kk].x - m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].x, 2) + pow(pTemp[kk].y - m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].y, 2);
							disttmp1 = sqrt(disttmp1);
							if (disttmp1 < m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].kuandu/* / 2.0 */ + 0.0001/*+m_RoadData3[ii].minR*/ && pTemp[kk].RDcankao>0)
							{
								if (zory < 0)
								{
									//右岔路左边点";
									style = 9;
									ptemp_RD_Detail.ConnectStyle = style;
									_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
									m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
								}
								else
								{
									//"左岔路左边点";
									style = 10;
									ptemp_RD_Detail.ConnectStyle = style;
									_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
									m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
								}
								continue;
							}

							//与路段终点距离小于当前路宽，记为T右，约束条件交点序号小于最后两点
							disttmp2 = pow(pTemp[kk].x - m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao + 1].x, 2) + pow(pTemp[kk].y - m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao + 1].y, 2);
							disttmp2 = sqrt(disttmp2);
							if (disttmp2 < m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].kuandu /*/ 2.0*/ + 0.0001/* +m_RoadData3[ii].minR*/ && pTemp[kk].RDcankao < m_RoadData3[i].JDARRAY.size() - 2)
							{
								if (zory < 0)
								{
									//右岔路右边点";
									style = 11;
									ptemp_RD_Detail.ConnectStyle = style;
									_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
									m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
								}
								else
								{
									//"左岔路右边点";
									style = 12;
									ptemp_RD_Detail.ConnectStyle = style;
									_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
									m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
								}
								continue;
							}
						}
						//T半
						if (zory < 0)
						{
							//右岔路点";
							style = 2;
							ptemp_RD_Detail.ConnectStyle = style;
						}
						else
						{
							//"左岔路点";
							style = 3;
							ptemp_RD_Detail.ConnectStyle = style;
						}
						_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
						m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
						//break;
						continue;
					}

					//与相交线的最后一个点比较
					dist4 = pow(pTemp[kk].x - m_RoadData3[ii].JDARRAY[m_RoadData3[ii].JDARRAY.size() - 1].x, 2) + pow(pTemp[kk].y - m_RoadData3[ii].JDARRAY[m_RoadData3[ii].JDARRAY.size() - 1].y, 2);
					dist4 = sqrt(dist4);

					if (dist4 < m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].kuandu/* / 2.0 */ + 0.0001)
					{
						//T半
						int ci = ptemp_RD_Detail.RDcankao;
						double zory;
						zory = CCW2(m_RoadData3[i].JDARRAY[ci].x, m_RoadData3[i].JDARRAY[ci].y,
							m_RoadData3[i].JDARRAY[ci + 1].x, m_RoadData3[i].JDARRAY[ci + 1].y,
							m_RoadData3[ii].JDARRAY[m_RoadData3[ii].JDARRAY.size() - 1].x, m_RoadData3[ii].JDARRAY[m_RoadData3[ii].JDARRAY.size() - 1].y);

						//与相交路段两端比较，若与路段起点距离小于路宽，记为T后左 ，若与路段终点距离小于路宽，记为T后右
						double disttmp1 = 0, disttmp2 = 0;
						if (m_RoadData3[i].JDARRAY.size() > 2)//首先判断此路顶点大于两个
						{
							//与路段起点距离小于当前路宽，记为T左，约束条件交点序号大于0
							disttmp1 = pow(pTemp[kk].x - m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].x, 2) + pow(pTemp[kk].y - m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].y, 2);
							disttmp1 = sqrt(disttmp1);
							if (disttmp1 < m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].kuandu/* / 2.0 */ + 0.0001/*+m_RoadData3[ii].minR*/ && pTemp[kk].RDcankao>0)
							{
								if (zory > 0)
								{
									//右岔路左边点";
									style = 9;
									ptemp_RD_Detail.ConnectStyle = style;
									_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
									m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
								}
								else
								{
									//"左岔路左边点";
									style = 10;
									ptemp_RD_Detail.ConnectStyle = style;
									_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
									m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
								}
								continue;
							}

							//与路段终点距离小于当前路宽，记为T右，约束条件交点序号小于最后两点
							disttmp2 = pow(pTemp[kk].x - m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao + 1].x, 2) + pow(pTemp[kk].y - m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao + 1].y, 2);
							disttmp2 = sqrt(disttmp2);
							if (disttmp2 < m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].kuandu /*/ 2.0*/ + 0.0001/*+m_RoadData3[ii].minR*/ && pTemp[kk].RDcankao < m_RoadData3[i].JDARRAY.size() - 2)
							{
								if (zory > 0)
								{
									//右岔路右边点";
									style = 11;
									ptemp_RD_Detail.ConnectStyle = style;
									_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
									m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
								}
								else
								{
									//"左岔路右边点";
									style = 12;
									ptemp_RD_Detail.ConnectStyle = style;
									_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
									m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
								}
								continue;
							}
						}


						if (zory > 0)
						{
							//右岔路点";
							//   AfxMessageBox(L"T右");
							style = 2;
							ptemp_RD_Detail.ConnectStyle = style;
						}
						else
						{
							//"左岔路点";
							//	AfxMessageBox(L"T左");
							style = 3;
							ptemp_RD_Detail.ConnectStyle = style;
						}
						_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
						m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
						//break;
						continue;
					}

					double disttmp1 = 0, disttmp2 = 0;
					if (m_RoadData3[i].JDARRAY.size() > 2)//首先判断此路顶点大于两个
					{
						//与路段起点距离小于当前路宽，记为左，约束条件交点序号大于0
						disttmp1 = pow(pTemp[kk].x - m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].x, 2) + pow(pTemp[kk].y - m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].y, 2);
						disttmp1 = sqrt(disttmp1);
						if (disttmp1 < m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].kuandu/* / 2.0*/ + 0.0001/* +m_RoadData3[ii].minR*/ && pTemp[kk].RDcankao>0)
						{
							//十字路口左边点";
							style = 13;
							ptemp_RD_Detail.ConnectStyle = style;
							_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
							m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
							continue;
						}

						//与路段终点距离小于当前路宽，记为右，约束条件交点序号小于最后两点
						disttmp2 = pow(pTemp[kk].x - m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao + 1].x, 2) + pow(pTemp[kk].y - m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao + 1].y, 2);
						disttmp2 = sqrt(disttmp2);
						if (disttmp2 < m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].kuandu/* / 2.0*/ + 0.0001/*+m_RoadData3[ii].minR*/ && pTemp[kk].RDcankao < m_RoadData3[i].JDARRAY.size() - 2)
						{
							//十字路口右边点";
							style = 14;
							ptemp_RD_Detail.ConnectStyle = style;
							_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
							m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
							continue;
						}
					}

					//与相交路段比较
					disttmp1 = pow(pTemp[kk].x - m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].x, 2) + pow(pTemp[kk].y - m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao].y, 2);
					disttmp1 = sqrt(disttmp1);
					if (disttmp1 < m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].kuandu/* / 2.0*/ + 0.0001/*+m_RoadData3[i].minR*/ && pTemp[kk].JIAOxuhao>0)
					{
						//十字路口前边点";
						style = 15;
						ptemp_RD_Detail.ConnectStyle = style;
						_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
						m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
						continue;
					}

					//与路段终点距离小于当前路宽，记为右，约束条件交点序号小于最后两点
					disttmp2 = pow(pTemp[kk].x - m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao + 1].x, 2) + pow(pTemp[kk].y - m_RoadData3[ii].JDARRAY[pTemp[kk].JIAOxuhao + 1].y, 2);
					disttmp2 = sqrt(disttmp2);
					if (disttmp2 < m_RoadData3[i].JDARRAY[pTemp[kk].RDcankao].kuandu /*/ 2.0*/ + 0.0001/*+m_RoadData3[i].minR*/ && pTemp[kk].JIAOxuhao < m_RoadData3[ii].JDARRAY.size() - 2)
					{
						//十字路口后边点";
						style = 16;
						ptemp_RD_Detail.ConnectStyle = style;
						_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
						m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
						continue;
					}
					//十字路口
				//	AfxMessageBox(L"十字");
					style = 4;
					ptemp_RD_Detail.ConnectStyle = style;
					_tcscpy(ptemp_RD_Detail.DLBiaoHao, m_RoadData3[ii].DLBiaoHao);
					m_RoadData3[i].ConRD.push_back(ptemp_RD_Detail);
				}
			}
		}
		//对m_RoadData3[i].ConRD排序  从大到小
		ConnectRoad ptemp_RD_Detail;
		for (int kk = 1; kk < (int)m_RoadData3[i].ConRD.size(); kk++)
		{
			for (int jj = (int)m_RoadData3[i].ConRD.size() - 1; jj >= kk; jj--)
			{
				if (m_RoadData3[i].ConRD[jj].ConJD.lc > m_RoadData3[i].ConRD[jj - 1].ConJD.lc)
				{
					ptemp_RD_Detail = m_RoadData3[i].ConRD[jj - 1];
					m_RoadData3[i].ConRD[jj - 1] = m_RoadData3[i].ConRD[jj];
					m_RoadData3[i].ConRD[jj] = ptemp_RD_Detail;
				}
			}
		}
	}

}

int CDrawRoad::INTERJD(double& x, double& y, double X1, double Y1, double X2, double Y2, double X3, double Y3, double X4, double Y4) const
{
	double A11, A12, A21, A22, B1, B2, D, D1, D2;

	A11 = Y2 - Y1;
	A12 = X1 - X2;
	A21 = Y4 - Y3;
	A22 = X3 - X4;
	B1 = X1 * Y2 - X2 * Y1;
	B2 = X3 * Y4 - X4 * Y3;
	D = A11 * A22 - A21 * A12;


	D1 = B1 * A22 - B2 * A12;
	D2 = B2 * A11 - B1 * A21;
	if (fabs(D) < 0.00001)
	{
		vector<DPoint2d>PTArray;
		DPoint2d PT;
		PTArray.clear();
		PT.Init(X1, Y1);
		PTArray.push_back(PT);
		PT.Init(X2, Y2);
		PTArray.push_back(PT);
		PT.Init(X3, Y3);
		PTArray.push_back(PT);
		PT.Init(X4, Y4);
		PTArray.push_back(PT);
		//排序
		if (fabs(X1 - X2) < 0.001)
		{
			//Y从小到大
			for (int i = 1; i < (int)PTArray.size(); i++)
			{
				for (int j = (int)PTArray.size() - 1; j >= i; j--)
				{
					if (PTArray[j].y < PTArray[j - 1].y)
					{
						PT = PTArray[j - 1];
						PTArray[j - 1] = PTArray[j];
						PTArray[j] = PT;
					}
				}
			}
		}
		else
		{
			//Y从小到大
			for (int i = 1; i < (int)PTArray.size(); i++)
			{
				for (int j = (int)PTArray.size() - 1; j >= i; j--)
				{
					if (PTArray[j].x < PTArray[j - 1].x)
					{
						PT = PTArray[j - 1];
						PTArray[j - 1] = PTArray[j];
						PTArray[j] = PT;
					}
				}
			}
		}

		x = (PTArray[1].x + PTArray[2].x) / 2.0;
		y = (PTArray[1].y + PTArray[2].y) / 2.0;
		return 0;
	}
	else
	{
		x = D1 / D;
		y = D2 / D;
	}
	return 1;
}

//传入道路某一段交点数组，与当前的交点首尾比较，判断是否有重叠的起终点
void CDrawRoad::CheckJDData(vector<JDdata> JDdataIn, vector<vector<JDdata>>& JDdataOut,
	RoadChaiChuArray CCDin, vector<RoadChaiChuArray>& CCDout)
{
	if (JDdataIn.size() == 0)
		return;

	DPoint3d ptInStart, ptInEnd, ptOutStart, ptOutEnd;
	ptInStart.Init(JDdataIn[0].x, JDdataIn[0].y, 0);
	ptInEnd.Init(JDdataIn[(int)JDdataIn.size() - 1].x, JDdataIn[(int)JDdataIn.size() - 1].y, 0);

	for (int i = 0; i < (int)JDdataOut.size(); i++)
	{
		ptOutStart.Init(JDdataOut[i][0].x, JDdataOut[i][0].y, 0);
		ptOutEnd.Init(JDdataOut[i][JDdataOut[i].size() - 1].x, JDdataOut[i][JDdataOut[i].size() - 1].y, 0);
		//两者起点相同
		if (ptInStart.Distance(ptOutStart) < 1)
		{
			//检测第一点半径
			if (JDdataIn[0].R > 0.001)
				JDdataOut[i][0].R = JDdataIn[0].R;

			_tcscpy(JDdataOut[i][0].JXLC, L"交叉口");
			for (int j = 1; j < (int)JDdataIn.size(); j++)
				JDdataOut[i].insert(JDdataOut[i].begin(), JDdataIn[j]);

			//判别终点是否相等，检测环形道路
			if (ptInEnd.Distance(ptOutEnd) < 1)
			{
				JDdata JDCenter;
				InitJDdata(JDCenter);
				_tcscpy(JDCenter.JXLC, L"交叉口");
				JDCenter = JDdataOut[i][0];
				JDCenter.x = (JDdataOut[i][0].x + JDdataOut[i][1].x) / 2.0;
				JDCenter.y = (JDdataOut[i][0].y + JDdataOut[i][1].y) / 2.0;
				if (JDCenter.R < 0.1)
					JDCenter.R = 6;
				//修改起点
				JDdataOut[i][0] = JDCenter;
				JDdataOut[i].push_back(JDCenter);
			}
			for (int j = 0; j < (int)CCDin.size(); j++)
				CCDout[i].push_back(CCDin[j]);
			return;
		}
		//输入终点与输出起点相同
		if (ptInEnd.Distance(ptOutStart) < 1)
		{
			//检测第一点半径
			if (JDdataIn[(int)JDdataIn.size() - 1].R > 0.001)
				JDdataOut[i][0].R = JDdataIn[(int)JDdataIn.size() - 1].R;

			_tcscpy(JDdataOut[i][0].JXLC, L"交叉口");
			for (int j = (int)JDdataIn.size() - 2; j >= 0; j--)
				JDdataOut[i].insert(JDdataOut[i].begin(), JDdataIn[j]);
			//输入起点与输出终点相同
			if (ptInStart.Distance(ptOutEnd) < 1)
			{
				JDdata JDCenter;
				InitJDdata(JDCenter);
				_tcscpy(JDCenter.JXLC, L"道路交点");
				JDCenter = JDdataOut[i][0];
				JDCenter.x = (JDdataOut[i][0].x + JDdataOut[i][1].x) / 2.0;
				JDCenter.y = (JDdataOut[i][0].y + JDdataOut[i][1].y) / 2.0;
				//修改起点
				if (JDCenter.R < 0.1)
					JDCenter.R = 6;
				JDdataOut[i][0] = JDCenter;
				_tcscpy(JDdataOut[i][JDdataOut[i].size() - 1].JXLC, L"交叉口");
				JDdataOut[i].push_back(JDCenter);
			}
			for (int j = 0; j < (int)CCDin.size(); j++)
				CCDout[i].push_back(CCDin[j]);
			return;
		}
		//输入起点与输出终点相同
		if (ptInStart.Distance(ptOutEnd) < 1)
		{
			//检测最后一点半径
			if (JDdataIn[0].R > 0.001)
				JDdataOut[i][JDdataOut[i].size() - 1].R = JDdataIn[0].R;

			_tcscpy(JDdataOut[i][JDdataOut[i].size() - 1].JXLC, L"交叉口");
			for (int j = 1; j < (int)JDdataIn.size(); j++)
				JDdataOut[i].push_back(JDdataIn[j]);
			//输入终点与输出起点相同
			if (ptInEnd.Distance(ptOutStart) < 1)
			{
				JDdata JDCenter;
				InitJDdata(JDCenter);
				_tcscpy(JDCenter.JXLC, L"道路交点");
				JDCenter = JDdataOut[i][0];
				JDCenter.x = (JDdataOut[i][0].x + JDdataOut[i][1].x) / 2.0;
				JDCenter.y = (JDdataOut[i][0].y + JDdataOut[i][1].y) / 2.0;
				//修改起点
				if (JDCenter.R < 0.1)
					JDCenter.R = 6;
				JDdataOut[i][0] = JDCenter;
				_tcscpy(JDdataOut[i][JDdataOut[i].size() - 1].JXLC, L"交叉口");
				JDdataOut[i].push_back(JDCenter);
			}
			for (int j = 0; j < (int)CCDin.size(); j++)
				CCDout[i].push_back(CCDin[j]);
			return;
		}
		//输入终点与输出终点相同
		if (ptInEnd.Distance(ptOutEnd) < 1)
		{
			//检测最后一点半径
			if (JDdataIn[(int)JDdataIn.size() - 1].R > 0.001)
				JDdataOut[i][JDdataOut[i].size() - 1].R = JDdataIn[(int)JDdataIn.size() - 1].R;

			_tcscpy(JDdataOut[i][JDdataOut[i].size() - 1].JXLC, L"交叉口");
			for (int j = (int)JDdataIn.size() - 2; j >= 0; j--)
				JDdataOut[i].push_back(JDdataIn[j]);
			//两者起点相同
			if (ptInStart.Distance(ptOutStart) < 1)
			{
				JDdata JDCenter;
				InitJDdata(JDCenter);
				_tcscpy(JDCenter.JXLC, L"道路交点");
				JDCenter = JDdataOut[i][0];
				JDCenter.x = (JDdataOut[i][0].x + JDdataOut[i][1].x) / 2.0;
				JDCenter.y = (JDdataOut[i][0].y + JDdataOut[i][1].y) / 2.0;
				//修改起点
				if (JDCenter.R < 0.1)
					JDCenter.R = 6;
				JDdataOut[i][0] = JDCenter;
				_tcscpy(JDdataOut[i][JDdataOut[i].size() - 1].JXLC, L"交叉口");
				JDdataOut[i].push_back(JDCenter);
			}
			for (int j = 0; j < (int)CCDin.size(); j++)
				CCDout[i].push_back(CCDin[j]);
			return;
		}
	}
	if (fabs(JDdataIn[0].x - JDdataIn[(int)JDdataIn.size() - 1].x) < 1 && fabs(JDdataIn[0].y - JDdataIn[(int)JDdataIn.size() - 1].y) < 1)
	{
		JDdata JDCenter;
		InitJDdata(JDCenter);
		_tcscpy(JDCenter.JXLC, L"道路交点");
		JDCenter = JDdataIn[0];
		JDCenter.x = (JDdataIn[0].x + JDdataIn[1].x) / 2.0;
		JDCenter.y = (JDdataIn[0].y + JDdataIn[1].y) / 2.0;
		if (JDCenter.R < 0.1)
			JDCenter.R = 6;
		JDdataIn[0] = JDCenter;
		_tcscpy(JDdataIn[(int)JDdataIn.size() - 1].JXLC, L"交叉口");
		JDdataIn.push_back(JDCenter);
	}
	JDdataOut.push_back(JDdataIn);
	CCDout.push_back(CCDin);
}


Road_BX CDrawRoad::GENENewRoad_BX(Road RDData, double LeftOrRight)
{
	DVec3d vec, vecV;
	vector<DPoint3d> tempARRAY;
	DPoint3d tempPT;
	DPoint3d PT1, PT2;
	Road_BX NewRDData;
	//初值
	_tcscpy(NewRDData.SJShiTai, L"");
	NewRDData.minR =/*RDData.minR*/6;
	NewRDData.RoadL = 0;
	NewRDData.M_num = 0;
	NewRDData.ConRD.clear();
	tempARRAY.clear();

	if (RDData.JDARRAY.size() <= 1)
		return NewRDData;

	for (int i = 0; i < (int)RDData.JDARRAY.size() - 1; i++)
	{
		PT1.x = RDData.JDARRAY[i].x;
		PT1.y = RDData.JDARRAY[i].y;
		PT1.z = 0.0;
		PT2.x = RDData.JDARRAY[i + 1].x;
		PT2.y = RDData.JDARRAY[i + 1].y;
		PT2.z = 0.0;
		vec = PT2 - PT1;
		vec.Normalize();
		vecV = DVec3d::FromCrossProduct(vec,DVec3d::UnitZ());
		vecV.Normalize();
		if (LeftOrRight == 1)//右
		{
			tempPT = PT1 + RDData.JDARRAY[i].kuandu_right * LeftOrRight * vecV;
			tempPT.z = 0;
			tempARRAY.push_back(tempPT);
			tempPT = PT2 + RDData.JDARRAY[i/*+1*/].kuandu_right * LeftOrRight * vecV;
			tempPT.z = RDData.JDARRAY[i + 1].shunjieAngle;
			tempARRAY.push_back(tempPT);
		}
		else
		{
			tempPT = PT1 + RDData.JDARRAY[i].kuandu_left * LeftOrRight * vecV;
			tempPT.z = 0;
			tempARRAY.push_back(tempPT);
			tempPT = PT2 + RDData.JDARRAY[i/*+1*/].kuandu_left * LeftOrRight * vecV;
			tempPT.z = RDData.JDARRAY[i + 1].shunjieAngle;
			tempARRAY.push_back(tempPT);
		}
	}
	vector<JDdata>DLJDTmp;
	vector<int>JDIndex;
	JDIndex.clear();
	DLJDTmp.clear();
	JDdata JDTmp;
	InitJDdata(JDTmp);
	JDTmp.JDtype = L"";
	JDTmp.l1 = JDTmp.l2 = 0;
	JDTmp.R = 6;
	NewRDData.JDARRAY.resize(tempARRAY.size() / 2 + 1);
	for (int i = 0; i < (int)RDData.JDARRAY.size(); i++)
	{
		NewRDData.JDARRAY[i].JDtype = RDData.JDARRAY[i].JDtype;
		NewRDData.JDARRAY[i].l1 = RDData.JDARRAY[i].l1;
		NewRDData.JDARRAY[i].l2 = RDData.JDARRAY[i].l2;
		// 对于边线路宽赋值 20191012
		NewRDData.JDARRAY[i].kuandu = RDData.JDARRAY[i].kuandu_left + RDData.JDARRAY[i].kuandu_right;
		NewRDData.JDARRAY[i].gc = RDData.JDARRAY[i].gc; //ry 202304
		if (i == RDData.JDARRAY.size() - 1 && RDData.JDARRAY[i].R < 0.1)
			NewRDData.JDARRAY[i].R = 6;
		else
			NewRDData.JDARRAY[i].R = RDData.JDARRAY[i].R;
	}

	NewRDData.JDARRAY[0].x = tempARRAY[0].x;
	NewRDData.JDARRAY[0].y = tempARRAY[0].y;

	double fwj1, fwj2;
	DPoint3d PTInserttmp;
	for (int i = 0; i < (int)tempARRAY.size() - 2; i = i + 2)
	{
		//检测两条线段是否平行
		xyddaa(tempARRAY[i].x, tempARRAY[i].y, tempARRAY[i + 1].x, tempARRAY[i + 1].y, &fwj1);
		xyddaa(tempARRAY[i + 2].x, tempARRAY[i + 2].y, tempARRAY[i + 3].x, tempARRAY[i + 3].y, &fwj2);
		if (fabs(fwj1 - fwj2) < 0.001 || fabs(fabs(fwj1 - fwj2) - 2 * PI) < 0.001)
		{
			double distmp = sqrt(pow(tempARRAY[i + 1].x - tempARRAY[i + 2].x, 2.0)
				+ pow(tempARRAY[i + 1].y - tempARRAY[i + 2].y, 2.0));

			if (distmp < 0.001)
			{
				NewRDData.JDARRAY[i / 2 + 1].x = tempARRAY[i + 1].x;
				NewRDData.JDARRAY[i / 2 + 1].y = tempARRAY[i + 1].y;
				NewRDData.JDARRAY[i / 2 + 1].R = 0;
			}
			else
			{
				vec = tempARRAY[i + 1] - tempARRAY[i];
				vec.z = 0;
				vec.Normalize();

				double addlength = 0;
				if (tempARRAY[i + 1].z < 29.999 || tempARRAY[i + 1].z>90.0001)
					tempARRAY[i + 1].z = 45;
				if (fabs(tempARRAY[i + 1].z - PI / 2.0) > 0.001)
				{
					double fenmu = tan(tempARRAY[i + 1].z / 180.0 * PI);
					if (fabs(fenmu) > 0.0001)
						addlength = distmp / 2.0 / fenmu;
				}

				PTInserttmp = tempARRAY[i + 1] - addlength * vec;
				NewRDData.JDARRAY[i / 2 + 1].x = PTInserttmp.x;
				NewRDData.JDARRAY[i / 2 + 1].y = PTInserttmp.y;
				NewRDData.JDARRAY[i / 2 + 1].R =/*6*/int(distmp / 2.0);

				vec = tempARRAY[i + 3] - tempARRAY[i + 2];
				vec.z = 0;
				vec.Normalize();
				PTInserttmp = tempARRAY[i + 2] + addlength * vec;
				JDTmp.x = PTInserttmp.x;
				JDTmp.y = PTInserttmp.y;
				JDTmp.R = int(distmp / 2.0);
				JDTmp.gc = NewRDData.JDARRAY[i / 2 + 1].gc; //202304
				DLJDTmp.push_back(JDTmp);
				JDIndex.push_back(i / 2 + 1);
			}
		}
		else
			INTERJD(NewRDData.JDARRAY[i / 2 + 1].x, NewRDData.JDARRAY[i / 2 + 1].y, tempARRAY[i].x, tempARRAY[i].y, tempARRAY[i + 1].x, tempARRAY[i + 1].y, tempARRAY[i + 2].x, tempARRAY[i + 2].y, tempARRAY[i + 3].x, tempARRAY[i + 3].y);
	}
	NewRDData.JDARRAY[tempARRAY.size() / 2].x = tempARRAY[(int)tempARRAY.size() - 1].x;
	NewRDData.JDARRAY[tempARRAY.size() / 2].y = tempARRAY[(int)tempARRAY.size() - 1].y;
	tempARRAY.clear();

	//加入插入点
	for (int i = (int)DLJDTmp.size() - 1; i >= 0; i--)
		NewRDData.JDARRAY.insert(NewRDData.JDARRAY.begin() + JDIndex[i] + 1, DLJDTmp[i]);

	NewRDData.ConRD.clear();
	for (int i = 0; i < (int)RDData.ConRD.size(); i++)
	{
		NewRDData.ConRD.push_back(RDData.ConRD[i]);
	}

	if (NewRDData.JDARRAY[0].R < 0.1)
		NewRDData.JDARRAY[0].R = 6;

	if (NewRDData.JDARRAY[(int)NewRDData.JDARRAY.size() - 1].R < 0.1)
		NewRDData.JDARRAY[(int)NewRDData.JDARRAY.size() - 1].R = 6;

	NewRDData.m_ChaiChuArray = RDData.m_ChaiChuArray;
	NewRDData.m_BPDArray = RDData.m_BPDArray;//202304
	return NewRDData;
}

vector<DPoint3d> CDrawRoad::JC_JD_qian_hou(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4,
	double x, double y, double kuan1_left, double kuan1_right, double kuan2_left, double kuan2_right, double R1, double R2, int isqian) const //宽1指代本条路半宽 宽2指相交路半宽 +左-右
{
	if (R2 < R1)
	{
		R1 = R2;
	}

	vector<DPoint3d> START_END;
	DPoint3d JCJD;
	DVec3d vec1, vec2;
	double angle;
	double l2_left, l2_right, T0, T1;
	//该道路矢量方向
	vec1.x = x2 - x1;
	vec1.y = y2 - y1;
	vec1.Normalize();
	//相交道路矢量方向
	vec2.x = x4 - x3;
	vec2.y = y4 - y3;
	vec2.Normalize();
	//两矢量夹角
	angle = vec1.AngleTo(vec2);

	int nnn = 0;
	double zory;
	//zory=CCW2(x1, y1, x2, y2,x3, y3);
	//if (zory>0)
	//{
	   // nnn=1;
	//}
	DPoint3d PT_CENTER;
	PT_CENTER.x = x;
	PT_CENTER.y = y;
	PT_CENTER.z = 0;
	DPoint3d PT4, PT3;
	PT3.Init(x3, y3, 0);
	PT4.Init(x4, y4, 0);
	if (PT3.Distance(PT_CENTER) > PT4.Distance(PT_CENTER) - 0.00001)
	{
		zory = CCW2(x1, y1, x2, y2, x3, y3);
		if (zory > 0)
			nnn = 1;
	}
	else
	{
		zory = CCW2(x1, y1, x2, y2, x4, y4);
		if (zory < 0)
			nnn = 1;
		zory = -1 * zory;
	}

	double l1 = 0.0;
	if (zory > 0 && isqian == 1 || zory < 0 && isqian == -1)
	{
		l1 = kuan2_left / sin(angle);
		//l1_right=kuan2_right/sin(angle);
	}
	else
	{
		l1 = kuan2_right / sin(angle);
		//l1_right=kuan2_left/sin(angle);
	}

	l2_left = kuan1_left / sin(angle);
	l2_right = kuan1_right / sin(angle);
	T0 = R1 * tan(angle / 2.0);
	T1 = R1 * tan(PI / 2.0 - angle / 2.0);
	//if(nnn==0)
	//{
	   // T0=R1*tan(angle/2.0);
	   // T1=R1*tan(PI/2.0-angle/2.0);
	   // if (kuan2<0)
	   // {
	   //	 T1=R1*tan(angle/2.0);
	   //	 T0=R1*tan(PI/2.0-angle/2.0);
	   // }
	//}
	//else if (nnn==1)
	//{
	   // T1=R1*tan(angle/2.0);
	   // T0=R1*tan(PI/2.0-angle/2.0);
	   // if (kuan2<0)
	   // {
	   //	 T0=R1*tan(angle/2.0);
	   //	 T1=R1*tan(PI/2.0-angle/2.0);
	   // }
	//}
	//if(l1<0)
	//{
	   // T0=-T0;
	   // T1=-T1;
	//}
	DPoint3d tmpPT;
	tmpPT = PT_CENTER + vec1 * l1;

	if (zory < 0)
	{
		JCJD = tmpPT + vec2 * (l2_left)+vec1 * T1;
		START_END.push_back(JCJD);
		JCJD = JCJD - vec2 * (l2_right + l2_left) - vec1 * T1 + vec1 * T0;
		START_END.push_back(JCJD);
	}
	else //左边
	{
		JCJD = tmpPT - vec2 * l2_left + vec1 * T1;
		START_END.push_back(JCJD);
		JCJD = JCJD + vec2 * (l2_left + l2_right) - vec1 * T1 + vec1 * T0;
		START_END.push_back(JCJD);
	}

	return START_END;
}

vector<DPoint3d> CDrawRoad::JC_JD_qian_hou_zy(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4,
	double kuan1_left, double kuan1_right, double kuan2_left, double kuan2_right, double R1, double R2, int isqian) const //宽1指代本条路半宽 宽2指相交路半宽 +左-右
{
	if (R2 < R1)
	{
		R1 = R2;
	}

	vector<DPoint3d> START_END;
	START_END.clear();
	DPoint3d JCJD;
	DVec3d vec1, vec2;
	double angle;
	double l1, l2_left, l2_right, T0, T1;
	//该道路矢量方向
	vec1.x = x2 - x1;
	vec1.y = y2 - y1;
	vec1.Normalize();
	//相交道路矢量方向
	vec2.x = x4 - x3;
	vec2.y = y4 - y3;
	vec2.Normalize();
	//两矢量夹角
	angle = vec1.AngleTo(vec2);
	double kuan2 = 0;
	if (angle > 0)
		kuan2 = kuan2_right;
	else
		kuan2 = kuan2_left;
	int nnn = 0;
	DPoint3d PT_CENTER;
	double x, y;
	INTERJD(x, y, x1, y1, x2, y2, x3, y3, x4, y4);
	PT_CENTER.x = x;
	PT_CENTER.y = y;
	PT_CENTER.z = 0;
	double zory;
	DPoint3d PT4, PT3;
	PT3.Init(x3, y3, 0);
	PT4.Init(x4, y4, 0);
	if (PT3.Distance(PT_CENTER) > PT4.Distance(PT_CENTER) - 0.00001)
	{
		zory = CCW2(x1, y1, x2, y2, x3, y3);
		if (zory > 0)
			nnn = 1;
	}
	else
	{
		zory = CCW2(x1, y1, x2, y2, x4, y4);
		if (zory < 0)
			nnn = 1;
		zory = -1 * zory;
	}

	l1 = 0.0;
	if (zory > 0 && isqian == 1 || zory < 0 && isqian == -1)
	{
		l1 = kuan2_left / sin(angle);
		//l1_right=kuan2_right/sin(angle);
	}
	else
	{
		l1 = kuan2_right / sin(angle);
		//l1_right=kuan2_left/sin(angle);
	}

	l2_left = kuan1_left / sin(angle);
	l2_right = kuan1_right / sin(angle);
	if (nnn == 0)
	{
		T0 = R1 * tan(angle / 2.0);
		T1 = R1 * tan(PI / 2.0 - angle / 2.0);
	}
	else if (nnn == 1)
	{
		T1 = R1 * tan(angle / 2.0);
		T0 = R1 * tan(PI / 2.0 - angle / 2.0);
	}
	if (l1 < 0)
	{
		T0 = -T0;
		T1 = -T1;
	}
	DPoint3d tmpPT;


	tmpPT = PT_CENTER + vec1 * l1;

	if (zory < 0)
	{
		JCJD = tmpPT + vec2 * (l2_left)+vec1 * T1;
		START_END.push_back(JCJD);
		JCJD = JCJD - vec2 * (l2_left + l2_right) - vec1 * T1 + vec1 * T0;
		START_END.push_back(JCJD);
	}
	else //左边
	{
		JCJD = tmpPT - vec2 * l2_left + vec1 * T1;
		START_END.push_back(JCJD);
		JCJD = JCJD + vec2 * (l2_left + l2_right) - vec1 * T1 + vec1 * T0;
		START_END.push_back(JCJD);
	}

	return START_END;
}

vector<DPoint3d> CDrawRoad::JC_JD(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4,
	double x, double y, double kuan1_left, double kuan1_right, double kuan2_left, double kuan2_right, double R1, double R2) const //宽1指代本条路半宽 宽2指相交路半宽 +左-右
{
	if (R2 < R1)
	{
		R1 = R2;
	}
	vector<DPoint3d> START_END;
	START_END.clear();
	DPoint3d JCJD;
	DVec3d vec1, vec2;
	double angle;
	double l1_left, l1_right, l2_left, l2_right;
	double T0, T1;
	//该道路矢量方向
	vec1.x = x2 - x1;
	vec1.y = y2 - y1;
	vec1.Normalize();
	//相交道路矢量方向
	vec2.x = x4 - x3;
	vec2.y = y4 - y3;
	vec2.Normalize();
	//两矢量夹角
	angle = vec1.AngleTo(vec2);
	int nnn = 0;
	double zory;

	//zory=CCW2(x1, y1, x2, y2,x3, y3);
	//if (zory>0)
	//{
 //      nnn=1;
	//}
	DPoint3d PT_CENTER;
	PT_CENTER.x = x;
	PT_CENTER.y = y;
	PT_CENTER.z = 0;
	DPoint3d PT4, PT3;
	PT3.Init(x3, y3, 0);
	PT4.Init(x4, y4, 0);
	if (PT3.Distance(PT_CENTER) > PT4.Distance(PT_CENTER))
	{
		zory = CCW2(x1, y1, x2, y2, x3, y3);
		if (zory > 0)
			nnn = 1;
	}
	else
	{
		zory = CCW2(x1, y1, x2, y2, x4, y4);
		if (zory < 0)
			nnn = 1;
		zory = -1 * zory;
	}
	if (zory > 0)
	{
		l1_left = kuan2_left / sin(angle);
		l1_right = kuan2_right / sin(angle);
	}
	else
	{
		l1_left = kuan2_right / sin(angle);
		l1_right = kuan2_left / sin(angle);
	}

	l2_left = kuan1_left / sin(angle);
	l2_right = kuan1_right / sin(angle);
	if (nnn == 0)
	{
		T0 = R1 * tan(angle / 2.0);
		T1 = R1 * tan(PI / 2.0 - angle / 2.0);
		if (kuan1_left < 0)
		{
			T1 = R1 * tan(angle / 2.0);
			T0 = R1 * tan(PI / 2.0 - angle / 2.0);
		}
	}
	else if (nnn == 1)
	{
		T1 = R1 * tan(angle / 2.0);
		T0 = R1 * tan(PI / 2.0 - angle / 2.0);
		if (kuan1_left < 0)
		{
			T0 = R1 * tan(angle / 2.0);
			T1 = R1 * tan(PI / 2.0 - angle / 2.0);
		}
	}
	DPoint3d tmpPT;

	double l2 = 0;
	if (kuan1_right < 0 /*&& zory>0  || kuan1_right>0 && zory<0 */)
		l2 = l2_right;
	else
		l2 = l2_left;

	if (zory < 0)
	{
		tmpPT = PT_CENTER - vec1 * l1_right;
		JCJD = tmpPT + vec2 * l2;
		START_END.push_back(JCJD);
		JCJD += vec1 * (l1_left + l1_right);
		START_END.push_back(JCJD);
		JCJD = JCJD - vec1 * (l1_left + l1_right + T0);
		START_END.push_back(JCJD);
		JCJD = JCJD + vec1 * (l1_left + l1_right + T0 + T1);
		START_END.push_back(JCJD);
		if (l2 < 0)
		{
			T0 = -T0;
		}
		JCJD = JCJD - vec1 * (l1_left + l1_right + T1) + vec2 * T0;
		START_END.push_back(JCJD);
		if (l2 < 0)
		{
			T1 = -T1;
		}
		JCJD = JCJD + vec1 * (l1_left + l1_right) - vec2 * T0 + vec2 * T1;
		START_END.push_back(JCJD);
	}
	else //左边
	{
		tmpPT = PT_CENTER - vec1 * l1_right;
		JCJD = tmpPT - vec2 * l2;
		START_END.push_back(JCJD);
		JCJD += vec1 * (l1_left + l1_right);
		START_END.push_back(JCJD);
		JCJD = JCJD - vec1 * (l1_left + l1_right + T0);
		START_END.push_back(JCJD);
		JCJD = JCJD + vec1 * (l1_left + l1_right + T0 + T1);
		START_END.push_back(JCJD);
		if (l2 < 0)
		{
			T0 = -T0;
		}
		JCJD = JCJD - vec1 * (l1_left + l1_right + T1) - vec2 * T0;
		START_END.push_back(JCJD);
		if (l2 < 0)
		{
			T1 = -T1;
		}
		JCJD = JCJD + vec1 * (l1_left + l1_right) + vec2 * T0 - vec2 * T1;
		START_END.push_back(JCJD);
	}

	return START_END;
}

vector<DPoint3d> CDrawRoad::JC_JD_zy(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4,
	double kuan1_left, double kuan1_right, double kuan2_left, double kuan2_right, double R1, double R2) const //宽1指代本条路半宽 宽2指相交路半宽 +左-右
{
	if (R2 < R1)
	{
		R1 = R2;
	}
	vector<DPoint3d> START_END;
	START_END.clear();
	DPoint3d JCJD;
	DVec3d vec1, vec2;
	double angle;
	double l1_left, l1_right, l2_left, l2_right;
	double T0, T1;
	//该道路矢量方向
	vec1.x = x2 - x1;
	vec1.y = y2 - y1;
	vec1.Normalize();
	//相交道路矢量方向
	vec2.x = x4 - x3;
	vec2.y = y4 - y3;
	vec2.Normalize();
	//两矢量夹角
	angle = vec1.AngleTo(vec2);

	int nnn = 0;
	DPoint3d PT_CENTER;
	double x, y;
	int isZX = 0;
	isZX = INTERJD(x, y, x1, y1, x2, y2, x3, y3, x4, y4);

	PT_CENTER.x = x;
	PT_CENTER.y = y;
	PT_CENTER.z = 0;
	double zory = 0;
	if (isZX == 1)
	{
		DPoint3d PT4, PT3;
		PT3.Init(x3, y3, 0);
		PT4.Init(x4, y4, 0);
		if (PT3.Distance(PT_CENTER) > PT4.Distance(PT_CENTER))
		{
			zory = CCW2(x1, y1, x2, y2, x3, y3);
			if (zory > 0)
				nnn = 1;
		}
		else
		{
			zory = CCW2(x1, y1, x2, y2, x4, y4);
			if (zory < 0)
				nnn = 1;
			zory = -1 * zory;
		}
	}
	else
	{
		if (kuan1_right < 0)
			zory = -1;
		else
			zory = 1;
	}

	if (fabs(angle) < 0.0001)
	{
		l1_left = kuan2_left;
		l1_right = kuan2_right;
		l2_left = kuan1_left;
		l2_right = kuan1_right;
	}
	else
	{
		if (zory > 0)
		{
			l1_left = kuan2_left / sin(angle);
			l1_right = kuan2_right / sin(angle);
		}
		else
		{
			l1_left = kuan2_right / sin(angle);
			l1_right = kuan2_left / sin(angle);
		}
		l2_left = kuan1_left / sin(angle);
		l2_right = kuan1_right / sin(angle);
	}

	if (nnn == 0)
	{
		T0 = R1 * tan(angle / 2.0);
		T1 = R1 * tan(PI / 2.0 - angle / 2.0);
		if (kuan1_left < 0)
		{
			T1 = R1 * tan(angle / 2.0);
			T0 = R1 * tan(PI / 2.0 - angle / 2.0);
		}
	}
	else if (nnn == 1)
	{
		T1 = R1 * tan(angle / 2.0);
		T0 = R1 * tan(PI / 2.0 - angle / 2.0);
		if (kuan1_left < 0)
		{
			T0 = R1 * tan(angle / 2.0);
			T1 = R1 * tan(PI / 2.0 - angle / 2.0);
		}
	}
	DPoint3d tmpPT;
	tmpPT = PT_CENTER - vec1 * l1_right;
	double l2 = 0;
	if (kuan1_right < 0 /*&& zory>0  || kuan1_right>0 && zory<0 */)
		l2 = l2_right;
	else
		l2 = l2_left;

	if (zory < 0)
	{
		JCJD = tmpPT + vec2 * l2;
		START_END.push_back(JCJD);
		JCJD += vec1 * (l1_left + l1_right);
		START_END.push_back(JCJD);
		JCJD = JCJD - vec1 * (l1_left + l1_right + T0);
		START_END.push_back(JCJD);
		JCJD = JCJD + vec1 * (l1_left + l1_right + T0 + T1);
		START_END.push_back(JCJD);
		if (l2_left < 0)
		{
			T0 = -T0;
		}
		JCJD = JCJD - vec1 * (l1_left + l1_right + T1) + vec2 * T0;
		START_END.push_back(JCJD);
		if (l2_left < 0)
		{
			T1 = -T1;
		}
		JCJD = JCJD + vec1 * (l1_left + l1_right) - vec2 * T0 + vec2 * T1;
		START_END.push_back(JCJD);
	}
	else //左边
	{
		JCJD = tmpPT - vec2 * l2;
		START_END.push_back(JCJD);
		JCJD += vec1 * (l1_left + l1_right);
		START_END.push_back(JCJD);
		JCJD = JCJD - vec1 * (l1_left + l1_right + T0);
		START_END.push_back(JCJD);
		JCJD = JCJD + vec1 * (l1_left + l1_right + T0 + T1);
		START_END.push_back(JCJD);
		if (l2_left < 0)
		{
			T0 = -T0;
		}
		JCJD = JCJD - vec1 * (l1_left + l1_right + T1) - vec2 * T0;
		START_END.push_back(JCJD);
		if (l2_left < 0)
		{
			T1 = -T1;
		}
		JCJD = JCJD + vec1 * (l1_left + l1_right) + vec2 * T0 - vec2 * T1;
		START_END.push_back(JCJD);
	}

	return START_END;
}

//检测四点是否共线 若共线返回1 否则0
int CDrawRoad::CheckFourPtIsLine(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double kuandu, DPoint3d& tmpptPTGX)
{
	tmpptPTGX.Init(0, 0, 0);
	double x_chuizu, y_chuizu;
	int is3in12 = 0;//3号点是否在1、2两点构成的直线上
	int is2in34 = 0;//2号点是否在3、4两点构成的直线上

	ChuizuToZx(is3in12, x_chuizu, y_chuizu, x3, y3, x1, y1, x2, y2);
	if (sqrt(pow(x_chuizu - x3, 2) + pow(y_chuizu - y3, 2)) < 0.1)
		is3in12 = 1;

	ChuizuToZx(is2in34, x_chuizu, y_chuizu, x2, y2, x3, y3, x4, y4);
	if (sqrt(pow(x_chuizu - x2, 2) + pow(y_chuizu - y2, 2)) < 0.1)
		is2in34 = 1;

	DVec3d vecold;
	if (is3in12 == 1 && is2in34 == 1)
	{
		//共线时返回中间两点中心
		vector<DPoint3d>PTArray;
		DPoint3d PT;
		PTArray.clear();
		PT.Init(x1, y1, 0);
		PTArray.push_back(PT);
		PT.Init(x2, y2, 0);
		PTArray.push_back(PT);
		PT.Init(x3, y3, 0);
		PTArray.push_back(PT);
		PT.Init(x4, y4, 0);
		PTArray.push_back(PT);

		vecold = PTArray[1] - PTArray[0];
		vecold.Normalize();
		//排序
		if (fabs(x1 - x2) < 0.001)
		{
			//Y从小到大
			for (int i = 1; i < (int)PTArray.size(); i++)
			{
				for (int j = (int)PTArray.size() - 1; j >= i; j--)
				{
					if (PTArray[j].y < PTArray[j - 1].y)
					{
						PT = PTArray[j - 1];
						PTArray[j - 1] = PTArray[j];
						PTArray[j] = PT;
					}
				}
			}
		}
		else
		{
			//Y从小到大
			for (int i = 1; i < (int)PTArray.size(); i++)
			{
				for (int j = (int)PTArray.size() - 1; j >= i; j--)
				{
					if (PTArray[j].x < PTArray[j - 1].x)
					{
						PT = PTArray[j - 1];
						PTArray[j - 1] = PTArray[j];
						PTArray[j] = PT;
					}
				}
			}
		}

		tmpptPTGX.x = (PTArray[1].x + PTArray[2].x) / 2.0;
		tmpptPTGX.y = (PTArray[1].y + PTArray[2].y) / 2.0;

		DVec3d vec, vecV;
		vec = PTArray[1] - PTArray[0];
		if (vec.AngleTo(vecold) > PI / 2.0 - 0.00001)
			vec = -1.0 * vec;

		vecV = DVec3d::FromCrossProduct(vec, DVec3d::UnitZ());
		vecV.Normalize();
		tmpptPTGX += vecV * kuandu;
		return 1;
	}
	else
		return 0;
}

//检测直线 
int CDrawRoad::CheckZXBK(vector<JDdata> JDARRAY, int Iindex, int leftOrright) const
{
	double f1, f2;
	vector<int>JDindex;
	JDindex.clear();
	if (JDARRAY.size() <= 2)
		return 0;
	int num = 0;
	for (int i = 0; i < (int)JDARRAY.size() - 2; i++)
	{
		xyddaa(JDARRAY[i].x, JDARRAY[i].y, JDARRAY[i + 1].x, JDARRAY[i + 1].y, f1);
		xyddaa(JDARRAY[i + 1].x, JDARRAY[i + 1].y, JDARRAY[i + 2].x, JDARRAY[i + 2].y, f2);
		//三点共线
		if (leftOrright == -1)//左
		{
			if ((fabs(f1 - f2) < 0.001 || fabs(fabs(f1 - f2) - 2 * PI) < 0.001) && fabs(JDARRAY[i].kuandu_left - JDARRAY[i + 1].kuandu_left) > 0.01)
				JDindex.push_back(i + 1);
		}
		else
		{
			if ((fabs(f1 - f2) < 0.001 || fabs(fabs(f1 - f2) - 2 * PI) < 0.001) && fabs(JDARRAY[i].kuandu_right - JDARRAY[i + 1].kuandu_right) > 0.01)
				JDindex.push_back(i + 1);
		}
	}
	for (int i = 0; i < (int)JDindex.size(); i++)
	{
		if (Iindex >= JDindex[i])
			num++;
	}
	JDindex.clear();
	return num;
}

//形成边线拆除段
void CDrawRoad::GeneBXCCDpt(Road_BX RD_LuJian, vector<JDdata> DLJDdataTmp, RoadChaiChuArray& FDChaiChuArray)
{
	Cal_xianyuan(RD_LuJian);
	FDChaiChuArray.clear();
	if (DLJDdataTmp.size() < 2 || RD_LuJian.m_ChaiChuArray.size() == 0)
		return;
	//判断当前小分段的点位起终里程
	double startCCml, endCCml;
	TrsNEtoCml(RD_LuJian, DLJDdataTmp[0].y, DLJDdataTmp[0].x, startCCml);
	TrsNEtoCml(RD_LuJian, DLJDdataTmp[(int)DLJDdataTmp.size() - 1].y, DLJDdataTmp[(int)DLJDdataTmp.size() - 1].x, endCCml);
	if (startCCml > endCCml)
	{
		double cmltmp;
		cmltmp = startCCml;
		startCCml = endCCml;
		endCCml = cmltmp;
	}

	//截取拆除范围
	Roadccinf Roadccinftmp;
	xlpoint PZ;
	DPoint3d PTtmp;
	for (int i = 0; i < (int)RD_LuJian.m_ChaiChuArray.size(); i++)
	{
		if (RD_LuJian.m_ChaiChuArray[i].EndFDCml < startCCml)
			continue;
		if (RD_LuJian.m_ChaiChuArray[i].StartFDCml > endCCml)
			continue;
		//首端取大值
		if (RD_LuJian.m_ChaiChuArray[i].StartFDCml > startCCml)
			Roadccinftmp.StartFDCml = RD_LuJian.m_ChaiChuArray[i].StartFDCml;
		else
			Roadccinftmp.StartFDCml = startCCml;

		//末端取小值
		if (RD_LuJian.m_ChaiChuArray[i].EndFDCml > endCCml)
			Roadccinftmp.EndFDCml = endCCml;
		else
			Roadccinftmp.EndFDCml = RD_LuJian.m_ChaiChuArray[i].EndFDCml;

		Roadccinftmp.CCPTArray.clear();
		_tcscpy(Roadccinftmp.BianHao, L"");
		TrsCmltoNE(Roadccinftmp.StartFDCml, PZ, RD_LuJian);
		PTtmp.Init(PZ.y, PZ.x, 0);
		Roadccinftmp.CCPTArray.push_back(PTtmp);
		TrsCmltoNE(Roadccinftmp.EndFDCml, PZ, RD_LuJian);
		PTtmp.Init(PZ.y, PZ.x, 0);
		Roadccinftmp.CCPTArray.push_back(PTtmp);
		FDChaiChuArray.push_back(Roadccinftmp);
	}
}

void CDrawRoad::GENE_RD_Net_BX(vector<Road>m_RoadData4, vector<Rd_BX>& JDdataOutFinally1)
{
	vector<Road_BX> Road_BX_Left; //左边线数组
	vector<Road_BX> Road_BX_Right; //右边线数组
	Road_BX_Left.clear();
	Road_BX_Right.clear();
	Road_BX RD_LuJian_Left;
	Road_BX RD_LuJian_Right;
	Road_BX RD_LuJian_Tmp;

	for (int i = 0; i < (int)m_RoadData4.size(); i++)
	{
		for (int j = 0; j < (int)m_RoadData4[i].ConRD.size(); j++)
		{
			DPoint3d TargetPoint = DPoint3d::FromZero();
			TargetPoint.x = m_RoadData4[i].ConRD[j].ConJD.x;
			TargetPoint.y = m_RoadData4[i].ConRD[j].ConJD.y;
			for (int k = 0; k < (int)m_RoadData4[i].JDARRAY.size() - 1; k++)
			{
				DPoint3d Point1 = DPoint3d::FromZero();
				Point1.x = m_RoadData4[i].JDARRAY[k].x;
				Point1.y = m_RoadData4[i].JDARRAY[k].y;
				Point1.z = m_RoadData4[i].JDARRAY[k].gc;
				DPoint3d Point2 = DPoint3d::FromZero();
				Point2.x = m_RoadData4[i].JDARRAY[k + 1].x;
				Point2.y = m_RoadData4[i].JDARRAY[k + 1].y;
				Point2.z = m_RoadData4[i].JDARRAY[k + 1].gc;
				bool IsInLine = GetPointIsInLine(TargetPoint, Point1, Point2);
				if (IsInLine)
				{
					double Distancetmp = sqrt(pow((Point1.x - Point2.x), 2) + pow((Point1.y - Point2.y), 2));
					double Distancetmp1 = sqrt(pow((Point1.x - TargetPoint.x), 2) + pow((Point1.y - TargetPoint.y), 2));
					if (Distancetmp1 == 0)
					{
						m_RoadData4[i].ConRD[j].ConJD.gc = Point1.z;
						break;
					}
					else
					{
						double GCValue = 0.0;
						GCValue = Point2.z - Point1.z;
						if (Distancetmp == 0)
							m_RoadData4[i].ConRD[j].ConJD.gc = Point1.z;
						else
							m_RoadData4[i].ConRD[j].ConJD.gc = Point1.z + GCValue * Distancetmp1 / Distancetmp;
						break;
					}
				}
			}
		}
	}

	//绘制路肩线	
	for (int i = 0; i < (int)m_RoadData4.size(); i++)
	{
		//获取交叉数
		int jiaochanum = (int)m_RoadData4[i].ConRD.size();
		// ads_printf(L"相交路总数   %d   \n",jiaochanum);
		//如果无交叉，直接绘制
		if (jiaochanum == 0)
		{
			RD_LuJian_Right = GENENewRoad_BX(m_RoadData4[i], 1);
			RD_LuJian_Left = GENENewRoad_BX(m_RoadData4[i], -1);
			Road_BX_Left.push_back(RD_LuJian_Left);
			Road_BX_Right.push_back(RD_LuJian_Right);
			continue;
		}
		else //有交叉点
		{
			RD_LuJian_Right = GENENewRoad_BX(m_RoadData4[i], 1);
			RD_LuJian_Left = GENENewRoad_BX(m_RoadData4[i], -1);
			int rightCheck = 0;
			int leftCheck = 0;
			DPoint3d tmpptPTGX;
			for (int j = 0; j < jiaochanum; j++)  //对相交的路循环
			{
				if (m_RoadData4[i].ConRD[j].ConnectStyle == 0)  //T前
				{
					DPoint3d pt1, pt2/*, tmppt*/;
					pt1.Init(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, 0);
					pt2.Init(m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y, 0);
					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}
					vector<DPoint3d> tmpptARRAY;
					int nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					tmpptARRAY = JC_JD_qian_hou(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[0].kuandu_left, m_RoadData4[i].JDARRAY[0].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //此函数写了，注释掉了

					RD_LuJian_Left.JDARRAY[0].x = tmpptARRAY[0].x;
					RD_LuJian_Left.JDARRAY[0].y = tmpptARRAY[0].y;
					RD_LuJian_Right.JDARRAY[0].x = tmpptARRAY[1].x;
					RD_LuJian_Right.JDARRAY[0].y = tmpptARRAY[1].y;
					tmpptARRAY.clear();
				}
				if (m_RoadData4[i].ConRD[j].ConnectStyle == 5)  //T前左
				{
					DPoint3d pt1, pt2/*, tmppt*/;
					pt1.Init(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, 0);
					pt2.Init(m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y, 0);
					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}
					vector<DPoint3d> tmpptARRAY;
					int nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					double zoy = 0;
					zoy = CCW2(m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x,
						m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y);

					if (zoy < 0)//顺时针
					{
						//检测4点是否共线
						if (CheckFourPtIsLine(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
							m_RoadData4[bh].JDARRAY[nn - 1].x, m_RoadData4[bh].JDARRAY[nn - 1].y, m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[i].JDARRAY[0].kuandu_right, tmpptPTGX) > 0)
						{
							RD_LuJian_Right.JDARRAY[0].x = tmpptPTGX.x;
							RD_LuJian_Right.JDARRAY[0].y = tmpptPTGX.y;
						}
						else
						{
							tmpptARRAY = JC_JD_qian_hou_zy(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
								m_RoadData4[bh].JDARRAY[nn - 1].x, m_RoadData4[bh].JDARRAY[nn - 1].y, m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y,
								m_RoadData4[i].JDARRAY[0].kuandu_left, m_RoadData4[i].JDARRAY[0].kuandu_right,
								m_RoadData4[bh].JDARRAY[nn - 1].kuandu_left, m_RoadData4[bh].JDARRAY[nn - 1].kuandu_right, 0, 0); //此函数写了，注释掉了

							RD_LuJian_Right.JDARRAY[0].x = tmpptARRAY[1].x;
							RD_LuJian_Right.JDARRAY[0].y = tmpptARRAY[1].y;
						}

						tmpptARRAY.clear();

						tmpptARRAY = JC_JD_qian_hou(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[0].kuandu_left, m_RoadData4[i].JDARRAY[0].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0);
						RD_LuJian_Left.JDARRAY[0].x = tmpptARRAY[0].x;
						RD_LuJian_Left.JDARRAY[0].y = tmpptARRAY[0].y;
					}
					else
					{
						//检测4点是否共线
						if (CheckFourPtIsLine(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
							m_RoadData4[bh].JDARRAY[nn - 1].x, m_RoadData4[bh].JDARRAY[nn - 1].y, m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, -1.0 * m_RoadData4[i].JDARRAY[0].kuandu_left, tmpptPTGX) > 0)
						{
							RD_LuJian_Left.JDARRAY[0].x = tmpptPTGX.x;
							RD_LuJian_Left.JDARRAY[0].y = tmpptPTGX.y;
						}
						else
						{
							tmpptARRAY = JC_JD_qian_hou_zy(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
								m_RoadData4[bh].JDARRAY[nn - 1].x, m_RoadData4[bh].JDARRAY[nn - 1].y, m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y,
								m_RoadData4[i].JDARRAY[0].kuandu_left, m_RoadData4[i].JDARRAY[0].kuandu_right,
								m_RoadData4[bh].JDARRAY[nn - 1].kuandu_left, m_RoadData4[bh].JDARRAY[nn - 1].kuandu_right, 0, 0);

							RD_LuJian_Left.JDARRAY[0].x = tmpptARRAY[0].x;
							RD_LuJian_Left.JDARRAY[0].y = tmpptARRAY[0].y;
						}
						tmpptARRAY.clear();

						tmpptARRAY = JC_JD_qian_hou(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[0].kuandu_left, m_RoadData4[i].JDARRAY[0].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0);

						RD_LuJian_Right.JDARRAY[0].x = tmpptARRAY[1].x;
						RD_LuJian_Right.JDARRAY[0].y = tmpptARRAY[1].y;
					}
				}
				if (m_RoadData4[i].ConRD[j].ConnectStyle == 6)  //T前右
				{
					DPoint3d pt1, pt2/*, tmppt*/;
					pt1.Init(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, 0);
					pt2.Init(m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y, 0);
					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}
					vector<DPoint3d> tmpptARRAY;
					int nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					double zoy = 0;
					zoy = CCW2(m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x,
						m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y);
					if (zoy < 0)//顺时针
					{
						//检测4点是否共线
						if (CheckFourPtIsLine(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
							m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[bh].JDARRAY[nn + 2].x, m_RoadData4[bh].JDARRAY[nn + 2].y, -1.0 * m_RoadData4[i].JDARRAY[0].kuandu_left, tmpptPTGX) > 0)
						{
							RD_LuJian_Left.JDARRAY[0].x = tmpptPTGX.x;
							RD_LuJian_Left.JDARRAY[0].y = tmpptPTGX.y;
						}
						else
						{
							tmpptARRAY = JC_JD_qian_hou_zy(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
								m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[bh].JDARRAY[nn + 2].x, m_RoadData4[bh].JDARRAY[nn + 2].y,
								m_RoadData4[i].JDARRAY[0].kuandu_left, m_RoadData4[i].JDARRAY[0].kuandu_right,
								m_RoadData4[bh].JDARRAY[nn + 1].kuandu_left, m_RoadData4[bh].JDARRAY[nn + 1].kuandu_right, 0, 0);
							RD_LuJian_Left.JDARRAY[0].x = tmpptARRAY[0].x;
							RD_LuJian_Left.JDARRAY[0].y = tmpptARRAY[0].y;
						}

						tmpptARRAY.clear();
						tmpptARRAY = JC_JD_qian_hou(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[0].kuandu_left, m_RoadData4[i].JDARRAY[0].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0);

						RD_LuJian_Right.JDARRAY[0].x = tmpptARRAY[1].x;
						RD_LuJian_Right.JDARRAY[0].y = tmpptARRAY[1].y;
					}
					else
					{
						//检测4点是否共线
						if (CheckFourPtIsLine(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
							m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[bh].JDARRAY[nn + 2].x, m_RoadData4[bh].JDARRAY[nn + 2].y, m_RoadData4[i].JDARRAY[0].kuandu_right, tmpptPTGX) > 0)
						{
							RD_LuJian_Right.JDARRAY[0].x = tmpptPTGX.x;
							RD_LuJian_Right.JDARRAY[0].y = tmpptPTGX.y;
						}
						else
						{
							tmpptARRAY = JC_JD_qian_hou_zy(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
								m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[bh].JDARRAY[nn + 2].x, m_RoadData4[bh].JDARRAY[nn + 2].y,
								m_RoadData4[i].JDARRAY[0].kuandu_left, m_RoadData4[i].JDARRAY[0].kuandu_right,
								m_RoadData4[bh].JDARRAY[nn + 1].kuandu_left, m_RoadData4[bh].JDARRAY[nn + 1].kuandu_right, 0, 0);

							RD_LuJian_Right.JDARRAY[0].x = tmpptARRAY[1].x;
							RD_LuJian_Right.JDARRAY[0].y = tmpptARRAY[1].y;
						}

						tmpptARRAY.clear();
						tmpptARRAY = JC_JD_qian_hou(m_RoadData4[i].JDARRAY[0].x, m_RoadData4[i].JDARRAY[0].y, m_RoadData4[i].JDARRAY[1].x, m_RoadData4[i].JDARRAY[1].y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[0].kuandu_left, m_RoadData4[i].JDARRAY[0].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0);

						RD_LuJian_Left.JDARRAY[0].x = tmpptARRAY[0].x;
						RD_LuJian_Left.JDARRAY[0].y = tmpptARRAY[0].y;
					}
					tmpptARRAY.clear();
				}
				if (m_RoadData4[i].ConRD[j].ConnectStyle == 7)  //T后左
				{
					DPoint3d pt1, pt2/*, tmppt*/;
					pt1.Init(m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].x, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].y, 0);
					pt2.Init(m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 1].x, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 1].y, 0);
					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}
					vector<DPoint3d> tmpptARRAY;
					int nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					double zoy;
					zoy = CCW2(m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x,
						m_RoadData4[bh].JDARRAY[nn + 1].y, pt1.x, pt1.y);
					if (zoy < 0)//顺时针
					{
						tmpptARRAY = JC_JD_qian_hou(pt1.x, pt1.y, pt2.x, pt2.y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y,
							m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_left, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_right,
							-m_RoadData4[bh].JDARRAY[nn].kuandu_left, -m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0, -1);

						RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].x = tmpptARRAY[1].x;
						RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].y = tmpptARRAY[1].y;
						tmpptARRAY.clear();

						//检测4点是否共线
						if (CheckFourPtIsLine(pt1.x, pt1.y, pt2.x, pt2.y,
							m_RoadData4[bh].JDARRAY[nn - 1].x, m_RoadData4[bh].JDARRAY[nn - 1].y, m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y,
							-1.0 * m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_left, tmpptPTGX) > 0)
						{
							RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].x = tmpptPTGX.x;
							RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].y = tmpptPTGX.y;
						}
						else
						{
							tmpptARRAY = JC_JD_qian_hou_zy(pt1.x, pt1.y, pt2.x, pt2.y,
								m_RoadData4[bh].JDARRAY[nn - 1].x, m_RoadData4[bh].JDARRAY[nn - 1].y, m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y,
								m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_left, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_right,
								-m_RoadData4[bh].JDARRAY[nn - 1].kuandu_left, -m_RoadData4[bh].JDARRAY[nn - 1].kuandu_right, 0, 0, -1);
							RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].x = tmpptARRAY[0].x;
							RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].y = tmpptARRAY[0].y;
						}
						tmpptARRAY.clear();
					}
					else
					{
						tmpptARRAY = JC_JD_qian_hou(pt1.x, pt1.y, pt2.x, pt2.y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y,
							m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_left, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_right,
							-m_RoadData4[bh].JDARRAY[nn].kuandu_left, -m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0, -1);

						RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].x = tmpptARRAY[0].x;
						RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].y = tmpptARRAY[0].y;
						tmpptARRAY.clear();

						//检测4点是否共线
						if (CheckFourPtIsLine(pt1.x, pt1.y, pt2.x, pt2.y,
							m_RoadData4[bh].JDARRAY[nn - 1].x, m_RoadData4[bh].JDARRAY[nn - 1].y, m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y,
							m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_right, tmpptPTGX) > 0)
						{
							RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].x = tmpptPTGX.x;
							RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].y = tmpptPTGX.y;
						}
						else
						{
							tmpptARRAY = JC_JD_qian_hou_zy(pt1.x, pt1.y, pt2.x, pt2.y,
								m_RoadData4[bh].JDARRAY[nn - 1].x, m_RoadData4[bh].JDARRAY[nn - 1].y, m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y,
								m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_left, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_right,
								-m_RoadData4[bh].JDARRAY[nn - 1].kuandu_left, -m_RoadData4[bh].JDARRAY[nn - 1].kuandu_right, 0, 0, -1);

							RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].x = tmpptARRAY[1].x;
							RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].y = tmpptARRAY[1].y;
						}
						tmpptARRAY.clear();
					}
				}
				if (m_RoadData4[i].ConRD[j].ConnectStyle == 8)  //T后右
				{
					DPoint3d pt1, pt2/*, tmppt*/;
					pt1.Init(m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].x, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].y, 0);
					pt2.Init(m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 1].x, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 1].y, 0);
					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}
					vector<DPoint3d> tmpptARRAY;
					int nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					double zoy;
					zoy = CCW2(m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x,
						m_RoadData4[bh].JDARRAY[nn + 1].y, pt1.x, pt1.y);
					if (zoy < 0)//顺时针
					{
						tmpptARRAY = JC_JD_qian_hou(pt1.x, pt1.y, pt2.x, pt2.y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y,
							m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_left, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_right,
							-m_RoadData4[bh].JDARRAY[nn].kuandu_left, -m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0, -1);
						RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].x = tmpptARRAY[0].x;
						RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].y = tmpptARRAY[0].y;
						tmpptARRAY.clear();


						//检测4点是否共线
						if (CheckFourPtIsLine(pt1.x, pt1.y, pt2.x, pt2.y,
							m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[bh].JDARRAY[nn + 2].x, m_RoadData4[bh].JDARRAY[nn + 2].y,
							m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_right, tmpptPTGX) > 0)
						{
							RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].x = tmpptPTGX.x;
							RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].y = tmpptPTGX.y;
						}
						else
						{
							tmpptARRAY = JC_JD_qian_hou_zy(pt1.x, pt1.y, pt2.x, pt2.y,
								m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[bh].JDARRAY[nn + 2].x, m_RoadData4[bh].JDARRAY[nn + 2].y,
								m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_left, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_right,
								-m_RoadData4[bh].JDARRAY[nn + 1].kuandu_left, -m_RoadData4[bh].JDARRAY[nn + 1].kuandu_right, 0, 0, -1);
							RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].x = tmpptARRAY[1].x;
							RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].y = tmpptARRAY[1].y;
						}
						tmpptARRAY.clear();
					}
					else
					{
						tmpptARRAY = JC_JD_qian_hou(pt1.x, pt1.y, pt2.x, pt2.y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y,
							m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_left, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_right,
							-m_RoadData4[bh].JDARRAY[nn].kuandu_left, -m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0, -1);

						RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].x = tmpptARRAY[1].x;
						RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].y = tmpptARRAY[1].y;
						tmpptARRAY.clear();

						//检测4点是否共线
						if (CheckFourPtIsLine(pt1.x, pt1.y, pt2.x, pt2.y,
							m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[bh].JDARRAY[nn + 2].x, m_RoadData4[bh].JDARRAY[nn + 2].y,
							-1.0 * m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_right, tmpptPTGX) > 0)
						{
							RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].x = tmpptPTGX.x;
							RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].y = tmpptPTGX.y;
						}
						else
						{
							tmpptARRAY = JC_JD_qian_hou_zy(pt1.x, pt1.y, pt2.x, pt2.y,
								m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[bh].JDARRAY[nn + 2].x, m_RoadData4[bh].JDARRAY[nn + 2].y,
								m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_left, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_right,
								-m_RoadData4[bh].JDARRAY[nn + 1].kuandu_left, -m_RoadData4[bh].JDARRAY[nn + 1].kuandu_right, 0, 0, -1);

							RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].x = tmpptARRAY[0].x;
							RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].y = tmpptARRAY[0].y;
						}


						tmpptARRAY.clear();
					}
				}
				else if (m_RoadData4[i].ConRD[j].ConnectStyle == 1) //T后
				{
					DPoint3d pt1, pt2/*, tmppt*/;
					pt1.Init(m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].x, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].y, 0);
					pt2.Init(m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 1].x, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 1].y, 0);
					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}
					vector<DPoint3d> tmpptARRAY;
					int nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					tmpptARRAY = JC_JD_qian_hou(pt1.x, pt1.y, pt2.x, pt2.y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y,
						m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_left, m_RoadData4[i].JDARRAY[m_RoadData4[i].JDARRAY.size() - 2].kuandu_right,
						-m_RoadData4[bh].JDARRAY[nn].kuandu_left, -m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0, -1);

					RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].x = tmpptARRAY[0].x;
					RD_LuJian_Left.JDARRAY[(int)RD_LuJian_Left.JDARRAY.size() - 1].y = tmpptARRAY[0].y;
					RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].x = tmpptARRAY[1].x;
					RD_LuJian_Right.JDARRAY[(int)RD_LuJian_Right.JDARRAY.size() - 1].y = tmpptARRAY[1].y;
					tmpptARRAY.clear();
				}
				else if (m_RoadData4[i].ConRD[j].ConnectStyle == 2) //T右
				{
					int n;
					n = m_RoadData4[i].ConRD[j].RDcankao;
					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}

					RD_LuJian_Right.ConRD[j].RDcankao = n;
					JDdata tempJDData;
					InitJDdata(tempJDData);
					vector<DPoint3d> JC_JD_ARRAY;
					int nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, -m_RoadData4[i].JDARRAY[n].kuandu_left, -m_RoadData4[i].JDARRAY[n].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右 //写了，注释掉了
					//起点
					tempJDData.JDtype = L"起点";
					tempJDData.x = JC_JD_ARRAY[2].x;
					tempJDData.y = JC_JD_ARRAY[2].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					rightCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, 1);
					RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 1 + rightCheck, tempJDData);

					//终点
					tempJDData.JDtype = L"终点";
					tempJDData.x = JC_JD_ARRAY[3].x;
					tempJDData.y = JC_JD_ARRAY[3].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					int inorout = 1;
					double chui1, chui2;
					BAS_DRAW_FUN::ChuizuToZx(inorout, chui1, chui2, tempJDData.x, tempJDData.y, m_RoadData4[i].JDARRAY[n].x,
						m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y);
					if (inorout != 1)
					{
						tempJDData.x = m_RoadData4[i].JDARRAY[n].x;
						tempJDData.y = m_RoadData4[i].JDARRAY[n].y;
					}
					//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+2+JDExistNum*2,tempJDData);
					RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 2 + rightCheck, tempJDData);
					JC_JD_ARRAY.clear();
				}
				else if (m_RoadData4[i].ConRD[j].ConnectStyle == 9) //右岔路左边点
				{
					int n;
					n = m_RoadData4[i].ConRD[j].RDcankao;

					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}

					JDdata tempJDData;
					InitJDdata(tempJDData);
					vector<DPoint3d> JC_JD_ARRAY;
					int nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					//DPoint3d tmpptPTGX;

					if (CheckFourPtIsLine(m_RoadData4[i].JDARRAY[n - 1].x, m_RoadData4[i].JDARRAY[n - 1].y, m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[i].JDARRAY[n - 1].kuandu_right, tmpptPTGX) > 0)
					{
						tempJDData.x = tmpptPTGX.x;
						tempJDData.y = tmpptPTGX.y;
					}
					else
					{
						JC_JD_ARRAY = JC_JD_zy(m_RoadData4[i].JDARRAY[n - 1].x, m_RoadData4[i].JDARRAY[n - 1].y, m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							-m_RoadData4[i].JDARRAY[n - 1].kuandu_left, -m_RoadData4[i].JDARRAY[n - 1].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
						//起点位置要改变		
						tempJDData.x = JC_JD_ARRAY[2].x;
						tempJDData.y = JC_JD_ARRAY[2].y;
					}
					tempJDData.JDtype = L"起点";
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					rightCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, 1);
					RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 1 + rightCheck, tempJDData);

					JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, -m_RoadData4[i].JDARRAY[n].kuandu_left, -m_RoadData4[i].JDARRAY[n].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
					//终点
					tempJDData.JDtype = L"终点";
					tempJDData.x = JC_JD_ARRAY[3].x;
					tempJDData.y = JC_JD_ARRAY[3].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 2 + rightCheck, tempJDData);
					RD_LuJian_Right.JDARRAY.erase(RD_LuJian_Right.JDARRAY.begin() + n + rightCheck);
					if (rightCheck > 0)
						RD_LuJian_Right.JDARRAY.erase(RD_LuJian_Right.JDARRAY.begin() + n + rightCheck - 1);
					JC_JD_ARRAY.clear();
				}
				else if (m_RoadData4[i].ConRD[j].ConnectStyle == 11) //右岔路右边点
				{
					int n;
					n = m_RoadData4[i].ConRD[j].RDcankao;

					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}

					JDdata tempJDData;
					InitJDdata(tempJDData);
					vector<DPoint3d> JC_JD_ARRAY;
					int nn = m_RoadData4[i].ConRD[j].JIAOxuhao;

					JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, -m_RoadData4[i].JDARRAY[n].kuandu_left, -m_RoadData4[i].JDARRAY[n].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
					tempJDData.x = JC_JD_ARRAY[2].x;
					tempJDData.y = JC_JD_ARRAY[2].y;
					//起点位置要改变
					tempJDData.JDtype = L"起点";
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					rightCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, 1);
					//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+1+JDExistNum*2,tempJDData);
					RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 1 + rightCheck, tempJDData);


					if (CheckFourPtIsLine(m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y, m_RoadData4[i].JDARRAY[n + 2].x, m_RoadData4[i].JDARRAY[n + 2].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[i].JDARRAY[n + 1].kuandu_right, tmpptPTGX) > 0)
					{
						tempJDData.x = tmpptPTGX.x;
						tempJDData.y = tmpptPTGX.y;
					}
					else
					{
						JC_JD_ARRAY = JC_JD_zy(m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y, m_RoadData4[i].JDARRAY[n + 2].x, m_RoadData4[i].JDARRAY[n + 2].y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							-m_RoadData4[i].JDARRAY[n + 1].kuandu_left, -m_RoadData4[i].JDARRAY[n + 1].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
						tempJDData.x = JC_JD_ARRAY[3].x;
						tempJDData.y = JC_JD_ARRAY[3].y;
					}
					//终点
					tempJDData.JDtype = L"终点";

					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;

					//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+2+JDExistNum*2,tempJDData);
					RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 2 + rightCheck, tempJDData);
					RD_LuJian_Right.JDARRAY.erase(RD_LuJian_Right.JDARRAY.begin() + n + 3 + rightCheck);
					if (rightCheck > 0)
						RD_LuJian_Right.JDARRAY.erase(RD_LuJian_Right.JDARRAY.begin() + n + 3 + rightCheck - 1);
					JC_JD_ARRAY.clear();
				}
				else if (m_RoadData4[i].ConRD[j].ConnectStyle == 3) //T左
				{
					int n;
					n = m_RoadData4[i].ConRD[j].RDcankao;
					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}
					RD_LuJian_Left.ConRD[j].RDcankao = n;

					JDdata tempJDData;
					InitJDdata(tempJDData);
					//起点
					vector<DPoint3d> JC_JD_ARRAY;
					int nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[n].kuandu_left, m_RoadData4[i].JDARRAY[n].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
					//起点
					tempJDData.JDtype = L"起点";
					tempJDData.x = JC_JD_ARRAY[2].x;
					tempJDData.y = JC_JD_ARRAY[2].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					leftCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, -1);
					//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m+1+JDExistNum*2,tempJDData);
					RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 1 + leftCheck, tempJDData);
					//终点
					tempJDData.JDtype = L"终点";
					tempJDData.x = JC_JD_ARRAY[3].x;
					tempJDData.y = JC_JD_ARRAY[3].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;

					int inorout = 1;
					double chui1, chui2;
					BAS_DRAW_FUN::ChuizuToZx(inorout, chui1, chui2, tempJDData.x, tempJDData.y, m_RoadData4[i].JDARRAY[n].x,
						m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y);
					if (inorout != 1)
					{
						tempJDData.x = m_RoadData4[i].JDARRAY[n].x;
						tempJDData.y = m_RoadData4[i].JDARRAY[n].y;
					}
					//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m+2+JDExistNum*2,tempJDData);	
					RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 2 + leftCheck, tempJDData);
					JC_JD_ARRAY.clear();
				}
				else if (m_RoadData4[i].ConRD[j].ConnectStyle == 10) //左岔左边
				{
					int n;
					n = m_RoadData4[i].ConRD[j].RDcankao;

					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}
					JDdata tempJDData;
					InitJDdata(tempJDData);
					//起点
					vector<DPoint3d> JC_JD_ARRAY;
					int nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					if (CheckFourPtIsLine(m_RoadData4[i].JDARRAY[n - 1].x, m_RoadData4[i].JDARRAY[n - 1].y, m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, -1.0 * m_RoadData4[i].JDARRAY[n - 1].kuandu_left, tmpptPTGX) > 0)
					{
						tempJDData.x = tmpptPTGX.x;
						tempJDData.y = tmpptPTGX.y;
					}
					else
					{
						JC_JD_ARRAY = JC_JD_zy(m_RoadData4[i].JDARRAY[n - 1].x, m_RoadData4[i].JDARRAY[n - 1].y, m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].JDARRAY[n - 1].kuandu_left, m_RoadData4[i].JDARRAY[n - 1].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
						tempJDData.x = JC_JD_ARRAY[2].x;
						tempJDData.y = JC_JD_ARRAY[2].y;
					}
					//起点
					tempJDData.JDtype = L"起点";
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					leftCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, -1);
					//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m+1+JDExistNum*2,tempJDData);
					RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 1 + leftCheck, tempJDData);
					//终点
					JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[n].kuandu_left, m_RoadData4[i].JDARRAY[n].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
					tempJDData.JDtype = L"终点";
					tempJDData.x = JC_JD_ARRAY[3].x;
					tempJDData.y = JC_JD_ARRAY[3].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;

					//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m+2+JDExistNum*2,tempJDData);
					RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 2 + leftCheck, tempJDData);
					RD_LuJian_Left.JDARRAY.erase(RD_LuJian_Left.JDARRAY.begin() + n + leftCheck);
					if (leftCheck > 0)
						RD_LuJian_Left.JDARRAY.erase(RD_LuJian_Left.JDARRAY.begin() + n + leftCheck - 1);
					JC_JD_ARRAY.clear();
				}
				else if (m_RoadData4[i].ConRD[j].ConnectStyle == 12) //左岔右边
				{
					int n;
					n = m_RoadData4[i].ConRD[j].RDcankao;

					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}

					JDdata tempJDData;
					InitJDdata(tempJDData);
					//起点
					vector<DPoint3d> JC_JD_ARRAY;
					int nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[n].kuandu_left, m_RoadData4[i].JDARRAY[n].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右

					//起点
					tempJDData.JDtype = L"起点";
					tempJDData.x = JC_JD_ARRAY[2].x;
					tempJDData.y = JC_JD_ARRAY[2].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					leftCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, -1);
					//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m+1+JDExistNum*2,tempJDData);
					RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 1 + leftCheck, tempJDData);
					//终点
					if (CheckFourPtIsLine(m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y, m_RoadData4[i].JDARRAY[n + 2].x, m_RoadData4[i].JDARRAY[n + 2].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, -1.0 * m_RoadData4[i].JDARRAY[n + 1].kuandu_left, tmpptPTGX) > 0)
					{
						tempJDData.x = tmpptPTGX.x;
						tempJDData.y = tmpptPTGX.y;
					}
					else
					{
						JC_JD_ARRAY = JC_JD_zy(m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y, m_RoadData4[i].JDARRAY[n + 2].x, m_RoadData4[i].JDARRAY[n + 2].y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].JDARRAY[n + 1].kuandu_left, m_RoadData4[i].JDARRAY[n + 1].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
						tempJDData.x = JC_JD_ARRAY[3].x;
						tempJDData.y = JC_JD_ARRAY[3].y;
					}
					tempJDData.JDtype = L"终点";

					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;

					//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m+2+JDExistNum*2,tempJDData);
					RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 2 + leftCheck, tempJDData);
					//	if (m+3+JDExistNum*2<RD_LuJian_Left.JDARRAY.size())
					RD_LuJian_Left.JDARRAY.erase(RD_LuJian_Left.JDARRAY.begin() + n + 3 + leftCheck);
					if (leftCheck > 0)
						RD_LuJian_Left.JDARRAY.erase(RD_LuJian_Left.JDARRAY.begin() + n + 3 + leftCheck - 1);

					//else
					//	RD_LuJian_Left.JDARRAY.pop_back();
					JC_JD_ARRAY.clear();
				}
				else if (m_RoadData4[i].ConRD[j].ConnectStyle == 13) //十字左
				{
					int n;
					n = m_RoadData4[i].ConRD[j].RDcankao;

					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}

					int nn;
					nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					RD_LuJian_Right.ConRD[j].RDcankao = n;

					JDdata tempJDData;
					InitJDdata(tempJDData);
					vector<DPoint3d> JC_JD_ARRAY;
					//起点
					tempJDData.JDtype = L"起点";
					//if(CheckFourPtIsLine(m_RoadData4[i].JDARRAY[n-1].x,m_RoadData4[i].JDARRAY[n-1].y,m_RoadData4[i].JDARRAY[n].x,m_RoadData4[i].JDARRAY[n].y,
					//	m_RoadData4[bh].JDARRAY[nn].x,m_RoadData4[bh].JDARRAY[nn].y,m_RoadData4[bh].JDARRAY[nn+1].x,m_RoadData4[bh].JDARRAY[nn+1].y,m_RoadData4[i].JDARRAY[n-1].kuandu_right,tmpptPTGX)>0)
					//{
					//	tempJDData.x=tmpptPTGX.x;
					//	tempJDData.y=tmpptPTGX.y;
					//}
					//else
					//{
					JC_JD_ARRAY = JC_JD_zy(m_RoadData4[i].JDARRAY[n - 1].x, m_RoadData4[i].JDARRAY[n - 1].y, m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						-m_RoadData4[i].JDARRAY[n - 1].kuandu_left, -m_RoadData4[i].JDARRAY[n - 1].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
					tempJDData.x = JC_JD_ARRAY[2].x;
					tempJDData.y = JC_JD_ARRAY[2].y;
					//}

					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+1+JDExistNum*2,tempJDData);
					rightCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, 1);
					RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 1 + rightCheck, tempJDData);

					//终点
					JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, -m_RoadData4[i].JDARRAY[n].kuandu_left, -m_RoadData4[i].JDARRAY[n].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
					tempJDData.JDtype = L"终点";
					tempJDData.x = JC_JD_ARRAY[3].x;
					tempJDData.y = JC_JD_ARRAY[3].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+2+JDExistNum*2,tempJDData);	
					RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 2 + rightCheck, tempJDData);
					RD_LuJian_Right.JDARRAY.erase(RD_LuJian_Right.JDARRAY.begin() + n + rightCheck);
					if (rightCheck > 0)
						RD_LuJian_Right.JDARRAY.erase(RD_LuJian_Right.JDARRAY.begin() + n + rightCheck - 1);
					//求出路肩线上对应的垂足插入点


					//if(CheckFourPtIsLine(m_RoadData4[i].JDARRAY[n-1].x,m_RoadData4[i].JDARRAY[n-1].y,m_RoadData4[i].JDARRAY[n].x,m_RoadData4[i].JDARRAY[n].y,
					//	m_RoadData4[bh].JDARRAY[nn].x,m_RoadData4[bh].JDARRAY[nn].y,m_RoadData4[bh].JDARRAY[nn+1].x,m_RoadData4[bh].JDARRAY[nn+1].y,m_RoadData4[i].JDARRAY[n-1].kuandu_right,tmpptPTGX)>0)
					//{
					//	tempJDData.x=tmpptPTGX.x;
					//	tempJDData.y=tmpptPTGX.y;
					//}
					//else
					//{
					JC_JD_ARRAY = JC_JD_zy(m_RoadData4[i].JDARRAY[n - 1].x, m_RoadData4[i].JDARRAY[n - 1].y, m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].JDARRAY[n - 1].kuandu_left, m_RoadData4[i].JDARRAY[n - 1].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
					tempJDData.x = JC_JD_ARRAY[2].x;
					tempJDData.y = JC_JD_ARRAY[2].y;
					//}
					//起点
					tempJDData.JDtype = L"起点";

					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+1+JDExistNum*2,tempJDData);
					leftCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, -1);
					RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 1 + leftCheck, tempJDData);
					//终点
					JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[n].kuandu_left, m_RoadData4[i].JDARRAY[n].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
					tempJDData.JDtype = L"终点";
					tempJDData.x = JC_JD_ARRAY[3].x;
					tempJDData.y = JC_JD_ARRAY[3].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+2+JDExistNum*2,tempJDData);
					RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 2 + leftCheck, tempJDData);
					RD_LuJian_Left.JDARRAY.erase(RD_LuJian_Left.JDARRAY.begin() + n + leftCheck);
					if (leftCheck > 0)
						RD_LuJian_Left.JDARRAY.erase(RD_LuJian_Left.JDARRAY.begin() + n + leftCheck - 1);
					JC_JD_ARRAY.clear();
				}
				else if (m_RoadData4[i].ConRD[j].ConnectStyle == 14) //十字右
				{
					int n;
					n = m_RoadData4[i].ConRD[j].RDcankao;

					//ads_printf(L" i   %d     m   %d \n",i,m);
					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}

					int nn;
					nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					RD_LuJian_Right.ConRD[j].RDcankao = n;

					//对已插入的道路交点进行循环,如果发现相同的参照点按距离远近排序

					JDdata tempJDData;
					InitJDdata(tempJDData);
					vector<DPoint3d> JC_JD_ARRAY;
					//起点
					tempJDData.JDtype = L"起点";
					JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, -m_RoadData4[i].JDARRAY[n].kuandu_left, -m_RoadData4[i].JDARRAY[n].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
					tempJDData.x = JC_JD_ARRAY[2].x;
					tempJDData.y = JC_JD_ARRAY[2].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					rightCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, 1);
					//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+1+JDExistNum*2,tempJDData);
					RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 1 + rightCheck, tempJDData);
					//终点
					//if(CheckFourPtIsLine(m_RoadData4[i].JDARRAY[n+1].x,m_RoadData4[i].JDARRAY[n+1].y,m_RoadData4[i].JDARRAY[n+2].x,m_RoadData4[i].JDARRAY[n+2].y,
					//	m_RoadData4[bh].JDARRAY[nn].x,m_RoadData4[bh].JDARRAY[nn].y,m_RoadData4[bh].JDARRAY[nn+1].x,m_RoadData4[bh].JDARRAY[nn+1].y,m_RoadData4[i].JDARRAY[n+1].kuandu_right,tmpptPTGX)>0)
					//{
					//	tempJDData.x=tmpptPTGX.x;
					//	tempJDData.y=tmpptPTGX.y;
					//}
					//else
					//{
					JC_JD_ARRAY = JC_JD_zy(m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y, m_RoadData4[i].JDARRAY[n + 2].x, m_RoadData4[i].JDARRAY[n + 2].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						-m_RoadData4[i].JDARRAY[n + 1].kuandu_left, -m_RoadData4[i].JDARRAY[n + 1].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
					tempJDData.x = JC_JD_ARRAY[3].x;
					tempJDData.y = JC_JD_ARRAY[3].y;
					//}
					tempJDData.JDtype = L"终点";
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+2+JDExistNum*2,tempJDData);	
					RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 2 + rightCheck, tempJDData);
					RD_LuJian_Right.JDARRAY.erase(RD_LuJian_Right.JDARRAY.begin() + n + 3 + rightCheck);
					if (rightCheck > 0)
						RD_LuJian_Right.JDARRAY.erase(RD_LuJian_Right.JDARRAY.begin() + n + 3 + rightCheck - 1);

					//求出路肩线上对应的垂足插入点

					RD_LuJian_Left.ConRD[j].RDcankao = n;
					JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[n].kuandu_left, m_RoadData4[i].JDARRAY[n].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右

					//起点
					tempJDData.JDtype = L"起点";
					tempJDData.x = JC_JD_ARRAY[2].x;
					tempJDData.y = JC_JD_ARRAY[2].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+1+JDExistNum*2,tempJDData);
					leftCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, -1);
					RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 1 + leftCheck, tempJDData);
					//终点
					//if(CheckFourPtIsLine(m_RoadData4[i].JDARRAY[n+1].x,m_RoadData4[i].JDARRAY[n+1].y,m_RoadData4[i].JDARRAY[n+2].x,m_RoadData4[i].JDARRAY[n+2].y,
					//	m_RoadData4[bh].JDARRAY[nn].x,m_RoadData4[bh].JDARRAY[nn].y,m_RoadData4[bh].JDARRAY[nn+1].x,m_RoadData4[bh].JDARRAY[nn+1].y,m_RoadData4[i].JDARRAY[n+1].kuandu_right,tmpptPTGX)>0)
					//{
					//	tempJDData.x=tmpptPTGX.x;
					//	tempJDData.y=tmpptPTGX.y;
					//}
					//else
					//{
					JC_JD_ARRAY = JC_JD_zy(m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y, m_RoadData4[i].JDARRAY[n + 2].x, m_RoadData4[i].JDARRAY[n + 2].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].JDARRAY[n + 1].kuandu_left, m_RoadData4[i].JDARRAY[n + 1].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
					tempJDData.x = JC_JD_ARRAY[3].x;
					tempJDData.y = JC_JD_ARRAY[3].y;
					//}
					tempJDData.JDtype = L"终点";

					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+2+JDExistNum*2,tempJDData);
					RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 2 + leftCheck, tempJDData);
					//if (m+3+JDExistNum*2<RD_LuJian_Left.JDARRAY.size())
					RD_LuJian_Left.JDARRAY.erase(RD_LuJian_Left.JDARRAY.begin() + n + 3 + leftCheck);
					if (leftCheck > 0)
						RD_LuJian_Left.JDARRAY.erase(RD_LuJian_Left.JDARRAY.begin() + n + 3 + leftCheck - 1);
					//else
					//	RD_LuJian_Left.JDARRAY.pop_back();
					JC_JD_ARRAY.clear();
				}
				else if (m_RoadData4[i].ConRD[j].ConnectStyle == 15) //十字
				{
					int n;
					n = m_RoadData4[i].ConRD[j].RDcankao;

					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}

					int nn;
					nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					RD_LuJian_Right.ConRD[j].RDcankao = n;
					rightCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, 1);
					leftCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, -1);
					JDdata tempJDData;
					InitJDdata(tempJDData);
					vector<DPoint3d> JC_JD_ARRAY;
					double zoy = 0;
					zoy = CCW2(m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x,
						m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y);
					if (zoy > 0)//逆时针 右线不变
					{
						//起点
						tempJDData.JDtype = L"起点";
						JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, -m_RoadData4[i].JDARRAY[n].kuandu_left, -m_RoadData4[i].JDARRAY[n].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
						tempJDData.x = JC_JD_ARRAY[2].x;
						tempJDData.y = JC_JD_ARRAY[2].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+1+JDExistNum*2,tempJDData);
						RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 1 + rightCheck, tempJDData);
						//终点
						tempJDData.JDtype = L"终点";
						tempJDData.x = JC_JD_ARRAY[3].x;
						tempJDData.y = JC_JD_ARRAY[3].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+2+JDExistNum*2,tempJDData);
						RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 2 + rightCheck, tempJDData);
					}
					else
					{
						//起点
						tempJDData.JDtype = L"起点";
						//if(CheckFourPtIsLine(m_RoadData4[i].JDARRAY[n].x,m_RoadData4[i].JDARRAY[n].y,m_RoadData4[i].JDARRAY[n+1].x,m_RoadData4[i].JDARRAY[n+1].y,
						//	m_RoadData4[bh].JDARRAY[nn-1].x,m_RoadData4[bh].JDARRAY[nn-1].y,m_RoadData4[bh].JDARRAY[nn].x,m_RoadData4[bh].JDARRAY[nn].y,m_RoadData4[i].JDARRAY[n].kuandu_right,tmpptPTGX)>0)
						//{
						//	tempJDData.x=tmpptPTGX.x;
						//	tempJDData.y=tmpptPTGX.y;
						//}
						//else
						//{
						JC_JD_ARRAY = JC_JD_zy(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
							m_RoadData4[bh].JDARRAY[nn - 1].x, m_RoadData4[bh].JDARRAY[nn - 1].y, m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y,
							-m_RoadData4[i].JDARRAY[n].kuandu_left, -m_RoadData4[i].JDARRAY[n].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn - 1].kuandu_left, m_RoadData4[bh].JDARRAY[nn - 1].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
						tempJDData.x = JC_JD_ARRAY[2].x;
						tempJDData.y = JC_JD_ARRAY[2].y;
						//}
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+1+JDExistNum*2,tempJDData);
						RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 1 + rightCheck, tempJDData);
						//终点
						tempJDData.JDtype = L"终点";
						tempJDData.x = JC_JD_ARRAY[3].x;
						tempJDData.y = JC_JD_ARRAY[3].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+2+JDExistNum*2,tempJDData);	
						RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 2 + rightCheck, tempJDData);
					}
					//求出路肩线上对应的垂足插入点
					RD_LuJian_Left.ConRD[j].RDcankao = n;

					if (zoy < 0)//顺时 左线不变
					{
						JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[n].kuandu_left, m_RoadData4[i].JDARRAY[n].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右

						//起点
						tempJDData.JDtype = L"起点";
						tempJDData.x = JC_JD_ARRAY[2].x;
						tempJDData.y = JC_JD_ARRAY[2].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+1+JDExistNum*2,tempJDData);
						RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 1 + leftCheck, tempJDData);
						//终点
						tempJDData.JDtype = L"终点";
						tempJDData.x = JC_JD_ARRAY[3].x;
						tempJDData.y = JC_JD_ARRAY[3].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+2+JDExistNum*2,tempJDData);
						RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 2 + leftCheck, tempJDData);
					}
					else
					{
						//if(CheckFourPtIsLine(m_RoadData4[i].JDARRAY[n].x,m_RoadData4[i].JDARRAY[n].y,m_RoadData4[i].JDARRAY[n+1].x,m_RoadData4[i].JDARRAY[n+1].y,
						//	m_RoadData4[bh].JDARRAY[nn-1].x,m_RoadData4[bh].JDARRAY[nn-1].y,m_RoadData4[bh].JDARRAY[nn].x,m_RoadData4[bh].JDARRAY[nn].y,m_RoadData4[i].JDARRAY[n].kuandu_right,tmpptPTGX)>0)
						//{
						//	tempJDData.x=tmpptPTGX.x;
						//	tempJDData.y=tmpptPTGX.y;
						//}
						//else
						//{
						JC_JD_ARRAY = JC_JD_zy(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
							m_RoadData4[bh].JDARRAY[nn - 1].x, m_RoadData4[bh].JDARRAY[nn - 1].y, m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y,
							m_RoadData4[i].JDARRAY[n].kuandu_left, m_RoadData4[i].JDARRAY[n].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn - 1].kuandu_left, m_RoadData4[bh].JDARRAY[nn - 1].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
						tempJDData.x = JC_JD_ARRAY[2].x;
						tempJDData.y = JC_JD_ARRAY[2].y;
						//}

						//起点
						tempJDData.JDtype = L"起点";
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+1+JDExistNum*2,tempJDData);
						RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 1 + leftCheck, tempJDData);
						//终点
						tempJDData.JDtype = L"终点";
						tempJDData.x = JC_JD_ARRAY[3].x;
						tempJDData.y = JC_JD_ARRAY[3].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+2+JDExistNum*2,tempJDData);
						RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 2 + leftCheck, tempJDData);
					}
					JC_JD_ARRAY.clear();
				}
				else if (m_RoadData4[i].ConRD[j].ConnectStyle == 16) //十字
				{
					int n;
					n = m_RoadData4[i].ConRD[j].RDcankao;
					int bh = 0;
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}

					int nn;
					nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					RD_LuJian_Right.ConRD[j].RDcankao = n;
					rightCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, 1);
					leftCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, -1);
					JDdata tempJDData;
					InitJDdata(tempJDData);
					vector<DPoint3d> JC_JD_ARRAY;
					double zoy = 0;
					zoy = CCW2(m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x,
						m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[1 + n].y);
					if (zoy < 0)//顺时针 右线不变
					{
						//起点
						tempJDData.JDtype = L"起点";
						JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, -m_RoadData4[i].JDARRAY[n].kuandu_left, -m_RoadData4[i].JDARRAY[n].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
						tempJDData.x = JC_JD_ARRAY[2].x;
						tempJDData.y = JC_JD_ARRAY[2].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+1+JDExistNum*2,tempJDData);
						RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 1 + rightCheck, tempJDData);
						//终点
						tempJDData.JDtype = L"终点";
						tempJDData.x = JC_JD_ARRAY[3].x;
						tempJDData.y = JC_JD_ARRAY[3].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+2+JDExistNum*2,tempJDData);	
						RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 2 + rightCheck, tempJDData);
					}
					else
					{
						//起点
						tempJDData.JDtype = L"起点";
						//if(CheckFourPtIsLine(m_RoadData4[i].JDARRAY[n].x,m_RoadData4[i].JDARRAY[n].y,m_RoadData4[i].JDARRAY[n+1].x,m_RoadData4[i].JDARRAY[n+1].y,
						//	m_RoadData4[bh].JDARRAY[nn+1].x,m_RoadData4[bh].JDARRAY[nn+1].y,m_RoadData4[bh].JDARRAY[nn+2].x,m_RoadData4[bh].JDARRAY[nn+2].y,m_RoadData4[i].JDARRAY[n].kuandu_right,tmpptPTGX)>0)
						//{
						//	tempJDData.x=tmpptPTGX.x;
						//	tempJDData.y=tmpptPTGX.y;
						//}
						//else
						//{
						JC_JD_ARRAY = JC_JD_zy(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
							m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[bh].JDARRAY[nn + 2].x, m_RoadData4[bh].JDARRAY[nn + 2].y,
							-m_RoadData4[i].JDARRAY[n].kuandu_left, -m_RoadData4[i].JDARRAY[n].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn + 1].kuandu_left, m_RoadData4[bh].JDARRAY[nn + 1].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
						tempJDData.x = JC_JD_ARRAY[2].x;
						tempJDData.y = JC_JD_ARRAY[2].y;
						//}
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+1+JDExistNum*2,tempJDData);
						RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 1 + rightCheck, tempJDData);
						//终点
						tempJDData.JDtype = L"终点";
						tempJDData.x = JC_JD_ARRAY[3].x;
						tempJDData.y = JC_JD_ARRAY[3].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+2+JDExistNum*2,tempJDData);	
						RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 2 + rightCheck, tempJDData);
					}

					//求出路肩线上对应的垂足插入点

					RD_LuJian_Left.ConRD[j].RDcankao = n;
					//对已插入的道路交点进行循环,如果发现相同的参照点按距离远近排序
					if (zoy < 0)//顺时针 左线变
					{
						JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
							m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y, m_RoadData4[bh].JDARRAY[nn + 2].x, m_RoadData4[bh].JDARRAY[nn + 2].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[n].kuandu_left, m_RoadData4[i].JDARRAY[n].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn + 1].kuandu_left, m_RoadData4[bh].JDARRAY[nn + 1].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右

						//起点
						tempJDData.JDtype = L"起点";
						tempJDData.x = JC_JD_ARRAY[2].x;
						tempJDData.y = JC_JD_ARRAY[2].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+1+JDExistNum*2,tempJDData);
						RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 1 + leftCheck, tempJDData);
						//终点
						tempJDData.JDtype = L"终点";
						tempJDData.x = JC_JD_ARRAY[3].x;
						tempJDData.y = JC_JD_ARRAY[3].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+2+JDExistNum*2,tempJDData);
						RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 2 + leftCheck, tempJDData);
					}
					else
					{
						JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
							m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
							m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[n].kuandu_left, m_RoadData4[i].JDARRAY[n].kuandu_right,
							m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右

						//起点
						tempJDData.JDtype = L"起点";
						tempJDData.x = JC_JD_ARRAY[2].x;
						tempJDData.y = JC_JD_ARRAY[2].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+1+JDExistNum*2,tempJDData);
						RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 1 + leftCheck, tempJDData);
						//终点
						tempJDData.JDtype = L"终点";
						tempJDData.x = JC_JD_ARRAY[3].x;
						tempJDData.y = JC_JD_ARRAY[3].y;
						tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
						tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
						tempJDData.l1 = 0.0;
						tempJDData.l2 = 0.0;
						//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+2+JDExistNum*2,tempJDData);
						RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 2 + leftCheck, tempJDData);
					}
					JC_JD_ARRAY.clear();
				}

				else if (m_RoadData4[i].ConRD[j].ConnectStyle == 4) //十字
				{
					int n;
					n = m_RoadData4[i].ConRD[j].RDcankao;//本条路相交参考序号
					int bh = 0; // 相交的道路在数组中的序号
					for (int kk = 0; kk < (int)m_RoadData4.size(); kk++)
					{
						if (_tcscmp(m_RoadData4[i].ConRD[j].DLBiaoHao, m_RoadData4[kk].DLBiaoHao) == 0)
						{
							bh = kk;
							break;
						}
					}
					int nn;
					nn = m_RoadData4[i].ConRD[j].JIAOxuhao;
					RD_LuJian_Right.ConRD[j].RDcankao = n;
					rightCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, 1);
					leftCheck = CheckZXBK(m_RoadData4[i].JDARRAY, n, -1);
					JDdata tempJDData;
					InitJDdata(tempJDData);
					vector<DPoint3d> JC_JD_ARRAY;
					//起点
					tempJDData.JDtype = L"起点";
					// 传出十字路口的交点数组，2-0-4,3-1-5分别为道路一侧边线的路口三交点，2,4（3,5）是以切线长为距离求出的点（此处半径设为0，即0,2；1,3均为边线交点且重叠）
					// 2，3为本条道路上的新增点；4,5为相交道路上的新增点
					JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, -m_RoadData4[i].JDARRAY[n].kuandu_left, -m_RoadData4[i].JDARRAY[n].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右
					tempJDData.x = JC_JD_ARRAY[2].x;
					tempJDData.y = JC_JD_ARRAY[2].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+1+JDExistNum*2,tempJDData);
					RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 1 + rightCheck, tempJDData);
					//终点
					tempJDData.JDtype = L"终点";
					tempJDData.x = JC_JD_ARRAY[3].x;
					tempJDData.y = JC_JD_ARRAY[3].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					//RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin()+m+2+JDExistNum*2,tempJDData);
					RD_LuJian_Right.JDARRAY.insert(RD_LuJian_Right.JDARRAY.begin() + n + 2 + rightCheck, tempJDData);
					//求出路肩线上对应的垂足插入点

					RD_LuJian_Left.ConRD[j].RDcankao = n;
					// 传出十字路口的交点数组，2-0-4,3-1-5分别为道路一侧边线的路口三交点，2,4（3,5）是以切线长为距离求出的点（此处半径设为0，即0,2；1,3均为边线交点且重叠）
					// 2，3为本条道路上的新增点；4,5为相交道路上的新增点
					JC_JD_ARRAY = JC_JD(m_RoadData4[i].JDARRAY[n].x, m_RoadData4[i].JDARRAY[n].y, m_RoadData4[i].JDARRAY[n + 1].x, m_RoadData4[i].JDARRAY[n + 1].y,
						m_RoadData4[bh].JDARRAY[nn].x, m_RoadData4[bh].JDARRAY[nn].y, m_RoadData4[bh].JDARRAY[nn + 1].x, m_RoadData4[bh].JDARRAY[nn + 1].y,
						m_RoadData4[i].ConRD[j].ConJD.x, m_RoadData4[i].ConRD[j].ConJD.y, m_RoadData4[i].JDARRAY[n].kuandu_left, m_RoadData4[i].JDARRAY[n].kuandu_right,
						m_RoadData4[bh].JDARRAY[nn].kuandu_left, m_RoadData4[bh].JDARRAY[nn].kuandu_right, 0, 0); //宽1指代本条路半宽 宽2指相交路半宽 +左-右

					//起点
					tempJDData.JDtype = L"起点";
					tempJDData.x = JC_JD_ARRAY[2].x;
					tempJDData.y = JC_JD_ARRAY[2].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+1+JDExistNum*2,tempJDData);
					RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 1 + leftCheck, tempJDData);
					//终点
					tempJDData.JDtype = L"终点";
					tempJDData.x = JC_JD_ARRAY[3].x;
					tempJDData.y = JC_JD_ARRAY[3].y;
					tempJDData.R = m_RoadData4[i].ConRD[j].ConJD.R;
					tempJDData.gc = m_RoadData4[i].ConRD[j].ConJD.gc;
					tempJDData.l1 = 0.0;
					tempJDData.l2 = 0.0;
					//RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin()+m2+2+JDExistNum*2,tempJDData);
					RD_LuJian_Left.JDARRAY.insert(RD_LuJian_Left.JDARRAY.begin() + n + 2 + leftCheck, tempJDData);
					JC_JD_ARRAY.clear();
				}
			}
		}
		Road_BX_Left.push_back(RD_LuJian_Left);
		Road_BX_Right.push_back(RD_LuJian_Right);
	}

	JDdata JDdataTmp;
	InitJDdata(JDdataTmp);
	vector<JDdata> DLJDdataTmp;
	vector<vector<JDdata>> DLJDdata;
	vector<RoadChaiChuArray> RoadChaiChuArrayData;//每一小分段的拆除信息
	vector<DLBPD>RoadBPDArrayData;
	RoadChaiChuArray CCtmp;
	DLJDdataTmp.clear();
	DLJDdata.clear();
	RoadChaiChuArrayData.clear();
	CCtmp.clear();
	RoadBPDArrayData.clear();
	//根据边线生成小分段
	for (int i = 0; i < (int)Road_BX_Left.size(); i++)
	{
		if (Road_BX_Left[i].ConRD.size() == 0)
		{
			DLJDdata.push_back(Road_BX_Left[i].JDARRAY);
			//生成拆除信息
			GeneBXCCDpt(Road_BX_Left[i], Road_BX_Left[i].JDARRAY, CCtmp);
			RoadChaiChuArrayData.push_back(CCtmp);
			RoadBPDArrayData.insert(RoadBPDArrayData.end(), Road_BX_Left[i].m_BPDArray.begin(), Road_BX_Left[i].m_BPDArray.end());
		}
		else
		{
			for (int j = 0; j < (int)Road_BX_Left[i].JDARRAY.size(); j++)
			{
				if (j == Road_BX_Left[i].JDARRAY.size() - 1)
				{
					DLJDdataTmp.push_back(Road_BX_Left[i].JDARRAY[j]);
					DLJDdata.push_back(DLJDdataTmp);
					//生成拆除信息
					GeneBXCCDpt(Road_BX_Left[i], DLJDdataTmp, CCtmp);
					RoadChaiChuArrayData.push_back(CCtmp);
					DLJDdataTmp.clear();
					RoadBPDArrayData.insert(RoadBPDArrayData.end(), Road_BX_Left[i].m_BPDArray.begin(), Road_BX_Left[i].m_BPDArray.end());
				}
				else
				{
					//寻找起点
					if (Road_BX_Left[i].JDARRAY[j].JDtype == L"主路点" || Road_BX_Left[i].JDARRAY[j].JDtype == L"")
					{
						DLJDdataTmp.push_back(Road_BX_Left[i].JDARRAY[j]);
						continue;
					}
					if (Road_BX_Left[i].JDARRAY[j].JDtype == L"终点")
					{
						DLJDdataTmp.clear();
						DLJDdataTmp.push_back(Road_BX_Left[i].JDARRAY[j]);
						continue;
					}
					if (Road_BX_Left[i].JDARRAY[j].JDtype == L"起点")
					{
						DLJDdataTmp.push_back(Road_BX_Left[i].JDARRAY[j]);
						DLJDdata.push_back(DLJDdataTmp);
						//生成拆除信息
						GeneBXCCDpt(Road_BX_Left[i], DLJDdataTmp, CCtmp);
						RoadChaiChuArrayData.push_back(CCtmp);
						DLJDdataTmp.clear();
						RoadBPDArrayData.insert(RoadBPDArrayData.end(), Road_BX_Left[i].m_BPDArray.begin(), Road_BX_Left[i].m_BPDArray.end());
					}
				}
			}
		}
	}

	for (int i = 0; i < (int)Road_BX_Right.size(); i++)
	{
		if (Road_BX_Right[i].ConRD.size() == 0)
		{
			DLJDdata.push_back(Road_BX_Right[i].JDARRAY);
			//生成拆除信息
			GeneBXCCDpt(Road_BX_Right[i], Road_BX_Right[i].JDARRAY, CCtmp);
			RoadChaiChuArrayData.push_back(CCtmp);
		}
		else
		{
			for (int j = 0; j < (int)Road_BX_Right[i].JDARRAY.size(); j++)
			{
				if (j == Road_BX_Right[i].JDARRAY.size() - 1)
				{
					DLJDdataTmp.push_back(Road_BX_Right[i].JDARRAY[j]);
					DLJDdata.push_back(DLJDdataTmp);
					//生成拆除信息
					GeneBXCCDpt(Road_BX_Right[i], DLJDdataTmp, CCtmp);
					RoadChaiChuArrayData.push_back(CCtmp);
					DLJDdataTmp.clear();
				}
				else
				{
					//寻找起点
					if (Road_BX_Right[i].JDARRAY[j].JDtype == L"主路点" || Road_BX_Right[i].JDARRAY[j].JDtype == L"")
					{
						DLJDdataTmp.push_back(Road_BX_Right[i].JDARRAY[j]);
						continue;
					}
					if (Road_BX_Right[i].JDARRAY[j].JDtype == L"终点")
					{
						DLJDdataTmp.clear();
						DLJDdataTmp.push_back(Road_BX_Right[i].JDARRAY[j]);
						continue;;
					}
					if (Road_BX_Right[i].JDARRAY[j].JDtype == L"起点")
					{
						DLJDdataTmp.push_back(Road_BX_Right[i].JDARRAY[j]);
						DLJDdata.push_back(DLJDdataTmp);
						//生成拆除信息
						GeneBXCCDpt(Road_BX_Right[i], DLJDdataTmp, CCtmp);
						RoadChaiChuArrayData.push_back(CCtmp);
						DLJDdataTmp.clear();
					}
				}
			}
		}
	}
	JDdataOutFinally1.clear();

	vector<vector<JDdata>> JDdataOut;
	JDdataOut.clear();
	vector<RoadChaiChuArray> CCDdataOut;
	CCDdataOut.clear();
	for (int i = 0; i < (int)DLJDdata.size(); i++)
	{
		for (int j = 0; j < (int)DLJDdata[i].size(); j++)
			_tcscpy(DLJDdata[i][j].JXLC, L"道路交点");
		CheckJDData(DLJDdata[i], JDdataOut, RoadChaiChuArrayData[i], CCDdataOut);
	}


	vector<vector<JDdata>> JDdataOuttmp;
	JDdataOuttmp.clear();
	vector<RoadChaiChuArray> CCDdataOuttmp;
	CCDdataOuttmp.clear();
	vector<DLBPD>m_BPDDatatmp;
	m_BPDDatatmp.clear();
	for (int i = 0; i < (int)JDdataOut.size(); i++)
		CheckJDData(JDdataOut[i], JDdataOuttmp, CCDdataOut[i], CCDdataOuttmp);

	JDdataOut.clear();
	JDdataOut = JDdataOuttmp;
	JDdataOuttmp.clear();
	CCDdataOut.clear();
	CCDdataOut = CCDdataOuttmp;
	CCDdataOuttmp.clear();
	for (int i = 0; i < (int)JDdataOut.size(); i++)
		CheckJDData(JDdataOut[i], JDdataOuttmp, CCDdataOut[i], CCDdataOuttmp);

	//修正交叉口的属性
	for (int i = 0; i < (int)JDdataOuttmp.size(); i++)
	{
		for (int j = 1; j < (int)JDdataOuttmp[i].size() - 1; j++)
		{
			if (JDdataOuttmp[i][j].JDtype == L"起点" || JDdataOuttmp[i][j].JDtype == L"终点")
				_tcscpy(JDdataOuttmp[i][j].JXLC, L"交叉口");
		}
	}

	JDdataOutFinally1.resize((int)JDdataOuttmp.size());
	for (int i = 0; i < (int)JDdataOuttmp.size(); i++)
	{
		_tcscpy(JDdataOutFinally1[i].LWBH, m_RoadData4[0].BianHaoIn);
		_tcscpy(JDdataOutFinally1[i].BJBH, BAS_DRAW_FUN::getBHID());
		JDdataOutFinally1[i].JDARRAY = JDdataOuttmp[i];
		JDdataOutFinally1[i].m_ChaiChuArray = CCDdataOuttmp[i];
		JDdataOutFinally1[i].m_BPDArray = RoadBPDArrayData;
	}

	DPoint3d PT1, PT2;
	for (int i = 0; i < (int)JDdataOutFinally1.size(); i++)
	{
		for (int j = 0; j < (int)JDdataOutFinally1[i].JDARRAY.size(); j++)
		{
			//比对交点坐标,替换相关半径
			PT1.Init(JDdataOutFinally1[i].JDARRAY[j].x, JDdataOutFinally1[i].JDARRAY[j].y, 0);
			int isfind = 0;
			for (int k = 0; k < (int)ConRDArray.size(); k++)
			{
				PT2.Init(ConRDArray[k].x, ConRDArray[k].y, 0);
				double dis = PT1.Distance(PT2);
				if (dis < 0.1)
				{
					JDdataOutFinally1[i].JDARRAY[j].R = fabs(ConRDArray[k].z); // 20190914
					if (ConRDArray[k].z < -0.00001)
						JDdataOutFinally1[i].JDARRAY[j].isShowR = 0;
					else
						JDdataOutFinally1[i].JDARRAY[j].isShowR = 1;
					isfind = 1;
					break;
				}
			}
		}
	}

	for (int j = 0; j < (int)JDdataOutFinally1.size(); j++)
	{
		CheckRDBX(JDdataOutFinally1[j].JDARRAY);
		//将拆除段投影到边线
		Cal_xianyuan(JDdataOutFinally1[j].JDARRAY);
		if (JDdataOutFinally1[j].m_ChaiChuArray.size() > 0)
		{
			for (int k = 0; k < (int)JDdataOutFinally1[j].m_ChaiChuArray.size(); k++)
			{
				TrsNEtoCml(JDdataOutFinally1[j], JDdataOutFinally1[j].m_ChaiChuArray[k].CCPTArray[0].y,
					JDdataOutFinally1[j].m_ChaiChuArray[k].CCPTArray[0].x, JDdataOutFinally1[j].m_ChaiChuArray[k].StartFDCml);
				TrsNEtoCml(JDdataOutFinally1[j], JDdataOutFinally1[j].m_ChaiChuArray[k].CCPTArray[JDdataOutFinally1[j].m_ChaiChuArray[k].CCPTArray.size() - 1].y,
					JDdataOutFinally1[j].m_ChaiChuArray[k].CCPTArray[JDdataOutFinally1[j].m_ChaiChuArray[k].CCPTArray.size() - 1].x, JDdataOutFinally1[j].m_ChaiChuArray[k].EndFDCml);

				if (JDdataOutFinally1[j].m_ChaiChuArray[k].StartFDCml > JDdataOutFinally1[j].m_ChaiChuArray[k].EndFDCml)
				{
					double cmltmp;
					cmltmp = JDdataOutFinally1[j].m_ChaiChuArray[k].StartFDCml;
					JDdataOutFinally1[j].m_ChaiChuArray[k].StartFDCml = JDdataOutFinally1[j].m_ChaiChuArray[k].EndFDCml;
					JDdataOutFinally1[j].m_ChaiChuArray[k].EndFDCml = cmltmp;
				}
			}
		}
	}

	//二次比较
	for (int i = 0; i < (int)JDdataOutFinally1.size(); i++)
	{
		for (int j = 0; j < (int)JDdataOutFinally1[i].JDARRAY.size(); j++)
		{
			//比对交点坐标,替换相关半径
			PT1.Init(JDdataOutFinally1[i].JDARRAY[j].x, JDdataOutFinally1[i].JDARRAY[j].y, 0);
			int isfind = 0;
			for (int k = 0; k < (int)ConRDArray.size(); k++)
			{
				PT2.Init(ConRDArray[k].x, ConRDArray[k].y, 0);
				double dis = PT1.Distance(PT2);
				if (dis < 1)
				{
					JDdataOutFinally1[i].JDARRAY[j].R = fabs(ConRDArray[k].z); // 20190914
					if (ConRDArray[k].z < -0.00001)
						JDdataOutFinally1[i].JDARRAY[j].isShowR = 0;
					else
						JDdataOutFinally1[i].JDARRAY[j].isShowR = 1;
					// JDdataOutFinally1[i].JDARRAY[j].R = ConRDArray[k].z;
					isfind = 1;
					break;
				}
			}
		}
	}

	//剔除重复点
	for (int i = 0; i < (int)JDdataOutFinally1.size(); i++)
	{
		int jdnumtmp = (int)JDdataOutFinally1[i].JDARRAY.size();
		for (int j = 0; j < (int)JDdataOutFinally1[i].JDARRAY.size() - 1; j++)
		{
			double distmp = pow(JDdataOutFinally1[i].JDARRAY[j].x - JDdataOutFinally1[i].JDARRAY[j + 1].x, 2)
				+ pow(JDdataOutFinally1[i].JDARRAY[j].y - JDdataOutFinally1[i].JDARRAY[j + 1].y, 2);
			if (distmp < 0.1)
			{
				JDdataOutFinally1[i].JDARRAY.erase(JDdataOutFinally1[i].JDARRAY.begin() + j + 1);
				j--;
			}
		}
	}
	//剔除《=1个点的边
	for (int i = 0; i < (int)JDdataOutFinally1.size(); i++)
	{
		if (JDdataOutFinally1[i].JDARRAY.size() <= 1)
		{
			JDdataOutFinally1.erase(JDdataOutFinally1.begin() + i);
			i--;
		}
	}


	DLJDdataTmp.clear();
	JDdataOut.clear();
	Road_BX_Left.clear();
	Road_BX_Right.clear();
	JDdataOuttmp.clear();
	RoadBPDArrayData.clear();
}

// 依据拆除段信息，形成分段绘制里程 isCC 1为拆除段 0不为拆除段
void CDrawRoad::FormCmlArrayCCD(vector<DLDrawFD> &GDFDArray, RoadChaiChuArray m_ChaiChuArray, double RoadL)
{
	GDFDArray.clear();
	if (m_ChaiChuArray.size() == 0)
	{
		GDFDArray.resize(1);
		GDFDArray[0].StartCml = 0;
		GDFDArray[0].EndCml = RoadL;
		GDFDArray[0].type = 0;
		return;
	}

	RoadChaiChuArray ChaiChuArraytmp;
	for (int i = 0; i < (int)m_ChaiChuArray.size(); i++)
		ChaiChuArraytmp.push_back(m_ChaiChuArray[i]);

	//先将非拆除段赋值
	GDFDArray.resize((int)ChaiChuArraytmp.size() + 1);
	GDFDArray[0].StartCml = 0;
	int ii = 1;
	for (int i = 0; i < (int)ChaiChuArraytmp.size(); i++)
	{
		GDFDArray[ii].StartCml = ChaiChuArraytmp[i].EndFDCml;
		ii++;
	}
	for (int i = 0; i < (int)ChaiChuArraytmp.size(); i++)
		GDFDArray[i].EndCml = ChaiChuArraytmp[i].StartFDCml;
	GDFDArray[(int)GDFDArray.size() - 1].EndCml = RoadL;
	for (int i = 0; i < (int)GDFDArray.size(); i++)
		GDFDArray[i].type = 0;

	DLDrawFD GDDrawFDtmp;
	for (int i = 0; i < (int)ChaiChuArraytmp.size(); i++)
	{
		GDDrawFDtmp.StartCml = ChaiChuArraytmp[i].StartFDCml;
		GDDrawFDtmp.EndCml = ChaiChuArraytmp[i].EndFDCml;
		GDDrawFDtmp.type = 1;
		GDFDArray.push_back(GDDrawFDtmp);
	}

	for (int i = 0; i < (int)GDFDArray.size(); i++)
	{
		if (GDFDArray[i].StartCml > GDFDArray[i].EndCml - 0.01)
		{
			GDFDArray.erase(GDFDArray.begin() + i);
			i--;
		}
	}

	if (GDFDArray.size() == 0)
	{
		GDFDArray.resize(1);
		GDFDArray[0].StartCml = 0;
		GDFDArray[0].EndCml = RoadL;
		GDFDArray[0].type = 0;
	}
}

//生成从统一里程lc1到统一里程lc2的线路中线
void CDrawRoad::MakeWXYByStartEndcml(Road Draw_Road,double(*XYArray)[10], int XYNum, double lc1, double lc2, int isChai)
{
	xlpoint PB, PE;
	double Scml = lc1;
	double Ecml = lc2;

	//ACHAR LayerName[STR_NORMAL];
	//ACHAR lineType[STR_NORMAL];
	//int color;
	//double lw;
	if (isChai == 1)
	{
		/*_tcscpy(lineType, DLShiTiDuiXiangDataCC.XianXing);
		color = DLShiTiDuiXiangDataCC.Color;
		lw = DLShiTiDuiXiangDataCC.XianKuan;
		_tcscpy(LayerName, DLShiTiDuiXiangDataCC.TuCeng);
		Lw = DLShiTiDuiXiangDataCC.Lw;*/
	}
	else
	{
		/*	_tcscpy(lineType, DLShiTiDuiXiangData.XianXing);
			color = DLShiTiDuiXiangData.Color;
			lw = DLShiTiDuiXiangData.XianKuan;
			_tcscpy(LayerName, DLShiTiDuiXiangData.TuCeng);
			Lw = DLShiTiDuiXiangData.Lw;*/
	}

	// 绘线位
	PB.x = XYArray[0][1]; //N
	PB.y = XYArray[0][2]; // E
	PB.a = XYArray[0][3];// FA
	PB.lc = XYArray[0][4];
	PB.r = 1e40;
	PE.x = PE.y = PE.lc = PE.a = 0.0;
	int DrawXySn, DrawXyEn, i;
	//DPoint3d Pt, PtText;
	double cml;

	DrawXySn = 1; DrawXyEn = XYNum;
	for (i = 1; i < XYNum; i++)
	{
		if (XYArray[i][6] > Scml - 0.01)
		{
			DrawXySn = i;
			break;
		}
	}
	if (i == XYNum)
	{
		DrawXySn = XYNum;
	}
	for (i = 1; i <= XYNum; i++)
	{
		if (XYArray[i][6] > Ecml - 0.01)
		{
			DrawXyEn = i - 1;
			break;
		}
	}
	xlpoint  PZtmp;
	vector<DPoint3d> Pt2dAy;
	Pt2dAy.clear();
	double Offset = 0.0;

	if (DrawXySn > 1)
	{
		cml = Scml;
		PZtmp.lc = cml;
		xlpoint_pz(XYArray, XYNum, &PZtmp);
		double GCtmp = 0.0;
		TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp);
		if (GCtmp == 0.0)
			CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GCtmp);
		Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp));

		if (DrawXyEn == DrawXySn - 1)//绘图范围不足一个线元
		{
			xlpoint PZtmp2;
			PZtmp2.lc = Ecml;
			xlpoint_pz(XYArray, XYNum, &PZtmp2);
			if (XYArray[DrawXySn - 1][0] < 1.1)//直线
			{
				double GCtmp1 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp2.lc, GCtmp1);
				if (GCtmp1 == 0.0)
					CalGCFromRoadGC(Draw_Road, PZtmp2.y, PZtmp2.x, GCtmp1);
				Pt2dAy.push_back(DPoint3d::From(PZtmp2.y, PZtmp2.x, GCtmp1));

				/*DPoint3d tmp1;
				tmp1.Init(PZtmp2.y, PZtmp2.x, 0);
				Pt2dAy.push_back(tmp1);*/
			}
			//else if( XYArray[DrawXySn-1][0]<2.1)//圆
			//{
			// int NUM=Pt2dAy.length();
			// Pt2dAy[NUM-1].z=-tan((Ecml-Scml)/XYArray[DrawXySn-1][1]/4)*XYArray[DrawXySn-1][4];
			// Pt2dAy.append(AcGePoint3d( PZtmp2.y, PZtmp2.x,0));
			//}
			else//缓和曲线
			{
				cml = XYArray[DrawXySn - 1][6];

				double TotolLength = Ecml - cml;
				//起点高程
				PZtmp.lc = cml;
				xlpoint_pz(XYArray, XYNum, &PZtmp);
				double GC1 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp.lc, GC1);
				if (GC1 == 0.0)
					CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC1);

				//终点高程
				PZtmp.lc = Ecml;
				xlpoint_pz(XYArray, XYNum, &PZtmp);
				double GC2 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp.lc, GC2);
				if (GC2 == 0.0)
					CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC2);
				double GCC = GC2 - GC1;

				while (cml < Ecml)
				{
					PZtmp.lc = cml;
					xlpoint_pz(XYArray, XYNum, &PZtmp);
					double GCtmp2 = 0.0;
					TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp2);
					if (GCtmp2 == 0.0)
						GetGCFromRoadGCForHHQX(cml - XYArray[DrawXySn - 1][6], TotolLength, GCC,GC1, GCtmp2);
					Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp2));
					
					cml += 0.2;
				}
				PZtmp.lc = Ecml;
				xlpoint_pz(XYArray, XYNum, &PZtmp);
				double GCtmp3 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp3);
				if (GCtmp3 == 0.0)
					CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GCtmp3);
				Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp3));
			}

			/*pWd->subEntityTraits().setColor(color);
			pWd->subEntityTraits().setLineWeight(Lw);*/
			int size =(int)Pt2dAy.size();
			DPoint3d* pArr = new DPoint3d[size];
			for (int k = 0; k < size; k++)
				pArr[k].Init(Pt2dAy[k].x, Pt2dAy[k].y, Pt2dAy[k].z);
			
			//pWd->geometry().polyline(size, pArr);

			return;
		}

		if (XYArray[DrawXySn - 1][0] < 1.1)//直线
		{
			double GCtmp4 = 0.0;
			TrsCmltoGC(Draw_Road, XYArray[DrawXySn][6], GCtmp4);
			if (GCtmp4 == 0.0)
				CalGCFromRoadGC(Draw_Road, XYArray[DrawXySn][9], XYArray[DrawXySn][8], GCtmp4);
			Pt2dAy.push_back(DPoint3d::From(XYArray[DrawXySn][9], XYArray[DrawXySn][8], GCtmp4));
		}
		//else if( XYArray[DrawXySn-1][0]<2.1)//圆
		//{
		// int NUM=Pt2dAy.length();
		// Pt2dAy[NUM-1].z=-tan((XYArray[DrawXySn-1][2]-Scml+XYArray[DrawXySn-1][6])/XYArray[DrawXySn-1][1]/4)*XYArray[DrawXySn-1][4];
		// Pt2dAy.append(AcGePoint3d( XYArray[DrawXySn][9], XYArray[DrawXySn][8],0.0));
		//}
		else//缓和曲线
		{
			cml += 0.2;

			double StartCml = cml;
			double TotolLength = XYArray[DrawXySn][6] - cml;
			//起点高程
			PZtmp.lc = cml;
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GC1 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GC1);
			if (GC1 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC1);

			//终点高程
			PZtmp.lc = XYArray[DrawXySn][6];
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GC2 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GC2);
			if (GC2 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC2);
			double GCC = GC2 - GC1;

			while (cml < XYArray[DrawXySn][6])
			{
				PZtmp.lc = cml;
				xlpoint_pz(XYArray, XYNum, &PZtmp);
				double GCtmp5 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp5);
				if (GCtmp5 == 0.0)
					GetGCFromRoadGCForHHQX(cml-StartCml,TotolLength,GCC,GC1, GCtmp5);
				Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp5));
				cml += 0.2;
			}
			PZtmp.lc = XYArray[DrawXySn][6];
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GCtmp6 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp6);
			if (GCtmp6 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GCtmp6);
			Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp6));
		}
	}

	for (i = DrawXySn; i < DrawXyEn; i++)
	{
		if (XYArray[i][0] < 1.1)//直线
		{
			double GCtmp7 = 0.0;
			TrsCmltoGC(Draw_Road, XYArray[i][6], GCtmp7);
			if (GCtmp7 == 0.0)
				CalGCFromRoadGC(Draw_Road, XYArray[i][9], XYArray[i][8], GCtmp7);
			Pt2dAy.push_back(DPoint3d::From(XYArray[i][9], XYArray[i][8], GCtmp7));
			double GCtmp8 = 0.0;
			TrsCmltoGC(Draw_Road, XYArray[i + 1][6], GCtmp8);
			if (GCtmp8 == 0.0)
				CalGCFromRoadGC(Draw_Road, XYArray[i + 1][9], XYArray[i + 1][8], GCtmp8);
			Pt2dAy.push_back(DPoint3d::From(XYArray[i + 1][9], XYArray[i + 1][8], GCtmp8));
		}
		// 		 else if( XYArray[i][0]<2.1)//圆
		// 		 {
		// 			 double TempTD;
		// 			 TempTD=-tan(XYArray[i][2]/XYArray[i][1]/4)*XYArray[i][4];
		// 			 Pt2dAy.append(AcGePoint3d( XYArray[i][9], XYArray[i][8],TempTD));
		// 			 Pt2dAy.append(AcGePoint3d( XYArray[i+1][9], XYArray[i+1][8],0.0));
		// 		 }
		else//缓和曲线
		{
			cml = XYArray[i][6];

			double TotolLength = XYArray[i + 1][6] - cml;
			//起点高程
			PZtmp.lc = cml;
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GC1 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GC1);
			if (GC1 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC1);

			//终点高程
			PZtmp.lc = XYArray[i + 1][6];
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GC2 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GC2);
			if (GC2 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC2);
			double GCC = GC2 - GC1;

			while (cml < XYArray[i + 1][6])
			{
				PZtmp.lc = cml;
				xlpoint_pz(XYArray, XYNum, &PZtmp);
				double GCtmp9 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp9);
				if (GCtmp9 == 0.0)
					GetGCFromRoadGCForHHQX(cml-XYArray[i][6], TotolLength, GCC,GC1, GCtmp9);
				Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp9));
				cml += 0.2;
			}
			PZtmp.lc = XYArray[i + 1][6];
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GCtmp10 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp10);
			if (GCtmp10 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GCtmp10);
			Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp10));
		}
	}

	if (DrawXyEn < XYNum)
	{
		cml = XYArray[DrawXyEn][6];
		double GCtmp11 = 0.0;
		TrsCmltoGC(Draw_Road, XYArray[DrawXyEn][6], GCtmp11);
		if (GCtmp11 == 0.0)
			CalGCFromRoadGC(Draw_Road, XYArray[DrawXyEn][9], XYArray[DrawXyEn][8], GCtmp11);
		Pt2dAy.push_back(DPoint3d::From(XYArray[DrawXyEn][9], XYArray[DrawXyEn][8], GCtmp11));
		if (XYArray[DrawXyEn][0] < 1.1)//直线
		{
			cml = Ecml;
			PZtmp.lc = cml;
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GCtmp12 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp12);
			if (GCtmp12 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GCtmp12);
			Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp12));
		}
		// 		 else if( XYArray[DrawXyEn][0]<2.1)//圆
		// 		 {
		// 			 int NUM=Pt2dAy.length();
		// 			 Pt2dAy[NUM-1].z=-tan((Ecml-cml)/XYArray[DrawXyEn][1]/4)*XYArray[DrawXyEn][4];
		// 			 PZtmp.lc = Ecml;
		// 			 xlpoint_pz(XYArray,XYNum,&PZtmp);
		// 			 Pt2dAy.append(AcGePoint3d( PZtmp.y, PZtmp.x,0.0));
		// 		 }
		else
		{
			cml = XYArray[DrawXyEn][6];

			double TotolLength = Ecml - cml;
			//起点高程
			PZtmp.lc = cml;
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GC1 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GC1);
			if (GC1 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC1);

			//终点高程
			PZtmp.lc = Ecml;
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GC2 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GC2);
			if (GC2 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC2);
			double GCC = GC2 - GC1;


			while (cml < Ecml)
			{
				PZtmp.lc = cml;
				xlpoint_pz(XYArray, XYNum, &PZtmp);
				double GCtmp13 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp13);
				if (GCtmp13 == 0.0)
					GetGCFromRoadGCForHHQX(cml-XYArray[DrawXyEn][6], TotolLength,GCC, GC1, GCtmp13);
				Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp13));
				cml += 0.2;
			}
			PZtmp.lc = Ecml;
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GCtmp14 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp14);
			if (GCtmp14 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GCtmp14);
			Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp14));
		}
	}

	/*pWd->subEntityTraits().setColor(color);
	pWd->subEntityTraits().setLineWeight(Lw);*/
	int size = (int)Pt2dAy.size();
	vector<DPoint3d>Pt2dAy_Bot;
	Pt2dAy_Bot.clear();
	DPoint3d* pArr = NULL;
	if (size > 1)
	{
		pArr = new DPoint3d[size];
		for (int k = 0; k < size; k++)
			pArr[k].Init(Pt2dAy[k].x, Pt2dAy[k].y, Pt2dAy[k].z);
		
		//pWd->geometry().polyline(size, pArr);
	}

	if (pArr)
		delete[]pArr;
	pArr = NULL;
}

void CDrawRoad::MakeWXYByStartEndcml(Road_BX Draw_Road, double(*XYArray)[10], int XYNum, double lc1, double lc2, int isChai)
{
	xlpoint PB, PE;
	double Scml = lc1;
	double Ecml = lc2;

	//ACHAR LayerName[STR_NORMAL];
	//ACHAR lineType[STR_NORMAL];
	//int color;
	//double lw;
	if (isChai == 1)
	{
		/*_tcscpy(lineType, DLShiTiDuiXiangDataCC.XianXing);
		color = DLShiTiDuiXiangDataCC.Color;
		lw = DLShiTiDuiXiangDataCC.XianKuan;
		_tcscpy(LayerName, DLShiTiDuiXiangDataCC.TuCeng);
		Lw = DLShiTiDuiXiangDataCC.Lw;*/
	}
	else
	{
		/*	_tcscpy(lineType, DLShiTiDuiXiangData.XianXing);
			color = DLShiTiDuiXiangData.Color;
			lw = DLShiTiDuiXiangData.XianKuan;
			_tcscpy(LayerName, DLShiTiDuiXiangData.TuCeng);
			Lw = DLShiTiDuiXiangData.Lw;*/
	}

	// 绘线位
	PB.x = XYArray[0][1]; //N
	PB.y = XYArray[0][2]; // E
	PB.a = XYArray[0][3];// FA
	PB.lc = XYArray[0][4];
	PB.r = 1e40;
	PE.x = PE.y = PE.lc = PE.a = 0.0;
	int DrawXySn, DrawXyEn, i;
	//DPoint3d Pt, PtText;
	double cml;

	DrawXySn = 1; DrawXyEn = XYNum;
	for (i = 1; i < XYNum; i++)
	{
		if (XYArray[i][6] > Scml - 0.01)
		{
			DrawXySn = i;
			break;
		}
	}
	if (i == XYNum)
	{
		DrawXySn = XYNum;
	}
	for (i = 1; i <= XYNum; i++)
	{
		if (XYArray[i][6] > Ecml - 0.01)
		{
			DrawXyEn = i - 1;
			break;
		}
	}
	xlpoint  PZtmp;
	vector<DPoint3d> Pt2dAy;
	Pt2dAy.clear();
	double Offset = 0.0;

	//在缓和曲线地段的高程由前直线最后一点高程和后直线开始一点高程内插而得
	//根据0.2m的间距以及整个缓和曲线的长度从而内插每个点的高程
	//以下缓和曲线处理方式同理

	if (DrawXySn > 1)
	{
		cml = Scml;
		PZtmp.lc = cml;
		double GCtmp = 0.0;
		TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp);
		if(GCtmp == 0.0)
			CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GCtmp);
		Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp));
		LinearPoints.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp));

		if (DrawXyEn == DrawXySn - 1)//绘图范围不足一个线元
		{
			xlpoint PZtmp2;
			PZtmp2.lc = Ecml;
			xlpoint_pz(XYArray, XYNum, &PZtmp2);
			if (XYArray[DrawXySn - 1][0] < 1.1)//直线
			{
				double GCtmp1 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp2.lc, GCtmp1);
				if (GCtmp1 == 0.0)
					CalGCFromRoadGC(Draw_Road, PZtmp2.y, PZtmp2.x, GCtmp1);
				Pt2dAy.push_back(DPoint3d::From(PZtmp2.y, PZtmp2.x, GCtmp1));
				LinearPoints.push_back(DPoint3d::From(PZtmp2.y, PZtmp2.x, GCtmp1));

				/*DPoint3d tmp1;
				tmp1.Init(PZtmp2.y, PZtmp2.x, 0);
				Pt2dAy.push_back(tmp1);*/
			}
			//else if( XYArray[DrawXySn-1][0]<2.1)//圆
			//{
			// int NUM=Pt2dAy.length();
			// Pt2dAy[NUM-1].z=-tan((Ecml-Scml)/XYArray[DrawXySn-1][1]/4)*XYArray[DrawXySn-1][4];
			// Pt2dAy.append(AcGePoint3d( PZtmp2.y, PZtmp2.x,0));
			//}
			else//缓和曲线
			{
				cml = XYArray[DrawXySn - 1][6];

				double TotolLength = Ecml - cml;
				//起点高程
				PZtmp.lc = cml;
				xlpoint_pz(XYArray, XYNum, &PZtmp);
				double GC1 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp.lc, GC1);
				if (GC1 == 0.0)
					CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC1);

				//终点高程
				PZtmp.lc = Ecml;
				xlpoint_pz(XYArray, XYNum, &PZtmp);
				double GC2 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp.lc, GC2);
				if (GC2 == 0.0)
					CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC2);
				double GCC = GC2 - GC1;

				while (cml < Ecml)
				{
					PZtmp.lc = cml;
					xlpoint_pz(XYArray, XYNum, &PZtmp);
					double GCtmp2 = 0.0;
					TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp2);
					if (GCtmp2 == 0.0)
					{
						GetGCFromRoadGCForHHQX(cml - XYArray[DrawXySn - 1][6],TotolLength,GCC,GC1,GCtmp2);//GCC 表示高程
					}
					Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp2));
					CurvesPoints.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp2));

					cml += 0.2;
				}
				PZtmp.lc = Ecml;
				xlpoint_pz(XYArray, XYNum, &PZtmp);
				double GCtmp3 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp3);
				if (GCtmp3 == 0.0)
					CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GCtmp3);
				Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp3));
				CurvesPoints.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp3));
			}

			/*pWd->subEntityTraits().setColor(color);
			pWd->subEntityTraits().setLineWeight(Lw);*/
			int size = (int)Pt2dAy.size();
			DPoint3d* pArr = new DPoint3d[size];
			for (int k = 0; k < size; k++)
				pArr[k].Init(Pt2dAy[k].x, Pt2dAy[k].y, Pt2dAy[k].z);
		
			//pWd->geometry().polyline(size, pArr);

			return;
		}

		if (XYArray[DrawXySn - 1][0] < 1.1)//直线
		{
			double GCtmp4 = 0.0;
			TrsCmltoGC(Draw_Road, XYArray[DrawXySn][6], GCtmp4);
			if (GCtmp4 == 0.0)
				CalGCFromRoadGC(Draw_Road, XYArray[DrawXySn][9], XYArray[DrawXySn][8], GCtmp4);
			Pt2dAy.push_back(DPoint3d::From(XYArray[DrawXySn][9], XYArray[DrawXySn][8], GCtmp4));
			LinearPoints.push_back(DPoint3d::From(XYArray[DrawXySn][9], XYArray[DrawXySn][8], GCtmp4));
		}
		//else if( XYArray[DrawXySn-1][0]<2.1)//圆
		//{
		// int NUM=Pt2dAy.length();
		// Pt2dAy[NUM-1].z=-tan((XYArray[DrawXySn-1][2]-Scml+XYArray[DrawXySn-1][6])/XYArray[DrawXySn-1][1]/4)*XYArray[DrawXySn-1][4];
		// Pt2dAy.append(AcGePoint3d( XYArray[DrawXySn][9], XYArray[DrawXySn][8],0.0));
		//}
		else//缓和曲线
		{
			cml += 0.2;

			double StartCml = cml;
			double TotolLength = XYArray[DrawXySn][6] - cml;
			//起点高程
			PZtmp.lc = cml;
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GC1 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GC1);
			if (GC1 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC1);

			//终点高程
			PZtmp.lc = XYArray[DrawXySn][6];
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GC2 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GC2);
			if (GC2 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC2);
			double GCC = GC2 - GC1;


			while (cml < XYArray[DrawXySn][6])
			{
				PZtmp.lc = cml;
				xlpoint_pz(XYArray, XYNum, &PZtmp);
				double GCtmp5 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp5);
				if (GCtmp5 == 0.0)
				{
					GetGCFromRoadGCForHHQX(cml - StartCml, TotolLength, GCC,GC1, GCtmp5);
				}
				Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp5));
				CurvesPoints.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp5));
				cml += 0.2;
			}
			PZtmp.lc = XYArray[DrawXySn][6];
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GCtmp6 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp6);
			if (GCtmp6 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GCtmp6);
			Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp6));
			CurvesPoints.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp6));
		}
	}

	for (i = DrawXySn; i < DrawXyEn; i++)
	{
		if (XYArray[i][0] < 1.1)//直线
		{
			double GCtmp7 = 0.0;
			TrsCmltoGC(Draw_Road, XYArray[i][6], GCtmp7);
			if (GCtmp7 == 0.0)
				CalGCFromRoadGC(Draw_Road, XYArray[i][9], XYArray[i][8], GCtmp7);
			Pt2dAy.push_back(DPoint3d::From(XYArray[i][9], XYArray[i][8], GCtmp7));
			LinearPoints.push_back(DPoint3d::From(XYArray[i][9], XYArray[i][8], GCtmp7));
			double GCtmp8 = 0.0;
			TrsCmltoGC(Draw_Road, XYArray[i + 1][6], GCtmp8);
			if (GCtmp8 == 0.0)
				CalGCFromRoadGC(Draw_Road, XYArray[i + 1][9], XYArray[i + 1][8], GCtmp8);
			Pt2dAy.push_back(DPoint3d::From(XYArray[i + 1][9], XYArray[i + 1][8], GCtmp8));
			LinearPoints.push_back(DPoint3d::From(XYArray[i + 1][9], XYArray[i + 1][8], GCtmp8));
		}
		// 		 else if( XYArray[i][0]<2.1)//圆
		// 		 {
		// 			 double TempTD;
		// 			 TempTD=-tan(XYArray[i][2]/XYArray[i][1]/4)*XYArray[i][4];
		// 			 Pt2dAy.append(AcGePoint3d( XYArray[i][9], XYArray[i][8],TempTD));
		// 			 Pt2dAy.append(AcGePoint3d( XYArray[i+1][9], XYArray[i+1][8],0.0));
		// 		 }
		else//缓和曲线
		{
			cml = XYArray[i][6];

			double TotolLength = XYArray[i + 1][6] - cml;
			//起点高程
			PZtmp.lc = cml;
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GC1 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GC1);
			if (GC1 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC1);

			//终点高程
			PZtmp.lc = XYArray[i + 1][6];
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GC2 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GC2);
			if (GC2 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC2);
			double GCC = GC2 - GC1;

			while (cml < XYArray[i + 1][6])
			{
				PZtmp.lc = cml;
				xlpoint_pz(XYArray, XYNum, &PZtmp);
				double GCtmp9 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp9);
				if (GCtmp9 == 0.0)
				{
					GetGCFromRoadGCForHHQX(cml - XYArray[i][6],TotolLength,GCC,GC1,GCtmp9);
				}
				Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp9));
				CurvesPoints.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp9));
				cml += 0.2;
			}
			PZtmp.lc = XYArray[i + 1][6];
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GCtmp10 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp10);
			if (GCtmp10 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GCtmp10);
			Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp10));
			CurvesPoints.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp10));
		}
	}

	if (DrawXyEn < XYNum)
	{
		cml = XYArray[DrawXyEn][6];
		double GCtmp11 = 0.0;
		double GCtmp12 = 0.0;
		TrsCmltoGC(Draw_Road, XYArray[DrawXyEn][6], GCtmp11);
		if (GCtmp11 == 0.0)
			CalGCFromRoadGC(Draw_Road, XYArray[DrawXyEn][9], XYArray[DrawXyEn][8], GCtmp11);
		Pt2dAy.push_back(DPoint3d::From(XYArray[DrawXyEn][9], XYArray[DrawXyEn][8], GCtmp11));
		LinearPoints.push_back(DPoint3d::From(XYArray[DrawXyEn][9], XYArray[DrawXyEn][8], GCtmp11));
		if (XYArray[DrawXyEn][0] < 1.1)//直线
		{
			cml = Ecml;
			PZtmp.lc = cml;
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp12);
			if (GCtmp12 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GCtmp12);
			Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp12));
			LinearPoints.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp12));
		}
		// 		 else if( XYArray[DrawXyEn][0]<2.1)//圆
		// 		 {
		// 			 int NUM=Pt2dAy.length();
		// 			 Pt2dAy[NUM-1].z=-tan((Ecml-cml)/XYArray[DrawXyEn][1]/4)*XYArray[DrawXyEn][4];
		// 			 PZtmp.lc = Ecml;
		// 			 xlpoint_pz(XYArray,XYNum,&PZtmp);
		// 			 Pt2dAy.append(AcGePoint3d( PZtmp.y, PZtmp.x,0.0));
		// 		 }
		else
		{
			cml = XYArray[DrawXyEn][6];

			double TotolLength = Ecml - cml;
			//起点高程
			PZtmp.lc = cml;
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GC1 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GC1);
			if (GC1 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC1);

			//终点高程
			PZtmp.lc = Ecml;
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GC2 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GC2);
			if (GC2 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GC2);
			double GCC = GC2 - GC1;


			while (cml < Ecml)
			{
				PZtmp.lc = cml;
				xlpoint_pz(XYArray, XYNum, &PZtmp);
				double GCtmp13 = 0.0;
				TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp13);
				if (GCtmp13 == 0.0)
				{
					GetGCFromRoadGCForHHQX(cml - XYArray[DrawXyEn][6], TotolLength,GCC,GC1, GCtmp13);
				}
				Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp13));
				CurvesPoints.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp13));
				cml += 0.2;
			}
			PZtmp.lc = Ecml;
			xlpoint_pz(XYArray, XYNum, &PZtmp);
			double GCtmp14 = 0.0;
			TrsCmltoGC(Draw_Road, PZtmp.lc, GCtmp14);
			if (GCtmp14 == 0.0)
				CalGCFromRoadGC(Draw_Road, PZtmp.y, PZtmp.x, GCtmp14);
			Pt2dAy.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp14));
			CurvesPoints.push_back(DPoint3d::From(PZtmp.y, PZtmp.x, GCtmp14));
		}
	}

	/*pWd->subEntityTraits().setColor(color);
	pWd->subEntityTraits().setLineWeight(Lw);*/
	int size = (int)Pt2dAy.size();
	vector<DPoint3d>Pt2dAy_Bot;
	Pt2dAy_Bot.clear();
	DPoint3d* pArr = NULL;
	if (size > 1)
	{
		pArr = new DPoint3d[size];
		for (int k = 0; k < size; k++)
		{
			pArr[k].Init(Pt2dAy[k].x, Pt2dAy[k].y, Pt2dAy[k].z);
			AllPoints.push_back(Pt2dAy[k]);
		}
			
		
		//pWd->geometry().polyline(size, pArr);
		
	}
	if (size > 1)
	{
		for (int k = 0; k < size; k++)
			Pt2dAy_Bot.push_back(DPoint3d::From(Pt2dAy[k].x, Pt2dAy[k].y, Pt2dAy[k].z - LuMianHou));
	
	}
	Road_BX1_ForStarEnd.push_back(Pt2dAy[0]);
	Road_BX1_ForStarEnd.push_back(Pt2dAy[Pt2dAy.size() - 1]);
	Road_BX2_ForStarEnd.push_back(Pt2dAy_Bot[0]);
	Road_BX2_ForStarEnd.push_back(Pt2dAy_Bot[Pt2dAy_Bot.size() - 1]);

	if (pArr)
		delete[]pArr;
	pArr = NULL;
}

void CDrawRoad::Draw_xianyuan(Road& Draw_Road, CString RDStyle)
{
	int NJD = (int)Draw_Road.JDARRAY.size();
	DPoint3d * verts = new DPoint3d[NJD];
	DVec3d  normal = DVec3d::From(0.0, 0.0, 1.0);
	int i = 0, j = 0, k = 0;

	//DPoint3d StaPt, CenPt, End1, End2, End3;
	//DPoint3d  ptb, pte, pt;

	DrawFDArray.clear();
	FormCmlArrayCCD(DrawFDArray, Draw_Road.m_ChaiChuArray, Draw_Road.RoadL);
	Draw_Road.DrawFDArray = DrawFDArray;
	for (i = 0; i < (int)DrawFDArray.size(); i++)
	{
		MakeWXYByStartEndcml(Draw_Road,Draw_Road.array, Draw_Road.tarray, DrawFDArray[i].StartCml, DrawFDArray[i].EndCml, DrawFDArray[i].type);
		//绘制拆除段
		/*if (DrawFDArray[i].type == 1)
		{
			BAS_DRAW_FUN::LineXXX(pWd, Draw_Road.array, Draw_Road.tarray,
				DrawFDArray[i].StartCml, DrawFDArray[i].EndCml,
				50, DLShiTiDuiXiangDataCCF.Color, DLShiTiDuiXiangDataCCF.Lw);
		}*/
	}
}

void CDrawRoad::Draw_xianyuan_BX(Road_BX& Draw_Road, CString RDStyle)
{
	int NJD = (int)Draw_Road.JDARRAY.size();
	DPoint3d /*Pt,*/ * verts = new DPoint3d[NJD];
	DVec3d  normal = DVec3d::From(0.0, 0.0, 1.0);
	int i = 0, j = 0, k = 0;

	/*DPoint3d StaPt, CenPt, End1, End2, End3;
	DPoint3d  ptb, pte, pt;*/
	//AcDbLinetypeTable* pLinetypeTable1 = NULL;
	//AcDbObjectId ltId;//虚线层
	/*if (RDStyle == L"中线")
	{
		acdbHostApplicationServices()->workingDatabase()->loadLineTypeFile(L"DASHDOT", L"acadiso.lin");
		acdbHostApplicationServices()->workingDatabase()->getLinetypeTable(pLinetypeTable1, AcDb::kForRead);
		pLinetypeTable1->getAt(L"DASHDOT", ltId, Adesk::kTrue);
	}
	else
	{
		acdbHostApplicationServices()->workingDatabase()->loadLineTypeFile(L"Continuous", L"acadiso.lin");
		acdbHostApplicationServices()->workingDatabase()->getLinetypeTable(pLinetypeTable1, AcDb::kForRead);
		pLinetypeTable1->getAt(L"Continuous", ltId, Adesk::kTrue);
	}
	pLinetypeTable1->close();
	pWd->subEntityTraits().setLineType(ltId);*/

	DrawFDArray.clear();
	FormCmlArrayCCD(DrawFDArray, Draw_Road.m_ChaiChuArray, Draw_Road.RoadL);
	Draw_Road.DrawFDArray = DrawFDArray;
	for (i = 0; i < (int)DrawFDArray.size(); i++)
	{
		MakeWXYByStartEndcml(Draw_Road,array_BX, tarray_BX, DrawFDArray[i].StartCml, DrawFDArray[i].EndCml, DrawFDArray[i].type);
		//绘制拆除段
		if (DrawFDArray[i].type == 1)
		{
		/*	BAS_DRAW_FUN::LineXXX(pWd, array_BX, tarray_BX, DrawFDArray[i].StartCml, DrawFDArray[i].EndCml,
				50, DLShiTiDuiXiangDataCCF.Color, DLShiTiDuiXiangDataCCF.Lw);*/
		}
	}
	
}

void CDrawRoad::DRAW_RD_Net_BX(vector<Rd_BX> JDdataOutFinally2, vector<Road_BX>& Road_BXArray)
{
	Road_BX Road_BXObject;
	Road_BXArray.resize((int)JDdataOutFinally2.size());
	for (int i = 0; i < (int)JDdataOutFinally2.size(); i++)
	{
		Road_BXObject.JDARRAY = JDdataOutFinally2[i].JDARRAY;
		Road_BXObject.m_ChaiChuArray = JDdataOutFinally2[i].m_ChaiChuArray;
		Road_BXObject.m_BPDArray = JDdataOutFinally2[i].m_BPDArray;

		//202304
		/*for (int k = 0; k < (int)JDdataOutFinally2[i].JDARRAY.size() - 2; k++)
		{
			if (JDdataOutFinally2[i].JDARRAY[k + 1].gc == 0)
			{
				DPoint3d TargetPoint = DPoint3d::FromZero();
				TargetPoint.x = JDdataOutFinally2[i].JDARRAY[k + 1].x;
				TargetPoint.y = JDdataOutFinally2[i].JDARRAY[k + 1].y;

				DPoint3d Point1 = DPoint3d::FromZero();
				Point1.x = JDdataOutFinally2[i].JDARRAY[k].x;
				Point1.y = JDdataOutFinally2[i].JDARRAY[k].y;
				Point1.z = JDdataOutFinally2[i].JDARRAY[k].gc;

				DPoint3d Point2 = DPoint3d::FromZero();
				Point2.x = JDdataOutFinally2[i].JDARRAY[k+2].x;
				Point2.y = JDdataOutFinally2[i].JDARRAY[k+2].y;
				Point2.z = JDdataOutFinally2[i].JDARRAY[k+2].gc;
				bool isInLine = GetPointIsInLine(TargetPoint, Point1, Point2);
				if (isInLine)
				{
					double Distancetmp = sqrt(pow((Point1.x - Point2.x), 2) + pow((Point1.y - Point2.y), 2));
					double Distancetmp1 = sqrt(pow((Point1.x - TargetPoint.x), 2) + pow((Point1.y - TargetPoint.y), 2));
					if (Distancetmp1 == 0)
					{
						JDdataOutFinally2[i].JDARRAY[k + 1].gc = Point1.z;
						break;
					}
					else
					{
						double GCValue = 0.0;
						GCValue = Point2.z - Point1.z;
						if (Distancetmp == 0)
							JDdataOutFinally2[i].JDARRAY[k + 1].gc = Point1.z;
						else
							JDdataOutFinally2[i].JDARRAY[k + 1].gc = Point1.z + GCValue * Distancetmp1 / Distancetmp;
						break;
					}
				}
			}
		}*/
		AllPoints.clear();
		LinearPoints.clear();
		CurvesPoints.clear();
		Cal_xianyuan(Road_BXObject);
		Draw_xianyuan_BX(Road_BXObject, L"肩线");
		//BAS_DRAW_FUN::createAProjectedSolid(AllPoints,-LuMianHou);
		//BAS_DRAW_FUN::createAProjectedSolid(LinearPoints, -LuMianHou);
		//BAS_DRAW_FUN::createAProjectedSolid(CurvesPoints, -LuMianHou);
		Road_BXArray[i] = Road_BXObject;
	}

	vector<vector<DPoint3d>>DrawLinePoints;
	DrawLinePoints.clear();
	for (int jj = 0; jj < Road_BX1_ForStarEnd.size(); jj++)
	{
		vector<DPoint3d>tmp1;
		tmp1.clear();
		tmp1 = Road_BX1_ForStarEnd;
		tmp1.erase(tmp1.begin()+jj);
		int Indextmp = 0;
		vector<double>Distmp;
		Distmp.clear();
		for (int kk = 0; kk < tmp1.size(); kk++)
		{
			double Distmp1 = Road_BX1_ForStarEnd[jj].Distance(tmp1[kk]);
			Distmp.push_back(Distmp1);
		}
		Indextmp = min_element(Distmp.begin(), Distmp.end()) - Distmp.begin();

		//BAS_DRAW_FUN::createLines(Road_BX1_ForStarEnd[jj], tmp1[Indextmp]);
		vector<DPoint3d>TwoPoints;
		TwoPoints.resize(2);
		TwoPoints[0] = Road_BX1_ForStarEnd[jj];
		TwoPoints[1] = tmp1[Indextmp];
		DrawLinePoints.push_back(TwoPoints);
	}
	for (vector<vector<DPoint3d>>::iterator iter = DrawLinePoints.begin(); iter != DrawLinePoints.end(); iter++)
	{
		vector<vector<DPoint3d>>::iterator tmp = iter + 1;
		for (vector<vector<DPoint3d>>::iterator it = tmp; it != DrawLinePoints.end(); it++)
		{
			if (fabs((*iter)[0].x - (*it)[1].x) < 0.01 && fabs((*iter)[0].y - (*it)[1].y) < 0.01&&
				fabs((*iter)[1].y - (*it)[0].y) < 0.01 && fabs((*iter)[1].x - (*it)[0].x) < 0.01)
			{
				DrawLinePoints.erase(iter);
				iter = DrawLinePoints.begin();
				break;
			}
		}
	}
	for (int jj = 0; jj < DrawLinePoints.size(); jj++)
		//BAS_DRAW_FUN::createLines(DrawLinePoints[jj][0], DrawLinePoints[jj][1]);
	DrawLinePoints.clear();

	for (int jj = 0; jj < Road_BX2_ForStarEnd.size(); jj++)
	{
		vector<DPoint3d>tmp1;
		tmp1.clear();
		tmp1 = Road_BX2_ForStarEnd;
		tmp1.erase(tmp1.begin() + jj);
		int Indextmp = 0;
		vector<double>Distmp;
		Distmp.clear();
		for (int kk = 0; kk < tmp1.size(); kk++)
		{
			double Distmp1 = Road_BX2_ForStarEnd[jj].Distance(tmp1[kk]);
			Distmp.push_back(Distmp1);
		}
		Indextmp = min_element(Distmp.begin(), Distmp.end()) - Distmp.begin();
		//BAS_DRAW_FUN::createLines(Road_BX2_ForStarEnd[jj], tmp1[Indextmp]);
		vector<DPoint3d>TwoPoints;
		TwoPoints.resize(2);
		TwoPoints[0] = Road_BX2_ForStarEnd[jj];
		TwoPoints[1] = tmp1[Indextmp];
		DrawLinePoints.push_back(TwoPoints);
	}
	for (vector<vector<DPoint3d>>::iterator iter = DrawLinePoints.begin(); iter != DrawLinePoints.end(); iter++)
	{
		vector<vector<DPoint3d>>::iterator tmp = iter + 1;
		for (vector<vector<DPoint3d>>::iterator it = tmp; it != DrawLinePoints.end(); it++)
		{
			if (fabs((*iter)[0].x - (*it)[1].x) < 0.01 && fabs((*iter)[0].y - (*it)[1].y) < 0.01 &&
				fabs((*iter)[1].y - (*it)[0].y) < 0.01 && fabs((*iter)[1].x - (*it)[0].x) < 0.01)
			{
				DrawLinePoints.erase(iter);
				iter = DrawLinePoints.begin();
				break;
			}
		}
	}
	for (int jj = 0; jj < DrawLinePoints.size(); jj++)
	//	BAS_DRAW_FUN::createLines(DrawLinePoints[jj][0], DrawLinePoints[jj][1]);
	DrawLinePoints.clear();


	Road_BX1_ForStarEnd.clear();
	Road_BX2_ForStarEnd.clear();

	ConRDArray.clear();
	DPoint3d tmpjd;
	//DPoint3d pt1, pt2;
	for (int i = 0; i < (int)JDdataOutFinally2.size(); i++)
	{
		for (int j = 0; j < (int)JDdataOutFinally2[i].JDARRAY.size(); j++)
		{
			// 20190914
			double RisShow = 1;
			if (!JDdataOutFinally2[i].JDARRAY[j].isShowR)
				RisShow = -1;
			tmpjd.Init(JDdataOutFinally2[i].JDARRAY[j].x, JDdataOutFinally2[i].JDARRAY[j].y, RisShow * JDdataOutFinally2[i].JDARRAY[j].R);
			ConRDArray.push_back(tmpjd);
		}
	}
}

vector<DPoint3d> CDrawRoad::DrawCross(DPoint3d centralPoint, double LuMianKuan,double LuMianHou1,double fwj)
{
	vector<DPoint3d>CrossPoints;
	CrossPoints.resize(4);
	DPoint3d tmp = DPoint3d::From(centralPoint.x - LuMianKuan / 2.0 * cos(fwj), centralPoint.y - LuMianKuan / 2.0 * sin(fwj), centralPoint.z);
	CrossPoints[0] = tmp;
	tmp = DPoint3d::From(centralPoint.x - LuMianKuan / 2.0 * cos(fwj), centralPoint.y - LuMianKuan / 2.0 * sin(fwj), centralPoint.z + LuMianHou);
	CrossPoints[1] = tmp;
	tmp = DPoint3d::From(centralPoint.x + LuMianKuan / 2.0 * cos(fwj), centralPoint.y + LuMianKuan / 2.0 * sin(fwj), centralPoint.z + LuMianHou);
	CrossPoints[2] = tmp;
	tmp = DPoint3d::From(centralPoint.x + LuMianKuan / 2.0 * cos(fwj), centralPoint.y + LuMianKuan / 2.0 * sin(fwj), centralPoint.z);
	CrossPoints[3] = tmp;

	return CrossPoints;
}

void CDrawRoad::CalAndDrawRoad()
{
	m_RoadNum = (int)m_RoadData.size();
	m_RoadDataCheck.clear();
	vector<vector<CString>>DLLength;
	DLLength.clear();
	DLLength.resize(m_RoadNum); // 道路长度属性
	for (int i = 0; i < m_RoadNum; i++)
	{
		//如果冠号为空 自动修正属性
		if (_tcscmp(m_RoadData[i].GH, L"") == 0 || m_RoadData[i].isZongduanmian != 1)
		{
			m_RoadData[i].isZongduanmian = 0;
			m_RoadData[i].m_BPDArray.clear();
			_tcscpy(m_RoadData[i].GH, L"");
		}

		CheckRDBX(m_RoadData[i].JDARRAY, 1); // 检测并修正道路中线数据
		int iii = CheckZiJiao(m_RoadData[i].JDARRAY); // 自相交返回交点号，闭合返回终点序号，否则返回-1
		if (iii == m_RoadData[i].JDARRAY.size() - 1)//闭合,更新轮换交点
		{
			Cal_xianyuan(m_RoadData[i]);
			xlpoint PZ;
			for (int k = 0; k < (int)m_RoadData[i].m_ChaiChuArray.size(); k++)
			{
				m_RoadData[i].m_ChaiChuArray[k].CCPTArray.resize(2);
				TrsCmltoNE(m_RoadData[i].m_ChaiChuArray[k].StartFDCml, PZ, m_RoadData[i]);
				m_RoadData[i].m_ChaiChuArray[k].CCPTArray[0].Init(PZ.y, PZ.x, 0);
				TrsCmltoNE(m_RoadData[i].m_ChaiChuArray[k].EndFDCml, PZ, m_RoadData[i]);
				m_RoadData[i].m_ChaiChuArray[k].CCPTArray[1].Init(PZ.y, PZ.x, 0);
			}

			JDdata JDCenter;
			InitJDdata(JDCenter);
			JDCenter = m_RoadData[i].JDARRAY[0];
			JDCenter.x = m_RoadData[i].JDARRAY[0].x + (m_RoadData[i].JDARRAY[1].x - m_RoadData[i].JDARRAY[0].x) / 2.0;
			JDCenter.y = m_RoadData[i].JDARRAY[0].y + (m_RoadData[i].JDARRAY[1].y - m_RoadData[i].JDARRAY[0].y) / 2.0;
			Road Road1;
			Road1 = m_RoadData[i];
			Road1.JDARRAY[0] = JDCenter;
			Road1.JDARRAY[(int)Road1.JDARRAY.size() - 1].kuandu_left = JDCenter.kuandu_left;
			Road1.JDARRAY[(int)Road1.JDARRAY.size() - 1].kuandu_right = JDCenter.kuandu_right;
			Road1.JDARRAY.push_back(JDCenter);
			DLLength[i].push_back(Road1.DLBiaoHao);

			Cal_xianyuan(Road1);
			for (int k = 0; k < (int)Road1.m_ChaiChuArray.size(); k++)
			{
				TrsNEtoCml(Road1, Road1.m_ChaiChuArray[k].CCPTArray[0].y, Road1.m_ChaiChuArray[k].CCPTArray[0].x, Road1.m_ChaiChuArray[k].StartFDCml);
				TrsNEtoCml(Road1, Road1.m_ChaiChuArray[k].CCPTArray[1].y, Road1.m_ChaiChuArray[k].CCPTArray[1].x, Road1.m_ChaiChuArray[k].EndFDCml);

				if (Road1.m_ChaiChuArray[k].StartFDCml > Road1.m_ChaiChuArray[k].EndFDCml)
				{
					double cmltmp;
					cmltmp = Road1.m_ChaiChuArray[k].StartFDCml;
					Road1.m_ChaiChuArray[k].StartFDCml = Road1.m_ChaiChuArray[k].EndFDCml;
					Road1.m_ChaiChuArray[k].EndFDCml = cmltmp;
				}
			}
			m_RoadDataCheck.push_back(Road1);
		}
		else
		{
			m_RoadDataCheck.push_back(m_RoadData[i]);
			DLLength[i].push_back(m_RoadData[i].DLBiaoHao);
		}
		m_RoadData[i].M_num = (int)m_RoadData[i].JDARRAY.size();
	}
	//绘制路中线
	for (int i = 0; i < (int)m_RoadDataCheck.size(); i++)
	{
		m_RoadDataCheck[i].M_num = (int)m_RoadDataCheck[i].JDARRAY.size();
		Cal_xianyuan(m_RoadDataCheck[i]);
		LuMianHou = (m_RoadDataCheck[i].lumian[0].hd + m_RoadDataCheck[i].lumian[1].hd + m_RoadDataCheck[i].lumian[2].hd + m_RoadDataCheck[i].lumian[3].hd + m_RoadDataCheck[i].lumian[4].hd) * 0.01;
		if (m_RoadDataCheck[i].isshowZX == 1)
			Draw_xianyuan(m_RoadDataCheck[i], L"中线");
	}

	//判别每条路之间的相交关系，求出各交点坐标、相交关系、相应里程
	RD_QiuJiao(m_RoadDataCheck);
	AllPoints.clear();
	LinearPoints.clear();
	CurvesPoints.clear();

	//绘制路网
	GENE_RD_Net_BX(m_RoadDataCheck, JDdataOutFinally);
	JDdataOutFinally_DRAW.clear();
	DRAW_RD_Net_BX(JDdataOutFinally, JDdataOutFinally_DRAW);
	// 20191011 绘制完边线后消除初始化标志
	isIniRdaious = 0;
}