public static IPoint ConvertPcsToGcs(IPoint point, IProjectedCoordinateSystem projectedCoordinateSystem) { WKSPoint wksPoint = new WKSPoint(); wksPoint.X = point.X; wksPoint.Y = point.Y; projectedCoordinateSystem.Inverse(1, ref wksPoint); IPoint pPoint = new PointClass(); pPoint.X = wksPoint.X; pPoint.Y = wksPoint.Y; return(pPoint); }
/// <summary> /// 设置矩形框范围 /// </summary> /// <param name="pFeature"></param> /// <param name="XLength">X轴方向长度二分之一</param> /// <param name="YLength">Y轴方向长度二分之一</param> /// <returns></returns> private IGeometry SetGeometry(IFeature pFeature, ref string mapNO) { IGeometry res = null; //pGeometry = new EnvelopeClass(); IEnvelope penvelope = new EnvelopeClass(); ISpatialReference pSpatialRefrence = pFeature.ShapeCopy.SpatialReference; string mapNo = ""; if (pSpatialRefrence is IProjectedCoordinateSystem) { IGeographicCoordinateSystem pGCS = (pSpatialRefrence as IProjectedCoordinateSystem).GeographicCoordinateSystem; IArea pArea = pFeature.ShapeCopy as IArea; IPoint pCPoint = pArea.Centroid; double difX = 1 * 3600 / 16, difY = 1 * 3600 / 24; IProjectedCoordinateSystem pPCS = pSpatialRefrence as IProjectedCoordinateSystem; WKSPoint pPointMin = new WKSPoint(); pPointMin.X = pCPoint.X; pPointMin.Y = pCPoint.Y; pPCS.Inverse(1, ref pPointMin); double minX = Math.Floor(pPointMin.X * 3600 / difX) * difX; double minY = Math.Floor(pPointMin.Y * 3600 / difY) * difY; long lScale = 10000; GeoDrawSheetMap.basPageLayout.GetNewCodeFromCoordinate(ref mapNo, (long)(pPointMin.X * 3600), (long)(pPointMin.Y * 3600), lScale); //GeoDrawSheetMap.basPageLayout.GetNewCodeFromCoordinate(ref mapNo, (long)(minX), (long)(minY+3), lScale); penvelope.PutCoords(minX / 3600, minY / 3600, (minX + difX) / 3600, (minY + difY) / 3600); penvelope.SpatialReference = pGCS; penvelope.Project(pSpatialRefrence); res = penvelope; } mapNO = mapNo; return(res); }