Skip to content

Instantly share code, notes, and snippets.

@CEZERT
Last active July 7, 2022 14:19
Show Gist options
  • Save CEZERT/cf15d86901cf378522ba1f9bd8113791 to your computer and use it in GitHub Desktop.
Save CEZERT/cf15d86901cf378522ba1f9bd8113791 to your computer and use it in GitHub Desktop.
import os
from PyQt5 import uic
from PyQt5.QtWidgets import QWidget, QApplication, QProgressBar
from qgis.core import QgsProcessingAlgorithm
from PyQt5.QtCore import QTimer
os.chdir(r"S:\09-Production\CLIENTS\AIR LIQUIDE\21-0178 TOPO 3D ALFI NORD 2021\Travail\Dao\Outils de traitement\Configurations")
FORM_CLASS, _ = uic.loadUiType("alfi_nord_2022.ui")
layers = QgsProject.instance().mapLayers().values()
for l in layers:
if 'Fusion' in l.name() and 'DET' in l.name():
l_det = l
if 'Fusion' in l.name() and 'CTRL' in l.name():
l_ctrl = l
if 'Fusion' in l.name() and 'SIG' in l.name():
l_sig = l
class MyWidget(QWidget, FORM_CLASS):
def __init__(self, parent=None):
super(MyWidget, self).__init__(parent)
self.setupUi(self)
# signals
self.preparation.pressed.connect(self.Preparation)
self.ctrlindiv.pressed.connect(self.CTRLS_INDIV)
self.ctrldxf.pressed.connect(self.CTRLS_DXF)
self.renum.pressed.connect(self.RENUM)
self.export_2.pressed.connect(self.EXPORTT)
self.prepaffsig.pressed.connect(self.PREPA_SIG)
self.majprofile.pressed.connect(self.PROFILE)
self.symbols.pressed.connect(self.styleapp)
#chargement calques client
self.centerline_2.pressed.connect(self.Centerline)
self.install_annexes.pressed.connect(self.Install_Annexes)
self.markers.pressed.connect(self.Markers)
def Preparation(self):
processing.runAndLoadResults("model:01-Preparation", {'FusionCTRL':l_ctrl,
'FusionDET':l_det,
'memorypoly':'DET Ligne',
'native:buffer_1:Buffer 10cm DET':'TEMPORARY_OUTPUT',
'native:buffer_2:Buffer 10cm CTRL':'TEMPORARY_OUTPUT',
'native:deleteduplicategeometries_1:LOCALISATION ERREURS LIGNE DET':'TEMPORARY_OUTPUT',
'native:extractbyattribute_1:VERIF EPOS CTRL':'TEMPORARY_OUTPUT',
'native:refactorfields_1:Distances et Angles':'TEMPORARY_OUTPUT',
'qgis:joinattributesbylocation_1:DET':'TEMPORARY_OUTPUT',
'qgis:refactorfields_4:CTRL':'TEMPORARY_OUTPUT'})
def CTRLS_INDIV(self):
processing.runAndLoadResults("model:02-Create CTRLS INDIV", {'det2':'DET',
'qgis:createpointslayerfromtable_4:CTRLs_Crées':'TEMPORARY_OUTPUT'})
def CTRLS_DXF(self):
pass
def RENUM(self):
processing.runAndLoadResults("model:04-Renum", {'CONCERT2dxfCANAENTERRESURVEY':'CANA_ENTERRE_SURVEY(L)',
'cetligne2':'DET Ligne 2',
'det':'CTRL',
'fusiondet':'DET',
'virtuallayer':'CTRL Ligne 2',
'native:deleteduplicategeometries_1:LOCALISATION ERREURS LIGNE DET 2':'TEMPORARY_OUTPUT',
'native:deleteduplicategeometries_2:LOCALISATION ERREURS LIGNE CTRL 2':'TEMPORARY_OUTPUT',
'native:extractbyattribute_3:VERIF OPERATEURS':'TEMPORARY_OUTPUT',
'native:refactorfields_3:Qualif_trace_initial':'TEMPORARY_OUTPUT',
'qgis:refactorfields_1:Fusion DET RENUM':'TEMPORARY_OUTPUT',
'qgis:refactorfields_4:Fusion CTRL RENUM':'TEMPORARY_OUTPUT',
'script:0 Profile AL_1:PROFILE DET CANA':'TEMPORARY_OUTPUT',
'script:0 Profile AL_2:PROFILE DET TN':'TEMPORARY_OUTPUT',
'script:0 Profile AL_2:PROFILE ETIQUETTES':'TEMPORARY_OUTPUT',
'script:0 Profile AL_2:PROFILE TABLEAU':'TEMPORARY_OUTPUT'})
def styleapp(self):
layers = QgsProject.instance().mapLayers().values()
for ll in layers:
if "ETIQUETTES" in ll.name():
ll.loadNamedStyle('S:/09-Production/CLIENTS/AIR LIQUIDE/21-0178 TOPO 3D ALFI NORD 2021/Travail/Dao/Outils de traitement/Styles/PROFIL_ETIQUETTES.qml')
ll.triggerRepaint()
def EXPORTT(self):
processing.runAndLoadResults("model:06-Export", {'CONVERT2dxfAltDetect':'AtlDetect(P)',
'FusionCTRLModif':'Fusion CTRL RENUM',
'FusionDETModif':'Fusion DET RENUM',
'Qualiftraceinitial':'Qualif_trace_initial',
'native:fieldcalculator_1:Qualif_trace_final':'TEMPORARY_OUTPUT',
'native:fieldcalculator_13:Fusion_DET_final':'TEMPORARY_OUTPUT',
'native:fieldcalculator_14:Fusion_CTRL_final':'TEMPORARY_OUTPUT',})
def PREPA_SIG(self):
processing.runAndLoadResults("model:07-Prepa_AFF_SIG", {'Accessoiresannexe13':'Fusion_80_AFF_SIG Sheet1_pt',
'native:refactorfields_2:Fusion_AFF_SIG_preparé':'TEMPORARY_OUTPUT'})
def PROFILE(self):
processing.runAndLoadResults("model:MAJ Profile 3D", {'DET':'Fusion DET RENUM',
'script:0 Profile AL_1:PROFILE DET CANA':'TEMPORARY_OUTPUT',
'script:0 Profile AL_2:PROFILE DET TN':'TEMPORARY_OUTPUT'})
def Centerline(self):
centerline_l = r"S:\09-Production\CLIENTS\AIR LIQUIDE\21-0178 TOPO 3D ALFI NORD 2021\Travail\Dao\Outils de traitement\SHP_FME\CENTERLINE_AVEC_DN RGF93 pour QualifTracé.shp"
vlayer = QgsVectorLayer(centerline_l, "CENTERLINE", "ogr")
QgsProject.instance().addMapLayer(vlayer)
def Install_Annexes(self):
inst_annex_l = r"S:\09-Production\CLIENTS\AIR LIQUIDE\21-0178 TOPO 3D ALFI NORD 2021\Travail\Dao\Outils de traitement\SHP_FME\INSTALLATIONS_ANNEXES.shp"
vlayer = QgsVectorLayer(inst_annex_l, "INSTALLATION_ANNEXES", "ogr")
QgsProject.instance().addMapLayer(vlayer)
def Markers(self):
mark = r"S:\09-Production\CLIENTS\AIR LIQUIDE\21-0178 TOPO 3D ALFI NORD 2021\Travail\Dao\Outils de traitement\SHP_FME\markers_mars2021_v5_2154.shp"
vlayer = QgsVectorLayer(mark, "MARKERS", "ogr")
QgsProject.instance().addMapLayer(vlayer)
class MyTool(QgsProcessingAlgorithm):
INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
def createCustomParametersWidget(self):
self.myWidget = MyWidget()
self.myWidget.show()
my_alg = MyTool()
my_alg.createCustomParametersWidget()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment