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

📄 cenvironment.cs

📁 公布ilrbuivbiu复合带搜ifd回复地鸥鸟个能否地偶女男的
💻 CS
📖 第 1 页 / 共 3 页
字号:
				}
			}		

			if (0 == nCount)
				bVisible = false;

			return bVisible;
		}

		/////////////////////////////////////////////////////////////////// 
		/// 功能:设置图层是否可见
		/// 参数:
		/// 返回值:
		/// ///////////////////////////////////////////////////////////////
		public void SetLayerVisible(int disp, bool bVisible, double dScale)
		{
			int  nType = 2;
			string szSubType = "";

			switch ((MapDisp)disp)
			{
				case MapDisp.MO_ALL:
					nType = 1;
					break;
				case MapDisp.MO_HOSPITAL:
					szSubType = "医院";
					break;
				case MapDisp.MO_SCHOOL:
					szSubType = "教育";
					break;
				case MapDisp.MO_SHOP:
					szSubType = "零售";
					break;
				case MapDisp.MO_TOUR:
					szSubType = "旅游";
					break;
				case MapDisp.MO_GAS:
					break;
				case MapDisp.MO_HOTEL: 
					szSubType = "住宿";
					break;
				case MapDisp.MO_LIBRAY:
					szSubType = "图书馆";
					nType = 3;
					break;
				case MapDisp.MO_MOVIE:
					szSubType = "影剧院、音乐厅";
					nType = 3;
					break;
				case MapDisp.MO_POST:
					szSubType = "邮政";
					break;
				case MapDisp.MO_RESTAURANT:
					szSubType = "餐饮";
					break;
				case MapDisp.MO_WS:
					szSubType = "厕所";
					break;
				case MapDisp.MO_STATION:
					szSubType = "站点";
					nType = 4;
					break;
			}

			for (int i = 0; i < this.m_nLayerNum; i ++)
			{
				if (m_layerInfos[i].bCanControl) 
				{
					switch (nType)
					{
						case 1:
							if (!bVisible)
							{
								m_layerInfos[i].bVisible = bVisible;
								m_layerInfos[i].layer.Visible =  m_layerInfos[i].bVisible;
							}
							else
							{
								m_layerInfos[i].bVisible = bVisible;

								if (m_layerInfos[i].dScale > dScale)
									m_layerInfos[i].layer.Visible =  m_layerInfos[i].bVisible;
							}
							break;
						case 2:
							if (szSubType == m_layerInfos[i].szSubType)
							{
								if (!bVisible)
								{
									m_layerInfos[i].bVisible = bVisible;
									m_layerInfos[i].layer.Visible =  m_layerInfos[i].bVisible;
								}
								else
								{
									m_layerInfos[i].bVisible = bVisible;

									if (m_layerInfos[i].dScale > dScale)
										m_layerInfos[i].layer.Visible =  m_layerInfos[i].bVisible;
								}
							}
							break;
						case 3:
							if (szSubType == m_layerInfos[i].szSubType2)
							{
								if (!bVisible)
								{
									m_layerInfos[i].bVisible = bVisible;
									m_layerInfos[i].layer.Visible =  m_layerInfos[i].bVisible;
								}
								else
								{
									m_layerInfos[i].bVisible = bVisible;

									if (m_layerInfos[i].dScale > dScale)
										m_layerInfos[i].layer.Visible =  m_layerInfos[i].bVisible;
								}
							}
							break;
						case 4:
							if (szSubType == m_layerInfos[i].szSubType3)
							{
								if (!bVisible)
								{
									m_layerInfos[i].bVisible = bVisible;
									m_layerInfos[i].layer.Visible =  m_layerInfos[i].bVisible;
								}
								else
								{
									m_layerInfos[i].bVisible = bVisible;

									if (m_layerInfos[i].dScale > dScale)
										m_layerInfos[i].layer.Visible =  m_layerInfos[i].bVisible;
								}
							}
							break;
					}
				}
			}
		}

		private void SubGussFs(ref double X,ref double Y,double B,double L,int nCenterLongi)
		{
			//高斯投影分带
			int nzonenum;
			if(nCenterLongi==0)
			{
				nzonenum = (int)L/6+1;
				nCenterLongi = nzonenum*6-3;
			}
			else
				nzonenum = (int)nCenterLongi/6+1;

			//以弧度为单位的经纬度数值
			double rB = B/180*3.1415926;
			double rL = (L-nCenterLongi)/180*3.1415926;		//同时计算了中央经线
			//1980坐标系参数
			const double a = 6378245.00;		//长轴
			const double b = 6356863.50;		//短轴
			//			const double alpha = 0.0033523299;	//扁率
			double sqre1 = (a*a-b*b)/(a*a);		//第一偏心率平方
			//			double sqre2 = (a*a-b*b)/(b*b);		//第二偏心率平方
			//B:纬度
			//L:精度
			//子午圈曲率半径
			double sinb = Math.Sin(rB);
			double cosb = Math.Cos(rB);
			double M = a*(1-sqre1)/(1-sqre1*sinb*sinb)/Math.Sqrt(1-sqre1*sinb*sinb);
			//卯酉圈曲率半径
			double N = a/Math.Sqrt(1-sqre1*sinb*sinb);
			double sqrita = N/M-1;
			
			//该纬度点到赤道的子午线弧长
			double s = a*(1-sqre1)*(1.00505117739*rB-0.00506237764/2*Math.Sin(2*rB)+
				0.0000106245/4*Math.Sin(4*rB)-0.00000002081/6*Math.Sin(6*rB));

			double tanb = Math.Tan(rB);
			X = s+rL*rL*N/2*sinb*cosb+rL*rL*rL*rL*N/24*sinb*cosb*cosb*cosb*(5-tanb*tanb+9*sqrita*sqrita+4*sqrita);
			Y = rL*N*cosb+rL*rL*rL*N/6*cosb*cosb*cosb*(1-tanb*tanb+sqrita)+
				rL*rL*rL*rL*rL*N/120*cosb*cosb*cosb*cosb*cosb*(5-18*tanb*tanb+tanb*tanb*tanb*tanb);
			Y = Y+500000+nzonenum*1.0e+6;
		}

		private void SubGussFs(double X,double Y,double L0,ref double B,ref double L)
		{   
			double p=57.29577951472;
			const double a=6.378245000e+06;
			const double e2=0.00669342162297;
			const double e12=0.00673852541468;
			const double c0=0.157046064172e-06;
			const double c1=0.005051773759;
			const double c2=0.000029837302;
			const double c3=0.000000238189;

			double bf0=c0*X;
			double bf0c=Math.Cos(bf0);
			double bf0s=Math.Sin(bf0);
			double bf=bf0+bf0c*(c1*bf0s-c2*Math.Pow(bf0s,3)+c3*Math.Pow(bf0s,5));
			double bt=Math.Tan(bf);
			double bc=Math.Cos(bf);
			double bs=Math.Sin(bf);
			double bi=e12*Math.Pow(bc,2);
			double v2=1.0e+0+bi;
			double bn=a/Math.Sqrt(1.0-e2*Math.Pow(bs,2));
			double yn=Y/bn;

			/*calculate lantitude b */

			double b1=-v2*bt*Math.Pow(yn,2)/2.0;
			double b2=-(5.0+3.0*Math.Pow(bt,2)+bi-9.0*bi*Math.Pow(bt,2))*b1*Math.Pow(yn,2)/12.0;
			double b3=(61.0+90.0*Math.Pow(bt,2)+45.0*Math.Pow(bt,4))*b1*Math.Pow(yn,4)/360.0;
			B = bf+b1+b2+b3;
			B = B * p;

			/* calculate the longitude l */

			double l1=yn/bc;
			double l2=-(1.0+2.0*Math.Pow(bt,2)+bi)*l1*Math.Pow(yn,2)/6.0;
			double l3=(5.0+28.0*Math.Pow(bt,2)+24.0*Math.Pow(bt,4)+6.0*bi
				+8.0*bi*Math.Pow(bt,2))*l1*Math.Pow(yn,4)/120.0;
			L=l1+l2+l3;
			L=L * p;

			L=L + L0;
			if(L > 360.0)
				L=L - 360.0;
		}

		private void CalGuassToLB(double dX, double dY, ref double dLongitude, ref double dLatitude) 
		{
			// TODO: Add your dispatch handler code here
			double L0;
			int nZoonNum;
						
			nZoonNum = (int)(dY/(1.0E+6));
			L0 = nZoonNum * 6-3;
			
			dY = dY - nZoonNum*1.0E+6;
			SubGussFs(dX,dY-500000,L0,ref dLatitude,ref dLongitude);
			dLongitude = dLongitude + nZoonNum*6 - 3 ;
		}

		private void CalGuassFromLB(double dLongitude, double dLatitude, ref double dX, ref double dY, long nCenterL) 
		{
			// TODO: Add your dispatch handler code here
			int CenterL = (int)nCenterL;

			SubGussFs(ref dX,ref dY,dLatitude,dLongitude,CenterL);

			nCenterL = (long)CenterL;
		}

		private double CalcLenght(MPoint[] pt,int nSize)
		{
			double dLength = 0;
			double x1=0,x2=0,y1=0,y2=0;
			int nCenterL = ((int)(pt[0].x)/6+1)*6-3; 

			for(int i=0;i<nSize-1;i++)
			{
				CalGuassFromLB(pt[i].x, pt[i].y, ref x1, ref y1, nCenterL);
				CalGuassFromLB(pt[i+1].x, pt[i+1].y, ref x2, ref y2, nCenterL);
				dLength += Math.Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
			}

			return dLength;
		}	

		private double CalcArea(MPoint[] pt,int nSize)
		{
			double dArea = 0;
			double x1=0,x2=0,y1=0,y2=0;
			int nCenterL = ((int)(pt[0].x)/6+1)*6-3; 

			for(int i=0;i<nSize-1;i++)
			{
				CalGuassFromLB(pt[i].x, pt[i].y, ref x1, ref y1, nCenterL);
				CalGuassFromLB(pt[i+1].x, pt[i+1].y, ref x2, ref y2, nCenterL);
				dArea += (x2-x1)*(y1+y2)/2;
			}

			if (dArea < 0)
				dArea = 0 - dArea; 
			return dArea;
		}

		public double GetLineLength(MapObjects2.Line line)
		{
			MPoint[]				pt;
			int						nPtCount;
			//			double					dLength;
			MapObjects2.Points	pts;

			pts = (MapObjects2.Points)line.Parts.Item(0);
			nPtCount = pts.Count;
 
			if (nPtCount < 2)
				return 0.0;

			pt = new MPoint[nPtCount];
 
			for (int i = 0; i < nPtCount; i ++)
			{
				MapObjects2.Point point = (MapObjects2.Point)pts.Item(i);
				pt[i] = new MPoint(); 
				pt[i].x = point.X;
				pt[i].y = point.Y; 
			}

			return CalcLenght(pt, nPtCount);

		}

		public double GetPolygonLength(MapObjects2.Polygon poly)
		{
			MPoint[]				pt;
			int						nPtCount;			
			MapObjects2.Points	pts;

			pts = (MapObjects2.Points)poly.Parts.Item(0);
			nPtCount = pts.Count;
 
			if (nPtCount < 2)
				return 0.0;

			pt = new MPoint[nPtCount+1];
 
			for (int i = 0; i < nPtCount; i ++)
			{
				MapObjects2.Point point = (MapObjects2.Point)pts.Item(i);
				pt[i] = new MPoint(); 
				pt[i].x = point.X;
				pt[i].y = point.Y; 
			}

			pt[nPtCount] = new MPoint(); 
			pt[nPtCount].x = pt[0].x;
			pt[nPtCount].y = pt[0].y;

			return CalcLenght(pt, nPtCount+1);
		}

		public double GetPolygonArea(MapObjects2.Polygon poly)
		{

			MPoint[]				pt;
			int						nPtCount;
			MapObjects2.Points	pts;

			pts = (MapObjects2.Points)poly.Parts.Item(0);
			nPtCount = pts.Count;
 
			if (nPtCount < 3)
				return 0.0;

			pt = new MPoint[nPtCount+1];
 
			for (int i = 0; i < nPtCount; i ++)
			{
				MapObjects2.Point point = (MapObjects2.Point)pts.Item(i);
				pt[i] = new MPoint(); 
				pt[i].x = point.X;
				pt[i].y = point.Y; 
			}
			pt[nPtCount] = new MPoint(); 
			pt[nPtCount].x = pt[0].x;
			pt[nPtCount].y = pt[0].y;

			return CalcArea(pt, nPtCount+1);
		}

		private void CreatePolygon(double dCenterX,double dCenterY,double dR,ref MPoint[] pPoints,ref int nSize)
		{
			long nCenterL = ((long)(dCenterX)/6+1)*6-3; 
			double ncx=0.0,ncy=0.0;
			CalGuassFromLB(dCenterX, dCenterY, ref ncx, ref ncy, nCenterL);

			const int nPointNumber = 20;
			const double PI = 3.1415926;
			pPoints = new MPoint[nPointNumber+1];

			double x1,y1;
			double x2=0.0,y2=0.0;
			for(int i=0;i<nPointNumber;i++)
			{
				x1 = dCenterX + dR * Math.Cos(2*PI/nPointNumber*i);
				y1 = dCenterY + dR * Math.Sin(2*PI/nPointNumber*i);
				CalGuassToLB(x1, y1, ref x2, ref y2);
				pPoints[i].x = x2;
				pPoints[i].y = y2;
			}
			pPoints[nPointNumber] = pPoints[0];

			nSize = nPointNumber + 1;
		}

		public void CreatePolygon(MapObjects2.Polygon poly, double x, double y, double dLength)
		{
			MPoint[]	pts = null;
			int			nSize = 0;

			CreatePolygon(x,y,dLength,ref pts,ref nSize);

			poly.Parts.Count = 1;
			MapObjects2.Points points = (MapObjects2.Points)poly.Parts.Item(0);
			points.Count = nSize;

			for (int i = 0; i < nSize; i ++)
			{
				points.Item(i).X = pts[i].x;
				points.Item(i).Y = pts[i].y;
			}
		}

		public long SearchByDistance(double dX, double dY,double dDistance, System.Windows.Forms.ListBox listBox)
		{
			bool bClosest = false;

			if (dDistance <= 0.0)
			{
				bClosest = true;
				dDistance = 1000000000;
			}

			listBox.DataSource = null;
			listBox.Items.Clear();

			for (int i = 0; i < this.m_nLayerNum; i ++)
			{
				if (this.m_layerInfos[i].bSelected
					&& this.m_layerInfos[i].layer.shapeType ==  MapObjects2.ShapeTypeConstants.moShapeTypePoint)
				{
					MapObjects2.Recordset rs = null;

					string					szPlaceName = "";
					double					dMinDist = -1.0;
					double					dDist = 0.0;

					rs = this.m_layerInfos[i].layer.Records;
 	
					if (rs != null)
					{
						rs.MoveFirst();
 
						while (!rs.EOF)
						{
							MPoint[] pts=new MPoint[2];
 
							MapObjects2.Point pt;
					
							pt = (MapObjects2.Point)rs.Fields.Item("shape").Value;
							
							pts[0] = new MPoint();
							pts[0].x = dX;
							pts[0].y = dY;
							pts[1] = new MPoint();
							pts[1].x = pt.X ;
							pts[1].y = pt.Y;
							
							dDist = this.CalcLenght(pts, 2);
							if (dDistance >= this.CalcLenght(pts, 2))
							{
								if (bClosest)
								{
									//查找最近
									string szTemp = rs.Fields.Item("名称").Value.ToString();

									if (szTemp == "")
										continue;

									if (((dMinDist < 0) || (dMinDist > dDist)) && (!this.m_szPlaceName.Equals(szTemp)))
									{
										dMinDist = dDist;
										szPlaceName = szTemp;
									}
								}
								else
								{
									listBox.Items.Add(rs.Fields.Item("名称").Value.ToString()); 
							
								}
							}

							rs.MoveNext(); 
						}

						if (bClosest && (szPlaceName != "") && (!this.m_szPlaceName.Equals(szPlaceName)) )
							listBox.Items.Add(szPlaceName); 

					}
				}
				else
				{
					this.m_layerInfos[i].rsSel = null;
				}
			}

			return listBox.Items.Count;  

		}

		public bool IsImage(string szName)
		{
			string strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_szDBName + 
				";Persist Security Info=False";		

⌨️ 快捷键说明

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