public AbsTFClass() { //默认为西安80 this.m_EllipseParameter = new Xian80_EllipseParameter(); //还可以使用ISpatialReference this.Datum = EnumProjectionDatum.Xian80; }
/// <summary> /// 大地坐标转换为高斯投影坐标 正解公式 /// WGC84->高斯投影 /// Description: ///' 大地坐标转换为高斯投影坐标 ///' Parameters: ///' LX,BX - 输入,经纬度坐标 ///' x,y - 输出,高斯投影坐标(大数) ///' nearright - 输入,L是相邻两带的分界线时的取法,0 - 左带(小),1 - 右带(大) ///' ProjectionType - 输入,1 - 80坐标系,0 - 54坐标系 ///' StripType - 输入,1 - 6度分带,0 - 3度分带 /// 当只有一个已知控制点时,根据平移参数调整东伪偏移、北纬偏移值实现WGS84到北京54的转换 /// 东伪偏移=东伪偏移值=tpMainStrip * 1000000+500000.0 /// 北纬偏移值=0; /// </summary> /// <param name="BX">大地纬度B</param> /// <param name="LX">大地经度L</param> /// <param name="x">高斯投影X</param> /// <param name="y">高斯投影Y</param> /// <param name="nearright">输入,L是相邻两带的分界线时的取法,0 - 左带(小),1 - 右带(大)</param> /// <param name="ProjectionType"> 输入,1 - 80坐标系,0 - 54坐标系</param> /// <param name="StripType"> 输入,1 - 6度分带,0 - 3度分带</param> /// <param name="IsBigNumber">输入, 是大数坐标吗?</param> public void GetXYFromBL(decimal BX, decimal LX, ref decimal x, ref decimal y, long nearright, EnumProjectionDatum ProjectionType, EnumStrip StripType, bool IsBigNumber) { decimal t = 0; decimal B = 0; decimal L = 0; decimal x0 = 0; decimal y2 = 0; decimal E12 = 0; decimal c0 = 0; decimal n1 = 0; decimal m = 0; decimal temp1 = 0, temp2 = 0; decimal LX1 = 0; decimal fc_pi = 3.14159265358979M; //PI值 B = (BX / 180) * fc_pi; //转为弧度值bx*(PI/180) L = (LX / 180) * fc_pi; //转为弧度值lx*(PI/180) //求带内中央子午线经度 LX1 = GetLocalLongitude(LX, nearright, StripType); m = Maths.Cos(B) * fc_pi * LX1 / 180.0M; t = Maths.Tan(B); switch (ProjectionType) { case EnumProjectionDatum.Xian80: //80坐标 c0 = 6399596.65198801M; E12 = 0.0067395018195M; x0 = 111133.0047M * BX - (32009.8575M * Maths.Sin(B) + 133.9978M * (Maths.Pow(Maths.Sin(B), 3)) + 0.6975M * (Maths.Pow(Maths.Sin(B), 5)) + 0.0039M * (Maths.Pow(Maths.Sin(B), 7))) * Maths.Cos(B); break; case EnumProjectionDatum.Bejing54: //54坐标 c0 = 6399698.90178271M; E12 = 0.00673852541468M; x0 = 111134.8611M * BX - (32005.7798M * Maths.Sin(B) + 133.9614M * (Maths.Pow(Maths.Sin(B), 3)) + 0.6972M * (Maths.Pow(Maths.Sin(B), 5)) + 0.0039M * (Maths.Pow(Maths.Sin(B), 7))) * Maths.Cos(B); break; default: //其它暂为空 break; } y2 = E12 * (Maths.Pow(Maths.Cos(B), 2)); n1 = c0 / Maths.Sqrt(1.0M + y2); temp1 = (Maths.Pow(m, 2)) / 2.0M + (5.0M - (Maths.Pow(t, 2)) + 9.0M * y2 + 4 * (Maths.Pow(y2, 2))) * (Maths.Pow(m, 4)) / 24.0M + (61.0M - 58.0M * (Maths.Pow(t, 2)) + (Maths.Pow(t, 4))) * (Maths.Pow(m, 6)) / 720.0M; temp2 = m + (1.0M - (Maths.Pow(t, 2)) + y2) * (Maths.Pow(m, 3)) / 6.0M + (5.0M - 18.0M * (Maths.Pow(t, 2)) + (Maths.Pow(t, 4)) + 14.0M * y2 - 58.0M * y2 * (Maths.Pow(t, 2))) * (Maths.Pow(m, 5)) / 120.0M; x = x0 + n1 * t * temp1; y = n1 * temp2 + 500000.0M; //与中央经线的距离m //500000.0表示平移了500公里距离 目的是把负数坐标转为正数好处理 //主带数值(整数) decimal tpMainStrip = 0; //主带数值 switch (StripType) { case EnumStrip.Strip3: tpMainStrip = (int)Math.Truncate(LX / 3) + 1; break; case EnumStrip.Strip6: tpMainStrip = (int)Math.Truncate(LX / 6) + 1; break; default: //则自动计算 ,默认为3度带 tpMainStrip = (int)Math.Truncate(LX / 3) + 1; break; } //转为大数坐标y=带数*1000000+与中央经线的距离m //东伪偏移值=tpMainStrip * 1000000+500000.0 if (IsBigNumber == true) //转为高斯投影是大数投影吗?即Zone 35带数 (小数投影为CM_105E) { y = y + tpMainStrip * 1000000; } }
/// <summary> /// 高斯投影坐标转换为大地坐标 反解公式 /// Parameters: /// x,y - 输入,高斯投影坐标(大数) /// LX,BX - 输出,经纬度坐标 /// nearright - 输入,L是相邻两带的分界线时的取法,0 - 左带(小),1 - 右带(大) /// ProjectionType - 输入,1 - 80坐标系,0 - 54坐标系 /// StripType - 输入,1 - 6度分带,0 - 3度分带 /// L0 - 输入, 3度或6度分带的中央子午线 单位为度 /// </summary> /// <param name="x"> 输入,高斯投影X坐标</param> /// <param name="y"> 输入,高斯投影Y坐标(大数)</param> /// <param name="BX">输入,纬度坐标</param> /// <param name="LX">输入,经度坐标</param> /// <param name="nearright">输入,L是相邻两带的分界线时的取法,0 - 左带(小),1 - 右带(大)</param> /// <param name="ProjectionType">输入,1 - 80坐标系,0 - 54坐标系</param> /// <param name="StripType">输入,1 - 6度分带,0 - 3度分带</param> /// <param name="L0">输入, 3度或6度分带的中央子午线 单位为度</param> /// <param name="IsBigNumber">输入, 是大数坐标吗?</param> /// <returns></returns> public bool GetBLFromXY(decimal x, decimal y, ref decimal BX, ref decimal LX, int nearright, EnumProjectionDatum ProjectionType, EnumStrip StripType, decimal L0, bool IsBigNumber) { decimal a0 = 0; decimal b0 = 0; decimal c0 = 0; decimal E12 = 0; decimal bf0 = 0; decimal bf = 0; decimal tf = 0; decimal yf2 = 0; decimal n = 0; decimal b1 = 0; decimal l1 = 0; decimal temp1 = 0; long iStripNum = 0; decimal fc_pi = 3.14159265358979M; //要素的Y坐标中是否含有大地坐标的大数? switch (StripType) { case EnumStrip.Strip6: iStripNum = (long)Math.Round(L0 / 6); break; case EnumStrip.Strip3: iStripNum = (long)Math.Round(L0 / 3); break; } //认为高斯投影Y坐标为大数(y=带数*1000000 + 与中央经线的距离m //要素的Y坐标包含有大地坐标吗?y=y+带数*1000000 + 与中央经线的距离m(500公里) if (IsBigNumber == true) { y = y - iStripNum * 1000000; } x = x / 1000000; y = y - 500000; switch (ProjectionType) { case EnumProjectionDatum.Bejing54: //北京54 a0 = 6378245M; //长半轴 a(米) b0 = 6356863.01877305M; //短半轴b(米) c0 = 6399698.90178271M; E12 = 0.0067385254147M; bf0 = 27.11115372595M + 9.02468257083M * (x - 3) - 0.00579740442M * (Maths.Pow((x - 3), 2)) - 0.00043532572M * (Maths.Pow((x - 3), 3)) + 0.00004857285M * (Maths.Pow((x - 3), 4)) + 0.00000215727M * (Maths.Pow((x - 3), 5)) - 0.00000019399M * (Maths.Pow((x - 3), 6)); break; case EnumProjectionDatum.Xian80: //西安80 a0 = 6378140M; //长半轴 a(米) b0 = 6356755.28815753M; //短半轴b(米) c0 = 6399596.65198801M; E12 = 0.0067395018195M; bf0 = 27.11162289465M + 9.02483657729M * (x - 3) - 0.00579850656M * (Maths.Pow((x - 3), 2)) - 0.00043540029M * (Maths.Pow((x - 3), 3)) + 0.00004858357M * (Maths.Pow((x - 3), 4)) + 0.00000215769M * (Maths.Pow((x - 3), 5)) - 0.00000019404M * (Maths.Pow((x - 3), 6)); break; default: //暂为空 break; } bf = bf0 * fc_pi / 180; tf = Maths.Tan(bf); yf2 = E12 * (Maths.Pow(Maths.Cos(bf), 2)); n = y * Maths.Sqrt(1 + yf2) / c0; temp1 = 90.0M * (Maths.Pow(n, 2)) - 7.5M * (5.0M + 3.0M * (Maths.Pow(tf, 2)) + yf2 - 9.0M * yf2 * (Maths.Pow(tf, 2))) * (Maths.Pow(n, 4)) + 0.25M * (61.0M + 90.0M * (Maths.Pow(tf, 2)) + 45.0M * (Maths.Pow(tf, 4))) * (Maths.Pow(n, 6)); b1 = bf0 - (1.0M + yf2) * tf * temp1 / fc_pi; l1 = (180.0M * n - 30.0M * (1.0M + 2.0M * (Maths.Pow(tf, 2)) + yf2) * (Maths.Pow(n, 3)) + 1.5M * (5.0M + 28.0M * (Maths.Pow(tf, 2)) + 24.0M * (Maths.Pow(tf, 4))) * (Maths.Pow(n, 5))) / fc_pi / Maths.Cos(bf); l1 = l1 + L0; if (l1 < 0.0M) { l1 = l1 + 360.0M; } if (l1 >= 360.0M) { l1 = l1 - 360.0M; } BX = b1; LX = l1; return(true); }
public AnyTrapeziaEllipseAreaCompute() { //默认为西安80 this.m_EllipseParameter = new Xian80_EllipseParameter(); //还可以使用ISpatialReference this.Datum = EnumProjectionDatum.Xian80; }
/// <summary> /// IGeometry对象投影转换 /// </summary> /// <param name="sourceGeometry">源对象</param> /// <param name="SourceProjection">源投影</param> /// <param name="SourceStrip">源分带</param> /// <param name="L0">源中央子午线</param> /// <param name="IsBigNumber_Source">源是/否是大数</param> /// <param name="ObjectProjection">目标投影</param> /// <param name="ObjectStrip">目标分带</param> /// <param name="IsBigNumber_Object">目标是/否是大数</param> /// <param name="ObjectSpatialReference">目标空间参考接口</param> /// <returns>返加投影转换后对象IGeometry</returns> public IGeometry getObjectGeometry(IGeometry sourceGeometry, EnumProjectionDatum SourceProjection, EnumStrip SourceStrip, double L0, bool IsBigNumber_Source, EnumProjectionDatum ObjectProjection, EnumStrip ObjectStrip, bool IsBigNumber_Object, ISpatialReference ObjectSpatialReference) { IGeometry ObjGeometry = null; IPoint p = null; if (sourceGeometry is IPoint) { //点 #region Point double x = 0; double y = 0; double B = 0; double L = 0; x = (sourceGeometry as IPoint).X; y = (sourceGeometry as IPoint).Y; this.GetBLFromXY(y, x, ref B, ref L, 0, SourceProjection, SourceStrip, L0, IsBigNumber_Source); this.GetXYFromBL(B, L, ref x, ref y, 0, ObjectProjection, ObjectStrip, IsBigNumber_Object); IPoint objP = new PointClass(); objP.X = y; objP.Y = x; //投影到目标点对象 objP.SpatialReference = ObjectSpatialReference; ObjGeometry = objP as IGeometry; #endregion } else if (sourceGeometry is IPolyline) { //线 #region polyline IPolyline objPolyline = new PolylineClass(); IPointCollection objPc = objPolyline as IPointCollection; double x = 0; double y = 0; double B = 0; double L = 0; IPointCollection pcol = sourceGeometry as IPointCollection; object miss = Type.Missing; for (int j = 0; j < pcol.PointCount; j++) { p = pcol.get_Point(j); x = p.X; y = p.Y; this.GetBLFromXY(y, x, ref B, ref L, 0, SourceProjection, SourceStrip, L0, IsBigNumber_Source); this.GetXYFromBL(B, L, ref x, ref y, 0, ObjectProjection, ObjectStrip, IsBigNumber_Object); IPoint objPoint = new PointClass(); objPoint.X = y; objPoint.Y = x; objPoint.SpatialReference = ObjectSpatialReference; objPc.AddPoint(objPoint, ref miss, ref miss); } objPolyline.SpatialReference = ObjectSpatialReference; ObjGeometry = objPolyline as IGeometry; #endregion } else if (sourceGeometry is IPolygon) { //面 /注记面 #region polygon IPolygon objPolygon = new PolygonClass(); IGeometryCollection objPc = objPolygon as IGeometryCollection; double x = 0; double y = 0; double B = 0; double L = 0; IGeometryCollection GeoCol = sourceGeometry as IGeometryCollection; object miss = Type.Missing; IGeometry tpGeo = null; IPointCollection pcol = null; IRing newRing = null; IPointCollection newRingPointColl = null; for (int j = 0; j < GeoCol.GeometryCount; j++) { tpGeo = GeoCol.get_Geometry(j); //面内环ring(内/外环) pcol = tpGeo as IPointCollection; newRing = new RingClass(); newRingPointColl = newRing as IPointCollection; for (int k = 0; k < pcol.PointCount; k++) { p = pcol.get_Point(k); x = p.X; y = p.Y; this.GetBLFromXY(y, x, ref B, ref L, 0, SourceProjection, SourceStrip, L0, IsBigNumber_Source); this.GetXYFromBL(B, L, ref x, ref y, 0, ObjectProjection, ObjectStrip, IsBigNumber_Object); IPoint objPoint = new PointClass(); objPoint.X = y; objPoint.Y = x; objPoint.SpatialReference = ObjectSpatialReference; newRingPointColl.AddPoint(objPoint, ref miss, ref miss); } newRing.SpatialReference = ObjectSpatialReference; objPc.AddGeometry(newRing as IGeometry, ref miss, ref miss); } objPolygon.SpatialReference = ObjectSpatialReference; ObjGeometry = objPolygon as IGeometry; #endregion } else if (sourceGeometry is IGeometryBag) { //包 #region GeometryBag GeometryBagClass objgeobag = new GeometryBagClass(); IGeometryBag geoBag = sourceGeometry as IGeometryBag; IGeometryCollection geoColl = geoBag as IGeometryCollection; IGeometry geo = null; IGeometry objgeo = null; object miss = Type.Missing; IGeometryCollection objgeobagColl = objgeobag as IGeometryCollection; for (int i = 0; i < geoColl.GeometryCount; i++) { geo = geoColl.get_Geometry(i); objgeo = this.getObjectGeometry(geo, SourceProjection, SourceStrip, L0, IsBigNumber_Source, ObjectProjection, ObjectStrip, IsBigNumber_Object, ObjectSpatialReference); objgeo.SpatialReference = ObjectSpatialReference; objgeobagColl.AddGeometry(objgeo, ref miss, ref miss); } objgeobag.SpatialReference = ObjectSpatialReference; ObjGeometry = objgeobag as IGeometry; #endregion } else if (sourceGeometry is IMultipoint) { //多点 #region Multipoint MultipointClass objMuliPoint = new MultipointClass(); IPointCollection objPc = objMuliPoint as IPointCollection; double x = 0; double y = 0; double B = 0; double L = 0; IPointCollection pcol = sourceGeometry as IPointCollection; object miss = Type.Missing; for (int j = 0; j < pcol.PointCount; j++) { p = pcol.get_Point(j); x = p.X; y = p.Y; this.GetBLFromXY(y, x, ref B, ref L, 0, SourceProjection, SourceStrip, L0, IsBigNumber_Source); this.GetXYFromBL(B, L, ref x, ref y, 0, ObjectProjection, ObjectStrip, IsBigNumber_Object); IPoint objPoint = new PointClass(); objPoint.X = y; objPoint.Y = x; objPoint.SpatialReference = ObjectSpatialReference; objPc.AddPoint(objPoint, ref miss, ref miss); } objMuliPoint.SpatialReference = ObjectSpatialReference; ObjGeometry = objMuliPoint as IGeometry; #endregion } else { //暂未写 ObjGeometry = null; } return(ObjGeometry); }
private void ShapeFileProjectionConvert(ISpatialReference SourceSpatialReference, ISpatialReference ObjectSpatialReference, IFeatureClass SourceFeatureClass, IFeatureClass ObjectFeatureClass) { int SourceFactoryCode = SourceSpatialReference.FactoryCode; int ObjectFactoryCode = ObjectSpatialReference.FactoryCode; //if (SourceFactoryCode == 0 || ObjectFactoryCode == 0) //{ // MessageBox.Show("源文件是自定义的投影坐标系统,这里暂不进行转换", "投影转换提示"); // return; //} EnumProjectionDatum SourceProjection = EnumProjectionDatum.Bejing54; //默认 EnumStrip SourceStrip = EnumStrip.Strip3; //默认 EnumProjectionDatum ObjectProjection = EnumProjectionDatum.Xian80; //默认 EnumStrip ObjectStrip = EnumStrip.Strip3; //默认 //源中央子午线 double L0 = (SourceSpatialReference as IProjectedCoordinateSystem4GEN).GetCentralLongitude(); bool IsBigNumber_Source = true; //源文件默认是大数 bool IsBigNumber_Object = true; //目标默认是大数 //------------------------------------------------------------------------------------------ //高斯投影大数情况分析 int BJ54D3_25srid = (int)esriSRProjCS4Type.esriSRProjCS_Beijing1954_3_Degree_GK_Zone_25; int BJ54D3_45srid = (int)esriSRProjCS4Type.esriSRProjCS_Beijing1954_3_Degree_GK_Zone_45; int BJ54D6_13srid = (int)esriSRProjCSType.esriSRProjCS_Beijing1954GK_13; int BJ54D6_23srid = (int)esriSRProjCSType.esriSRProjCS_Beijing1954GK_23; int Xian80D3_25srid = (int)esriSRProjCS4Type.esriSRProjCS_Xian1980_3_Degree_GK_Zone_25; int Xian80D3_45srid = (int)esriSRProjCS4Type.esriSRProjCS_Xian1980_3_Degree_GK_Zone_45; int Xian80D6_13srid = (int)esriSRProjCS4Type.esriSRProjCS_Xian1980_GK_Zone_13; int Xian80D6_23srid = (int)esriSRProjCS4Type.esriSRProjCS_Xian1980_GK_Zone_23; //源文件分析 //BeiJing1954 3 degree if (SourceFactoryCode >= BJ54D3_25srid && SourceFactoryCode <= BJ54D3_45srid) { SourceProjection = EnumProjectionDatum.Bejing54; SourceStrip = EnumStrip.Strip3; IsBigNumber_Source = true; } //BeiJing1954 6 degree if (SourceFactoryCode >= BJ54D6_13srid && SourceFactoryCode <= BJ54D6_23srid) { SourceProjection = EnumProjectionDatum.Bejing54; SourceStrip = EnumStrip.Strip3; IsBigNumber_Source = true; } //Xian1980 3 degree if (SourceFactoryCode >= Xian80D3_25srid && SourceFactoryCode <= Xian80D3_45srid) { SourceProjection = EnumProjectionDatum.Xian80; SourceStrip = EnumStrip.Strip3; IsBigNumber_Source = true; } //Xian1980 6 degree if (SourceFactoryCode >= Xian80D6_13srid && SourceFactoryCode <= Xian80D6_23srid) { SourceProjection = EnumProjectionDatum.Xian80; SourceStrip = EnumStrip.Strip3; IsBigNumber_Source = true; } //目标文件分析 //BeiJing1954 3 degree if (ObjectFactoryCode >= BJ54D3_25srid && ObjectFactoryCode <= BJ54D3_45srid) { ObjectProjection = EnumProjectionDatum.Bejing54; ObjectStrip = EnumStrip.Strip3; IsBigNumber_Object = true; } //BeiJing1954 6 degree if (ObjectFactoryCode >= BJ54D6_13srid && ObjectFactoryCode <= BJ54D6_23srid) { ObjectProjection = EnumProjectionDatum.Bejing54; ObjectStrip = EnumStrip.Strip3; IsBigNumber_Object = true; } //Xian1980 3 degree if (ObjectFactoryCode >= Xian80D3_25srid && ObjectFactoryCode <= Xian80D3_45srid) { ObjectProjection = EnumProjectionDatum.Xian80; ObjectStrip = EnumStrip.Strip3; IsBigNumber_Object = true; } //Xian1980 6 degree if (ObjectFactoryCode >= Xian80D6_13srid && ObjectFactoryCode <= Xian80D6_23srid) { ObjectProjection = EnumProjectionDatum.Xian80; ObjectStrip = EnumStrip.Strip3; IsBigNumber_Object = true; } //------------------------------------------------------------------------------------- ////高斯投影小数情况分析 int BJ54D3_25srid_CM = (int)esriSRProjCS4Type.esriSRProjCS_Beijing1954_3_Degree_GK_CM_75E; int BJ54D3_45srid_CM = (int)esriSRProjCS4Type.esriSRProjCS_Beijing1954_3_Degree_GK_CM_135E; int BJ54D6_13srid_CM = (int)esriSRProjCSType.esriSRProjCS_Beijing1954GK_13N; int BJ54D6_23srid_CM = (int)esriSRProjCSType.esriSRProjCS_Beijing1954GK_23N; int Xian80D3_25srid_CM = (int)esriSRProjCS4Type.esriSRProjCS_Xian1980_3_Degree_GK_CM_75E; int Xian80D3_45srid_CM = (int)esriSRProjCS4Type.esriSRProjCS_Xian1980_3_Degree_GK_CM_135E; int Xian80D6_13srid_CM = (int)esriSRProjCS4Type.esriSRProjCS_Xian1980_GK_CM_75E; int Xian80D6_23srid_CM = (int)esriSRProjCS4Type.esriSRProjCS_Xian1980_GK_CM_135E; //源文件分析 //BeiJing1954 3 degree if (SourceFactoryCode >= BJ54D3_25srid_CM && SourceFactoryCode <= BJ54D3_45srid_CM) { SourceProjection = EnumProjectionDatum.Bejing54; SourceStrip = EnumStrip.Strip3; IsBigNumber_Source = false; } //BeiJing1954 6 degree if (SourceFactoryCode >= BJ54D6_13srid_CM && SourceFactoryCode <= BJ54D6_23srid_CM) { SourceProjection = EnumProjectionDatum.Bejing54; SourceStrip = EnumStrip.Strip3; IsBigNumber_Source = false; } //Xian1980 3 degree if (SourceFactoryCode >= Xian80D3_25srid_CM && SourceFactoryCode <= Xian80D3_45srid_CM) { SourceProjection = EnumProjectionDatum.Xian80; SourceStrip = EnumStrip.Strip3; IsBigNumber_Source = false; } //Xian1980 6 degree if (SourceFactoryCode >= Xian80D6_13srid_CM && SourceFactoryCode <= Xian80D6_23srid_CM) { SourceProjection = EnumProjectionDatum.Xian80; SourceStrip = EnumStrip.Strip3; IsBigNumber_Source = false; } //目标文件分析 //BeiJing1954 3 degree if (ObjectFactoryCode >= BJ54D3_25srid_CM && ObjectFactoryCode <= BJ54D3_45srid_CM) { ObjectProjection = EnumProjectionDatum.Bejing54; ObjectStrip = EnumStrip.Strip3; IsBigNumber_Object = false; } //BeiJing1954 6 degree if (ObjectFactoryCode >= BJ54D6_13srid_CM && ObjectFactoryCode <= BJ54D6_23srid_CM) { ObjectProjection = EnumProjectionDatum.Bejing54; ObjectStrip = EnumStrip.Strip3; IsBigNumber_Object = false; } //Xian1980 3 degree if (ObjectFactoryCode >= Xian80D3_25srid_CM && ObjectFactoryCode <= Xian80D3_45srid_CM) { ObjectProjection = EnumProjectionDatum.Xian80; ObjectStrip = EnumStrip.Strip3; IsBigNumber_Object = false; } //Xian1980 6 degree if (ObjectFactoryCode >= Xian80D6_13srid_CM && ObjectFactoryCode <= Xian80D6_23srid_CM) { ObjectProjection = EnumProjectionDatum.Xian80; ObjectStrip = EnumStrip.Strip3; IsBigNumber_Object = false; } //------------------------------------------------------------------------------ //KDFeatureClass sfc = new KDFeatureClass_TYPoint(SourceFeatureClass); //KDFeatureClass ofc = new KDFeatureClass_TYPoint(ObjectFeatureClass); ZhFeatureClass sfc = new ZhPointFeatureClass(SourceFeatureClass); ZhFeatureClass ofc = new ZhPointFeatureClass(ObjectFeatureClass); //KDFeature[] FeatArray = sfc.getSelectedFeaturesByQueryFilter(null); //KDFeature sfeat = null; //KDFeature ofeat = null; ZhFeature[] FeatArray = sfc.getSelectedFeaturesByQueryFilter(null); ZhFeature sfeat = null; ZhFeature ofeat = null; IGeometry geo = null; IPoint p = null; /*frmProgressBar1 pb = new frmProgressBar1(); * pb.Text = "坐标投影转换"; * pb.label1.Text = "总数:" + FeatArray.Length.ToString(); * pb.progressBar1.Maximum = FeatArray.Length + 1; * pb.progressBar1.Value = 0; * pb.Show();*/ for (int i = 0; i < FeatArray.Length; i++) { /*if (pb.progressBar1.Value < pb.progressBar1.Maximum) * { * pb.progressBar1.Value += 1; * pb.label1.Text = "第[" + pb.progressBar1.Value.ToString() + "]个/总数[" + FeatArray.Length.ToString() + "]"; * pb.Refresh(); * }*/ sfeat = FeatArray[i]; //ofeat = ofc.CreateKDFeature(); ofeat = ofc.CreateFeature(); //copy 源字段的值到目标字段中 sfeat.CopyField(ref ofeat); geo = sfeat.pFeature.ShapeCopy; //geo.Project(ObjectSpatialReference); ////坐标投影转换 IGeometry ObjGeometry = null; if (geo is IPoint) { //点 double x = 0; double y = 0; double B = 0; double L = 0; x = (geo as IPoint).X; y = (geo as IPoint).Y; this.GetBLFromXY(y, x, ref B, ref L, 0, SourceProjection, SourceStrip, L0, IsBigNumber_Source); this.GetXYFromBL(B, L, ref x, ref y, 0, ObjectProjection, ObjectStrip, IsBigNumber_Object); IPoint objP = new PointClass(); objP.X = y; objP.Y = x; objP.SpatialReference = ObjectSpatialReference; //投影到目标点对象 ObjGeometry = objP as IGeometry; } else if (geo is IPolyline) { //线 IPolyline objPolyline = new PolylineClass(); IPointCollection objPc = objPolyline as IPointCollection; double x = 0; double y = 0; double B = 0; double L = 0; IPointCollection pcol = geo as IPointCollection; object miss = Type.Missing; for (int j = 0; j < pcol.PointCount; j++) { p = pcol.get_Point(j); x = p.X; y = p.Y; this.GetBLFromXY(y, x, ref B, ref L, 0, SourceProjection, SourceStrip, L0, IsBigNumber_Source); this.GetXYFromBL(B, L, ref x, ref y, 0, ObjectProjection, ObjectStrip, IsBigNumber_Object); IPoint objPoint = new PointClass(); objPoint.X = y; objPoint.Y = x; objPoint.SpatialReference = ObjectSpatialReference; objPc.AddPoint(objPoint, ref miss, ref miss); } (objPc as ITopologicalOperator).Simplify(); ObjGeometry = objPc as IGeometry; } else if (geo is IPolygon) { //面 IPolygon objPolygon = new PolygonClass(); IGeometryCollection objPc = objPolygon as IGeometryCollection; double x = 0; double y = 0; double B = 0; double L = 0; IGeometryCollection GeoCol = geo as IGeometryCollection; object miss = Type.Missing; IGeometry tpGeo = null; IPointCollection pcol = null; IRing newRing = null; IPointCollection newRingPointColl = null; for (int j = 0; j < GeoCol.GeometryCount; j++) { tpGeo = GeoCol.get_Geometry(j); //面内环ring(内/外环) pcol = tpGeo as IPointCollection; newRing = new RingClass(); newRingPointColl = newRing as IPointCollection; for (int k = 0; k < pcol.PointCount; k++) { p = pcol.get_Point(k); x = p.X; y = p.Y; this.GetBLFromXY(y, x, ref B, ref L, 0, SourceProjection, SourceStrip, L0, IsBigNumber_Source); this.GetXYFromBL(B, L, ref x, ref y, 0, ObjectProjection, ObjectStrip, IsBigNumber_Object); IPoint objPoint = new PointClass(); objPoint.X = y; objPoint.Y = x; newRingPointColl.AddPoint(objPoint, ref miss, ref miss); } newRing.SpatialReference = ObjectSpatialReference; objPc.AddGeometry(newRing as IGeometry, ref miss, ref miss); } (objPc as IGeometry).SpatialReference = ObjectSpatialReference; (objPc as ITopologicalOperator).Simplify(); ObjGeometry = objPc as IGeometry; } else { //注记 暂未写 } ofeat.pFeature.Shape = ObjGeometry; ofeat.SaveFeature(); } /*pb.Close(); * pb.Dispose(); * pb = null;zk*/ }