Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,7 +45,8 @@ prjnamesURL= 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7
|
|
| 45 |
prjpartsURL= 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=34865056'
|
| 46 |
prjsectionsURL= 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=1751466819'
|
| 47 |
|
| 48 |
-
|
|
|
|
| 49 |
|
| 50 |
@app.route("/",methods=["GET", "POST"])
|
| 51 |
def getInfotoMeasure():
|
|
@@ -204,6 +205,7 @@ def measure2_1():
|
|
| 204 |
# @app.route('/projecttomeasure/<jsdata>',methods=["GET","POST"])
|
| 205 |
def measureproject(result,dataDoc=0,img=0,dxffile=0):
|
| 206 |
colorarr=[]
|
|
|
|
| 207 |
# result = json.loads(jsdata)
|
| 208 |
pdfpath='/'
|
| 209 |
################################# -1.0- #################################
|
|
@@ -219,6 +221,7 @@ def measureproject(result,dataDoc=0,img=0,dxffile=0):
|
|
| 219 |
colorarr.append(c)
|
| 220 |
print('RATIOS=',result[3], result[4])
|
| 221 |
# cv2.imwrite(img,'imgg.png')
|
|
|
|
| 222 |
imgPerimeter1,image_new1,SimilarAreaDictionary , colorsUsed,spreadsheet_url, spreadsheetId,list1, pdflink, areas_Perimeters, namepathArr =pilecaps_adr.drawAllContours(dataDoc,img,result[1],colorarr, result[3], result[4], result[0],pdfpath)
|
| 223 |
_, buffer = cv2.imencode('.png', image_new1)
|
| 224 |
arr=[base64.b64encode(buffer).decode('utf-8'),SimilarAreaDictionary.to_dict(),spreadsheet_url , spreadsheetId,colorsUsed,list1.to_dict(), pdflink, areas_Perimeters, namepathArr]
|
|
@@ -244,9 +247,13 @@ def measureproject(result,dataDoc=0,img=0,dxffile=0):
|
|
| 244 |
temp_file.write(dxfpath)
|
| 245 |
temp_filename = temp_file.name
|
| 246 |
print(temp_filename)
|
|
|
|
| 247 |
doc,outputimg, SimilarAreaDictionary ,spreadsheetId, spreadsheet_url , namepathArr , list1,hatched_areas=deploying_3_3.mainFunctionDrawImgPdf(dataDoc,temp_filename,result[4] , pdfpath,result[0])
|
|
|
|
|
|
|
| 248 |
dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
|
| 249 |
print(dbPath,result[0])
|
|
|
|
| 250 |
pdflink= tsadropboxretrieval.uploadanyFile(doc=doc,path=dbPath,pdfname=result[0]) #doc=doc,pdfname=path,pdfpath=pdfpath+'Measured Plan/'
|
| 251 |
|
| 252 |
_, buffer = cv2.imencode('.png', outputimg)
|
|
@@ -267,7 +274,9 @@ def measureproject(result,dataDoc=0,img=0,dxffile=0):
|
|
| 267 |
annotatedimg,pdf_document,spreadsheet_url, list1 , df_doors=doors_fasterrcnn.main_run(dataDoc,'single_double.pth',result[0],pdfpath, result[4]) #single_double.pth
|
| 268 |
|
| 269 |
dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
|
|
|
|
| 270 |
pdflink= tsadropboxretrieval.uploadanyFile(doc=pdf_document,path=dbPath,pdfname=result[0]) #doc=doc,pdfname=path,pdfpath=pdfpath+'Measured Plan/'
|
|
|
|
| 271 |
print(pdflink)
|
| 272 |
# dpxlinks.append(pdflink)
|
| 273 |
# legendLinks.append(spreadsheet_url)
|
|
@@ -342,9 +351,15 @@ def convert2img(path):
|
|
| 342 |
def sendmctnametoLegend(jsdata):
|
| 343 |
result = json.loads(jsdata)
|
| 344 |
print(result)
|
| 345 |
-
|
|
|
|
| 346 |
allreturns=[summaryid]
|
| 347 |
return jsonify(allreturns)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
#_________________________________________________________________________________________________________________________
|
| 349 |
#_________________________________________________________________________________________________________________________
|
| 350 |
#NOT USED (pixel conversion instead)
|
|
@@ -610,11 +625,6 @@ def checktables():
|
|
| 610 |
a1 = table1N.to_numpy()
|
| 611 |
row1 = np.where(a1 == projectname)
|
| 612 |
prjid=a1[row1[0]][0][0]
|
| 613 |
-
# a2 = table2N.to_numpy()
|
| 614 |
-
# row2 = np.where(a2 == projectpart)
|
| 615 |
-
|
| 616 |
-
# partid=a2[row2[0]][0][1]
|
| 617 |
-
|
| 618 |
t3Diff1=table3[~table3.isin(table3N)].dropna()
|
| 619 |
t3Diff=table3N[~table3N.isin(table3)].dropna()
|
| 620 |
|
|
@@ -724,7 +734,6 @@ def cvtSummarytoXML(jsdata):
|
|
| 724 |
# print(result[1])
|
| 725 |
xmllink=google_sheet_to_xml.create_xml(documentname=result[1],dbPath=path)
|
| 726 |
return jsonify(xmllink)
|
| 727 |
-
|
| 728 |
#_________________________________________________________________________________________________________________________
|
| 729 |
#_________________________________________________________________________________________________________________________
|
| 730 |
|
|
|
|
| 45 |
prjpartsURL= 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=34865056'
|
| 46 |
prjsectionsURL= 'https://docs.google.com/spreadsheets/d/1nsIgi9o9VSBKQlNxbxihPzG_N7s4um0eNVfgL4gaGPc/export?format=csv&gid=1751466819'
|
| 47 |
|
| 48 |
+
global colorsused
|
| 49 |
+
global pdflink
|
| 50 |
|
| 51 |
@app.route("/",methods=["GET", "POST"])
|
| 52 |
def getInfotoMeasure():
|
|
|
|
| 205 |
# @app.route('/projecttomeasure/<jsdata>',methods=["GET","POST"])
|
| 206 |
def measureproject(result,dataDoc=0,img=0,dxffile=0):
|
| 207 |
colorarr=[]
|
| 208 |
+
global pdflink
|
| 209 |
# result = json.loads(jsdata)
|
| 210 |
pdfpath='/'
|
| 211 |
################################# -1.0- #################################
|
|
|
|
| 221 |
colorarr.append(c)
|
| 222 |
print('RATIOS=',result[3], result[4])
|
| 223 |
# cv2.imwrite(img,'imgg.png')
|
| 224 |
+
# global pdflink
|
| 225 |
imgPerimeter1,image_new1,SimilarAreaDictionary , colorsUsed,spreadsheet_url, spreadsheetId,list1, pdflink, areas_Perimeters, namepathArr =pilecaps_adr.drawAllContours(dataDoc,img,result[1],colorarr, result[3], result[4], result[0],pdfpath)
|
| 226 |
_, buffer = cv2.imencode('.png', image_new1)
|
| 227 |
arr=[base64.b64encode(buffer).decode('utf-8'),SimilarAreaDictionary.to_dict(),spreadsheet_url , spreadsheetId,colorsUsed,list1.to_dict(), pdflink, areas_Perimeters, namepathArr]
|
|
|
|
| 247 |
temp_file.write(dxfpath)
|
| 248 |
temp_filename = temp_file.name
|
| 249 |
print(temp_filename)
|
| 250 |
+
|
| 251 |
doc,outputimg, SimilarAreaDictionary ,spreadsheetId, spreadsheet_url , namepathArr , list1,hatched_areas=deploying_3_3.mainFunctionDrawImgPdf(dataDoc,temp_filename,result[4] , pdfpath,result[0])
|
| 252 |
+
global colorsused
|
| 253 |
+
colorsused=list(SimilarAreaDictionary['Color'])
|
| 254 |
dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
|
| 255 |
print(dbPath,result[0])
|
| 256 |
+
#
|
| 257 |
pdflink= tsadropboxretrieval.uploadanyFile(doc=doc,path=dbPath,pdfname=result[0]) #doc=doc,pdfname=path,pdfpath=pdfpath+'Measured Plan/'
|
| 258 |
|
| 259 |
_, buffer = cv2.imencode('.png', outputimg)
|
|
|
|
| 274 |
annotatedimg,pdf_document,spreadsheet_url, list1 , df_doors=doors_fasterrcnn.main_run(dataDoc,'single_double.pth',result[0],pdfpath, result[4]) #single_double.pth
|
| 275 |
|
| 276 |
dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
|
| 277 |
+
# global pdflink
|
| 278 |
pdflink= tsadropboxretrieval.uploadanyFile(doc=pdf_document,path=dbPath,pdfname=result[0]) #doc=doc,pdfname=path,pdfpath=pdfpath+'Measured Plan/'
|
| 279 |
+
|
| 280 |
print(pdflink)
|
| 281 |
# dpxlinks.append(pdflink)
|
| 282 |
# legendLinks.append(spreadsheet_url)
|
|
|
|
| 351 |
def sendmctnametoLegend(jsdata):
|
| 352 |
result = json.loads(jsdata)
|
| 353 |
print(result)
|
| 354 |
+
global pdflink
|
| 355 |
+
summaryid=google_sheet_Legend.mapnametoLegend(result,colorsused,pdflink)
|
| 356 |
allreturns=[summaryid]
|
| 357 |
return jsonify(allreturns)
|
| 358 |
+
|
| 359 |
+
@app.route("/getguessednamepath/",methods=["GET", "POST"])
|
| 360 |
+
def getguessedNames():
|
| 361 |
+
guessednamesDrpdwn=google_sheet_Legend.getallguessednames()
|
| 362 |
+
return jsonify(guessednamesDrpdwn)
|
| 363 |
#_________________________________________________________________________________________________________________________
|
| 364 |
#_________________________________________________________________________________________________________________________
|
| 365 |
#NOT USED (pixel conversion instead)
|
|
|
|
| 625 |
a1 = table1N.to_numpy()
|
| 626 |
row1 = np.where(a1 == projectname)
|
| 627 |
prjid=a1[row1[0]][0][0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 628 |
t3Diff1=table3[~table3.isin(table3N)].dropna()
|
| 629 |
t3Diff=table3N[~table3N.isin(table3)].dropna()
|
| 630 |
|
|
|
|
| 734 |
# print(result[1])
|
| 735 |
xmllink=google_sheet_to_xml.create_xml(documentname=result[1],dbPath=path)
|
| 736 |
return jsonify(xmllink)
|
|
|
|
| 737 |
#_________________________________________________________________________________________________________________________
|
| 738 |
#_________________________________________________________________________________________________________________________
|
| 739 |
|