24小时热门版块排行榜    

Znn3bq.jpeg
查看: 884  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[有机交流] 反应很差,大量原料没有反应 5+3 Mr.Zot 2026-05-19 7/350 2026-05-20 19:56 by 88817753
[基金申请] 面上本子正文33页,违规吗?会被低分嘛? +11 1234567wang 2026-05-17 13/650 2026-05-20 18:55 by tanfancy
[基金申请] 评审有感 +14 popular289 2026-05-18 23/1150 2026-05-20 17:39 by lincyb
[基金申请] 提交了我也来说说感想 +6 fummck 2026-05-20 6/300 2026-05-20 17:29 by 姜太公烤鱼
[论文投稿] Sci. Bull. 悲剧经验 +6 jyang1999 2026-05-16 7/350 2026-05-20 16:39 by feng6531
[基金申请] 今年审到国自然15份,谈谈感受 +19 国自然国社科中 2026-05-17 20/1000 2026-05-20 14:14 by 仲夏夜的星星
[考博] 如果工作了想读博,可以边工作边读全日制嘛? 30+3 铁达火车 2026-05-18 5/250 2026-05-20 09:33 by tfang
[有机交流] 如何实现卤原子转化 +3 BT20230424 2026-05-15 8/400 2026-05-20 09:32 by xtlilibin
[基金申请] 河北省自然科学基金 +3 Peterchao 2026-05-18 3/150 2026-05-20 08:57 by 霸_霸
[教师之家] 上海大学实验技术岗位非升即走 +12 嘻嘻哈哈乐呵呵 2026-05-15 13/650 2026-05-20 08:34 by xli1984
[考博] 云南大学材料与能源学院解琳课题组钙钛矿博士招生 +3 光伏爱好者 2026-05-17 5/250 2026-05-19 19:13 by 光伏爱好者
[考博] 找博士生导师 +6 小代想上岸 2026-05-15 7/350 2026-05-19 10:22 by free_fisher
[考博] 26/27申博自荐-锂/钠电池方向 5+3 狗头军师. 2026-05-15 4/200 2026-05-19 09:10 by moonboat
[基金申请] 别被青基扩招骗了!26年科研内卷才刚刚开始 +3 国自然国社科中 2026-05-14 4/200 2026-05-19 08:48 by archvillain
[考博] 博士申请 +5 星…… 2026-05-18 6/300 2026-05-18 23:49 by 糊糊涂涂好
[硕博家园] 我在等一个没有答案的答案 +3 Love_MH 2026-05-17 3/150 2026-05-18 02:22 by 竹林孤影
[文学芳草园] 半夜喝咖啡 +3 myrtle 2026-05-15 5/250 2026-05-18 01:03 by 小沈2018
[考博] 光量子物理方向 博士招生 1人(2026.09) +3 sandyworld 2026-05-15 4/200 2026-05-17 14:38 by sandyworld
[有机交流] 求助2,4-二氯-5-嘧啶甲醛的合成方法 20+3 光吃不拉 2026-05-14 6/300 2026-05-16 19:46 by Equinoxhua
[硕博家园] 申请博士 +3 呃?呃 2026-05-15 3/150 2026-05-16 11:01 by a4742549
信息提示
请填处理意见