//double[] cVerticesArray=null; //int angle = (int)(item.AvgProgress * 360); //int count = 0; //cVerticesArray = CoordinateConverter.GPSPie(cx, cy, z, 15, angle, out count); //polyline = sgworld.Creator.CreatePolygonFromArray(cVerticesArray, sgworld.Creator.CreateColor(255, 215, 0, 255), sgworld.Creator.CreateColor(255, 215, 0, 255), /// <summary> /// /// </summary> /// <param name="x">中心点经度</param> /// <param name="y">中心点纬度</param> /// <param name="h">中心点高度</param> /// <param name="l">矩形宽度</param> /// <param name="w">矩形高度</param> /// <returns>矩形点集</returns> public static double[] GPSRectangle(double x, double y, double h, double l, double w, double dir) { //n = 4; double cosa = Math.Cos(dir * Math.PI / 180); double sina = Math.Sin(dir * Math.PI / 180); double[] ps = new double[] { -l / 2, w / 2, h, l / 2, w / 2, h, l / 2, -w / 2, h, -l / 2, -w / 2, h }; double[] p = new double[12]; double ux, uy; //int zone; // 计算中心点 utm坐标 CoordinateConverter.LatLonToUTMXY(y, x, out ux, out uy); // 计算四个顶点utm坐标 for (int i = 0; i < 12; i += 3) { p[i] = cosa * ps[i] + sina * ps[i + 1] + ux; p[i + 1] = -sina * ps[i] + cosa * ps[i + 1] + uy; p[i + 2] = h; } // 顶点坐标转换为经纬度坐标 for (int i = 0; i < 12; i += 3) { CoordinateConverter.UTMXYToLatLon(p[i], p[i + 1], out ps[i + 1], out ps[i], false); } return(ps); }
/// <summary> /// /// </summary> /// <param name="x">中心点经度</param> /// <param name="y">中心点纬度</param> /// <param name="h">中心点高度</param> /// <param name="r">半径,以米为单位</param> /// <param name="angle">角度,圆周360度</param> /// <param name="count">点的个数</param> /// <returns>圆周点集(经纬度,高度)</returns> public static double[] GPSPie(double x, double y, double h, double r, int angle, out int count) { int step = 5; count = angle / step + 1 + (angle % step > 0 ? 1 : 0); if (count == 1) { count = 0; return(null); } //double[] ps = new double[] { -l / 2, w / 2, h, l / 2, w / 2, h, l / 2, -w / 2, h, -l / 2, -w / 2, h }; double[] p = new double[count * 3]; double[] pd = new double[count * 3]; double a = 0; double astep = Math.PI / 180 * step; double ux, uy; int i = 0; CoordinateConverter.LatLonToUTMXY(y, x, out ux, out uy); // 计算圆弧点utm坐标 for (i = 0; i < 3 * (count - 1); a += astep, i += 3) { p[i] = r * Math.Cos(a) + ux; p[i + 1] = r * Math.Sin(a) + uy; pd[i + 2] = h; } //if (i == count){ // i --; p[i] = r * Math.Cos(angle * Math.PI / 180) + ux; p[i + 1] = r * Math.Sin(angle * Math.PI / 180) + uy; pd[i + 2] = h; //} for (i = 0; i < count * 3; i += 3) { CoordinateConverter.UTMXYToLatLon(p[i], p[i + 1], out pd[i + 1], out pd[i], false); } return(pd); }
// 117.11726427,36.67414252 public static void MarsToEarth(double[] marsLong, double[] marsLat, double[] earthLong, double[] earthLat, double[] newMarsLong, double[] newMarsLat, out double[] newEarthLong, out double[] newEarthLat) { int ptNum = marsLong.Length; double[,] X = MatrixTool.Init(2 * ptNum, 1); double[,] Y = MatrixTool.Init(2 * ptNum, 1); int pN = newMarsLong.Length; double[] XX = new double[pN * 2]; double[] YY = new double[pN * 2]; newEarthLong = new double[pN]; newEarthLat = new double[pN]; //double[] YYRes = new double[pN * 2]; for (int i = 0; i < ptNum; i++) { CoordinateConverter.LatLonToUTMXY(marsLat[i], marsLong[i], out X[2 * i + 0, 0], out X[2 * i + 1, 0]); CoordinateConverter.LatLonToUTMXY(earthLat[i], earthLong[i], out Y[2 * i + 0, 0], out Y[2 * i + 1, 0]); CoordinateConverter.LatLonToUTMXY(newMarsLat[i], newMarsLong[i], out XX[2 * i + 0], out XX[2 * i + 1]); } CoordTrans4Param ct = new CoordTrans4Param(); ct.CalculateTrans4Param(X, Y); for (int i = 0; i < pN; i++) { ct.TransCoord(XX[i * 2 + 0], XX[i * 2 + 1], out YY[i * 2 + 0], out YY[i * 2 + 1]); CoordinateConverter.UTMXYToLatLon(YY[i * 2 + 0], YY[i * 2 + 1], out newEarthLat[i], out newEarthLong[i]); //Console.WriteLine("准确的 x {0}, y {1}, 计算的 x {2} , y {3} ", YYRead[i * 2 + 0], YYRead[i * 2 + 1], YY84[i * 2 + 0], YY84[i * 2 + 1]); //Console.WriteLine("准确的 x {0}, y {1}, 计算的 x {2} , y {3} ", YYRead[i * 2 + 0], YYRead[i * 2 + 1], YY[i * 2 + 0] / sx + cx2, YY[i * 2 + 1] / sy + cy2); } //return YYRes; }