控制网复测平面基准归算程序(包含控制网复测平面基准计算,平面控制网稳定性计算,水准测段高差稳定计算三个程序功能)
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. import sqlite3
  2. import os
  3. import tkinter as tk
  4. from tkinter import messagebox
  5. import math
  6. import numpy as np
  7. import math
  8. import tkinter as tk
  9. import numpy as np
  10. from tkinter import messagebox
  11. from tkinter import *
  12. from PySide6.QtWidgets import QMessageBox
  13. # region 各种方法
  14. def to_utf8(text):
  15. str1 = text.encode('utf-8')
  16. return str1
  17. def jzys1(listy, zxzby, listx, zxzbx, sf):
  18. rlist = []
  19. listlen = len(listy)
  20. ll = 0
  21. while ll < listlen:
  22. # 第一个的值
  23. # num1 = round(((listx[ll] - zxzbx) / sf),0)
  24. # num2 = round(((listy[ll] - zxzby) / sf),0)
  25. num1 = listx[ll] - zxzbx
  26. num2 = listy[ll] - zxzby
  27. rlist.append(num1)
  28. rlist.append(num2)
  29. ll = ll + 1
  30. return rlist
  31. def jzys2(listy, zxzby, listx, zxzbx, sf):
  32. rlist = []
  33. listlen = len(listy)
  34. ll = 0
  35. while ll < listlen:
  36. # 第一个的值
  37. num2 = (-1) * (listx[ll] - zxzbx) / sf
  38. num1 = (listy[ll] - zxzby) / sf
  39. rlist.append(num1)
  40. rlist.append(num2)
  41. ll = ll + 1
  42. return rlist
  43. def jzys3(listy, aa, bb):
  44. rlist = []
  45. listlen = len(listy)
  46. ll = 0
  47. while ll < listlen:
  48. # 第一个的值
  49. num1 = aa
  50. num2 = bb
  51. rlist.append(num1)
  52. rlist.append(num2)
  53. ll = ll + 1
  54. return rlist
  55. def jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx, listnewy, zxzbnewy, listnewx, zxzbnewx, sf):
  56. rlist = []
  57. listlen = len(listnewx)
  58. ll = 0
  59. while ll < listlen:
  60. num1 = (listpastx[ll] - listnewx[ll] - zxzbpastx + zxzbnewx) / sf
  61. num2 = (listpasty[ll] - listnewy[ll] - zxzbpasty + zxzbnewy) / sf
  62. rlist.append(num1)
  63. rlist.append(num2)
  64. ll = ll + 1
  65. return rlist
  66. def jzys5(listp, zxzbp, sf):
  67. rlist = []
  68. listlen = len(listp)
  69. ll = 0
  70. while ll < listlen:
  71. num1 = (listp[ll] - zxzbp) / sf
  72. rlist.append(num1)
  73. ll = ll + 1
  74. return rlist
  75. def jzys6(listp, num):
  76. rlist = []
  77. listlen = len(listp)
  78. ll = 0
  79. while ll < listlen:
  80. num1 = listp[ll] * num
  81. rlist.append(num1)
  82. ll = ll + 1
  83. return rlist
  84. def cjh(listp):
  85. rp = 0
  86. listlen = len(listp)
  87. ll = 0
  88. while ll < listlen:
  89. num1 = listp[ll] * listp[ll]
  90. rp = rp + num1
  91. ll = ll + 1
  92. return rp
  93. def cjh2(lista, listb):
  94. rp = 0
  95. listlen = len(lista)
  96. ll = 0
  97. while ll < listlen:
  98. num1 = lista[ll] * listb[ll]
  99. rp = rp + num1
  100. ll = ll + 1
  101. return rp
  102. def gsys(listnewp, jxlist1, jylist1, lxlist, lylist, arrz, sf, zxzbnewp, zxzbpastp, ii):
  103. # 新x+(矩阵[jx1 jy1 lx1 ly1]*矩阵z)*缩放-新重心坐标x+旧重心坐标x
  104. rlist = []
  105. listlen = len(listnewp)
  106. ll = 0
  107. while ll < listlen:
  108. arr0 = np.array((jxlist1[ll], jylist1[ll],
  109. lxlist[2 * ll + ii], lylist[2 * ll + ii]))
  110. arr1 = np.matmul(arr0, arrz)
  111. arr3 = sf * arr1
  112. newp = listnewp[ll] + arr3 - zxzbnewp + zxzbpastp
  113. rlist.append(newp)
  114. ll = ll + 1
  115. return rlist
  116. def xcys(newlist, pastlist):
  117. listlen = len(newlist)
  118. ll = 0
  119. rlist = []
  120. while ll < listlen:
  121. num1 = newlist[ll] - pastlist[ll]
  122. num2 = num1 * 1000
  123. rlist.append(num2)
  124. ll = ll + 1
  125. return rlist
  126. def takeFirst(elem):
  127. return elem[0]
  128. # endregion
  129. def insert_into_database1(database, pastname, newname, beforename, excelname, listname1, listpastx1, listpasty1,
  130. listcgcs1, listbex, listbey, sxylist, wypd, gsx, gsy, listcgcs):
  131. # 转换下汉字
  132. utf_tn = to_utf8(excelname)
  133. utf_nn = to_utf8(newname)
  134. utf_pn = to_utf8(pastname)
  135. utf_bn = to_utf8(beforename)
  136. utf_bx = to_utf8('变形')
  137. utf_wd = to_utf8('稳定')
  138. # 将结果输出到数据库
  139. db1 = sqlite3.connect(database)
  140. # 获取游标
  141. cursor1 = db1.cursor()
  142. # 先清除已有数据,用来更新
  143. try:
  144. sqlstr3 = 'delete from WD_Result_Param WHERE TableName = ?'
  145. sqlstr4 = 'delete from WD_Result_Point WHERE TableName = ?'
  146. cursor1.execute(sqlstr3, (utf_tn,))
  147. cursor1.execute(sqlstr4, (utf_tn,))
  148. except:
  149. pass
  150. cursor1.execute(
  151. 'INSERT INTO WD_Result_Param(TableName,Last_ResultName,New_ResultName,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3) VALUES(?,?,?,?,?,?,?,?,?)',
  152. (utf_tn, utf_pn, utf_nn, sxylist[0], sxylist[1], sxylist[2], sxylist[3], sxylist[4], sxylist[5],))
  153. # WD_Result_Point的输入
  154. kk = -1
  155. kk1 = -1
  156. if (-1) in listcgcs:
  157. kk = 1
  158. # 记位移点个数
  159. wyd = 0
  160. for lname in listname1:
  161. # 获取对应索引号
  162. index1 = listname1.index(lname)
  163. PointName = lname
  164. First_X = listbex[index1]
  165. First_Y = listbey[index1]
  166. Last_X = listpastx1[index1]
  167. Last_Y = listpasty1[index1]
  168. Last_Wight = listcgcs1[index1]
  169. New_Wight = listcgcs[index1]
  170. # 位移点
  171. if New_Wight == -1:
  172. # 获取他原本的坐标和初始改算值进行对比
  173. for smx in jslist:
  174. if First_X == smx[0] and First_Y == smx[1]:
  175. numa3 = sxylist[0] * jslist1[index1][0]
  176. numa4 = sxylist[1] * jslist1[index1][1]
  177. numa5 = numa3 + numa4 + sxylist[2]
  178. numa6 = sxylist[3] * jslist1[index1][0]
  179. numa7 = sxylist[4] * jslist1[index1][1]
  180. numa8 = numa6 + numa7 + sxylist[5]
  181. Result_X = numa5
  182. Result_Y = numa8
  183. New_Wight = 1
  184. numb1 = (numa5 - First_X) * 1000
  185. numb2 = (numa8 - First_Y) * 1000
  186. numb3 = numb1 * numb1
  187. numb4 = numb2 * numb2
  188. numb5 = math.sqrt(numb3 + numb4)
  189. New_FirstX = numb1
  190. New_FirstY = numb2
  191. New_FirstP = numb5
  192. # 新-首有个位移判定
  193. if numb5 > wypd:
  194. NFDis_Ass = utf_bx
  195. else:
  196. NFDis_Ass = utf_wd
  197. numc1 = (numa5 - Last_X) * 1000
  198. numc2 = (numa8 - Last_Y) * 1000
  199. numc3 = numc1 * numc1
  200. numc4 = numc2 * numc2
  201. numc5 = math.sqrt(numc3 + numc4)
  202. New_LastX = numc1
  203. New_LastY = numc2
  204. New_LastP = numc5
  205. NLDis_Ass = utf_bx
  206. kk1 = 1
  207. wyd = wyd + 1
  208. break
  209. # 不是位移点
  210. else:
  211. # 全部都是稳定点
  212. if kk == -1:
  213. num3 = Last_X * Last_Wight
  214. num4 = num3 + gsx[index1]
  215. num5 = Last_Wight + 1
  216. num6 = num4 / num5
  217. num7 = Last_Y * Last_Wight
  218. num8 = num7 + gsy[index1]
  219. num10 = num8 / num5
  220. Result_X = num6
  221. Result_Y = num10
  222. New_Wight = num5
  223. numd1 = (num6 - First_X) * 1000
  224. numd2 = (num10 - First_Y) * 1000
  225. numd3 = numd1 * numd1
  226. numd4 = numd2 * numd2
  227. numd5 = math.sqrt(numd3 + numd4)
  228. New_FirstX = numd1
  229. New_FirstY = numd2
  230. New_FirstP = numd5
  231. # 新-首有个位移判定
  232. if numd5 > wypd:
  233. NFDis_Ass = utf_bx
  234. else:
  235. NFDis_Ass = utf_wd
  236. nume1 = (num6 - Last_X) * 1000
  237. nume2 = (num10 - Last_Y) * 1000
  238. nume3 = nume1 * nume1
  239. nume4 = nume2 * nume2
  240. nume5 = math.sqrt(nume3 + nume4)
  241. New_LastX = nume1
  242. New_LastY = nume2
  243. New_LastP = nume5
  244. NLDis_Ass = utf_wd
  245. # 有位移点,且已经走过了
  246. if kk == 1 and kk1 == 1:
  247. num3 = Last_X * Last_Wight
  248. num4 = num3 + gsx[index1 - wyd]
  249. num5 = Last_Wight + 1
  250. num6 = num4 / num5
  251. num7 = Last_Y * Last_Wight
  252. num8 = num7 + gsy[index1 - wyd]
  253. num10 = num8 / num5
  254. Result_X = num6
  255. Result_Y = num10
  256. New_Wight = num5
  257. numd1 = (num6 - First_X) * 1000
  258. numd2 = (num10 - First_Y) * 1000
  259. numd3 = numd1 * numd1
  260. numd4 = numd2 * numd2
  261. numd5 = math.sqrt(numd3 + numd4)
  262. New_FirstX = numd1
  263. New_FirstY = numd2
  264. New_FirstP = numd5
  265. # 新-首有个位移判定
  266. if numd5 > wypd:
  267. NFDis_Ass = utf_bx
  268. else:
  269. NFDis_Ass = utf_wd
  270. nume1 = (num6 - Last_X) * 1000
  271. nume2 = (num10 - Last_Y) * 1000
  272. nume3 = nume1 * nume1
  273. nume4 = nume2 * nume2
  274. nume5 = math.sqrt(nume3 + nume4)
  275. New_LastX = nume1
  276. New_LastY = nume2
  277. New_LastP = nume5
  278. NLDis_Ass = utf_wd
  279. # 有位移点,但没有走过
  280. if kk == 1 and kk1 == -1:
  281. num3 = Last_X * Last_Wight
  282. num4 = num3 + gsx[index1]
  283. num5 = Last_Wight + 1
  284. num6 = num4 / num5
  285. num7 = Last_Y * Last_Wight
  286. num8 = num7 + gsy[index1]
  287. num10 = num8 / num5
  288. Result_X = num6
  289. Result_Y = num10
  290. New_Wight = num5
  291. numd1 = (num6 - First_X) * 1000
  292. numd2 = (num10 - First_Y) * 1000
  293. numd3 = numd1 * numd1
  294. numd4 = numd2 * numd2
  295. numd5 = math.sqrt(numd3 + numd4)
  296. New_FirstX = numd1
  297. New_FirstY = numd2
  298. New_FirstP = numd5
  299. # 新-首有个位移判定
  300. if numd5 > wypd:
  301. NFDis_Ass = utf_bx
  302. else:
  303. NFDis_Ass = utf_wd
  304. nume1 = (num6 - Last_X) * 1000
  305. nume2 = (num10 - Last_Y) * 1000
  306. nume3 = nume1 * nume1
  307. nume4 = nume2 * nume2
  308. nume5 = math.sqrt(nume3 + nume4)
  309. New_LastX = nume1
  310. New_LastY = nume2
  311. New_LastP = nume5
  312. NLDis_Ass = utf_wd
  313. # 在这里整体输出
  314. cursor1.execute(
  315. 'INSERT INTO WD_Result_Point(TableName,First_ResultName,Last_ResultName,New_ResultName,First_X,First_Y,Last_X,Last_Y,Result_X,Result_Y,Last_Wight,New_Wight,New_FirstX,New_FirstY,New_FirstP,NFDis_Ass,New_LastX,New_LastY,New_LastP,NLDis_Ass,PointName) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
  316. (
  317. utf_tn, utf_bn, utf_pn, utf_nn, First_X, First_Y, Last_X, Last_Y, Result_X, Result_Y, Last_Wight,
  318. New_Wight,
  319. New_FirstX, New_FirstY, New_FirstP, NFDis_Ass, New_LastX, New_LastY, New_LastP, NLDis_Ass, PointName,))
  320. # 数据库执行
  321. db1.commit()
  322. # 做完一切后,先关闭游标,再关闭数据库
  323. cursor1.close()
  324. db1.close()
  325. gszbx = []
  326. gszby = []
  327. jslist = []
  328. jslist1 = []
  329. def bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx, listpasty, points,
  330. listcgcs, listbex, listbey, sf, dbpath, befname, finalname, lastname, js, file_name):
  331. np.set_printoptions(suppress=False)
  332. # pt用于给点数point计数
  333. # point会随着回递函数而减少
  334. pt = 0
  335. sumnewx = 0
  336. sumnewy = 0
  337. sumpastx = 0
  338. sumpasty = 0
  339. while pt < points:
  340. sumnewx = sumnewx + listnewx[pt]
  341. sumnewy = sumnewy + listnewy[pt]
  342. sumpastx = sumpastx + listpastx[pt]
  343. sumpasty = sumpasty + listpasty[pt]
  344. pt = pt + 1
  345. # 计算4个重心坐标(最新一期和上一期的)
  346. zxzbnewx = round((sumnewx / points), 7)
  347. zxzbnewy = round((sumnewy / points), 7)
  348. zxzbpastx = round((sumpastx / points), 7)
  349. zxzbpasty = round((sumpasty / points), 7)
  350. # 先计算平移参数
  351. # pycsx = abs(zxzbnewx - zxzbpastx) * 1000
  352. # pycsy = abs(zxzbnewy - zxzbpasty) * 1000
  353. pycsx = abs(zxzbnewx - zxzbpastx)
  354. pycsy = abs(zxzbnewy - zxzbpasty)
  355. # 分别得k,sita的值
  356. klist = jzys1(listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
  357. slist = jzys2(listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
  358. # 得dx,dy
  359. dxlist = jzys3(listnewy, 1, 0)
  360. dylist = jzys3(listnewy, 0, 1)
  361. # 矩阵太难用了,还是手动计算
  362. # 分别计算k、s、dx、dy的乘积和
  363. k2 = cjh(klist)
  364. s2 = cjh(slist)
  365. dx2 = cjh(dxlist)
  366. dy2 = cjh(dylist)
  367. # 这里再创建矩阵1
  368. arr1 = np.array(((k2, 0, 0, 0), (0, s2, 0, 0),
  369. (0, 0, dx2, 0), (0, 0, 0, dy2)))
  370. # 矩阵1的逆矩阵矩阵2
  371. arr2 = np.linalg.inv(arr1)
  372. # 求矩阵l
  373. llist = jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx,
  374. listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
  375. # 得到数列e1,e2,e3,e4
  376. e1 = cjh2(klist, llist)
  377. e2 = cjh2(slist, llist)
  378. e3 = cjh2(dxlist, llist)
  379. e4 = cjh2(dylist, llist)
  380. arrl = np.array(((e1), (e2), (e3), (e4)))
  381. # 得到矩阵z
  382. arrz = np.matmul(arr2, arrl)
  383. # 求转换矩阵
  384. jxlist1 = jzys5(listnewx, zxzbnewx, sf)
  385. jylist1 = jzys5(listnewy, zxzbnewy, sf)
  386. jxlist2 = jylist1
  387. # jylist2 = jxlist1 * (-1)
  388. jylist2 = jzys6(jxlist1, -1)
  389. lxlist = jzys3(jylist1, 1, 0)
  390. lylist = jzys3(jylist1, 0, 1)
  391. # 求改算坐标
  392. gsx = gsys(listnewx, jxlist1, jylist1, lxlist,
  393. lylist, arrz, sf, zxzbnewx, zxzbpastx, 0)
  394. gsy = gsys(listnewy, jxlist2, jylist2, lxlist,
  395. lylist, arrz, sf, zxzbnewy, zxzbpasty, 1)
  396. # 还是要先求较差
  397. xcx = xcys(gsx, listpastx)
  398. xcy = xcys(gsy, listpasty)
  399. # 这里记录下第一次所有点的改算坐标
  400. if js == 0:
  401. lengs = len(gsx)
  402. xx = 0
  403. while xx < lengs:
  404. gszbx.append(gsx[xx])
  405. gszby.append(gsy[xx])
  406. zblist1 = []
  407. zblist1.append(listbex[xx])
  408. zblist1.append(listbey[xx])
  409. zblist1.append(gsx[xx])
  410. zblist1.append(gsy[xx])
  411. zblist1.append(xcx[xx])
  412. zblist1.append(xcy[xx])
  413. jslist.append(zblist1)
  414. zblist2 = []
  415. zblist2.append(listnewx[xx])
  416. zblist2.append(listnewy[xx])
  417. jslist1.append(zblist2)
  418. xx = xx + 1
  419. # 后面不需要经过这个if
  420. # 判定方式是用差值平方和和位移对比
  421. gxpd = 0
  422. lenxc = len(xcx)
  423. yy = 0
  424. while yy < lenxc:
  425. sumxcx = xcx[yy] * xcx[yy]
  426. sumxcy = xcy[yy] * xcy[yy]
  427. sumxc = sumxcx + sumxcy
  428. xcpd = math.sqrt(sumxc)
  429. if xcpd > wypd:
  430. gxpd = -1
  431. break
  432. yy = yy + 1
  433. if gxpd == 0:
  434. # 输出之前把转换参数都算出来
  435. # X=(z1+1)*x+z2*y+(旧重心坐标x-新重心坐标x-新重心坐标x*z1-新重心坐标y*z2+z3)
  436. # Y=(-z2)*x+(z1+1)*y+(z1*新重心坐标y+新重心坐标x*z2+z4+旧重心坐标y-新重心坐标y)
  437. n1 = float(arrz[0]) + 1
  438. n2 = float(arrz[1])
  439. s1 = zxzbnewx * float(arrz[0])
  440. s2 = zxzbnewy * float(arrz[1])
  441. n3 = zxzbpastx - zxzbnewx - s1 - s2 + float(arrz[2])
  442. n4 = (-1) * float(arrz[1])
  443. n5 = n1
  444. s3 = (-1) * float(arrz[0]) * zxzbnewy
  445. s4 = float(arrz[1]) * zxzbnewx
  446. n6 = s3 + s4 + float(arrz[3]) + zxzbpasty - zxzbnewy
  447. sxylist = []
  448. sxylist.append(n1)
  449. sxylist.append(n2)
  450. sxylist.append(n3)
  451. sxylist.append(n4)
  452. sxylist.append(n5)
  453. sxylist.append(n6)
  454. # 输出
  455. relist1 = []
  456. relist1.append(listname)
  457. relist1.append(xcx)
  458. relist1.append(xcy)
  459. relist1.append(listcgcs)
  460. relist1.append(gszbx)
  461. relist1.append(gszby)
  462. relist1.append(sxylist)
  463. # 存入数据库
  464. insert_into_database1(dbpath, lastname, finalname, befname, file_name, listname1, listpastx1, listpasty1,
  465. listcgcs1, listbex, listbey, sxylist, wypd, gsx, gsy, listcgcs)
  466. else:
  467. # 先把所有的合在一起,方便删除
  468. lenlist1 = len(xcx)
  469. ii = 0
  470. relist1 = []
  471. while ii < lenlist1:
  472. smlist1 = []
  473. nn2 = xcx[ii] * xcx[ii]
  474. mm2 = xcy[ii] * xcy[ii]
  475. nm2 = math.sqrt(nn2 + mm2)
  476. smlist1.append(nm2)
  477. smlist1.append(listname[ii])
  478. smlist1.append(listnewx[ii])
  479. smlist1.append(listnewy[ii])
  480. smlist1.append(listpastx[ii])
  481. smlist1.append(listpasty[ii])
  482. relist1.append(smlist1)
  483. ii = ii + 1
  484. # 直接删除最大的那个
  485. relist1.sort(key=takeFirst, reverse=True)
  486. num1 = relist1[0]
  487. # 获取name
  488. num2 = num1[1]
  489. ii2 = 0
  490. mm2 = 0
  491. while ii2 < lenlist1:
  492. if listname[ii2] == num2:
  493. del listname[ii2]
  494. del listnewx[ii2]
  495. del listnewy[ii2]
  496. del listpastx[ii2]
  497. del listpasty[ii2]
  498. points = points - 1
  499. break
  500. else:
  501. ii2 = ii2 + 1
  502. while mm2 < len(listcgcs):
  503. if listname1[mm2] == num2:
  504. listcgcs[mm2] = -1
  505. break
  506. else:
  507. mm2 = mm2 + 1
  508. print(" Finish!")
  509. js1 = 1
  510. bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx,
  511. listpasty, points, listcgcs, listbex, listbey, sf, dbpath, befname, finalname, lastname, js1, file_name)
  512. def tablein(dbpath, file_name):
  513. # 收集每一列的数据,方便后期计算
  514. listname1 = []
  515. listpastx1 = []
  516. listpasty1 = []
  517. listcgcs1 = []
  518. listname = []
  519. listnewx = []
  520. listnewy = []
  521. listpastx = []
  522. listpasty = []
  523. # 成果次数
  524. listcgcs = []
  525. # 最早的
  526. listbex = []
  527. listbey = []
  528. points = 0
  529. # 查询,提取需要的数据
  530. db2 = sqlite3.connect(dbpath)
  531. cursor2 = db2.cursor()
  532. utfstr1 = to_utf8(file_name)
  533. sqlstr1 = 'SELECT * FROM WD_Input_Point WHERE TableName = ?'
  534. cursor2.execute(sqlstr1, (utfstr1,))
  535. all_da = cursor2.fetchall()
  536. for da in all_da:
  537. listbex.append(da[4])
  538. listbey.append(da[5])
  539. listpastx.append(da[6])
  540. listpastx1.append(da[6])
  541. listpasty.append(da[7])
  542. listpasty1.append(da[7])
  543. listnewx.append(da[8])
  544. listnewy.append(da[9])
  545. listcgcs.append(da[10])
  546. listcgcs1.append(da[10])
  547. points = points + 1
  548. listname.append(da[11])
  549. listname1.append(da[11])
  550. sqlstr2 = 'SELECT * FROM WD_Input_Param WHERE TableName = ?'
  551. cursor2.execute(sqlstr2, (utfstr1,))
  552. all_par = cursor2.fetchall()
  553. befname = all_par[0][0].decode('utf-8')
  554. lastname = all_par[0][1].decode('utf-8')
  555. finalname = all_par[0][2].decode('utf-8')
  556. # pjbc是平均边长
  557. # fxzwc是方向中误差,zrbzwc是最弱边边长相对中误差,pjbcs是平均边数,pjfxs是平均方向数,sf是缩放值
  558. # 新增总边数zbs,总方向数zfxs
  559. # 先计算位移判断值
  560. pjbc = all_par[0][3]
  561. fxzwc = all_par[0][4]
  562. zbs = all_par[0][5]
  563. zfxs = all_par[0][7]
  564. sf = all_par[0][9]
  565. pjbcs = zbs / points
  566. pjfxs = zfxs / points
  567. # 再拆细点
  568. wy1 = pjbc / 1000
  569. wy2 = wy1 + 1
  570. wypd1 = wy2 * wy2 / pjbcs
  571. # 好像206.265是常数系数
  572. wy3 = pjbc * fxzwc / 206.265
  573. wypd2 = wy3 * wy3 / pjfxs
  574. wypd3 = math.sqrt(wypd1 + wypd2)
  575. wypd = round((wypd3 * 2 * math.sqrt(2)), 9)
  576. wypd0 = wypd
  577. js = 0
  578. return listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx, listpasty, points, listcgcs, listbex, listbey, sf, befname, finalname, lastname, js
  579. # 主函数 计算
  580. def main_function(file_name, dbpath):
  581. try:
  582. # 从数据库中调用
  583. listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx, listpasty, points, listcgcs, listbex, listbey, sf, befname, finalname, lastname, js = tablein(
  584. dbpath, file_name)
  585. # 计算
  586. bhjs(listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx, listpasty,
  587. points, listcgcs, listbex, listbey, sf, dbpath, befname, finalname, lastname, js, file_name)
  588. QMessageBox.information(None, "提示", f"文件 '{file_name}' 计算成功!")
  589. except Exception as e:
  590. QMessageBox.critical(None, "错误", f"文件 '{file_name}' 计算失败!错误信息: {str(e)}")