关于ToMapPoint过时造成的坐标转换的偏差

    制作点选(Identify )、框选(Select )等操作时,必要的一步是将客户端的屏幕坐标转换到地图坐标。在ArcGIS Server .NET ADF SP3 以前,使用如下语句进行转换:

Rectangle rect  =  (args  as  RectangleEventArgs).ScreenExtent;
ESRI.ArcGIS.ADF.Web.Geometry.Point minAdfPoint 
=  ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(rect.Left, rect.Bottom, mapCtrl.Extent, mapFunc.DisplaySettings.ImageDescriptor.Width, mapFunc.DisplaySettings.ImageDescriptor.Height);
ESRI.ArcGIS.ADF.Web.Geometry.Point maxAdfPoint 
=  ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(rect.Right, rect.Top, mapCtrl.Extent, mapFunc.DisplaySettings.ImageDescriptor.Width, mapFunc.DisplaySettings.ImageDescriptor.Height);
ESRI.ArcGIS.ADF.Web.Geometry.Envelope adfEnvelope 
=   new  ESRI.ArcGIS.ADF.Web.Geometry.Envelope(minAdfPoint, maxAdfPoint);

    而在
SP3 以后,上述语句在编译时会收到一条警告:“ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(int, int, ESRI.ArcGIS.ADF.Web.Geometry.Envelope, int, int) ”已过时。 运行程序,似乎没觉得有什么偏差嘛。给Map Service 做个缓存,再运行,出现了明显的偏差。看下面两张图:
                                      
                                                      图-1
                                      
                                                      图-2
    进一步测试,只要MapResourceManager 中引用的任何一个Map Service 做了缓存,就会出现偏差,而没有缓存的情况下居然正常。这也恰恰是忽悠人的地方。 最可气的是ESRI 的帮助文档之简陋令人发指,ArcGIS Server .NET ADF API 文档看上去一片光秃秃的,告诉你方法已过时,却不提示你用什么方法替代。看来真的像我经理说的,GIS 软件巨头在美国不过是个三流小软件公司。
    好在经过孜孜不倦的google 终于找到了正确的方法,请使用如下语句:

Rectangle rect  =  (args  as  RectangleEventArgs).ScreenExtent;
ESRI.ArcGIS.ADF.Web.Geometry.Point minAdfPoint 
=  ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(rect.Left, rect.Bottom, mapCtrl.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
ESRI.ArcGIS.ADF.Web.Geometry.Point maxAdfPoint 
=  ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(rect.Right, rect.Top, mapCtrl.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToMap));
ESRI.ArcGIS.ADF.Web.Geometry.Envelope adfEnvelope 
=   new  ESRI.ArcGIS.ADF.Web.Geometry.Envelope(minAdfPoint, maxAdfPoint);

    注意其中的GetTransformationParams和TransformationDirection。我的开发环境是Visual Studio 2005 + ArcGIS Server .NET ADF SP4 + ArcGIS Desktop 9.2 SP4 + ArcSDE 9.1。
    
posted on 2008-01-21 15:59  heminzhou 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/heminzhou/archive/2008/01/21/1047374.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值