如何把鼠标坐标转换为大地经纬度坐标代码
对于一款绘图软件或系统,无论如何都免不了鼠标位置坐标的处理,但是鼠标的位置坐标并不能直接用在地理系统里的大地经纬度坐标,因为他们的坐标系结构不一样。所以往往需要互相转化。那么本文就结合实际例子谈谈如何把鼠标坐标转化为大地经纬度坐标的方法并列举出用到的函数代码。
'运行此行程以前请将当前的地图属性下""Units""中的""display""设为用度分秒显示
Private Sub 实验按钮_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
Dim pDoc As IMxDocument
Dim I As Integer
Dim sLong As String '经度的字符串
Dim sLati As String '纬度的字符串
Dim iDD As Integer '度的符号所在位置
Dim iMM As Integer '分的符号所在的位置
Dim iSS As Integer '秒的符号所在的位置
Const sD = ""°""
Const sM = ""'""
Const sS = """"""""
Dim sStr As String
Dim iLongDegree As Integer '经度的度
Dim iLongMinute As Integer '经度的分
Dim dlongSecond As Double '经度的秒
Dim iLatitDegree As Integer '纬度的度
Dim iLatitMinute As Integer '纬度的分
Dim dLatitSecond As Double '纬度的秒
Set pDoc = ThisDocument
'设置前显示的坐标为经纬度坐标
Dim pScreenDisplay As IScreenDisplay
Set pScreenDisplay = pDoc.ActivatedView.ScreenDisplay
pDoc.ActiveView.Refresh
'With pScreenDisplay
' .StartDrawing pScreenDisplay.hdc, esriNoScreenCache
'.SetSymbol pLineSymbol
'.DrawPolyline pPolyLine
' .FinishDrawing
'End With
sStr = ThisDocument.Parent.StatusBar.Message(2)
'将经度与纬度分开
I = InStr(1, sStr, Space(1), vbTextCompare)
sLati = Right(sStr, I - 1)
sLong = Left(sStr, Len(sStr) - I)
'求纬度的DDMMSS
iDD = InStr(1, sLati, sD, vbTextCompare)
iMM = InStr(1, sLati, sM, vbTextCompare)
iSS = InStr(1, sLati, sS, vbTextCompare)
'MsgBox Right(sLong, 2)
iLatitDegree = Val(Left(sLati, (iDD - 1)))
iLatitMinute = Val(Mid(sLati, iDD + 1, 2))
dLatitSecond = Val(Mid(sLati, iMM + 1, (iSS - iMM - 1)))
MsgBox ""ilatitdegree="" & iLatitDegree & vbCrLf & ""ilatitminute="" & iLatitMinute & vbCrLf & ""ilatitsecond="" & dLatitSecond, vbCritical, """"
'求经度的DDMMSS
iDD = InStr(1, sLong, sD, vbTextCompare)
iMM = InStr(1, sLong, sM, vbTextCompare)
iSS = InStr(1, sLong, sS, vbTextCompare)
'MsgBox Right(sLong, 2)
iLongDegree = Val(Left(sLong, (iDD - 1)))
iLongMinute = Val(Mid(sLong, iDD + 1, 2))
dlongSecond = Val(Mid(sLong, iMM + 1, (iSS - iMM - 1)))
MsgBox ""ilongdegree="" & iLongDegree & vbCrLf & ""ilongminute="" & iLongMinute & vbCrLf & ""ilongsecond="" & dlongSecond, vbCritical, """"
End Sub"
最新文章
- 复合数据集 CAD到GIS的数据格式转换 [04-01]
- 2001年中国地质大学地信专业考研试 [03-31]
- 在VC++中嵌入MapX的集成二次开发 [03-30]
- Shapefile和MapGIS 文件格式转换 点 [03-25]
- VC++实现GPS定位信息的接收及对各定 [08-03]
- GDI+里将一个彩色图像转换成黑白图 [08-03]
- ArcMap连接微软SQL Server数据库三 [12-08]
- 如何把鼠标坐标转换为大地经纬度坐 [12-08]
- Avenue语言下实现经纬度转换大地坐 [11-22]
- 等高线加密基本原理以及算法代码实 [11-22]
推荐文章


热点文章
从数据结构角度理解ESRI的Geodat
高斯投影正算与反算的理论方法与
用C++实现矩阵基本运算的实例代码
常用的空间插值方法汇总及各自特
常用的几何计算算法思路和实例
在VB中如何将Access表中点和线转
地图着色算法原理及C语言实现实例
复合数据集 CAD到GIS的数据格式转
2001年中国地质大学地信专业考研
在VC++中嵌入MapX的集成二次开发
Shapefile和MapGIS 文件格式转换
VC++实现GPS定位信息的接收及对各
GDI+里将一个彩色图像转换成黑白
ArcMap连接微软SQL Server数据库
如何把鼠标坐标转换为大地经纬度
Avenue语言下实现经纬度转换大地
等高线加密基本原理以及算法代码

