24小时热门版块排行榜    

查看: 942  |  回复: 2

Shine.Z

铁虫 (小有名气)

[求助] ArcGlobe二次开发,鼠标拾取点转换成地理坐标错误

第一次发帖,不知道有什么要注意的,有什么不足请大家多多指教。
    C#+ArcEngine Globe二次开发,通过鼠标拾取点转换得到地理坐标。看帮助文档和别人基本都是这么做的,直接利用WindowToGeographic函数就能从二维屏幕坐标转换到三维空间大地坐标,我的代码如下:   
    IGlobeViewUtil globeViewUtil = axGlobeControl1.GlobeCamera as IGlobeViewUtil;
    IGlobeDisplay pGlobeDisplay = axGlobeControl1.GlobeDisplay;
    double dLon = 0;
    double dLat = 0;
    double dAlt = 0;
    globeViewUtil.WindowToGeographic(pGlobeDisplay, pGlobeDisplay.ActiveViewer, e.x, e.y,
        true, out dLon, out dLat, out dAlt);//由屏幕获取经纬度和高程
    这里我有点儿疑问。鼠标在屏幕上点击可获取一个二维坐标,映射到三维场景中其实就从观察点到屏幕坐标的一条射线,转换到三维空间不可能是一个特定的点,除非给定深度值或者说能严格限定视线长度的条件。我不知道这个函数是怎么确定的,猜想可能是得到视线和三维地形的交点,也就是说拾取的这个点在地面上。
    但是我现在做这一步的时候,周围的地形高度都在100米左右,鼠标拾取的点地理坐标的高度有七百多米,使得相应的经纬度也成了错误的。如下图所示:

    e是鼠标点取的位置(跟踪了下应该没问题),转换出来的应该是P的位置,但是实际上得到了P'的位置,由于高度不对,使得经纬度也有很大的偏差。直观的感受就是视线长度不对,还没有延伸到和地面的交点上。中间只用了一个函数,一直不知道为什么会出现这个问题。是不是有什么地方需要设置?菜鸟求指导,先谢谢了。
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

huohe2009

铜虫 (小有名气)

【答案】应助回帖

感谢参与,应助指数 +1
没错。在三维空间上拾取坐标本来就不准确
2楼2013-11-12 21:58:55
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

huohe2009

铜虫 (小有名气)

【答案】应助回帖

(1) WindowToGeographic() function was introduced for a fast and rough estimate of a geographic location that can then be used, for example, for accumulating the geographic extent of the 3D view as defined by a window; or as a faster (and rougher) substitute for standard Locate() when doing picking.
(2) It appears that a safe mode from within an AfterDraw() handler, is 'useZBufferValue = true' -- because otherwise Locate() is used and will draw the whole frame again in our 'internal' transformation and scaling for precision.
(3) Regarding precision:
(a) when useZBufferValue is true, we directly read from the Z-Buffer the depth component and then use gluUnProject() to get x, y, z coordinates. The precision of Z-Buffer depth values varies with "how far you zoom in or out" and is not that precise anyway.
(b) when useZBufferValue is false, we use Locate() which uses a 'Pick-Render' pass to calculate the intersection with the mesh at the current LOD as defined by the view -- so again the precision varies with the current view parameters.
- Note that the precision of the altitude (i.e. elevation) component can be improved by additionally calling IGlobeDisplay::GetSurfaceElevation(); with bGetMaxResolution argument set to true.
(4) Currently we are not using a "mesh-ray intersection algorithm " which would work for us only when no elevation data is present -- the case that can probably be easily calculated on the client side anyway.
3楼2013-11-12 22:02:11
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 Shine.Z 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 2026国自然放榜时间 +3 布布和一二 2026-08-08 3/150 2026-08-08 18:15 by Lightingo
[基金申请] 国基金的申报应该改成非等额制,评价高的钱多评价低的钱少,但是增加资助率 +7 a089 2026-08-07 7/350 2026-08-08 18:05 by gltch
[公派出国] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 qTvzQBRAHjCi 2026-08-07 4/200 2026-08-08 17:27 by oEVWOejN9taj
[考研] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 qTvzQBRAHjCi 2026-08-07 5/250 2026-08-08 16:47 by oEVWOejN9taj
[考博] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +3 Vi50GxzrFcSG 2026-08-07 4/200 2026-08-08 16:22 by oEVWOejN9taj
[公派出国] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +3 Vi50GxzrFcSG 2026-08-07 5/250 2026-08-08 15:59 by oEVWOejN9taj
[硕博家园] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +4 HEQlVqMTIA7d 2026-08-07 6/300 2026-08-08 14:47 by oEVWOejN9taj
[公派出国] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +3 HEQlVqMTIA7d 2026-08-07 6/300 2026-08-08 14:39 by oEVWOejN9taj
[教师之家] 售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急 +4 HEQlVqMTIA7d 2026-08-07 5/250 2026-08-08 14:27 by oEVWOejN9taj
[教师之家] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +3 KXLV3nuBVBY7 2026-08-07 5/250 2026-08-08 14:07 by oEVWOejN9taj
[基金申请] 关于代码变化问题,想知道的进来 +11 且听虎啸 2026-08-07 14/700 2026-08-08 12:50 by 布布和一二
[基金申请] 娱乐 +6 Tide man 2026-08-03 6/300 2026-08-07 22:40 by 铁帽子农民
[基金申请] 固定端突然变了,今天 +6 archvillain 2026-08-06 10/500 2026-08-07 16:03 by 医学老男孩
[基金申请] 听说今天filecode变了 +24 布布和一二 2026-08-06 47/2350 2026-08-07 16:02 by zhiyanjiang
[基金申请] filecode与中标关系的预测 +3 布布和一二 2026-08-07 3/150 2026-08-07 15:09 by gltch
[基金申请] 大家散了吧,后缀研究没有意义,别浪费时间了,过好目前的每一天,不要焦虑 +5 Tide man 2026-08-06 7/350 2026-08-07 13:11 by 医学老男孩
[基金申请] 求各位大神看下 100+6 hpkpkpkp 2026-08-05 33/1650 2026-08-06 14:49 by zhiyanjiang
[基金申请] 8月时间戳变的,举个手。玩一下,释放压力 +9 archvillain 2026-08-04 11/550 2026-08-05 20:06 by wlwhappy
[基金申请] 面上提前没消息,有中的吗 +14 archvillain 2026-08-02 18/900 2026-08-04 14:42 by archvillain
[基金申请] 什么时候能放榜呀? +3 Jacob678 2026-08-03 3/150 2026-08-03 16:14 by gltch
信息提示
请填处理意见