|
@@ -1,17 +1,18 @@
|
1
|
1
|
import sqlite3
|
2
|
2
|
import os
|
3
|
|
-import tkinter as tk
|
4
|
|
-from tkinter import messagebox
|
5
|
3
|
import math
|
6
|
4
|
import numpy as np
|
|
5
|
+from PySide6.QtWidgets import QMessageBox
|
7
|
6
|
|
8
|
|
-#region 各种方法
|
|
7
|
+
|
|
8
|
+# region 各种方法
|
9
|
9
|
|
10
|
10
|
def to_utf8(text):
|
11
|
11
|
str1 = text.encode('utf-8')
|
12
|
12
|
return str1
|
13
|
13
|
|
14
|
|
-def sfjs(gsx,listx,gsy,listy):
|
|
14
|
+
|
|
15
|
+def sfjs(gsx, listx, gsy, listy):
|
15
|
16
|
s1 = gsx[len(gsx) - 1] - gsx[0]
|
16
|
17
|
s2 = s1 * s1
|
17
|
18
|
s3 = gsy[len(gsy) - 1] - gsy[0]
|
|
@@ -24,10 +25,11 @@ def sfjs(gsx,listx,gsy,listy):
|
24
|
25
|
t4 = t3 * t3
|
25
|
26
|
t5 = t2 + t4
|
26
|
27
|
t6 = math.sqrt(t5)
|
27
|
|
- num1 = round(s6/t6,8)
|
|
28
|
+ num1 = round(s6 / t6, 8)
|
28
|
29
|
return num1
|
29
|
30
|
|
30
|
|
-def mxjd(gs,nw):
|
|
31
|
+
|
|
32
|
+def mxjd(gs, nw):
|
31
|
33
|
ii = 0
|
32
|
34
|
sum1 = 0
|
33
|
35
|
while ii < len(gs):
|
|
@@ -40,7 +42,8 @@ def mxjd(gs,nw):
|
40
|
42
|
num1 = s4 * 1000
|
41
|
43
|
return num1
|
42
|
44
|
|
43
|
|
-def xzjs(gsx,listx,gsy,listy):
|
|
45
|
+
|
|
46
|
+def xzjs(gsx, listx, gsy, listy):
|
44
|
47
|
s1 = gsx[len(gsx) - 1] - gsx[0]
|
45
|
48
|
s2 = gsy[len(gsy) - 1] - gsy[0]
|
46
|
49
|
s3 = s2 / s1
|
|
@@ -53,7 +56,8 @@ def xzjs(gsx,listx,gsy,listy):
|
53
|
56
|
num1 = n1 * 180 / math.pi * 3600
|
54
|
57
|
return num1
|
55
|
58
|
|
56
|
|
-def gsjs(x,y,nlist):
|
|
59
|
+
|
|
60
|
+def gsjs(x, y, nlist):
|
57
|
61
|
listgsx = []
|
58
|
62
|
xstr1 = nlist[0] * x
|
59
|
63
|
xstr2 = nlist[1] * y
|
|
@@ -65,6 +69,7 @@ def gsjs(x,y,nlist):
|
65
|
69
|
listgsx.append(yy)
|
66
|
70
|
return listgsx
|
67
|
71
|
|
|
72
|
+
|
68
|
73
|
def jzys1(listy, zxzby, listx, zxzbx, sf):
|
69
|
74
|
rlist = []
|
70
|
75
|
listlen = len(listy)
|
|
@@ -80,6 +85,7 @@ def jzys1(listy, zxzby, listx, zxzbx, sf):
|
80
|
85
|
ll = ll + 1
|
81
|
86
|
return rlist
|
82
|
87
|
|
|
88
|
+
|
83
|
89
|
def jzys2(listy, zxzby, listx, zxzbx, sf):
|
84
|
90
|
rlist = []
|
85
|
91
|
listlen = len(listy)
|
|
@@ -93,6 +99,7 @@ def jzys2(listy, zxzby, listx, zxzbx, sf):
|
93
|
99
|
ll = ll + 1
|
94
|
100
|
return rlist
|
95
|
101
|
|
|
102
|
+
|
96
|
103
|
def jzys3(listy, aa, bb):
|
97
|
104
|
rlist = []
|
98
|
105
|
listlen = len(listy)
|
|
@@ -106,6 +113,7 @@ def jzys3(listy, aa, bb):
|
106
|
113
|
ll = ll + 1
|
107
|
114
|
return rlist
|
108
|
115
|
|
|
116
|
+
|
109
|
117
|
def jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx, listnewy, zxzbnewy, listnewx, zxzbnewx, sf):
|
110
|
118
|
rlist = []
|
111
|
119
|
listlen = len(listnewx)
|
|
@@ -113,11 +121,12 @@ def jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx, listnewy, zxzbnewy, listne
|
113
|
121
|
while ll < listlen:
|
114
|
122
|
num1 = (listpastx[ll] - listnewx[ll] - zxzbpastx + zxzbnewx) / sf
|
115
|
123
|
num2 = (listpasty[ll] - listnewy[ll] - zxzbpasty + zxzbnewy) / sf
|
116
|
|
- rlist.append(round(num1,6))
|
117
|
|
- rlist.append(round(num2,6))
|
|
124
|
+ rlist.append(round(num1, 6))
|
|
125
|
+ rlist.append(round(num2, 6))
|
118
|
126
|
ll = ll + 1
|
119
|
127
|
return rlist
|
120
|
128
|
|
|
129
|
+
|
121
|
130
|
def jzys5(listp, zxzbp, sf):
|
122
|
131
|
rlist = []
|
123
|
132
|
listlen = len(listp)
|
|
@@ -128,6 +137,7 @@ def jzys5(listp, zxzbp, sf):
|
128
|
137
|
ll = ll + 1
|
129
|
138
|
return rlist
|
130
|
139
|
|
|
140
|
+
|
131
|
141
|
def jzys6(listp, num):
|
132
|
142
|
rlist = []
|
133
|
143
|
listlen = len(listp)
|
|
@@ -138,6 +148,7 @@ def jzys6(listp, num):
|
138
|
148
|
ll = ll + 1
|
139
|
149
|
return rlist
|
140
|
150
|
|
|
151
|
+
|
141
|
152
|
def cjh(listp):
|
142
|
153
|
rp = 0
|
143
|
154
|
listlen = len(listp)
|
|
@@ -148,6 +159,7 @@ def cjh(listp):
|
148
|
159
|
ll = ll + 1
|
149
|
160
|
return rp
|
150
|
161
|
|
|
162
|
+
|
151
|
163
|
def cjh2(lista, listb):
|
152
|
164
|
rp = 0
|
153
|
165
|
listlen = len(lista)
|
|
@@ -158,6 +170,7 @@ def cjh2(lista, listb):
|
158
|
170
|
ll = ll + 1
|
159
|
171
|
return rp
|
160
|
172
|
|
|
173
|
+
|
161
|
174
|
def gsys(listnewp, jxlist1, jylist1, lxlist, lylist, arrz, sf, zxzbnewp, zxzbpastp, ii):
|
162
|
175
|
# 新x+(矩阵[jx1 jy1 lx1 ly1]*矩阵z)*缩放-新重心坐标x+旧重心坐标x
|
163
|
176
|
rlist = []
|
|
@@ -165,7 +178,7 @@ def gsys(listnewp, jxlist1, jylist1, lxlist, lylist, arrz, sf, zxzbnewp, zxzbpas
|
165
|
178
|
ll = 0
|
166
|
179
|
while ll < listlen:
|
167
|
180
|
arr0 = np.array((jxlist1[ll], jylist1[ll],
|
168
|
|
- lxlist[2*ll+ii], lylist[2*ll+ii]))
|
|
181
|
+ lxlist[2 * ll + ii], lylist[2 * ll + ii]))
|
169
|
182
|
arr1 = np.matmul(arr0, arrz)
|
170
|
183
|
arr3 = sf * arr1
|
171
|
184
|
newp = listnewp[ll] + arr3 - zxzbnewp + zxzbpastp
|
|
@@ -173,91 +186,117 @@ def gsys(listnewp, jxlist1, jylist1, lxlist, lylist, arrz, sf, zxzbnewp, zxzbpas
|
173
|
186
|
ll = ll + 1
|
174
|
187
|
return rlist
|
175
|
188
|
|
|
189
|
+
|
176
|
190
|
def xcys(newlist, pastlist):
|
177
|
191
|
listlen = len(newlist)
|
178
|
192
|
ll = 0
|
179
|
193
|
rlist = []
|
180
|
194
|
while ll < listlen:
|
181
|
|
- num1 =pastlist[ll] - newlist[ll]
|
|
195
|
+ num1 = pastlist[ll] - newlist[ll]
|
182
|
196
|
num2 = num1 * 1000
|
183
|
197
|
rlist.append(num2)
|
184
|
198
|
ll = ll + 1
|
185
|
199
|
return rlist
|
186
|
200
|
|
|
201
|
+
|
187
|
202
|
def takeFirst(elem):
|
188
|
|
- return elem[0]
|
|
203
|
+ return elem[0]
|
|
204
|
+
|
189
|
205
|
|
190
|
|
-#endregion
|
|
206
|
+# endregion
|
191
|
207
|
|
192
|
|
-def insert_into_database1(database,utf_tn,listname1,listname,gsx,gsy,listpastx1,listpasty1,listnewx1,listnewy1,nlist,utf_pan,utf_nn,wypd,sfxs,xzj,pycsx,pycsy,mxjdx,mxjdy,zxzbpastx,zxzbpasty,zxzbnewx,zxzbnewy,n1,n2,n3,n4,n5,n6):
|
193
|
|
- #将结果输出到数据库
|
|
208
|
+def insert_into_database1(database, utf_tn, listname1, listname, gsx, gsy, listpastx1, listpasty1, listnewx1, listnewy1,
|
|
209
|
+ nlist, utf_pan, utf_nn, wypd, sfxs, xzj, pycsx, pycsy, mxjdx, mxjdy, zxzbpastx, zxzbpasty,
|
|
210
|
+ zxzbnewx, zxzbnewy, n1, n2, n3, n4, n5, n6):
|
|
211
|
+ # 将结果输出到数据库
|
194
|
212
|
db1 = sqlite3.connect(database)
|
195
|
|
- #获取游标
|
|
213
|
+ # 获取游标
|
196
|
214
|
cursor1 = db1.cursor()
|
197
|
|
- #先清除已有数据,用来更新
|
|
215
|
+ # 先清除已有数据,用来更新
|
198
|
216
|
try:
|
199
|
217
|
sqlstr3 = 'delete from GS_Trans_Param WHERE TableName = ?'
|
200
|
218
|
sqlstr4 = 'delete from GS_Trans_Point WHERE TableName = ?'
|
201
|
219
|
sqlstr5 = 'delete from GS_Result_Point WHERE TableName = ?'
|
202
|
|
- cursor1.execute(sqlstr3,(utf_tn,))
|
203
|
|
- cursor1.execute(sqlstr4,(utf_tn,))
|
204
|
|
- cursor1.execute(sqlstr5,(utf_tn,))
|
|
220
|
+ cursor1.execute(sqlstr3, (utf_tn,))
|
|
221
|
+ cursor1.execute(sqlstr4, (utf_tn,))
|
|
222
|
+ cursor1.execute(sqlstr5, (utf_tn,))
|
205
|
223
|
except:
|
206
|
224
|
pass
|
207
|
|
- cursor1.execute('INSERT INTO GS_Trans_Param(TableName,Last_ResultName,New_ResultName,Dis_RefValue,Pt_CalCount,Scale_Factor,Rotate_Angle,Trans_X,Trans_Y,Model_AccX,Model_AccY,Last_GcX,Last_GcY,New_GcX,New_GcY,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',(utf_tn,utf_pan,utf_nn,wypd,len(listname),sfxs,xzj,pycsx,pycsy,mxjdx,mxjdy,zxzbpastx,zxzbpasty,zxzbnewx,zxzbnewy,n1,n2,n3,n4,n5,n6,))
|
208
|
|
- #Trans_Point和Result_Point一起存
|
|
225
|
+ cursor1.execute(
|
|
226
|
+ 'INSERT INTO GS_Trans_Param(TableName,Last_ResultName,New_ResultName,Dis_RefValue,Pt_CalCount,Scale_Factor,Rotate_Angle,Trans_X,Trans_Y,Model_AccX,Model_AccY,Last_GcX,Last_GcY,New_GcX,New_GcY,Formula_X1,Formula_X2,Formula_X3,Formula_Y1,Formula_Y2,Formula_Y3) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
|
|
227
|
+ (utf_tn, utf_pan, utf_nn, wypd, len(listname), sfxs, xzj, pycsx, pycsy, mxjdx, mxjdy, zxzbpastx, zxzbpasty,
|
|
228
|
+ zxzbnewx, zxzbnewy, n1, n2, n3, n4, n5, n6,))
|
|
229
|
+ # Trans_Point和Result_Point一起存
|
209
|
230
|
for iname in listname1:
|
210
|
231
|
if iname in listname:
|
211
|
|
- #属于没问题点的
|
212
|
|
- #直接使用gsx,gsy
|
|
232
|
+ # 属于没问题点的
|
|
233
|
+ # 直接使用gsx,gsy
|
213
|
234
|
utf_pointname = to_utf8(str(iname))
|
214
|
235
|
wystr = to_utf8('稳定')
|
215
|
236
|
index1 = listname.index(iname)
|
216
|
|
- numm1 = round(gsx[index1],4)
|
217
|
|
- numm2 = round(gsy[index1],4)
|
218
|
|
- #先找到首次的index
|
|
237
|
+ numm1 = round(gsx[index1], 4)
|
|
238
|
+ numm2 = round(gsy[index1], 4)
|
|
239
|
+ # 先找到首次的index
|
219
|
240
|
index2 = listname1.index(iname)
|
220
|
|
- r1 = (listpastx1[index2] - gsx[index1])*1000
|
221
|
|
- r2 = (listpasty1[index2] - gsy[index1])*1000
|
|
241
|
+ r1 = (listpastx1[index2] - gsx[index1]) * 1000
|
|
242
|
+ r2 = (listpasty1[index2] - gsy[index1]) * 1000
|
222
|
243
|
r3 = r1 * r1
|
223
|
244
|
r4 = r2 * r2
|
224
|
245
|
r5 = r3 + r4
|
225
|
|
- r6 = round(math.sqrt(r5),1)
|
|
246
|
+ r6 = round(math.sqrt(r5), 1)
|
226
|
247
|
numn1 = listpastx1[index2]
|
227
|
248
|
numn2 = listnewx1[index2]
|
228
|
|
- cursor1.execute('INSERT INTO GS_Trans_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,New_X,New_Y) VALUES (?,?,?,?,?,?,?,?)',(utf_tn,utf_pan,utf_nn,utf_pointname,listpastx1[index2],listpasty1[index2],listnewx1[index2],listnewy1[index2],))
|
229
|
|
- cursor1.execute('INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',(utf_tn,utf_pan,utf_nn,utf_pointname,listpastx1[index2],listpasty1[index2],listpastx1[index2],listpasty1[index2],numm1,numm2,0,0,0,r1,r2,r6,wystr,))
|
|
249
|
+ cursor1.execute(
|
|
250
|
+ 'INSERT INTO GS_Trans_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,New_X,New_Y) VALUES (?,?,?,?,?,?,?,?)',
|
|
251
|
+ (utf_tn, utf_pan, utf_nn, utf_pointname, listpastx1[index2], listpasty1[index2], listnewx1[index2],
|
|
252
|
+ listnewy1[index2],))
|
|
253
|
+ cursor1.execute(
|
|
254
|
+ 'INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
|
|
255
|
+ (utf_tn, utf_pan, utf_nn, utf_pointname, listpastx1[index2], listpasty1[index2], listpastx1[index2],
|
|
256
|
+ listpasty1[index2], numm1, numm2, 0, 0, 0, r1, r2, r6, wystr,))
|
230
|
257
|
else:
|
231
|
258
|
index2 = listname1.index(iname)
|
232
|
259
|
utf_pointname = to_utf8(str(iname))
|
233
|
|
- #首先判断有没有第一个点
|
|
260
|
+ # 首先判断有没有第一个点
|
234
|
261
|
if listnewx1[index2] != 0:
|
235
|
|
- #有问题的点,使用公式跑
|
236
|
|
- listxy = gsjs(listnewx1[index2],listnewy1[index2],nlist)
|
237
|
|
- #判断有没有第一次的数据,没有就不写
|
|
262
|
+ # 有问题的点,使用公式跑
|
|
263
|
+ listxy = gsjs(listnewx1[index2], listnewy1[index2], nlist)
|
|
264
|
+ # 判断有没有第一次的数据,没有就不写
|
238
|
265
|
if listpastx1[index2] != 0:
|
239
|
|
- r1 = (listpastx1[index2] - listxy[0])*1000
|
240
|
|
- r2 = (listpasty1[index2] - listxy[1])*1000
|
|
266
|
+ r1 = (listpastx1[index2] - listxy[0]) * 1000
|
|
267
|
+ r2 = (listpasty1[index2] - listxy[1]) * 1000
|
241
|
268
|
r3 = r1 * r1
|
242
|
269
|
r4 = r2 * r2
|
243
|
270
|
r5 = r3 + r4
|
244
|
|
- r6 = round(math.sqrt(r5),1)
|
|
271
|
+ r6 = round(math.sqrt(r5), 1)
|
245
|
272
|
if r6 > 500:
|
246
|
273
|
wystr = to_utf8('复建')
|
247
|
|
- cursor1.execute('INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',(utf_tn,utf_pan,utf_nn,utf_pointname,listpastx1[index2],listpasty1[index2],listxy[0],listxy[1],listxy[0],listxy[1],r1,r2,r6,r1,r2,r6,wystr,))
|
|
274
|
+ cursor1.execute(
|
|
275
|
+ 'INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
|
|
276
|
+ (utf_tn, utf_pan, utf_nn, utf_pointname, listpastx1[index2], listpasty1[index2], listxy[0],
|
|
277
|
+ listxy[1], listxy[0], listxy[1], r1, r2, r6, r1, r2, r6, wystr,))
|
248
|
278
|
else:
|
249
|
279
|
wystr = to_utf8('位移')
|
250
|
|
- cursor1.execute('INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',(utf_tn,utf_pan,utf_nn,utf_pointname,listpastx1[index2],listpasty1[index2],listxy[0],listxy[1],listxy[0],listxy[1],r1,r2,r6,r1,r2,r6,wystr,))
|
|
280
|
+ cursor1.execute(
|
|
281
|
+ 'INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
|
|
282
|
+ (utf_tn, utf_pan, utf_nn, utf_pointname, listpastx1[index2], listpasty1[index2], listxy[0],
|
|
283
|
+ listxy[1], listxy[0], listxy[1], r1, r2, r6, r1, r2, r6, wystr,))
|
251
|
284
|
else:
|
252
|
285
|
wystr = to_utf8('新建')
|
253
|
|
- cursor1.execute('INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',(utf_tn,utf_pan,utf_nn,utf_pointname,listpastx1[index2],listpasty1[index2],listnewx1[index2],listnewy1[index2],listpastx1[index2],listpasty1[index2],0,0,0,0,0,0,wystr,))
|
254
|
|
- #数据库执行
|
|
286
|
+ cursor1.execute(
|
|
287
|
+ 'INSERT INTO GS_Result_Point(TableName,Last_ResultName,New_ResultName,PointName,Last_X,Last_Y,Result_X,Result_Y,Cal_X,Cal_Y,Last_ResultX,Last_ResultY,Last_ResultP,Last_CalX,Last_CalY,Last_CalP,Dis_Ass) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
|
|
288
|
+ (utf_tn, utf_pan, utf_nn, utf_pointname, listpastx1[index2], listpasty1[index2],
|
|
289
|
+ listnewx1[index2], listnewy1[index2], listpastx1[index2], listpasty1[index2], 0, 0, 0, 0, 0, 0,
|
|
290
|
+ wystr,))
|
|
291
|
+ # 数据库执行
|
255
|
292
|
db1.commit()
|
256
|
|
- #做完一切后,先关闭游标,再关闭数据库
|
|
293
|
+ # 做完一切后,先关闭游标,再关闭数据库
|
257
|
294
|
cursor1.close()
|
258
|
295
|
db1.close()
|
259
|
296
|
|
260
|
|
-def tablein(outpath,str1):
|
|
297
|
+
|
|
298
|
+def tablein(outpath, str1):
|
|
299
|
+ print(f"Connecting to database at path: {outpath}")
|
261
|
300
|
listcgcs1 = []
|
262
|
301
|
listname1 = []
|
263
|
302
|
listpastx1 = []
|
|
@@ -271,12 +310,12 @@ def tablein(outpath,str1):
|
271
|
310
|
listnewx1 = []
|
272
|
311
|
listnewy1 = []
|
273
|
312
|
points = 0
|
274
|
|
- #查询,提取需要的数据
|
|
313
|
+ # 查询,提取需要的数据
|
275
|
314
|
db2 = sqlite3.connect(outpath)
|
276
|
315
|
cursor2 = db2.cursor()
|
277
|
316
|
utfstr1 = to_utf8(str1)
|
278
|
317
|
sqlstr1 = 'SELECT * FROM GS_Input_Point WHERE TableName = ?'
|
279
|
|
- cursor2.execute(sqlstr1,(utfstr1,))
|
|
318
|
+ cursor2.execute(sqlstr1, (utfstr1,))
|
280
|
319
|
all_da = cursor2.fetchall()
|
281
|
320
|
for da in all_da:
|
282
|
321
|
listpastx.append(da[3])
|
|
@@ -293,8 +332,10 @@ def tablein(outpath,str1):
|
293
|
332
|
listcgcs1.append(da[8])
|
294
|
333
|
points = points + 1
|
295
|
334
|
sqlstr2 = 'SELECT * FROM GS_Input_Param WHERE TableName = ?'
|
296
|
|
- cursor2.execute(sqlstr2,(utfstr1,))
|
|
335
|
+ cursor2.execute(sqlstr2, (utfstr1,))
|
297
|
336
|
all_par = cursor2.fetchall()
|
|
337
|
+ if not all_par:
|
|
338
|
+ raise ValueError(f"No data found in GS_Input_Param for TableName: {str1}")
|
298
|
339
|
pastname = all_par[0][1].decode('utf-8')
|
299
|
340
|
newname = all_par[0][2].decode('utf-8')
|
300
|
341
|
# pjbc是平均边长
|
|
@@ -319,18 +360,20 @@ def tablein(outpath,str1):
|
319
|
360
|
wypd3 = math.sqrt(wypd1 + wypd2)
|
320
|
361
|
wypd = round(wypd3 * 3, 4)
|
321
|
362
|
wypd0 = wypd
|
322
|
|
- #更新下数据库(参数部分)
|
|
363
|
+ # 更新下数据库(参数部分)
|
323
|
364
|
sqlstr3 = 'update GS_Input_Param set Pt_Count=?,Avg_MSL=?,Avg_Dir=? WHERE TableName = ?'
|
324
|
|
- cursor2.execute(sqlstr3,(points,pjbcs,pjfxs,utfstr1,))
|
325
|
|
- #数据库执行
|
|
365
|
+ cursor2.execute(sqlstr3, (points, pjbcs, pjfxs, utfstr1,))
|
|
366
|
+ # 数据库执行
|
326
|
367
|
db2.commit()
|
327
|
|
- #做完一切后,先关闭游标,再关闭数据库
|
|
368
|
+ # 做完一切后,先关闭游标,再关闭数据库
|
328
|
369
|
cursor2.close()
|
329
|
370
|
db2.close()
|
330
|
371
|
js = 0
|
331
|
|
- return listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx,listpasty, points, listcgcs,sf, newname, pastname, js,listnewx1,listnewy1
|
|
372
|
+ return listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx, listpasty, points, listcgcs, sf, newname, pastname, js, listnewx1, listnewy1
|
332
|
373
|
|
333
|
|
-def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx, listpasty, points, listcgcs, sf, newname, pastname, js,listnewx1,listnewy1,excelname):
|
|
374
|
+
|
|
375
|
+def bhjs(dbpath, listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx, listpasty,
|
|
376
|
+ points, listcgcs, sf, newname, pastname, js, listnewx1, listnewy1, excelname):
|
334
|
377
|
np.set_printoptions(suppress=False)
|
335
|
378
|
# pt用于给点数point计数
|
336
|
379
|
# point会随着回递函数而减少
|
|
@@ -363,8 +406,8 @@ def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, li
|
363
|
406
|
# 先计算平移参数
|
364
|
407
|
# pycsx = abs(zxzbnewx - zxzbpastx) * 1000
|
365
|
408
|
# pycsy = abs(zxzbnewy - zxzbpasty) * 1000
|
366
|
|
- pycsx = round((zxzbpastx - zxzbnewx),4)
|
367
|
|
- pycsy = round((zxzbpasty - zxzbnewy),4)
|
|
409
|
+ pycsx = round((zxzbpastx - zxzbnewx), 4)
|
|
410
|
+ pycsy = round((zxzbpasty - zxzbnewy), 4)
|
368
|
411
|
# 分别得k,sita的值
|
369
|
412
|
klist = jzys1(listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
|
370
|
413
|
slist = jzys2(listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
|
|
@@ -379,12 +422,12 @@ def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, li
|
379
|
422
|
dy2 = cjh(dylist)
|
380
|
423
|
# 这里再创建矩阵1
|
381
|
424
|
arr1 = np.array(((k2, 0, 0, 0), (0, s2, 0, 0),
|
382
|
|
- (0, 0, dx2, 0), (0, 0, 0, dy2)))
|
|
425
|
+ (0, 0, dx2, 0), (0, 0, 0, dy2)))
|
383
|
426
|
# 矩阵1的逆矩阵矩阵2
|
384
|
427
|
arr2 = np.linalg.inv(arr1)
|
385
|
428
|
# 求矩阵l
|
386
|
429
|
llist = jzys4(listpasty, zxzbpasty, listpastx, zxzbpastx,
|
387
|
|
- listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
|
|
430
|
+ listnewy, zxzbnewy, listnewx, zxzbnewx, sf)
|
388
|
431
|
# 得到数列e1,e2,e3,e4
|
389
|
432
|
e1 = cjh2(klist, llist)
|
390
|
433
|
e2 = cjh2(slist, llist)
|
|
@@ -403,15 +446,15 @@ def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, li
|
403
|
446
|
lylist = jzys3(jylist1, 0, 1)
|
404
|
447
|
# 求改算坐标
|
405
|
448
|
gsx = gsys(listnewx, jxlist1, jylist1, lxlist,
|
406
|
|
- lylist, arrz, sf, zxzbnewx, zxzbpastx, 0)
|
|
449
|
+ lylist, arrz, sf, zxzbnewx, zxzbpastx, 0)
|
407
|
450
|
gsy = gsys(listnewy, jxlist2, jylist2, lxlist,
|
408
|
|
- lylist, arrz, sf, zxzbnewy, zxzbpasty, 1)
|
409
|
|
- #缩放系数也是计算出来的sfxs
|
410
|
|
- sfxs = sfjs(gsx,listnewx,gsy,listnewy)
|
411
|
|
- #旋转角,模型精度
|
412
|
|
- xzj = xzjs(gsx,listnewx,gsy,listnewy)
|
413
|
|
- mxjdx = mxjd(gsx,listpastx)
|
414
|
|
- mxjdy = mxjd(gsy,listpasty)
|
|
451
|
+ lylist, arrz, sf, zxzbnewy, zxzbpasty, 1)
|
|
452
|
+ # 缩放系数也是计算出来的sfxs
|
|
453
|
+ sfxs = sfjs(gsx, listnewx, gsy, listnewy)
|
|
454
|
+ # 旋转角,模型精度
|
|
455
|
+ xzj = xzjs(gsx, listnewx, gsy, listnewy)
|
|
456
|
+ mxjdx = mxjd(gsx, listpastx)
|
|
457
|
+ mxjdy = mxjd(gsy, listpasty)
|
415
|
458
|
# 还是要先求较差
|
416
|
459
|
xcx = xcys(gsx, listpastx)
|
417
|
460
|
xcy = xcys(gsy, listpasty)
|
|
@@ -458,9 +501,9 @@ def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, li
|
458
|
501
|
n3 = zxzbpastx - zxzbnewx - s1 - s2 + float(arrz[2])
|
459
|
502
|
n4 = (-1) * float(arrz[1])
|
460
|
503
|
n5 = n1
|
461
|
|
- s3 = (-1)*float(arrz[0])*zxzbnewy
|
462
|
|
- s4 = float(arrz[1])*zxzbnewx
|
463
|
|
- n6 = s3 + s4 + float(arrz[3])+zxzbpasty-zxzbnewy
|
|
504
|
+ s3 = (-1) * float(arrz[0]) * zxzbnewy
|
|
505
|
+ s4 = float(arrz[1]) * zxzbnewx
|
|
506
|
+ n6 = s3 + s4 + float(arrz[3]) + zxzbpasty - zxzbnewy
|
464
|
507
|
sxylist = []
|
465
|
508
|
sxylist.append(n1)
|
466
|
509
|
sxylist.append(n2)
|
|
@@ -484,13 +527,15 @@ def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, li
|
484
|
527
|
lengs1 = len(gszbx)
|
485
|
528
|
nlist = relist1[6]
|
486
|
529
|
# return relist
|
487
|
|
- #中文再来一次
|
|
530
|
+ # 中文再来一次
|
488
|
531
|
utf_pan = to_utf8(pastname)
|
489
|
532
|
utf_nn = to_utf8(newname)
|
490
|
533
|
utf_tn = to_utf8(excelname)
|
491
|
|
- insert_into_database1(dbpath,utf_tn,listname1,listname,gsx,gsy,listpastx1,listpasty1,listnewx1,listnewy1,nlist,utf_pan,utf_nn,wypd,sfxs,xzj,pycsx,pycsy,mxjdx,mxjdy,zxzbpastx,zxzbpasty,zxzbnewx,zxzbnewy,n1,n2,n3,n4,n5,n6)
|
|
534
|
+ insert_into_database1(dbpath, utf_tn, listname1, listname, gsx, gsy, listpastx1, listpasty1, listnewx1,
|
|
535
|
+ listnewy1, nlist, utf_pan, utf_nn, wypd, sfxs, xzj, pycsx, pycsy, mxjdx, mxjdy, zxzbpastx,
|
|
536
|
+ zxzbpasty, zxzbnewx, zxzbnewy, n1, n2, n3, n4, n5, n6)
|
492
|
537
|
|
493
|
|
- else:
|
|
538
|
+ else:
|
494
|
539
|
# 先把所有的合在一起,方便删除
|
495
|
540
|
lenlist1 = len(xcx)
|
496
|
541
|
ii = 0
|
|
@@ -534,14 +579,20 @@ def bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, li
|
534
|
579
|
mm2 = mm2 + 1
|
535
|
580
|
print(" Finish!")
|
536
|
581
|
js1 = 1
|
537
|
|
- bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx,
|
538
|
|
- listpasty, points, listcgcs, sf, newname, pastname, js1,listnewx1,listnewy1,excelname)
|
|
582
|
+ bhjs(dbpath, listcgcs1, listname1, listpastx1, listpasty1, wypd, listname, listnewx, listnewy, listpastx,
|
|
583
|
+ listpasty, points, listcgcs, sf, newname, pastname, js1, listnewx1, listnewy1, excelname)
|
539
|
584
|
|
540
|
585
|
|
541
|
586
|
# 主函数 计算
|
542
|
|
-def main_function(dbpath,file_name):
|
543
|
|
- #从数据库中调用
|
544
|
|
- listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx,listpasty, points, listcgcs,sf, newname, pastname, js,listnewx1,listnewy1 = tablein(dbpath,file_name)
|
545
|
|
- #计算
|
546
|
|
- bhjs(dbpath,listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx,listpasty, points, listcgcs,sf, newname, pastname, js,listnewx1,listnewy1,file_name)
|
547
|
|
- messagebox.showinfo("提示",f"文件 '{file_name}' 计算成功!")
|
|
587
|
+def main_function(file_name, dbpath):
|
|
588
|
+ try:
|
|
589
|
+ print(f"File name: {file_name}")
|
|
590
|
+ # 从数据库中调用
|
|
591
|
+ listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx, listpasty, points, listcgcs, sf, newname, pastname, js, listnewx1, listnewy1 = tablein(
|
|
592
|
+ dbpath, file_name)
|
|
593
|
+ # 计算
|
|
594
|
+ bhjs(dbpath, listcgcs1, listname1, listpastx1, listpasty1, wypd0, listname, listnewx, listnewy, listpastx,
|
|
595
|
+ listpasty, points, listcgcs, sf, newname, pastname, js, listnewx1, listnewy1, file_name)
|
|
596
|
+ QMessageBox.information(None, "提示", f"文件 '{file_name}' 计算成功!")
|
|
597
|
+ except Exception as e:
|
|
598
|
+ QMessageBox.critical(None, "错误", f"文件 '{file_name}' 计算失败!错误信息: {str(e)}")
|