首页 / 浏览问题 / 组件GIS / 问题详情
CoordSysTranslator做投影转换,需要如何传
5EXP 2020年09月09日
Point2Ds pPoint2Ds = new Point2Ds(new Point2D() { X = 130.593, Y = 45.358 });
            Point2Ds clonePoint2Ds = pPoint2Ds.Clone();
            PrjCoordSys pcs = new PrjCoordSys();
            pcs.FromEPSGCode(4531);
            bool convertSucc = CoordSysTranslator.Forward(clonePoint2Ds, pcs);
            System.Diagnostics.Debug.Print(convertSucc.ToString());
            System.Diagnostics.Debug.Print(clonePoint2Ds[0].X + ":" + clonePoint2Ds[0].Y);
            System.Diagnostics.Debug.Print(pPoint2Ds[0].X + ":" + pPoint2Ds[0].Y);

            Point2Ds pPoint2Ds1 = new Point2Ds(new Point2D() { X = 43624818.2017499, Y = 5025965.55557387 });
            Point2Ds clonePoint2Ds1 = pPoint2Ds1.Clone();
            PrjCoordSys pcs1 = new PrjCoordSys();
            bool succ= pcs1.FromEPSGCode(4490);
            bool convertSucc1 = CoordSysTranslator.Inverse(clonePoint2Ds1, pcs1);
            System.Diagnostics.Debug.Print(convertSucc1.ToString());
            System.Diagnostics.Debug.Print(clonePoint2Ds1[0].X + ":" + clonePoint2Ds1[0].Y);
            System.Diagnostics.Debug.Print(pPoint2Ds1[0].X + ":" + pPoint2Ds1[0].Y);

请问下,我测试4490到4531的转换;发现,4490转4531没问题,但4531转4490,转换不成功;

以下是输出内容:

     True
43624818.2017499:5025965.55557387
130.593:45.358
False
43624818.2017499:5025965.55557387
43624818.2017499:5025965.55557387

还有,原数据,是不是需要给空间参考,又如何给呢,好像只有dataset有prjcoordsys这个属性,point2ds或georegion这种的,能设置空间参考?

1个回答

用下面这个方法:

CoordSysTranslator.Convert 方法 (Point2Ds, PrjCoordSys, PrjCoordSys, CoordSysTransParameter, CoordSysTransMethod)
4,620EXP 2020年09月10日
谢谢,上述这个方法可以;想问下,那Inverse,Forward用在哪种情况下;

还有,我试着将一个从数据集中获取的geometry,从4531转到4490,不管我是否用geometry.clone,他都直接修改了geometry的原值,有什么方法,能产生一个新的geometry吗?或者说,geometry.clone是一个浅拷贝,有没有深拷贝的方法,谢谢;(我错了,是深拷贝)
...