程会超,张之友
(1.珠海市测绘院,广东 珠海 519015)
全站仪具有测量速度快、精度高、操作直接快速、测量数据便于输入计算机和容易实现内外业一体化的特点,已广泛应用于各等级控制测量、变形监测、碎部点采集等。不同型号的全站仪具有不同的数据格式,原始数据格式很难满足不同后处理软件的要求,一般也不可以直接打印归档。为了实现对全站仪原始数据文件的自动化提取,本文以徕卡系列全站仪为例,以Visual Basic 6.0语言为开发平台,进行数据格式转换程序的设计,转换后生成传统记录格式的观测数据文件和CASS通用编码格式的展点数据文件[1]。
为实现内业成图自动化,测量时要采用仪器程序记录数据,野外测量时输入自定义的野外操作简码。各种全站仪记录的数据格式不尽相同,需根据不同的仪器编写相应的程序处理数据,程序的原理相同[2]。
以徕卡全站仪为例,说明内业自动成图及外业观测数据设计和实现。徕卡型全站仪有2种野外观测数据格式:GSI格式和IDEX格式。
*410008+0000000000000000 42....+0000000000000000
43....+0000000000000000 44....+0000000000000000
45....+0000000000000000 46....+0000000000000000
47....+0000000000000000 48....+0000000000000000
49....+0000000000000000
*110009+00000000000000B1 21.324+0000000003510120
22.324 +0000000008847500 31...0+0000000000151591
81...0+0000000105179310 82...0+0000002440519147
83...0+0000000000007829 87...0+0000000000001680
*410010+0000000000000007 42....+0000000000000000
43....+0000000000000000 44....+0000000000000000
45....+0000000000000000 46....+0000000000000000
47....+0000000000000000 48....+0000000000000000
49....+0000000000000000
IDEX格式数据分为3个部分:坐标、编码信息和测量信息。
1)坐标。坐标数据里各字段的信息分别是观测点系统号、观测点号、东坐标、北坐标、高程、自定义的野外操作简码、测量点的日期时间信息、测量点设站点。Code为空的代码默认为上一个点的代码。
POINTS(PointNo, PointID, East, North, Elevation,Code, Date, CLASS)
1000004,"A1", , , ,"", 15-02-2012/15:11:49.0,MEAS;
1000008,"A2",101066.738153,2449139.782888,
2.743479 ,"",15-02-2012/15:16:30.0,MEAS;1000013,"0",101066.737305,2449139.780994,
2.745656 ,"99",15-02-2012/15:17:06.0,MEAS;1000016,"1",101067.830567,2449133.883843,
2.706405 ,"421",15-02-2012/15:17:28.0,MEAS;1000007,"A2",101066.726000,2449139.772000,
2.702000 ,"",15-02-2012/15:16:30.0,FIX;
1000307,"A1",100962.977000,2449046.824000,
2.804000 ,"",15-02-2012/16:16:21.0,FIX;
2)编码信息。
700335, "161","Info1", "";
700335, "161","Info2", "";
700335, "161","Info3", "";
700335, "161","Info4", "";
700335, "161","Info5", "";
700335, "161","Info6", "";
700335, "161","Info7", "";
700335, "161","Info8", "";
3)测量信息。测量数据包含设站点名、仪器高、定向或观测点点名、水平角、垂直角、斜距、觇标高等信息。
STN_ID "DT0705"
INST_HT 1.471000;
END SETUP
SLOPE(TgtNo, TgtID, CfgNo, Hz, Vz, SDist, RefHt,
Date, Ppm, ApplType, Flags)
700073,"6",1,201.295790,89.472640,65.285628,1.68,
15-02-2012/15:18:27.0,12.688406,107,000000;
700076,"6",1,201.300100,89.472820,65.287928,1.68,
15-02-2012/15:18:48.0,12.688406,107,000000;
通过对以上数据格式的分析,采用Visual Basic 6.0设计可视化界面并编写数据处理程序,实现了CASS内业自动成图。
首先按“野外操作码,CASS 9.0编码”格式,自定义一个名为“简码.txt”的野外操作码与CASS编码对应的.txt文件。
打开原始数据文件,逐行读取数据行;以“MEAS;”和“FIX;”为依据,把原始数据分离成格式为“简码、点号、东坐标、北坐标、高程”的测量数据和设站点数据;定义简码、测量和控制点数据为不同的数组,循环处理测量和控制点数据,把野外操作码替换成CASS编码。在替换野外操作码的过程中,要识别每个点是点状地物或线状地物,点状地物进行替换,线状地物替换后再根据野外测点顺序进行排序,让每个独立的线无折返,将替换排序后的数据生成.dat文件。根据坐标数据与测量信息里的系统号将坐标数据与测量信息合并输出观测原始数据[3,4],如图1所示。
利用VB语言以行为单位读取原格式数据文件,根据原文件的相关标识,对行字符串进行分解,来提取数据(系统号、测站点号、仪器高、定向点号、观测点号、水平角、垂直角、斜距、觇标高、简码、东坐标、北坐标、高程)进行处理,并同时生成外业观测手簿和南方CASS展点的.dat文件。野外观测手簿可根据野外碎布点的采集先后顺序输出,.dat数据需要根据野外碎布点的采集顺序和编码是否相同进行排序输出,防止自动成图时线性地物的折返[5-7]。
数据转换的部分编码如下:
……
Do Until EOF(1) '循环至文件尾
Input #1, z1, z2, z3, z4, z5, z6, z7, z8
Zbjm(zi, 1) = z1 '系统号
Zbjm(zi, 2) = z2 '点号
Zbjm(zi, 3) = z3 'X
Zbjm(zi, 4) = z4 'Y
Zbjm(zi, 5) = z5 'Z
Zbjm(zi, 6) = z6 '简码
Zbjm(zi, 7) = z7 '日期
Zbjm(zi, 8) = z8 '点属性
If Zbjm(zi, 6) = "" And zi = 0 Then Write #3, Zbjm(zi,6); Zbjm(zi, 2); Zbjm(zi, 4); Zbjm(zi, 3); Zbjm(zi, 5)
If Zbjm(zi, 6) = "" And zi >= 1 Then Zbjm(zi, 6) =Zbjm(zi - 1, 6)
If IsNumeric(Zbjm(zi, 3)) Then
If Zbjm(zi, 6) = "" Then Zbjm(zi, 6) = "99"
If Zbjm(zi, 8) = "FIX;" Then Zbjm(zi, 6) = "99"
Write #3, Zbjm(zi, 6); Zbjm(zi, 2); Zbjm(zi, 4);Zbjm(zi, 3); Zbjm(zi, 5) End If
zi = zi + 1
Loop
……
For bp = 0 To 3000
If Ac(bp, 1) = "" And Ac(bp, 2) = "" Then GoTo 16
If Ac(bp, 2) = "+" Then GoTo 15
If IsNumeric(Ac(bp, 2)) = True Then
a = Ac(bp, 2)
If a < 100 Then
For ao = 0 To 500
If Mb(ao, 1) = "" And Mb(ao, 2) = "" Then GoTo 15
b = StrComp(a, Mb(ao, 1), 1)
If b = 0 Then Ac(bp, 2) = Mb(ao, 2): GoTo 15
Next ao
Else
a = Mid(Ac(bp, 2), 1, 2)
For ao = 0 To 500
If Mb(ao, 1) = "" And Mb(ao, 2) = "" Then GoTo 15
c = a & "0"
b = StrComp(c, Mb(ao, 1), 1)
If b = 0 Then Ac(bp, 2) = Mb(ao, 2): GoTo 15
Next ao
End If
Else
If IsNumeric(Right(Ac(bp, 2), 1)) = False Then
a = Mid(Ac(bp, 2), 1, 2)
For ao = 0 To 500
If Mb(ao, 1) = "" And Mb(ao, 2) = "" Then GoTo 15
b = StrComp(a, Mb(ao, 1), 1)
If b = 0 Then Ac(bp, 2) = Mb(ao, 2): GoTo 15
Next ao
Else
m = StrReverse(Ac(bp, 2))
n = Val(m)
p = Len(Trim(n))
q = Len(Ac(bp, 2))
If Mid(m, 1, 1) = "0" Then
s = Mid(Ac(bp, 2), 1, q - p - 1)
Else
s = Mid(Ac(bp, 2), 1, q - p)
End If
For ao = 0 To 500
If Mb(ao, 1) = "" And Mb(ao, 2) = "" Then GoTo 15
b = StrComp(s, Mb(ao, 1), 1)
If b = 0 Then Ac(bp, 2) = Mb(ao, 2): GoTo 15
Next ao
End If
End If
15: Print #5, Ac(bp, 1) & "," & Ac(bp, 2) & "," &Format(Ac(bp, 4), "0.000") & "," & Format(Ac(bp, 3),"0.000") & "," & Format(Ac(bp, 5), "0.000")
……
Function sb(dm As Variant) As Boolean
If IsNumeric(Right(dm, 1)) = False Then
sb = True
Else
sb = False
End If
End Function
下面是处理后的数据片段:
1)观测数据.txt文件,即传统记录格式文件。
2)展点数据.dat文件(CASS数据格式),即通用成图软件展点文件。
2,Z1,97 651.008,2 452 170.009,0.541
3,+,97 652.645,2 452 168.301,0.555
4,+,97 650.265,2 452 166.307,1.115
16,+,97 672.197,2 452 151.366,0.728
17,+,97 668.863,2 452 154.874,0.745
18,+,97 678.083,2 452 164.095,0.789
5,F6,97 641.965,2 452 150.936,0.898
63,+,97 631.257,2 452 155.237,0.894
64,+,97 639.865,2 452 148.297,0.947
6,F6,97 643.272,2 452 151.925,0.706
本文通过对徕卡全站仪数据文件格式的探讨,利用Visual Basic 6.0设计可视化界面并编制了数据转换程序,对全站仪原始数据文件进行转换,满足了记录的要求,解决了全站仪原始数据与内业后处理软件的自动匹配问题。该程序已经过大量生产实践验证,转换的数据正确,格式严谨美观,能同时满足生产和传统质检程序的要求,操作方便快捷,能有效减轻工作强度,提高生产效率。
[1]喻家碧.全站仪空间测量精度浅析及其应用探讨[J].测绘通报,2010(4):70-73
[2]田春来,邢炜光,邢卫民,等.全站仪数据格式转换程序的设计与实现[J].测绘通报,2008(9):67-68
[3]王永尚,李以赫.数字水准仪的试验结果及分析[J].测绘通报,2002(4):58-61
[4]李维功,刘旭春.DINI数字水准仪数据格式转换及平差功能程序设计与实现[J].测绘通报, 2007(7):82
[5]宋伟,吴建国. 中文Visual Basic 6.0高级编程[M].北京:清华大学出版社,1999
[6]杨晓明,王军德,时东玉. 数字测图:内外业一体化[M].北京:测绘出版社,2001
[7]胡华科,吴惠恩,杨强.基于VB6.0实现全站仪与计算机数据通信与转换[J].嘉应学院学报:自然科学版 ,2005,23(6):64-66