This commit is contained in:
Alex38Lyon
2026-08-28 15:01:00 +02:00
parent df0750c86c
commit 972ad1c46e
4 changed files with 23 additions and 20 deletions
+4 -2
View File
@@ -8,8 +8,10 @@ pyThtoQGis
Script pour convertir les fichiers (.shp) produit par Therion en fichiers (.qkpg) pour Qgis Script pour convertir les fichiers (.shp) produit par Therion en fichiers (.qkpg) pour Qgis
Usage : python pyThtoGgis.py Usage :
- python pyThtoGgis.py --manual
- python pyThtoQgis.py --help
- python pyThtoQgis.py --folder "../../Outputs/SHP/"
pyThtoDat pyThtoDat
+1 -1
View File
@@ -12,7 +12,7 @@ Version = "2026.08.28"
pathshp = ".\\Inputs\\" pathshp = ".\\Inputs\\"
outputfolder ="QGis_QPKG_Files\\" outputfolder ="QGis_GPKG_Files\\"
outputspath = ".\\outputfolder" outputspath = ".\\outputfolder"
file_log = "pyThtoQgis.log" file_log = "pyThtoQgis.log"
+16 -15
View File
@@ -839,12 +839,14 @@ def ThtoQGis(pathshp, outputspath):
for fname in file_list: for fname in file_list:
log.info(f"Working with file: {Colors.ENDC}{fname}.shp") log.info(f"Working with file: {Colors.ENDC}{fname}.shp")
if not os.path.isfile(pathshp + fname + '.shp'): file = os.path.join(pathshp, fname + '.shp')
log.error(f"ERROR the file {Colors.ENDC}{(str(pathshp + fname + '.shp'))}{Colors.ERROR} does not exist'{Colors.ENDC}")
if not os.path.isfile(file):
log.error(f"ERROR the file {Colors.ENDC}{(str(file))}{Colors.ERROR} does not exist'{Colors.ENDC}")
globalDat.errorCount += 1 globalDat.errorCount += 1
continue continue
diagnostic(pathshp + fname + '.shp') diagnostic(file)
if fname in dest_list : if fname in dest_list :
destinationName = fname destinationName = fname
@@ -853,7 +855,7 @@ def ThtoQGis(pathshp, outputspath):
shp2gpkg(pathshp, fname, outputspath, destinationName) shp2gpkg(pathshp, fname, outputspath, destinationName)
err = diagnostic(outputspath + destinationName + '.gpkg') err = diagnostic(os.path.join(outputspath,destinationName + '.gpkg'))
if err != 0 : if err != 0 :
log.error(f"ERROR: in file {Colors.ENDC}{(str(outputspath + destinationName + '.gpkg'))} {Colors.ERROR} please fix it manually with QGis...") log.error(f"ERROR: in file {Colors.ENDC}{(str(outputspath + destinationName + '.gpkg'))} {Colors.ERROR} please fix it manually with QGis...")
@@ -864,16 +866,16 @@ def ThtoQGis(pathshp, outputspath):
log.info(f"{Colors.HEADER}{Colors.UNDERLINE}Step 2: Adapte drawing files for QGis in the folder:{Colors.ENDC} {safe_relpath(outputspath)}") log.info(f"{Colors.HEADER}{Colors.UNDERLINE}Step 2: Adapte drawing files for QGis in the folder:{Colors.ENDC} {safe_relpath(outputspath)}")
## Work with lines ## Work with lines
cutGPKG(outputspath + 'lines2d_fixed.gpkg', outputspath + 'outline2d.gpkg', outputspath + 'lines2dMasked.gpkg') cutGPKG(os.path.join(outputspath,'lines2d_fixed.gpkg'),os.path.join(outputspath,'outline2d.gpkg'), os.path.join(outputspath,'lines2dMasked.gpkg'))
diagnostic(outputspath + 'lines2dMasked.gpkg') diagnostic(os.path.join(outputspath,'lines2dMasked.gpkg'))
## Work with Areas ## Work with Areas
cutGPKG(outputspath + 'areas2d_fixed.gpkg', outputspath + 'outline2d.gpkg', outputspath + 'areas2dMasked.gpkg') cutGPKG(os.path.join(outputspath, 'areas2d_fixed.gpkg'), os.path.join(outputspath,'outline2d.gpkg'), os.path.join(outputspath,'areas2dMasked.gpkg'))
diagnostic(outputspath + 'areas2dMasked.gpkg') diagnostic(os.path.join(outputspath,'areas2dMasked.gpkg'))
## Work with Points 'add altitudes' ## Work with Points 'add altitudes'
extractVertices(outputspath + 'lines2dMasked.gpkg', outputspath + 'points2d.gpkg') extractVertices(os.path.join(outputspath,'lines2dMasked.gpkg'), os.path.join(outputspath,'points2d.gpkg'))
diagnostic(outputspath + 'points2d.gpkg') diagnostic(os.path.join(outputspath,'points2d.gpkg'))
##################################################################################################################################### #####################################################################################################################################
@@ -939,12 +941,11 @@ if __name__ == u'__main__':
if args.folder : if args.folder :
input_folder = args.folder input_folder = os.path.normpath(args.folder)
output_folder = input_folder + globalDat.outputfolder output_folder = os.path.join(input_folder,globalDat.outputfolder)
log = setup_logger(output_folder + globalDat.file_log, globalDat.debug_log)
if not os.path.exists(input_folder): if not os.path.exists(input_folder):
log = setup_logger(globalDat.output_log, globalDat.debug_log)
log.error(f"ERROR the folder {Colors.ENDC}{input_folder}{Colors.ERROR} does not exist'{Colors.ENDC}") log.error(f"ERROR the folder {Colors.ENDC}{input_folder}{Colors.ERROR} does not exist'{Colors.ENDC}")
globalDat.errorCount += 1 globalDat.errorCount += 1
sys.exit() sys.exit()
@@ -952,7 +953,7 @@ if __name__ == u'__main__':
if not os.path.exists(output_folder): if not os.path.exists(output_folder):
os.makedirs(output_folder) os.makedirs(output_folder)
log = setup_logger(output_folder + globalDat.file_log, globalDat.debug_log) log = setup_logger(os.path.join(output_folder,globalDat.file_log), globalDat.debug_log)
log.info(f'{Colors.HEADER}*********************************************************************************************************') log.info(f'{Colors.HEADER}*********************************************************************************************************')
log.info(f'{Colors.HEADER}Script to generate QGis (.gpkg) files from Therion (.shp) files with auto-correction if possible') log.info(f'{Colors.HEADER}Script to generate QGis (.gpkg) files from Therion (.shp) files with auto-correction if possible')