'******************************************************************************* ****' 本程序用于单一附(闭)合导线严密平差计算,采用按角度条件平差法。
以方向观测值中'误差的先验值作为单位权中误差。
计算结果可求得各待定点的坐标平差值及其点位精度Mx,My,'及M,并计算出各待定点误差椭圆元素E,F,Z''参考文献:郭久训.《控制网平差程序设计》北京:原子能出版社,2004.8''平差数据来源:潘正风等.《数字测图原理与方法》武汉大学出版社186页表6-5''等级:所用平差数据为首级图根导线数据(精度很不高)。
本程序中写出了方位角和导线全长相对闭合差的判'别,但考虑到程序的通用性,将这些限差判断当作了注释处理,而不实际运行。
''程序不足:没有导线网的图形表达。
'******************************************************************************* ****Private i%, j%, n%, tc#, tb#, B_x!, B_y!, e1!, e2!, m!, m0#, z#, aa As Boolean, bb As Boolean, cc As Boolean ',dd As BooleanPrivate Naa#(2, 2), Naa逆#(2, 2), W#(2), K#(2), qq#(2), fx#(2), fy#(2)Private A#(), Q#(), V#(), C#(), mx#(), my#(), mk#(), e#(), f#(), zz#()Private Po() As Point'文件格式说明:'文件格式详见文件"平差数据.txt"'Private Sub 打开文件_Click() '打开文件Dim ff$, temp$, A_name$, A_x!, A_y!, A_l#, A_s!, B_name$, B_l#, C_name$, C_x!, C_y!, D_name$, D_x!, D_y!Form1.Cls '清屏CommonDialog1.DialogTitle = "打开数据文件"CommonDialog1.FileName = ""CommonDialog1.ShowOpen'出错处理On Error GoTo FileErrff = CommonDialog1.FileName 'ff是文件路径名Open ff For Input As #1 '以顺序文件方式打开文件,使用inputLine Input #1, temp '读取文件中的说明语句Line Input #1, temp '读取文件中的说明语句Line Input #1, temp '读取文件中的说明语句Input #1, n '读取n,n为(测站数-1)ReDim Po(n) As Point '定义Po(n),其中Po(0)存A点数据,Po(n)存B点数据,Po(1)到Po(n-1)存n-1个未知点数据。
Line Input #1, temp '读取文件中的说明语句Line Input #1, temp '读取文件中的说明语句Input #1, m, e1, e2 '读取先验方向观测值中误差m,测距仪固定误差e1,比例误差e2Line Input #1, temp '读取文件中的说明语句Line Input #1, temp '读取文件中的说明语句Input #1, C_name, C_x, C_y '读取已知点CInput #1, A_name, A_x, A_y, A_l, A_s '读取已知点AFor i = 1 To n - 1 '读取n-1个未知点Input #1, Po(i).name, Po(i).l, Po(i).sNext iInput #1, B_name, B_x, B_y, B_l '读取已知点BInput #1, D_name, D_x, D_y '读取已知点DClose #1tc = ZBiaoFSuan(C_x, C_y, A_x, A_y) '坐标反算,求点C到A的坐标方位角,并记作tc,单位是度tb = ZBiaoFSuan(B_x, B_y, D_x, D_y) '坐标反算,求点B到D的坐标方位角,并记作tb,单位是度Po(0).name = A_name: Po(0).x = A_x: Po(0).y = A_y: Po(0).l = A_l: Po(0).s= A_s 'Po(0)存A点数据Po(n).name = B_name: Po(n).x = B_x: Po(n).y = B_y: Po(n).l = B_l 'Po(n)存B点数据For i = 0 To nPo(i).l = deg(Po(i).l) '将观测方向左角的单位度分秒化作度Next iReDim Q#(2 * n), A#(2, 2 * n), V#(2 * n), C#(1, 2 * n - 2), mx#(n - 1), my#(n- 1), _mk#(n - 1), e#(n - 1), f#(n - 1), zz#(n - 1) '变量重新定义bb = TrueMsgBox "文件已成功打开", , "提示"显示平差数据 ffExit SubFileErr:MsgBox "您的文件未打开或打开的文件格式有误!注意:请重新运行本程序!!", , "提示"End Sub'''Private Sub 开始计算_Click()If bb = True Then推算方位角和坐标 '求近似坐标求条件式'If dd = True Then '若平差数据没有超限,则进行下面的计算组法方程式求逆求K求改正数和平差值推算方位角和坐标 '求平差后坐标精度评定'Else'MsgBox "限差超限!", , "提示"'Exit Sub'End IfElseMsgBox "数据文件未打开!!", , "提示"Exit SubEnd Ifaa = TrueMsgBox "计算完毕!", , "提示"显示平差结果End Sub'''Private Sub 保存_Click()Dim ff$If aa = True ThenCommonDialog1.DialogTitle = "保存平差结果"CommonDialog1.Filter = "(*.txt)|*.txt"CommonDialog1.FileName = "平差结果.txt"CommonDialog1.ShowSaveff = CommonDialog1.FileNameIf ff = "" ThenMsgBox "文件名不能为空", , "警告"Exit SubEnd IfOpen ff For Output As #2 '以顺序文件方式保存文件,使用outputPrint #2, "平差结果:"Print #2, "---------------------------------------------------------------------------------------------"Print #2, " 单位权中误差 m0=" & Format(m0, "####.##") & " 秒"Print #2, "---------------------------------------------------------------------------------------------"Print #2, "点名", "x(m)", "y(m)", "点位误差(cm)", "E(cm)", "F(cm)", "Z(度分秒)"For i = 1 To n - 1Print #2, " " & Po(i).name, Format(Po(i).x, "########.####"), Format(Po(i).y, "########.####"), " " & Format(mk(i), "#####.##"), _" " & Format(e(i), "#####.##"), " " & Format(f(i), "#####.##"), " " & Format(zz(i), "###.#####")Next iPrint #2, "---------------------------------------------------------------------------------------------"Close #2cc = TrueMsgBox "保存完毕!", , "提示"ElseMsgBox "没有需要保存平差结果!", , "提示"Exit SubEnd IfEnd Sub'''Private Sub 退出_Click()If aa = True And cc = False Then提示.Show '若平差结果未保存则进行提示ElseEnd '若没有平差结果或平差结果已保存则退出End IfEnd Sub'''Private Sub 推算方位角和坐标()Po(0).t = tc + Po(0).l - 180If Po(0).t > 360 Then Po(0).t = Po(0).t - 360If Po(0).t < 0 Then Po(0).t = Po(0).t + 360For i = 1 To n'求方位角Po(i).t = Po(i - 1).t + Po(i).l - 180If Po(i).t > 360 Then Po(i).t = Po(i).t - 360If Po(i).t < 0 Then Po(i).t = Po(i).t + 360'求坐标Po(i).x = Po(i - 1).x + Po(i - 1).s * Cos(Po(i - 1).t / p0) 't要以度为单位Po(i).y = Po(i - 1).y + Po(i - 1).s * Sin(Po(i - 1).t / p0)Next iEnd Sub''角度改正数的单位是秒,边长改正数的单位是厘米'方向观测值中误差为单位权'方向观测值中误差的先验值为 m(秒)'角度观测值的权为 0.5'距离观测值中误差的先验值为 ms=e1+e2*s*0.0001(厘米)'Private Sub 求条件式()Dim sums!'求AFor i = 0 To n '求角度改正数系数A(0, n + i) = 1A(1, n + i) = (Po(i).y - Po(n).y) / 2062.65A(2, n + i) = (Po(n).x - Po(i).x) / 2062.65Q(n + i) = 2 '求角度观测值的权倒数Next iFor i = 0 To n - 1 '求边长改正数系数A(1, i) = Cos(Po(i).t / p0)A(2, i) = Sin(Po(i).t / p0)Q(i) = (e1 + e2 * Po(i).s * 0.0001) ^ 2 / m ^ 2 '求距离观测值的权倒数Next i'求WW(0) = (Po(n).t - tb) * 3600 '单位是sW(1) = (Po(n).x - B_x) * 100 '单位是cmW(2) = (Po(n).y - B_y) * 100 '单位是cmFor i = 0 To n - 1sums = sums + Po(i).sNext i'限差判断'这是首级图根导线的精度要求,其中 n+1 为测站数'If Abs(W(0)) > 40 * Sqr(n + 1) Or Sqr((W(1) / 100) ^ 2 + (W(2) / 100) ^ 2) / sums > 0.00025 Then '方位角闭合差和导线全长相对闭合差'Exit Sub'End If'dd = TrueEnd Sub'''Private Sub 组法方程式()Dim g%For i = 0 To 2For j = i To 2 '由于Naa是对称的,只求其上三角即可。