• 从TIN获取任意坐标点高程(原创)(ZZ)


    项目中碰到要处理TIN数据地面高程问题,于是开发了个小工具,主要用AE的ITinLayer接口,实现获取任意坐标点的高程值,进一步扩展实用功能,如下:
       鼠标点击获取高程值,根据TIN数据批量处理原始数据模板中的高程值,批量更新SDE 中管线数据地面高程,达到快速更新现状数据目的,客户反映满意。
       主要实现如下:

     1Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     2        If Me.FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
     3            If Me.FolderBrowserDialog1.SelectedPath <> "" Then
     4                Try
     5                    Dim Path As String = Me.FolderBrowserDialog1.SelectedPath
     6                    Dim FatherFolder, Folder As String
     7                    Dim pTinWorkspaceFactory As IWorkspaceFactory
     8                    Dim pTinWorkspace As ITinWorkspace
     9
    10                    pTinWorkspaceFactory = New TinWorkspaceFactoryClass
    11                    FatherFolder = Path.Substring(0, Path.LastIndexOf("\"c) + 1)
    12                    pTinWorkspace = pTinWorkspaceFactory.OpenFromFile(FatherFolder, 0)
    13
    14                    pTinLayer = New TinLayerClass
    15                    Dim pTin As ITin = New TinClass
    16
    17                    Folder = Path.Substring(Path.LastIndexOf("\"c))
    18                    pTin = pTinWorkspace.OpenTin(Folder)
    19                    pTinLayer.Dataset = pTin
    20                    Me.AxMapControl1.Map.ClearLayers()
    21                    Me.AxMapControl1.Map.AddLayer(pTinLayer)
    22                Catch ex As Exception
    23                    MessageBox.Show("打开TIN数据出现错误!" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Information)
    24                End Try
    25            End If
    26        End If
    27    End Sub
     1Private Function ShowZ(ByVal x As DoubleByVal y As DoubleOptional ByVal OnlyReturn As Boolean = FalseAs String
     2        Try
     3            If Me.AxMapControl1.Map.LayerCount = 0 Then
     4                MessageBox.Show("TIN数据未加载""注意", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
     5                Exit Function
     6            End If
     7            Dim pTinLayer As ITinLayer
     8            Dim pFuncSurf As IFunctionalSurface
     9            pTinLayer = Me.AxMapControl1.Map.Layer(0)
    10            If pTinLayer Is Nothing Then
    11                MessageBox.Show("TIN数据未加载""注意", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
    12                Exit Function
    13            End If
    14            pFuncSurf = pTinLayer.Dataset
    15            Dim z As Double
    16            z = pFuncSurf.Z(x, y)
    17
    18            If OnlyReturn = True Then
    19                Return String2String(z.ToString())
    20            End If
    21
    22            If z.ToString() = "非数字" Then
    23                MessageBox.Show("坐标超出范围!""警告", MessageBoxButtons.OK, MessageBoxIcon.Information)
    24            Else
    25                MessageBox.Show("该点高程值:" + String2String(z.ToString()), "", MessageBoxButtons.OK, MessageBoxIcon.Information)
    26            End If
    27        Catch ex As Exception
    28            MessageBox.Show("出现异常 " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information)
    29        End Try
    30    End Function

      为了后期扩展,动态加载MDB结构处理Dll,定义处理接口如下:
     1Public Interface InterfaceDoMDB
     2    Function GetTableName() As String()
     3    Function GetTableKey(ByVal TableName As StringAs TableKey
     4End Interface

     5
     6Public Structure TableKey
     7    Public TableName As String
     8    Public X_FieldName As String
     9    Public Y_FieldName As String
    10    Public LevelFieldName As String
    11End Structure

    效果图如下:

  • 相关阅读:
    设计模式之解释器模式
    设计模式之中介者模式
    设计模式之职责链模式
    设计模式之命令模式
    设计模式之迭代器模式
    设计模式之备忘录模式
    设计模式之状态模式
    【转】CSS中position属性( absolute | relative | static | fixed )详解
    【转】fiddler-http协议调试代理工具
    TCP/IP、Http、Socket的区别
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1796458.html
Copyright © 2020-2023  润新知