Commit 17e1e186 authored by Alice Salsé's avatar Alice Salsé
Browse files

🎁 recalage plugin

parent cf3e7baa
......@@ -134,6 +134,15 @@ class NetworkTools:
self.createevent.triggered.connect(self.createEvent)
self.menu.addAction(self.createevent)
self.moveselected = QAction(QIcon(":/plugins/qgsplug/icon.png"),
"Recaler les objets sélectionnés",
self.iface.mainWindow())
self.moveselected.setObjectName("MoveSelected")
self.moveselected.setWhatsThis("Recaler les objets sélectionnés")
self.moveselected.setStatusTip("This is status tip")
self.moveselected.triggered.connect(self.moveSelected)
self.menu.addAction(self.moveselected)
menuBar = self.iface.mainWindow().menuBar()
menuBar.insertMenu(self.iface.firstRightStandardMenu().menuAction(),
self.menu)
......@@ -386,3 +395,48 @@ class NetworkTools:
else :
self.iface.messageBar().pushMessage("Veuillez sélectionner une couche d'abord", Qgis.Warning)
return
def moveSelected(self):
print("moveSelected: run called!")
selection = self.activeLayerSelection()
if selection :
lyr_id, l_ids = selection
if len(l_ids) > 0:
layer = self.root.findLayer(lyr_id).layer()
if not layer.dataProvider().transaction():
self.iface.messageBar().pushMessage("La couche doit être en édition", Qgis.Warning)
return
if layer.geometryType() == QgsWkbTypes.PointGeometry :
leves, ctrl = QInputDialog.getItem(QInputDialog(), "Levés", "Choisir les levés cible", ['Corrige', 'ESRI', 'Chapuis', 'CSV', 'DWG', 'ProxDWG'], 0)
if ctrl :
echecs=[]
l_qtablename=layer.dataProvider().uri().quotedTablename ()
for i in l_ids :
if leves == 'ESRI' :
query="UPDATE "+l_qtablename+" SET geom = ST_SetSRID(st_makepoint(x_reel_esri,y_reel_esri),2154), statut = 'recal auto ESRI' WHERE id = " + str(i)+ ";"
elif leves == 'Chapuis':
query="UPDATE "+l_qtablename+" SET geom = ST_SetSRID(st_makepoint(x_chapuis,y_chapuis),2154), statut = 'recal auto Chapuis' WHERE id = " + str(i)+ ";"
elif leves == 'Corrige':
query="UPDATE "+l_qtablename+" SET geom = ST_SetSRID(st_makepoint(x_corrige,y_corrige),2154), statut = 'recal auto Corrige' WHERE id = " + str(i)+ ";"
elif leves == 'CSV':
query="UPDATE "+l_qtablename+" SET geom = ST_SetSRID(st_makepoint(x_csv,y_csv),2154), statut = 'recal auto CSV' WHERE id = " + str(i)+ ";"
elif leves == 'DWG':
query="UPDATE "+l_qtablename+" SET geom = ST_SetSRID(st_makepoint(x_dwg,y_dwg),2154), statut = 'recal auto DWG' WHERE id = " + str(i)+ ";"
elif leves == 'ProxDWG':
query="UPDATE "+l_qtablename+" SET geom = ST_SetSRID(st_makepoint(x_proxdwg,y_proxdwg),2154), statut = 'recal auto prox DWG' WHERE id = " + str(i)+ ";"
result=layer.dataProvider().transaction().executeSql(query,True)
if result[0] == True :
pass
else :
echecs.append(str(i) + " : " + result[1].split('\n')[0])
if len(echecs) == 0 :
self.iface.messageBar().pushMessage("Recalage réussi pour {} objets".format(len(l_ids)), Qgis.Info)
else :
self.iface.messageBar().pushMessage("Recalage echoué pour {}/{} : ".format(len(echecs),len(l_ids)) + ','.join(echecs), Qgis.Warning)
# return
else :
self.iface.messageBar().pushMessage("La couche sélectionnée n'est pas de type point", Qgis.Warning)
return
else:
self.iface.messageBar().pushMessage("Sélectionner au moins 1 objet", Qgis.Warning)
return
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment