update pyCreateTh

This commit is contained in:
Alex38Lyon
2026-06-20 16:35:15 +02:00
parent 96b4bc75ad
commit e7b8c4a27e
27 changed files with 269 additions and 1520 deletions
+1 -1
Submodule Data updated: f30ff8ad50...93ecd16426
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -195,7 +195,7 @@ td {border-bottom:1px solid #a7a9aa; padding-left:8px; padding-right:8px; paddin
<tr id=""><td align="left" style="padding-left: 0px">BOUQUE</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">679428.280</td><td align="right">4756752.620</td><td align="right">1577.000</td></tr>
<tr id=""><td align="left" style="padding-left: 0px">ILLAMI</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">675640.410</td><td align="right">4763131.610</td><td align="right">438.000</td></tr>
<tr id=""><td align="left" style="padding-left: 0px">M_108</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">684768.150</td><td align="right">4758414.650</td><td align="right">2030.000</td></tr>
<tr id=""><td align="left" style="padding-left: 0px">M_326</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">684890.140</td><td align="right">4758116.650</td><td align="right">2110.000</td></tr>
<tr id=""><td align="left" style="padding-left: 0px">M326 Embrochat</td><td align="right">756</td><td align="right">301</td><td align="right">&nbsp;</td><td align="right">684890.140</td><td align="right">4758116.650</td><td align="right">2110.000</td></tr>
<tr id=""><td align="left" style="padding-left: 0px">M_400</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">684928.130</td><td align="right">4757555.650</td><td align="right">2203.000</td></tr>
<tr id=""><td align="left" style="padding-left: 0px">M_405</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">684269.150</td><td align="right">4757764.650</td><td align="right">2125.000</td></tr>
<tr id=""><td align="left" style="padding-left: 0px">M_414</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">&nbsp;</td><td align="right">684115.000</td><td align="right">4757872.000</td><td align="right">2114.000</td></tr>
Binary file not shown.
+1 -1
View File
@@ -2890,7 +2890,7 @@ td {border-bottom:1px solid #a7a9aa; padding-left:8px; padding-right:8px; paddin
<tr id="Synthese-PSM_LARRA.M108.Explo_01_1980_07_29.Explo_01_1980_07_29"><td align="left" style="padding-left: 36px">1S1C1X1</td><td align="right">106</td><td align="right">81</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">18</td><td align="right">19</td></tr>
<tr id="Synthese-PSM_LARRA.M326-Embrochat"><td align="left" style="padding-left: 12px"><a href="javascript:xTree('Synthese-PSM_LARRA.M326-Embrochat')">M326-Embrochat</a></td><td align="right">1667</td><td align="right">384</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">303</td><td align="right">312</td></tr>
<tr id="Synthese-PSM_LARRA.M326-Embrochat.Explo_01_1978_08_20"><td align="left" style="padding-left: 24px"><a href="javascript:xTree('Synthese-PSM_LARRA.M326-Embrochat.Explo_01_1978_08_20')">Explo 01 1978 08 20</a></td><td align="right">756</td><td align="right">301</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">182</td><td align="right">183</td></tr>
<tr id="Synthese-PSM_LARRA.M326-Embrochat.Explo_01_1978_08_20.Explo_01_1978_08_20"><td align="left" style="padding-left: 36px">1S1C1X1 2S2C1X1 3S3C1X1 5S4C1X1 7S5C1X1</td><td align="right">756</td><td align="right">301</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">182</td><td align="right">183</td></tr>
<tr id="Synthese-PSM_LARRA.M326-Embrochat.Explo_01_1978_08_20.Explo_01_1978_08_20"><td align="left" style="padding-left: 36px">M326 Embrochat</td><td align="right">756</td><td align="right">301</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">182</td><td align="right">183</td></tr>
<tr id="Synthese-PSM_LARRA.M326-Embrochat.Explo_02_1979_07_16"><td align="left" style="padding-left: 24px"><a href="javascript:xTree('Synthese-PSM_LARRA.M326-Embrochat.Explo_02_1979_07_16')">Explo 02 1979 07 16</a></td><td align="right">299</td><td align="right">84</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">36</td><td align="right">37</td></tr>
<tr id="Synthese-PSM_LARRA.M326-Embrochat.Explo_02_1979_07_16.Explo_02_1979_07_16"><td align="left" style="padding-left: 36px">4S3C2X2</td><td align="right">299</td><td align="right">84</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">36</td><td align="right">37</td></tr>
<tr id="Synthese-PSM_LARRA.M326-Embrochat.Explo_03_1979_07_20"><td align="left" style="padding-left: 24px"><a href="javascript:xTree('Synthese-PSM_LARRA.M326-Embrochat.Explo_03_1979_07_20')">Explo 03 1979 07 20</a></td><td align="right">187</td><td align="right">108</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">0</td><td align="right">21</td><td align="right">22</td></tr>
+2 -2
View File
@@ -648,7 +648,7 @@
<Point> <coordinates>-0.73479838100195,42.95596748838191,2030.00000000000000</coordinates> </Point>
</Placemark>
<Placemark>
<styleUrl>#ThEntranceIcon</styleUrl><name><![CDATA[M_326]]></name>
<styleUrl>#ThEntranceIcon</styleUrl><name><![CDATA[M326 Embrochat]]></name>
<Point> <coordinates>-0.73340242354158,42.95325645615527,2110.00000000000000</coordinates> </Point>
</Placemark>
<Placemark>
@@ -74269,7 +74269,7 @@
<Folder>
<name><![CDATA[Explo 01 1978 08 20]]></name>
<Folder>
<name><![CDATA[1S1C1X1 2S2C1X1 3S3C1X1 5S4C1X1 7S5C1X1]]></name>
<name><![CDATA[M326 Embrochat]]></name>
<Placemark>
<name>M_326</name>
<styleUrl>#ThSurveyLine</styleUrl>
Binary file not shown.
+165 -1
View File
@@ -10,6 +10,7 @@ Alex 2025 06 09
import os, logging, sys, re, configparser, unicodedata, shutil
from pathlib import Path
import Lib.global_data as global_Data
from datetime import datetime
import tkinter as tk
from tkinter import filedialog
@@ -218,7 +219,7 @@ def select_file_tk_window():
#################################################################################################
def load_config(args, configIni="config.ini"):
def load_config_old(args, configIni="config.ini"):
"""
Charge un fichier de configuration .ini et initialise les variables globales.
@@ -288,6 +289,169 @@ def load_config(args, configIni="config.ini"):
exit(0)
def load_config(args, configIni="config.ini", profile="Default"):
"""
Charge un fichier de configuration .ini et initialise les variables globales.
Args:
args: Argument contenant le chemin du fichier principal.
configIni: Nom du fichier de configuration.
profile: Nom du profil Survey_Data à utiliser.
Exemple : Survey_Data:PSM
"""
try:
# Chemin potentiel du fichier config
config_file = os.path.join(os.path.dirname(args.file), configIni)
if not os.path.isfile(config_file):
config_file = configIni
config = configparser.ConfigParser()
config.read(config_file, encoding="utf-8")
# ----------------------------------------------------------
# Sélection du profil Survey_Data
# ----------------------------------------------------------
survey_section = f"Survey_Data:{profile}"
if survey_section in config:
survey_cfg = config[survey_section]
elif "Survey_Data" in config:
# Compatibilité ancienne configuration
survey_cfg = config["Survey_Data"]
if profile != "Default":
log.warning(f"Profile '{Colors.ENDC}{profile}{Colors.WARNING}' not found. Using legacy default {Colors.ENDC}[Survey_Data]{Colors.WARNING} section.")
profile = "Default"
else:
raise ValueError(f"Section [{survey_section}] not found and no legacy [Survey_Data] section available.")
# ----------------------------------------------------------
# Lecture Survey_Data
# ----------------------------------------------------------
survey_keys = {
'Author': 'Author',
'Copyright1': 'Copyright',
'Copyright2': 'Copyright',
'Copyright3': 'Copyright',
'Copyright_Short': None,
'map_comment': 'mapComment',
'club': 'club',
'thanksto': 'thanksto',
'datat': 'datat',
'wpage': 'wpage',
'cs': 'cs'
}
# ==========================================================
# Variables de substitution
# ==========================================================
variables = {
"YEAR": str(datetime.now().year)
}
def expand(value):
try:
return value.format(**variables)
except Exception:
return value
# ==========================================================
# Lecture Survey_Data
# ==========================================================
survey_keys = {
'Author': 'Author',
'map_comment': 'mapComment',
'club': 'club',
'thanksto': 'thanksto',
'datat': 'datat',
'wpage': 'wpage',
'cs': 'cs'
}
for key, attr in survey_keys.items():
if key in survey_cfg:
value = expand(survey_cfg[key])
setattr(global_Data, attr, value)
# ==========================================================
# Gestion Copyright
# ==========================================================
copyright_lines = []
for key in ("Copyright1", "Copyright2", "Copyright3"):
if key in survey_cfg:
copyright_lines.append(
expand(survey_cfg[key])
)
if copyright_lines:
global_Data.Copyright = "\n".join(
copyright_lines
)
if "Copyright_Short" in survey_cfg:
global_Data.CopyrightShort = expand(
survey_cfg["Copyright_Short"]
)
# ----------------------------------------------------------
# Lecture Application_Data
# ----------------------------------------------------------
app_keys = {
'template_path': 'templatePath',
'station_by_scrap': ('stationByScrap', int),
'final_therion_exe': ('finalTherionExe', lambda x: x.lower() == 'true'),
'parse_tro_files_by_explo': ('parse_tro_files_by_explo', lambda x: x.lower() == 'true'),
'therion_path': 'therionPath',
'survey_prefix_name': 'SurveyPrefixName',
'shot_lines_in_th2_files': ('linesInTh2', lambda x: x.lower() == 'true'),
'station_name_in_th2_files': ('stationNamesInTh2', lambda x: x.lower() == 'true'),
'wall_lines_in_th2_files': ('wallLinesInTh2', lambda x: x.lower() == 'true'),
'kSmooth': ('kSmooth', float)
}
if 'Application_Data' in config:
for key, value in app_keys.items():
if key not in config['Application_Data']:
continue
attr, caster = (
(value, str)
if isinstance(value, str)
else value
)
setattr(
global_Data,
attr,
caster(config['Application_Data'][key])
)
# log.info(f"Configuration profile : {profile}")
return config_file, profile
except Exception as e:
log.critical(f"Reading config file : {Colors.ENDC}{configIni}{Colors.ERROR} error : {Colors.ENDC}{e}" )
exit(0)
#################################################################################################
# Supprime les codes ANSI (pour l'écriture dans les fichiers)
#################################################################################################
+47 -3
View File
@@ -1,9 +1,13 @@
#############################################################################################
# config.ini file for configuration values of pyCreateTh.py script
#############################################################################################
#############################################################################################
# General layout information :
[Survey_Data]
#############################################################################################
[Survey_Data] # Default
Author = Alexandre Pont
Copyright1 = # Copyright (C) ARSIP 2026
Copyright1 = # Copyright (C) ARSIP {YEAR}
Copyright2 = # This work is under the Creative Commons Attribution-NonCommercial-NoDerivatives License:
Copyright3 = # <http://creativecommons.org/licenses/by-nc-nd/4.0/>
Copyright_Short = License CC by-nc-nd : http://creativecommons.org/licenses/by-nc-nd/4.0/
@@ -14,8 +18,48 @@ datat = https://github.com/Alex38Lyon/Synthese-PSM_LARRA
wpage = https://www.arsip.fr/
cs = UTM30
[Survey_Data:Tritons]
Author = Alexandre Pont
Copyright1 = # Copyright (C) Clan des Tritons {YEAR}
Copyright2 = # This work is under the Creative Commons Attribution-NonCommercial-NoDerivatives License:
Copyright3 = # <http://creativecommons.org/licenses/by-nc-nd/4.0/>
Copyright_Short = License CC by-nc-nd : http://creativecommons.org/licenses/by-nc-nd/4.0/
map_comment = Massif XXXX
club = Clan des Tritons
thanksto = Merci à tout le monde
datat = https://github.com/Alex38Lyon/Topographies-Diverses_Tritons
wpage = https://clandestritons.fr/
cs = UTM30
# configuration data
[Survey_Data:PSM]
Author = Alexandre Pont
Copyright1 = # Copyright (C) ARSIP {YEAR}
Copyright2 = # This work is under the Creative Commons Attribution-NonCommercial-NoDerivatives License:
Copyright3 = # <http://creativecommons.org/licenses/by-nc-nd/4.0/>
Copyright_Short = License CC by-nc-nd : http://creativecommons.org/licenses/by-nc-nd/4.0/
map_comment = Massif de la Pierre Saint Martin - Larra
club = ARSIP
thanksto = Merci à tout le monde
datat = https://github.com/Alex38Lyon/Synthese-PSM_LARRA
wpage = https://www.arsip.fr/
cs = UTM30
[Survey_Data:Xichou]
Author = Alexandre Pont
Copyright1 = # Copyright (C) XIchou {YEAR}
Copyright2 = # This work is under the Creative Commons Attribution-NonCommercial-NoDerivatives License:
Copyright3 = # <http://creativecommons.org/licenses/by-nc-nd/4.0/>
Copyright_Short = License CC by-nc-nd : http://creativecommons.org/licenses/by-nc-nd/4.0/
map_comment = Xichou {YEAR}
club = Xichou
thanksto = Merci à tout le monde
datat =
wpage =
cs = UTM48
#############################################################################################
# Configuration data
#############################################################################################
[Application_Data]
template_path = ./template
station_by_scrap = 30
+32 -11
View File
@@ -28,6 +28,7 @@ Sources documentaires :
Création Alex le 2025 06 09
Mise à jour : 2026 06 20
En cours :
- Exports Tro :
@@ -38,8 +39,8 @@ En cours :
- A créer pour avoir notamment les réseaux à plusieurs entrées
- Exports DAT/MARK
- Attention les Flags '#|L#' posent problèmes (A voir convertisseur PdB vers compass...)
- tester avec les dernières option de la version de DAT (CORRECTION2 et suivants)
- améliorer fonction wall shot pour faire habillage des th2 files, les jointures...
- Tester avec les dernières option de la version de DAT (CORRECTION2 et suivants)
- Améliorer fonction wall shot pour faire habillage des th2 files, les jointures...
- traiter les series avec 1 ou 2 stations
- PB des cartouches et des échelles pour faire des pdf automatiquement
@@ -2191,6 +2192,7 @@ if __name__ == u'__main__':
threads = []
fileTitle = ""
_fileTitle = ""
profile = "Default"
#################################################################################################
# Parse arguments #
@@ -2202,16 +2204,26 @@ if __name__ == u'__main__':
parser.add_argument("--file", help="the file (*.th, *.mak, *.dat, *.tro) to perform e.g. './Therion_file.th'", default="")
parser.add_argument("--proj", choices=['All', 'Plan', 'Extended', 'None'], help="the th2 files scrap projection to produce, default: All", default="All")
parser.add_argument("--scale", help="scale for the pdf layout exports, default value: 1000 (i.e. xvi files scale is 100)", default="1000")
parser.add_argument("--update", help="th2 files update mode (only for th input files, no folders created)", action="store_true", default=False)
parser.add_argument("--update", help=f"th2 files update mode (only for th input files, no folders created), {Colors.RED}Attention : save your old th2 files", action="store_true", default=False)
parser.epilog = (
f"{Colors.GREEN}Please, complete {Colors.BLUE}config.ini{Colors.GREEN} in {Colors.BLUE}FILE{Colors.GREEN} folder or in script folder for personal configuration{Colors.ENDC}\n"
f"{Colors.GREEN}If no argument: {Colors.BLUE} files selection by a windows\n{Colors.ENDC}\n"
f"{Colors.BLUE}Examples:{Colors.ENDC}\n"
f"\t> python pyCreateTh.py ./Tests/Entree.th --scale 1000\n"
f"\t> python pyCreateTh.py Entree.th\n"
f"{Colors.GREEN}Configuration profiles in {Colors.BLUE}config.ini{Colors.GREEN} file{Colors.ENDC}\n"
f"{Colors.GREEN}\t{Colors.BLUE}--Default{Colors.ENDC}\tDefault configuration (or none){Colors.ENDC}\n"
f"{Colors.GREEN}\t{Colors.BLUE}--PSM{Colors.ENDC}\t\tPSM configuration values{Colors.ENDC}\n\n"
f"{Colors.GREEN}If no {Colors.BLUE}--file {Colors.GREEN}argument : {Colors.ENDC}files selection by a windows\n\n"
f"{Colors.GREEN}Examples:{Colors.ENDC}\n"
f"\t> python pyCreateTh.py ./Tests/Entree.th --scale 1000 --Default\n"
f"\t> python pyCreateTh.py Entree.th --PSM\n"
f"\t> python pyCreateTh.py --Tritons\n"
f"\t> python pyCreateTh.py\n\n")
args = parser.parse_args()
args, unknown = parser.parse_known_args()
for arg in unknown:
if arg.startswith("--"):
profile = arg[2:]
section = f"Survey_Data:{profile}"
if args.file == "":
args.file = select_file_tk_window()
@@ -2233,7 +2245,7 @@ if __name__ == u'__main__':
#################################################################################################
# Reading config.ini #
#################################################################################################
config_file = load_config(args)
config_file, profile = load_config(args, profile=profile)
#################################################################################################
# titre #
@@ -2262,7 +2274,7 @@ if __name__ == u'__main__':
pad_line(f"Input file : {Colors.ENDC}{safe_relpath(args.file)}"),
pad_line(f"Output folder : {Colors.ENDC}{safe_relpath(splitext(abspath(args.file))[0])}"),
pad_line(f"Log file : {Colors.ENDC}{os.path.basename(output_log)}"),
pad_line(f"Config file: {Colors.ENDC}{safe_relpath(config_file)}"),
pad_line(f"Config file : {Colors.ENDC}{safe_relpath(config_file)}{Colors.GREEN}, profile : {Colors.ENDC}{profile}"),
pad_line(""),
bordure
]
@@ -2274,7 +2286,16 @@ if __name__ == u'__main__':
if args.file == "":
log.critical(f"No valid file selected, try again")
exit(0)
# print(f"{Colors.BLUE}Author = {Colors.ENDC}{globalData.Author}")
# print(f"{Colors.BLUE}Copyright = {Colors.ENDC}{globalData.Copyright}")
# print(f"{Colors.BLUE}CopyrightShort = {Colors.ENDC}{globalData.CopyrightShort}")
# print(f"{Colors.BLUE}mapComment = {Colors.ENDC}{globalData.mapComment}")
# print(f"{Colors.BLUE}cs = {Colors.ENDC}{globalData.cs}")
# print(f"{Colors.BLUE}club = {Colors.ENDC}{globalData.club}")
# print(f"{Colors.BLUE}thanksto = {Colors.ENDC}{globalData.thanksto}")
# print(f"{Colors.BLUE}datat = {Colors.ENDC}{globalData.datat}")
# print(f"{Colors.BLUE}wpage = {Colors.ENDC}{globalData.wpage}")
#################################################################################################
# Fichier TH #
+12 -8
View File
@@ -300,7 +300,7 @@ map MP-Synthese-PSM_LARRA-Plan-tot -title "Synthèse générale des réseaux de
endmap
# map MC-Synthese_PSM-Extended-tot -title "Synthese PSM"
map MC-Synthese_PSM-Extended-tot -title "Synthese PSM"
# # MC-00-Ref_Square-Extended-tot@00-Ref_Square
# break
# MC-Grotte_de_Alhais-Extended-tot@Grotte_de_Alhais
@@ -319,8 +319,8 @@ endmap
# break
# MC-C103-Extended-tot@C103
# break
# MC-C108-Sima_H-Extended-tot@C108-Sima_H
# break
MC-C108-Sima_H-Extended-tot@C108-Sima_H
break
# MC-C110-Extended-tot@C110
# break
# MC-Grotte_de_la_Cascade-Extended-tot@Grotte_de_la_Cascade
@@ -553,8 +553,8 @@ endmap
# break
# MC-Complexe_PSM_GdP-Extended-tot@Complexe_PSM_GdP
# break
# MC-L5-Extended-tot@L5
# break
MC-L5-Extended-tot@L5
break
# MC-AN455-Extended-tot@AN455
# break
# MC-AN465B-Extended-tot@AN465B
@@ -565,8 +565,6 @@ endmap
# break
# MC-Complexe_Ours-Veau-Extended-tot@Complexe_Ours-Veau
# break
# MC-Complexe_Lonne_Peyret-Bourrugues-Extended-tot@Complexe_Lonne_Peyret-Bourrugues
# break
# MC-AN326-Extended-tot@AN326
# break
# MC-C213-Extended-tot@C213
@@ -581,7 +579,13 @@ endmap
# break
# MC-Complexe_Anialarra-Extended-tot@Complexe_Anialarra
# break
MC-Complexe_Lonne_Peyret-Bourrugues-coupe-tot@Complexe_Lonne_Peyret-Bourrugues
break
MC-Z510-coupe-tot@Z510
break
MC-Tobozo-Extended-tot@Tobozo
break
# endmap
endmap
+2
View File
@@ -261,8 +261,10 @@ endlayout
# Export des xvi pour le dessin si besoin
#export map -fmt xvi -layout xviexport -o Data/xxxxxxxxxxxxxxxxxxx.xvi
select MC-Synthese_PSM-Extended-tot@Synthese-PSM_LARRA
select MP-Synthese-PSM_LARRA-Plan-tot@Synthese-PSM_LARRA
# Export des fichiers pdf, plan et coupe.
# ATTENTION, la topo étant énorme, il faut mettre l'option ne traçant pas la centerline !
export map -projection plan -fmt pdf -layout my_layout -o Outputs/Synthese-PSM_LARRA-Plan.pdf
+6 -1492
View File
File diff suppressed because one or more lines are too long