地图投影计算ESRI.ArcObjects实现

用ArcMap.VBA代码表示如下:

----------------------------------------------------------------------------------
Private Sub projectUsage()
    'wanxiangqian@163.com, 2007-10-29
     
    'Set up spatial references
    Dim facSR As SpatialReferenceEnvironment
    Set facSR = New SpatialReferenceEnvironment
   
    Dim srcSR As IGeographicCoordinateSystem
    Set srcSR = facSR.CreateGeographicCoordinateSystem(esriSRGeoCS_Xian1980) 'esriSRSpheroid_Xian1980
   
    Dim destSR As IProjectedCoordinateSystem
    Set destSR = facSR.CreateProjectedCoordinateSystem(esriSRProjCS_Xian1980_GK_CM_111E)
   
    'Set up Point for transforming
    Dim pt As IPoint
    Set pt = New Point
    pt.x = 111
    pt.y = 30
   
    Set pt.SpatialReference = srcSR
    pt.Project destSR
    MsgBox "(" & pt.x & "," & pt.y & ")"
   
    Set pt.SpatialReference = destSR
    pt.Project srcSR
    MsgBox "(" & pt.x & "," & pt.y & ")"
   
End Sub
----------------------------------------------------------------------------------
找到esriSRProjCS_Xian1980_GK_CM_111E、esriSRGeoCS_Xian1980、esriSRSpheroid_Xian1980这些常量可不容易!

有IProjectedCoordinateSystemEdit接口,但如下所示的方法全然看不懂该传什么值给它,帮助文件也没有任何补偿,很难学习!
public void Define (

    ref object Name,

    ref object Alias,

    ref object Abbreviation,

    ref object Remarks,

    ref object useage,

    ref object gcs,

    ref object projectedUnit,

    ref object Projection,

    ref object parameters

);

下面是帮助文件对参数列表的说明:

Name   To indicate that this parameter is undefined, first define a variable object Missing = Type.Missing; then pass this in as ref Missing.

Alias   To indicate that this parameter is undefined, first define a variable object Missing = Type.Missing; then pass this in as ref Missing.

Abbreviation   To indicate that this parameter is undefined, first define a variable object Missing = Type.Missing; then pass this in as ref Missing.

Remarks   To indicate that this parameter is undefined, first define a variable object Missing = Type.Missing; then pass this in as ref Missing.

useage   To indicate that this parameter is undefined, first define a variable object Missing = Type.Missing; then pass this in as ref Missing.

gcs   To indicate that this parameter is undefined, first define a variable object Missing = Type.Missing; then pass this in as ref Missing.

projectedUnit   To indicate that this parameter is undefined, first define a variable object Missing = Type.Missing; then pass this in as ref Missing.

Projection   To indicate that this parameter is undefined, first define a variable object Missing = Type.Missing; then pass this in as ref Missing.

parameters   To indicate that this parameter is undefined, first define a variable object Missing = Type.Missing; then pass this in as ref Missing.

——不明确每个参数的类型。

 

教训:接口上使用VARIANT作为数据类型,一定要在帮助文件里说明实际的数据类型。因为此时接口的prototype不能传递任何信息,全靠应用域知识。

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值