鼠标点击获取高程值,根据TIN数据批量处理原始数据模板中的高程值,批量更新SDE 中管线数据地面高程,达到快速更新现状数据目的,客户反映满意。
主要实现如下:
1
Private 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
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click2
If Me.FolderBrowserDialog1.ShowDialog = DialogResult.OK Then3
If Me.FolderBrowserDialog1.SelectedPath <> "" Then4
Try5
Dim Path As String = Me.FolderBrowserDialog1.SelectedPath6
Dim FatherFolder, Folder As String7
Dim pTinWorkspaceFactory As IWorkspaceFactory8
Dim pTinWorkspace As ITinWorkspace9

10
pTinWorkspaceFactory = New TinWorkspaceFactoryClass11
FatherFolder = Path.Substring(0, Path.LastIndexOf("\"c) + 1)12
pTinWorkspace = pTinWorkspaceFactory.OpenFromFile(FatherFolder, 0)13

14
pTinLayer = New TinLayerClass15
Dim pTin As ITin = New TinClass16

17
Folder = Path.Substring(Path.LastIndexOf("\"c))18
pTin = pTinWorkspace.OpenTin(Folder)19
pTinLayer.Dataset = pTin20
Me.AxMapControl1.Map.ClearLayers()21
Me.AxMapControl1.Map.AddLayer(pTinLayer)22
Catch ex As Exception23
MessageBox.Show("打开TIN数据出现错误!" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Information)24
End Try25
End If26
End If27
End Sub
1
Private Function ShowZ(ByVal x As Double, ByVal y As Double, Optional ByVal OnlyReturn As Boolean = False) As 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
Private Function ShowZ(ByVal x As Double, ByVal y As Double, Optional ByVal OnlyReturn As Boolean = False) As String2
Try3
If Me.AxMapControl1.Map.LayerCount = 0 Then4
MessageBox.Show("TIN数据未加载", "注意", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)5
Exit Function6
End If7
Dim pTinLayer As ITinLayer8
Dim pFuncSurf As IFunctionalSurface9
pTinLayer = Me.AxMapControl1.Map.Layer(0)10
If pTinLayer Is Nothing Then11
MessageBox.Show("TIN数据未加载", "注意", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)12
Exit Function13
End If14
pFuncSurf = pTinLayer.Dataset15
Dim z As Double16
z = pFuncSurf.Z(x, y)17

18
If OnlyReturn = True Then19
Return String2String(z.ToString())20
End If21

22
If z.ToString() = "非数字" Then23
MessageBox.Show("坐标超出范围!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information)24
Else25
MessageBox.Show("该点高程值:" + String2String(z.ToString()), "", MessageBoxButtons.OK, MessageBoxIcon.Information)26
End If27
Catch ex As Exception28
MessageBox.Show("出现异常 " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information)29
End Try30
End Function为了后期扩展,动态加载MDB结构处理Dll,定义处理接口如下:
1
Public Interface InterfaceDoMDB
2
Function GetTableName() As String()
3
Function GetTableKey(ByVal TableName As String) As TableKey
4
End Interface
5
6
Public Structure TableKey
7
Public TableName As String
8
Public X_FieldName As String
9
Public Y_FieldName As String
10
Public LevelFieldName As String
11
End Structure
Public Interface InterfaceDoMDB2
Function GetTableName() As String()3
Function GetTableKey(ByVal TableName As String) As TableKey4
End Interface5

6
Public Structure TableKey7
Public TableName As String8
Public X_FieldName As String9
Public Y_FieldName As String10
Public LevelFieldName As String11
End Structure效果图如下:

浙公网安备 33010602011771号