//投影转换 public void ProjConvert(string srcProjParam, string desProjParam, int pointCount, double[] X, double[] Y, double[] Z) { ////投影参数初始化 IntPtr pjSrc = ProjWrapper.pj_init_plus(srcProjParam); IntPtr pjDes = ProjWrapper.pj_init_plus(desProjParam); ProjWrapper.pj_transform(pjSrc, pjDes, pointCount, 0, X, Y, Z); // X = null; // Y = null; Z = null; }
//单点-正投影 public PointF GetXYFromLatLon(PointF pointOrg, MapHandle.config.ProjPara proj) { pointOrg.X = (float)(pointOrg.X * DEG2RAD); pointOrg.Y = (float)(pointOrg.Y * DEG2RAD); //投影参数初始化 IntPtr pj = ProjWrapper.pj_init_plus(getSrcProj(proj)); projUV temp = new projUV(pointOrg.X, pointOrg.Y); projUV coord = ProjWrapper.pj_fwd(temp, pj); PointF pointPrj = new PointF(); pointPrj.X = (float)(coord.U); pointPrj.Y = (float)(coord.V); return(pointPrj); }
//单点-反投影 public PointF GetLatLonFromXY(PointF pointXY, MapHandle.config.ProjPara proj) { //投影参数初始化 PointF result = new PointF(); IntPtr pj = ProjWrapper.pj_init_plus(getSrcProj(proj)); projUV temp = new projUV(pointXY.X, pointXY.Y); projUV coord = ProjWrapper.pj_inv(temp, pj); result.X = (float)(coord.U); result.Y = (float)(coord.V); result.X = (float)(result.X * RAD2DEG); result.Y = (float)(result.Y * RAD2DEG); return(result); }