Téléverser les fichiers vers "CenRa_FLUX"
This commit is contained in:
parent
7b6e77d17e
commit
839eb525e4
@ -34,6 +34,8 @@ import os.path, os, shutil
|
||||
from qgis.core import *
|
||||
from qgis.gui import *
|
||||
from qgis.utils import *
|
||||
from .forms.about_form import FluxAboutDialog
|
||||
import qgis
|
||||
import processing
|
||||
import psycopg2
|
||||
import psycopg2.extras
|
||||
@ -136,6 +138,14 @@ class FluxCEN:
|
||||
'i18n',
|
||||
'FluxCEN_{}.qm'.format(locale))
|
||||
|
||||
version = qgis.utils.pluginMetadata('CenRa_FLUX','version')
|
||||
# Display About window on first use
|
||||
s = QSettings()
|
||||
versionUse = s.value("flux/version", 1, type=str)
|
||||
if str(versionUse) != str(version) :
|
||||
s.setValue("flux/version", str(version))
|
||||
self.open_about_dialog()
|
||||
|
||||
if os.path.exists(locale_path):
|
||||
self.translator = QTranslator()
|
||||
self.translator.load(locale_path)
|
||||
@ -205,6 +215,10 @@ class FluxCEN:
|
||||
# else:
|
||||
# iface.messageBar().pushMessage("Information :", "Une nouvelle version de FluxCEN est disponible, veuillez mettre à jour le plugin !", level=Qgis.Info, duration=120)
|
||||
|
||||
def open_about_dialog(self):
|
||||
dialog = FluxAboutDialog(self.iface)
|
||||
dialog.exec_()
|
||||
|
||||
def _mousePressEvent(self, event):
|
||||
self.dlg.lineEdit.setText("")
|
||||
self.dlg.lineEdit.mousePressEvent = None
|
||||
@ -338,6 +352,7 @@ class FluxCEN:
|
||||
self.iface.removeToolBarIcon(action)
|
||||
|
||||
def bd_source(self):
|
||||
self.dlg.activateWindow()
|
||||
bd_origine=self.dlg.comboBox_2.currentText()
|
||||
if bd_origine == 'REF':
|
||||
self.run_ref()
|
||||
@ -713,13 +728,40 @@ class FluxCEN:
|
||||
table = self.dlg.tableWidget_2.item(row,2).text()#.split("?", 1)[0]
|
||||
uri = QgsDataSourceUri()
|
||||
uri.setConnection(host ,port ,dbtype ,user ,mdp)
|
||||
|
||||
# nom du schéma à remplacer: "hydrographie" à supprimer et mettre "couches_collaboratives" lorsqu'on aura regroupé les couches à modifier dans un même schéma
|
||||
|
||||
uri.setDataSource(schema, table, "geom")
|
||||
uri.setKeyColumn('gid')
|
||||
|
||||
# Chargement de la couche PostGIS
|
||||
layer = QgsVectorLayer(uri.uri(), table, "postgres")
|
||||
# Ajout de la couche au canevas QGIS
|
||||
QgsProject.instance().addMapLayer(layer)
|
||||
geom_type ='SELECT right(st_geometrytype(geom),-3) as a FROM '+schema+'.'+table+' GROUP BY a'
|
||||
cur.execute(geom_type)
|
||||
list_typegeom = cur.fetchall()
|
||||
print(len(list_typegeom))
|
||||
if len(list_typegeom) > 1:
|
||||
for typegeom in list_typegeom:
|
||||
if typegeom[0] == 'MultiPolygon':
|
||||
uri.setWkbType(QgsWkbTypes.MultiPolygon)
|
||||
elif typegeom[0] == 'MultiLineString':
|
||||
uri.setWkbType(QgsWkbTypes.MultiLineString)
|
||||
elif typegeom[0] == 'Point':
|
||||
uri.setWkbType(QgsWkbTypes.Point)
|
||||
if typegeom[0] == 'Polygon':
|
||||
uri.setWkbType(QgsWkbTypes.Polygon)
|
||||
elif typegeom[0] == 'LineString':
|
||||
uri.setWkbType(QgsWkbTypes.LineString)
|
||||
elif typegeom[0] == 'MultiPoint':
|
||||
uri.setWkbType(QgsWkbTypes.MultiPoint)
|
||||
if (typegeom[0] != None and typegeom[0] != 'Polygon'):
|
||||
uri.setSrid('2154')
|
||||
layer = QgsVectorLayer(uri.uri(), table, "postgres")
|
||||
# Ajout de la couche au canevas QGIS
|
||||
QgsProject.instance().addMapLayer(layer)
|
||||
else:
|
||||
layer = QgsVectorLayer(uri.uri(), table, "postgres")
|
||||
# Ajout de la couche au canevas QGIS
|
||||
QgsProject.instance().addMapLayer(layer)
|
||||
'''
|
||||
try:
|
||||
service = re.search('SERVICE=(.+?)&VERSION', self.dlg.tableWidget_2.item(row,4).text()).group(1)
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
name=CenRa_FLUX
|
||||
qgisMinimumVersion=3.0
|
||||
description=Permet d'ouvrire une table dans la base PostGis
|
||||
version=1.9
|
||||
version=1.14
|
||||
author=Conservatoire d'Espaces Naturels de Rhône-Alpes
|
||||
email=si_besoin@cen-rhonealpes.fr
|
||||
|
||||
@ -32,6 +32,8 @@ icon=cenra.png
|
||||
# experimental flag
|
||||
experimental=False
|
||||
|
||||
changelog=<h1>CenRA_FLUX:</h1></br><p><h3>03/10/2024 - Version 1.14:</h3> - Remonte la fênetre dans la pille.</br></p><p><h3>13/09/2024 - Version 1.13:</h3>- MAJ sur le lien du changelog</br>- Bug-fix: Ouvre MultiPolygone et Polygon séparément.</p></br><p><h3>10/09/2024 - Version 1.11:</h3>- Ouverture de table contenant plusieurs géométries.</p></br><p><h3>26/08/2024 - Version 1.10:</h3>- Ajoute d'un changelog et vérification de mise à jour.</p>
|
||||
|
||||
# deprecated flag (applies to the whole plugin, not just a single version)
|
||||
deprecated=False
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user