flake8 sicen
This commit is contained in:
parent
e503423e49
commit
ca1d895eb1
@ -22,6 +22,7 @@
|
|||||||
"""
|
"""
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
|
||||||
def classFactory(iface):
|
def classFactory(iface):
|
||||||
# load SICEN class from file SICEN
|
# load SICEN class from file SICEN
|
||||||
from .sicen import SICEN
|
from .sicen import SICEN
|
||||||
|
|||||||
@ -5,10 +5,9 @@
|
|||||||
# Created by: The Resource Compiler for PyQt5 (Qt v5.15.2)
|
# Created by: The Resource Compiler for PyQt5 (Qt v5.15.2)
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
try:
|
|
||||||
from PyQt5 import QtCore
|
from qgis.PyQt import QtCore
|
||||||
except:
|
|
||||||
from PyQt6 import QtCore
|
|
||||||
qt_resource_data = b"\
|
qt_resource_data = b"\
|
||||||
\x00\x00\x0d\x89\
|
\x00\x00\x0d\x89\
|
||||||
\x89\
|
\x89\
|
||||||
@ -558,10 +557,13 @@ else:
|
|||||||
rcc_version = 2
|
rcc_version = 2
|
||||||
qt_resource_struct = qt_resource_struct_v2
|
qt_resource_struct = qt_resource_struct_v2
|
||||||
|
|
||||||
|
|
||||||
def qInitResources():
|
def qInitResources():
|
||||||
QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
|
QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
|
||||||
|
|
||||||
|
|
||||||
def qCleanupResources():
|
def qCleanupResources():
|
||||||
QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
|
QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data)
|
||||||
|
|
||||||
|
|
||||||
qInitResources()
|
qInitResources()
|
||||||
|
|||||||
@ -1,61 +1,20 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
|
||||||
/***************************************************************************
|
|
||||||
SICEN
|
|
||||||
A QGIS plugin
|
|
||||||
Filtre sur données SICEN
|
|
||||||
-------------------
|
|
||||||
begin : 2014-10-17
|
|
||||||
copyright : (C) 2014 by Guillaume COSTES (CENRA)
|
|
||||||
email : guillaume.costes@espaces-naturels.fr
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
* *
|
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
|
||||||
* it under the terms of the GNU General Public License as published by *
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
***************************************************************************/
|
|
||||||
"""
|
|
||||||
"""from __future__ import absolute_import
|
|
||||||
# Import the PyQt and QGIS libraries
|
|
||||||
from builtins import str
|
|
||||||
from builtins import object
|
|
||||||
from PyQt4.QtCore import *
|
|
||||||
from PyQt4.QtGui import *
|
|
||||||
from qgis.core import *
|
|
||||||
from qgis.gui import *
|
|
||||||
from qgis.utils import iface"""
|
|
||||||
|
|
||||||
from builtins import str
|
from builtins import str
|
||||||
from builtins import object
|
from builtins import object
|
||||||
import os
|
import os
|
||||||
try:
|
|
||||||
from PyQt5.QtCore import *
|
|
||||||
from PyQt5.QtGui import *
|
|
||||||
except:
|
|
||||||
from PyQt6.QtCore import *
|
|
||||||
from PyQt6.QtGui import *
|
|
||||||
from qgis.PyQt import uic
|
|
||||||
from qgis.core import *
|
|
||||||
from qgis.core import QgsDataSourceUri, QgsWkbTypes, QgsLayerTreeGroup, QgsLayerTreeLayer
|
|
||||||
from qgis.PyQt.QtGui import QFont
|
|
||||||
from qgis.PyQt.QtWidgets import QMenu, QAction, QDialog, QDialogButtonBox, QLabel, QApplication, QTabWidget, QWidget, QGroupBox, QGridLayout, QComboBox, QCheckBox, QCalendarWidget, QToolBox, QFrame, QLineEdit, QSizePolicy, QFileDialog #Modifié
|
|
||||||
|
|
||||||
|
# from qgis.PyQt import uic
|
||||||
|
from qgis.core import QgsDataSourceUri, QgsLayerTreeLayer, QgsProject, QgsVectorLayer
|
||||||
|
from qgis.PyQt.QtGui import QIcon
|
||||||
|
from qgis.PyQt.QtWidgets import QMenu, QAction, QFileDialog
|
||||||
|
from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication, qVersion
|
||||||
|
|
||||||
# Initialize Qt resources from file resources.py
|
# Initialize Qt resources from file resources.py
|
||||||
from . import resources_rc
|
from . import resources_rc
|
||||||
# Import the code for the dialog
|
# Import the code for the dialog
|
||||||
from .sicendialog import SICENDialog
|
from .sicendialog import SICENDialog
|
||||||
|
|
||||||
from .tools.resources import maj_verif,pyperclip
|
|
||||||
pyperclip()
|
|
||||||
try:
|
|
||||||
from .tools.PythonSQL import login_base
|
|
||||||
except:
|
|
||||||
print('Pas de fichier PythonSQL')
|
|
||||||
import os.path
|
import os.path
|
||||||
import qgis
|
import qgis
|
||||||
import datetime
|
import datetime
|
||||||
@ -63,11 +22,19 @@ import csv
|
|||||||
|
|
||||||
from .forms.about_form import AboutDialog
|
from .forms.about_form import AboutDialog
|
||||||
|
|
||||||
import psycopg2
|
# import psycopg2
|
||||||
import psycopg2.extras
|
# import psycopg2.extras
|
||||||
import base64
|
# import base64
|
||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from .tools.resources import maj_verif, pyperclip
|
||||||
|
pyperclip()
|
||||||
|
try:
|
||||||
|
from .tools.PythonSQL import login_base
|
||||||
|
except ValueError:
|
||||||
|
print('Pas de fichier PythonSQL')
|
||||||
|
|
||||||
# import sys
|
# import sys
|
||||||
|
|
||||||
|
|
||||||
@ -105,7 +72,7 @@ class SICEN(object):
|
|||||||
self.toolBar = self.iface.addToolBar("SICEN")
|
self.toolBar = self.iface.addToolBar("SICEN")
|
||||||
self.toolBar.setObjectName("SICEN")
|
self.toolBar.setObjectName("SICEN")
|
||||||
|
|
||||||
## Create action that will start plugin configuration
|
# Create action that will start plugin configuration
|
||||||
self.action = QAction(
|
self.action = QAction(
|
||||||
QIcon(":/plugins/sicen/sicen.png"),
|
QIcon(":/plugins/sicen/sicen.png"),
|
||||||
u"Ouverture des données SICEN", self.iface.mainWindow())
|
u"Ouverture des données SICEN", self.iface.mainWindow())
|
||||||
@ -119,7 +86,7 @@ class SICEN(object):
|
|||||||
self.toolBar.addAction(self.action)
|
self.toolBar.addAction(self.action)
|
||||||
self.iface.addPluginToMenu(u"SICEN", self.action)
|
self.iface.addPluginToMenu(u"SICEN", self.action)
|
||||||
|
|
||||||
## Create action that will start plugin configuration
|
# Create action that will start plugin configuration
|
||||||
self.action = QAction(
|
self.action = QAction(
|
||||||
QIcon(":/plugins/sicen/sicen_export.png"),
|
QIcon(":/plugins/sicen/sicen_export.png"),
|
||||||
u"Export liste d'espèces", self.iface.mainWindow())
|
u"Export liste d'espèces", self.iface.mainWindow())
|
||||||
@ -175,7 +142,7 @@ class SICEN(object):
|
|||||||
cur = account[7]
|
cur = account[7]
|
||||||
con = account[8]
|
con = account[8]
|
||||||
|
|
||||||
## Creation des listes deroulantes
|
# Creation des listes deroulantes
|
||||||
# Listing de valeur des champs
|
# Listing de valeur des champs
|
||||||
SQL_observateur = u"""SELECT DISTINCT nom || '_' || prenom as nom FROM md.personne ORDER BY nom"""
|
SQL_observateur = u"""SELECT DISTINCT nom || '_' || prenom as nom FROM md.personne ORDER BY nom"""
|
||||||
SQL_nom_com = u"""SELECT DISTINCT nom FROM saisie.commune ORDER BY nom"""
|
SQL_nom_com = u"""SELECT DISTINCT nom FROM saisie.commune ORDER BY nom"""
|
||||||
@ -201,14 +168,14 @@ class SICEN(object):
|
|||||||
|
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
|
|
||||||
# Ajout des items dans les combobox
|
# Ajout des items dans les combobox
|
||||||
self.dlg.observateur_1.clear()
|
self.dlg.observateur_1.clear()
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(list_observateur):
|
while i < len(list_observateur):
|
||||||
self.dlg.observateur_1.addItems(list_observateur[i])
|
self.dlg.observateur_1.addItems(list_observateur[i])
|
||||||
i = i + 1
|
i = i + 1
|
||||||
self.dlg.observateur_1.setCurrentIndex(-1) # Pour ne pas commencer la liste au premier item
|
# Pour ne pas commencer la liste au premier item
|
||||||
|
self.dlg.observateur_1.setCurrentIndex(-1)
|
||||||
|
|
||||||
self.dlg.observateur_2.clear()
|
self.dlg.observateur_2.clear()
|
||||||
i = 0
|
i = 0
|
||||||
@ -496,7 +463,6 @@ class SICEN(object):
|
|||||||
else:
|
else:
|
||||||
sql_UICN = ''
|
sql_UICN = ''
|
||||||
|
|
||||||
|
|
||||||
if self.dlg.PATRIMONIALITE.isChecked() == 1:
|
if self.dlg.PATRIMONIALITE.isChecked() == 1:
|
||||||
sql_patrimonialite = """"patrimonialite" IS NOT NULL """
|
sql_patrimonialite = """"patrimonialite" IS NOT NULL """
|
||||||
else:
|
else:
|
||||||
@ -542,7 +508,6 @@ class SICEN(object):
|
|||||||
else:
|
else:
|
||||||
sql_patri74 = ''
|
sql_patri74 = ''
|
||||||
|
|
||||||
|
|
||||||
if self.dlg.ZNIEFF.isChecked() == 1:
|
if self.dlg.ZNIEFF.isChecked() == 1:
|
||||||
sql_znieff = """"znieff" IS NOT NULL """
|
sql_znieff = """"znieff" IS NOT NULL """
|
||||||
else:
|
else:
|
||||||
@ -573,7 +538,7 @@ class SICEN(object):
|
|||||||
else:
|
else:
|
||||||
sql_pr = ''
|
sql_pr = ''
|
||||||
|
|
||||||
reqwhere_pat = sql_lrd01 + 'OR' + sql_lrd07 + 'OR' + sql_lrd26 + 'OR' + sql_lrd38 + 'OR' + sql_lrd42 + 'OR' + sql_lrd69 + 'OR' + sql_lrd73 + 'OR' + sql_lrd74 + 'OR' + sql_lre + 'OR' + sql_LRN_Flore + 'OR' + sql_LRN_Oiseaux + 'OR' + sql_LRN_Ortho + 'OR' + sql_LRN_Autre + 'OR' + sql_LRR_Flore + 'OR' + sql_LRR_Oiseaux + 'OR' + sql_LRR_Autre + 'OR' + sql_UICN + 'OR' + sql_pd38 + 'OR' + sql_pd42 + 'OR' + sql_pn + 'OR' + sql_pr + 'OR' + sql_dh_an2 + 'OR' + sql_patri01 + 'OR' + sql_patri07 + 'OR' + sql_patri26 + 'OR' + sql_patri38 + 'OR' + sql_patri42 + 'OR' + sql_patri69 + 'OR' + sql_patri73 + 'OR' + sql_patri74 + 'OR' + sql_patrimonialite
|
reqwhere_pat = sql_lrd01 + 'OR' + sql_lrd07 + 'OR' + sql_lrd26 + 'OR' + sql_lrd38 + 'OR' + sql_lrd42 + 'OR' + sql_lrd69 + 'OR' + sql_lrd73 + 'OR' + sql_lrd74 + 'OR' + sql_lre + 'OR' + sql_LRN_Flore + 'OR' + sql_LRN_Oiseaux + 'OR' + sql_LRN_Ortho + 'OR' + sql_LRN_Autre + 'OR' + sql_LRR_Flore + 'OR' + sql_LRR_Oiseaux + 'OR' + sql_LRR_Autre + 'OR' + sql_UICN + 'OR' + sql_pd38 + 'OR' + sql_pd42 + 'OR' + sql_pn + 'OR' + sql_pr + 'OR' + sql_znieff + 'OR' + sql_dh_an2 + 'OR' + sql_patri01 + 'OR' + sql_patri07 + 'OR' + sql_patri26 + 'OR' + sql_patri38 + 'OR' + sql_patri42 + 'OR' + sql_patri69 + 'OR' + sql_patri73 + 'OR' + sql_patri74 + 'OR' + sql_patrimonialite
|
||||||
|
|
||||||
while reqwhere_pat.find('OROR') != - 1:
|
while reqwhere_pat.find('OROR') != - 1:
|
||||||
reqwhere_pat = reqwhere_pat.replace('OROR', 'OR')
|
reqwhere_pat = reqwhere_pat.replace('OROR', 'OR')
|
||||||
@ -586,9 +551,9 @@ class SICEN(object):
|
|||||||
if self.dlg.bouton_geom.isChecked() == 1:
|
if self.dlg.bouton_geom.isChecked() == 1:
|
||||||
|
|
||||||
layer = self.iface.activeLayer()
|
layer = self.iface.activeLayer()
|
||||||
if layer == None :
|
if layer is None:
|
||||||
# self.iface.messageBar().pushMessage(u"Vous devez sélectionner une table !", level=QgsMessageBar.WARNING, duration=5)
|
# self.iface.messageBar().pushMessage(u"Vous devez sélectionner une table !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner une table !", level=Qgis.Warning, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner une table !", level=1, duration=5)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
selection = layer.selectedFeatures()
|
selection = layer.selectedFeatures()
|
||||||
@ -620,14 +585,14 @@ class SICEN(object):
|
|||||||
while reqwhere_final[:3] == 'AND':
|
while reqwhere_final[:3] == 'AND':
|
||||||
reqwhere_final = reqwhere_final[3:]
|
reqwhere_final = reqwhere_final[3:]
|
||||||
|
|
||||||
## Affichage des tables
|
# Affichage des tables
|
||||||
table_name = 'observations'
|
table_name = 'observations'
|
||||||
|
|
||||||
uri = QgsDataSourceUri()
|
uri = QgsDataSourceUri()
|
||||||
uri.setConnection(host, port, dbname, user, mdp)
|
uri.setConnection(host, port, dbname, user, mdp)
|
||||||
|
|
||||||
if self.dlg.centroide.isChecked() == 1:
|
if self.dlg.centroide.isChecked() == 1:
|
||||||
### Centroide
|
# Centroide
|
||||||
if reqwhere_final.find('()') != - 1:
|
if reqwhere_final.find('()') != - 1:
|
||||||
reqwhere_final = ''
|
reqwhere_final = ''
|
||||||
print(reqwhere_final)
|
print(reqwhere_final)
|
||||||
@ -660,9 +625,9 @@ class SICEN(object):
|
|||||||
# groups = toc.
|
# groups = toc.
|
||||||
# groups = toc.groups()
|
# groups = toc.groups()
|
||||||
# index = groups.index(nomgroupe)
|
# index = groups.index(nomgroupe)
|
||||||
index = 1
|
# index = 1
|
||||||
|
|
||||||
### Polygone
|
# Polygone
|
||||||
reqwhere_final_poly = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POLYGON%'" + ')'
|
reqwhere_final_poly = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POLYGON%'" + ')'
|
||||||
if reqwhere_final_poly.find('()') != - 1:
|
if reqwhere_final_poly.find('()') != - 1:
|
||||||
reqwhere_final_poly = "(GeometryType(geometrie) LIKE '%POLYGON%')"
|
reqwhere_final_poly = "(GeometryType(geometrie) LIKE '%POLYGON%')"
|
||||||
@ -681,7 +646,7 @@ class SICEN(object):
|
|||||||
# groupe.addLayer(layer_poly)
|
# groupe.addLayer(layer_poly)
|
||||||
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_poly))
|
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_poly))
|
||||||
|
|
||||||
### Point
|
# Point
|
||||||
reqwhere_final_point = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POINT%'" + ')'
|
reqwhere_final_point = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POINT%'" + ')'
|
||||||
if reqwhere_final_point.find('()') != - 1:
|
if reqwhere_final_point.find('()') != - 1:
|
||||||
reqwhere_final_point = "(GeometryType(geometrie) LIKE '%POINT%')"
|
reqwhere_final_point = "(GeometryType(geometrie) LIKE '%POINT%')"
|
||||||
@ -700,7 +665,7 @@ class SICEN(object):
|
|||||||
# groupe.addLayer(layer_point)
|
# groupe.addLayer(layer_point)
|
||||||
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_point))
|
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_point))
|
||||||
|
|
||||||
### Ligne
|
# Ligne
|
||||||
reqwhere_final_ligne = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%LINE%'" + ')'
|
reqwhere_final_ligne = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%LINE%'" + ')'
|
||||||
if reqwhere_final_ligne.find('()') != - 1:
|
if reqwhere_final_ligne.find('()') != - 1:
|
||||||
reqwhere_final_ligne = "(GeometryType(geometrie) LIKE '%LINE%')"
|
reqwhere_final_ligne = "(GeometryType(geometrie) LIKE '%LINE%')"
|
||||||
@ -723,17 +688,16 @@ class SICEN(object):
|
|||||||
# legende.setGroupExpanded (index, True)
|
# legende.setGroupExpanded (index, True)
|
||||||
|
|
||||||
# self.iface.messageBar().pushMessage(u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=QgsMessageBar.INFO, duration=10)
|
# self.iface.messageBar().pushMessage(u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=QgsMessageBar.INFO, duration=10)
|
||||||
self.iface.messageBar().pushMessage("Info", u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=Qgis.Success, duration=4)
|
self.iface.messageBar().pushMessage("Info", u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=0, duration=4)
|
||||||
|
|
||||||
|
|
||||||
elif layer.selectedFeatureCount() == 0:
|
elif layer.selectedFeatureCount() == 0:
|
||||||
# self.iface.messageBar().pushMessage(u"Vous devez sélectionner au moins un polygone !", level=QgsMessageBar.WARNING, duration=5)
|
# self.iface.messageBar().pushMessage(u"Vous devez sélectionner au moins un polygone !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner au moins un polygone !", level=Qgis.Warning, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner au moins un polygone !", level=1, duration=5)
|
||||||
reqwhere_geom = ''
|
reqwhere_geom = ''
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# self.iface.messageBar().pushMessage(u"Vous devez sélectionner qu'un seul polygone !", level=QgsMessageBar.WARNING, duration=5)
|
# self.iface.messageBar().pushMessage(u"Vous devez sélectionner qu'un seul polygone !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous ne devez sélectionner qu'un seul polygone !", level=Qgis.Warning, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous ne devez sélectionner qu'un seul polygone !", level=1, duration=5)
|
||||||
reqwhere_geom = ''
|
reqwhere_geom = ''
|
||||||
else:
|
else:
|
||||||
# Requete finale
|
# Requete finale
|
||||||
@ -753,13 +717,13 @@ class SICEN(object):
|
|||||||
while reqwhere_final[:3] == 'AND':
|
while reqwhere_final[:3] == 'AND':
|
||||||
reqwhere_final = reqwhere_final[3:]
|
reqwhere_final = reqwhere_final[3:]
|
||||||
|
|
||||||
## Affichage des tables
|
# Affichage des tables
|
||||||
table_name = 'observations'
|
table_name = 'observations'
|
||||||
|
|
||||||
uri = QgsDataSourceUri()
|
uri = QgsDataSourceUri()
|
||||||
uri.setConnection(host, port, dbname, user, mdp)
|
uri.setConnection(host, port, dbname, user, mdp)
|
||||||
|
|
||||||
## Centroide
|
# Centroide
|
||||||
if self.dlg.centroide.isChecked() == 1:
|
if self.dlg.centroide.isChecked() == 1:
|
||||||
if reqwhere_final.find('()') != - 1:
|
if reqwhere_final.find('()') != - 1:
|
||||||
reqwhere_final = ''
|
reqwhere_final = ''
|
||||||
@ -792,9 +756,9 @@ class SICEN(object):
|
|||||||
# groups = toc.
|
# groups = toc.
|
||||||
# groups = toc.groups()
|
# groups = toc.groups()
|
||||||
# index = groups.index(nomgroupe)
|
# index = groups.index(nomgroupe)
|
||||||
index = 1
|
# index = 1
|
||||||
|
|
||||||
### Polygone
|
# Polygone
|
||||||
reqwhere_final_poly = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POLYGON%'" + ')'
|
reqwhere_final_poly = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POLYGON%'" + ')'
|
||||||
if reqwhere_final_poly.find('()') != - 1:
|
if reqwhere_final_poly.find('()') != - 1:
|
||||||
reqwhere_final_poly = "(GeometryType(geometrie) LIKE '%POLYGON%')"
|
reqwhere_final_poly = "(GeometryType(geometrie) LIKE '%POLYGON%')"
|
||||||
@ -813,7 +777,7 @@ class SICEN(object):
|
|||||||
# groupe.addLayer(layer_poly)
|
# groupe.addLayer(layer_poly)
|
||||||
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_poly))
|
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_poly))
|
||||||
|
|
||||||
### Point
|
# Point
|
||||||
reqwhere_final_point = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POINT%'" + ')'
|
reqwhere_final_point = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%POINT%'" + ')'
|
||||||
if reqwhere_final_point.find('()') != - 1:
|
if reqwhere_final_point.find('()') != - 1:
|
||||||
reqwhere_final_point = "(GeometryType(geometrie) LIKE '%POINT%')"
|
reqwhere_final_point = "(GeometryType(geometrie) LIKE '%POINT%')"
|
||||||
@ -832,7 +796,7 @@ class SICEN(object):
|
|||||||
# groupe.addLayer(layer_point)
|
# groupe.addLayer(layer_point)
|
||||||
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_point))
|
groupe.insertChildNode(0, QgsLayerTreeLayer(layer_point))
|
||||||
|
|
||||||
### Ligne
|
# Ligne
|
||||||
reqwhere_final_ligne = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%LINE%'" + ')'
|
reqwhere_final_ligne = '(' + reqwhere_final + " AND GeometryType(geometrie) LIKE '%LINE%'" + ')'
|
||||||
if reqwhere_final_ligne.find('()') != - 1:
|
if reqwhere_final_ligne.find('()') != - 1:
|
||||||
reqwhere_final_ligne = "(GeometryType(geometrie) LIKE '%LINE%')"
|
reqwhere_final_ligne = "(GeometryType(geometrie) LIKE '%LINE%')"
|
||||||
@ -855,7 +819,7 @@ class SICEN(object):
|
|||||||
# legende.setGroupExpanded (index, True)
|
# legende.setGroupExpanded (index, True)
|
||||||
|
|
||||||
# self.iface.messageBar().pushMessage(u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=QgsMessageBar.INFO, duration=10)
|
# self.iface.messageBar().pushMessage(u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=QgsMessageBar.INFO, duration=10)
|
||||||
self.iface.messageBar().pushMessage("Info", u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=Qgis.Success, duration=10)
|
self.iface.messageBar().pushMessage("Info", u"Extraction réussie : ", u" Pensez à renommer vos couches pour plus de lisibilité.", level=0, duration=10)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -863,9 +827,9 @@ class SICEN(object):
|
|||||||
|
|
||||||
layer = self.iface.activeLayer()
|
layer = self.iface.activeLayer()
|
||||||
|
|
||||||
if layer == None :
|
if layer is None:
|
||||||
# self.iface.messageBar().pushMessage(u"Vous devez sélectionner une table !", level=QgsMessageBar.WARNING, duration=5)
|
# self.iface.messageBar().pushMessage(u"Vous devez sélectionner une table !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner une table !", level=Qgis.Warning, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner une table !", level=1, duration=5)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
selection = layer.selectedFeatures()
|
selection = layer.selectedFeatures()
|
||||||
@ -877,13 +841,13 @@ class SICEN(object):
|
|||||||
buffer = '100'
|
buffer = '100'
|
||||||
|
|
||||||
account = login_base("account")
|
account = login_base("account")
|
||||||
user = account[0]
|
# user = account[0]
|
||||||
mdp = account[1]
|
# mdp = account[1]
|
||||||
host = account[2]
|
# host = account[2]
|
||||||
port = account[3]
|
# port = account[3]
|
||||||
dbname = account[4]
|
# dbname = account[4]
|
||||||
cur = account[7]
|
cur = account[7]
|
||||||
con = account[8]
|
# con = account[8]
|
||||||
|
|
||||||
SQL_list_sp = u"""SELECT DISTINCT classe::text,ordre::text,nom_complet::text,split_part(nom_vern::text,', ',1) as nom_vern,cd_ref::text as cd_ref,max(COALESCE(date_obs, date_debut_obs))::text AS derniere_obs FROM _agregation_ra.observations_table WHERE ST_intersects(geometrie,ST_Buffer(ST_geomFromText('""" + poly + "',2154), " + buffer + " ))GROUP BY classe::text, ordre::text, nom_complet::text, nom_vern::text, cd_ref::text ORDER BY nom_complet::text"""
|
SQL_list_sp = u"""SELECT DISTINCT classe::text,ordre::text,nom_complet::text,split_part(nom_vern::text,', ',1) as nom_vern,cd_ref::text as cd_ref,max(COALESCE(date_obs, date_debut_obs))::text AS derniere_obs FROM _agregation_ra.observations_table WHERE ST_intersects(geometrie,ST_Buffer(ST_geomFromText('""" + poly + "',2154), " + buffer + " ))GROUP BY classe::text, ordre::text, nom_complet::text, nom_vern::text, cd_ref::text ORDER BY nom_complet::text"""
|
||||||
cur.execute(SQL_list_sp)
|
cur.execute(SQL_list_sp)
|
||||||
@ -893,44 +857,51 @@ class SICEN(object):
|
|||||||
file = open(chemin_fichier, 'w', newline='', encoding='utf-8')
|
file = open(chemin_fichier, 'w', newline='', encoding='utf-8')
|
||||||
# file.write('\ufeff'.encode('utf8')) # BOM (optionel...Permet a Excel d'ouvrir proprement le fichier en UTF-8)
|
# file.write('\ufeff'.encode('utf8')) # BOM (optionel...Permet a Excel d'ouvrir proprement le fichier en UTF-8)
|
||||||
file.write('\ufeff')
|
file.write('\ufeff')
|
||||||
writer = csv.writer(file, delimiter = ';') # délimiteur ';' pour faciliter l'ouverture avec Excel
|
# délimiteur ';' pour faciliter l'ouverture avec Excel
|
||||||
writer.writerow(['Classe', 'Ordre', 'Nom Complet', 'Nom Vernaculaire','cd_ref', 'Date Derniere Observation']) # Création des entêtes
|
writer = csv.writer(file, delimiter=';')
|
||||||
|
# Création des entêtes
|
||||||
|
writer.writerow(['Classe', 'Ordre', 'Nom Complet', 'Nom Vernaculaire', 'cd_ref', 'Date Derniere Observation'])
|
||||||
|
|
||||||
for row in data_sp : # Boucle d'écriture ligne par ligne dans le csv
|
# Boucle d'écriture ligne par ligne dans le csv
|
||||||
|
for row in data_sp:
|
||||||
# print(1)
|
# print(1)
|
||||||
list_sp = []
|
list_sp = []
|
||||||
if row[0] == None : # Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
# Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
||||||
|
if row[0] is None:
|
||||||
row0 = str(row[0])
|
row0 = str(row[0])
|
||||||
row0 = ''
|
row0 = ''
|
||||||
else:
|
else:
|
||||||
row0 = row[0]
|
row0 = row[0]
|
||||||
# print(row0)
|
# print(row0)
|
||||||
list_sp.append(row0)
|
list_sp.append(row0)
|
||||||
if row[1] == None : # Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
# Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
||||||
|
if row[1] is None:
|
||||||
row1 = str(row[1])
|
row1 = str(row[1])
|
||||||
row1 = ''
|
row1 = ''
|
||||||
else:
|
else:
|
||||||
row1 = row[1]
|
row1 = row[1]
|
||||||
list_sp.append(row1)
|
list_sp.append(row1)
|
||||||
if row[2] == None : # Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
# Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
||||||
|
if row[2] is None:
|
||||||
row2 = str(row[2])
|
row2 = str(row[2])
|
||||||
row2 = ''
|
row2 = ''
|
||||||
else:
|
else:
|
||||||
row2 = row[2]
|
row2 = row[2]
|
||||||
list_sp.append(row2)
|
list_sp.append(row2)
|
||||||
if row[3] == None : # Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
# Si la valeur est 'None' l'encodage ne peut se faire donc boucle d'évitement
|
||||||
|
if row[3] is None:
|
||||||
row3 = str(row[3])
|
row3 = str(row[3])
|
||||||
row3 = ''
|
row3 = ''
|
||||||
else:
|
else:
|
||||||
row3 = row[3]
|
row3 = row[3]
|
||||||
list_sp.append(row3)
|
list_sp.append(row3)
|
||||||
if row[4] == None :
|
if row[4] is None:
|
||||||
row4 = str(row[4])
|
row4 = str(row[4])
|
||||||
row4 = ''
|
row4 = ''
|
||||||
else:
|
else:
|
||||||
row4 = row[4]
|
row4 = row[4]
|
||||||
list_sp.append(row4)
|
list_sp.append(row4)
|
||||||
if row[5] == None :
|
if row[5] is None:
|
||||||
row5 = str(row[5])
|
row5 = str(row[5])
|
||||||
row5 = ''
|
row5 = ''
|
||||||
else:
|
else:
|
||||||
@ -941,12 +912,12 @@ class SICEN(object):
|
|||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
# self.iface.messageBar().pushMessage(u"Export réussi dans " + chemin_fichier , level=QgsMessageBar.INFO, duration=5)
|
# self.iface.messageBar().pushMessage(u"Export réussi dans " + chemin_fichier , level=QgsMessageBar.INFO, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Export réussi dans " + chemin_fichier, level=Qgis.Success, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Export réussi dans " + chemin_fichier, level=0, duration=5)
|
||||||
|
|
||||||
elif (layer.selectedFeatureCount() == 0):
|
elif (layer.selectedFeatureCount() == 0):
|
||||||
# self.iface.messageBar().pushMessage(u"Vous devez sélectionner au moins un polygone !", level=QgsMessageBar.WARNING, duration=5)
|
# self.iface.messageBar().pushMessage(u"Vous devez sélectionner au moins un polygone !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner au moins un polygone !", level=Qgis.Warning, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous devez sélectionner au moins un polygone !", level=1, duration=5)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# self.iface.messageBar().pushMessage(u"Vous devez sélectionner qu'un seul polygone !", level=QgsMessageBar.WARNING, duration=5)
|
# self.iface.messageBar().pushMessage(u"Vous devez sélectionner qu'un seul polygone !", level=QgsMessageBar.WARNING, duration=5)
|
||||||
self.iface.messageBar().pushMessage("Ooops", u"Vous ne devez sélectionner qu'un seul polygone !", level=Qgis.Warning, duration=5)
|
self.iface.messageBar().pushMessage("Ooops", u"Vous ne devez sélectionner qu'un seul polygone !", level=1, duration=5)
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from qgis.PyQt import QtCore, QtGui
|
# from qgis.PyQt import QtCore, QtGui
|
||||||
from qgis.PyQt.QtWidgets import QAction, QDialog
|
from qgis.PyQt.QtWidgets import QDialog
|
||||||
from .ui_sicen import Ui_SICEN
|
from .ui_sicen import Ui_SICEN
|
||||||
# create the dialog for zoom to point
|
# create the dialog for zoom to point
|
||||||
|
|
||||||
|
|||||||
@ -8,9 +8,10 @@
|
|||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
from builtins import object
|
from builtins import object
|
||||||
from qgis.PyQt import QtCore, QtGui
|
from qgis.PyQt import QtCore
|
||||||
from qgis.PyQt.QtGui import QFont
|
from qgis.PyQt.QtGui import QFont
|
||||||
from qgis.PyQt.QtWidgets import QAction, QDialog, QDialogButtonBox, QLabel, QApplication, QTabWidget, QWidget, QGroupBox, QGridLayout, QComboBox, QCheckBox, QCalendarWidget, QToolBox, QFrame, QLineEdit, QSizePolicy #Modifié
|
# Modifié
|
||||||
|
from qgis.PyQt.QtWidgets import QDialogButtonBox, QLabel, QApplication, QTabWidget, QWidget, QGroupBox, QGridLayout, QComboBox, QCheckBox, QCalendarWidget, QToolBox, QFrame, QLineEdit, QSizePolicy
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -21,12 +22,14 @@ except AttributeError:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
_encoding = QApplication.UnicodeUTF8
|
_encoding = QApplication.UnicodeUTF8
|
||||||
|
|
||||||
def _translate(context, text, disambig):
|
def _translate(context, text, disambig):
|
||||||
return QApplication.translate(context, text, disambig, _encoding)
|
return QApplication.translate(context, text, disambig, _encoding)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
def _translate(context, text, disambig):
|
def _translate(context, text, disambig):
|
||||||
return QApplication.translate(context, text, disambig)
|
return QApplication.translate(context, text, disambig)
|
||||||
|
|
||||||
|
|
||||||
class Ui_SICEN(object):
|
class Ui_SICEN(object):
|
||||||
def setupUi(self, SICEN):
|
def setupUi(self, SICEN):
|
||||||
SICEN.setObjectName(_fromUtf8("SICEN"))
|
SICEN.setObjectName(_fromUtf8("SICEN"))
|
||||||
@ -681,7 +684,8 @@ class Ui_SICEN(object):
|
|||||||
self.Emprise.setCurrentIndex(0)
|
self.Emprise.setCurrentIndex(0)
|
||||||
self.protections.setCurrentIndex(0)
|
self.protections.setCurrentIndex(0)
|
||||||
self.buttonBox.accepted.connect(SICEN.accept)
|
self.buttonBox.accepted.connect(SICEN.accept)
|
||||||
self.buttonBox.rejected.connect(SICEN.reject) #Modifié
|
# Modifié
|
||||||
|
self.buttonBox.rejected.connect(SICEN.reject)
|
||||||
QtCore.QMetaObject.connectSlotsByName(SICEN)
|
QtCore.QMetaObject.connectSlotsByName(SICEN)
|
||||||
|
|
||||||
def retranslateUi(self, SICEN):
|
def retranslateUi(self, SICEN):
|
||||||
@ -753,4 +757,3 @@ class Ui_SICEN(object):
|
|||||||
self.label_11.setText(_translate("SICEN", "4.", None))
|
self.label_11.setText(_translate("SICEN", "4.", None))
|
||||||
self.Emprise.setTabText(self.Emprise.indexOf(self.tab_4), _translate("SICEN", "Filtre par Emprise", None))
|
self.Emprise.setTabText(self.Emprise.indexOf(self.tab_4), _translate("SICEN", "Filtre par Emprise", None))
|
||||||
self.centroide.setText(_translate("SICEN", "Utiliser les centroïdes pour les observations autres que ponctuelles", None))
|
self.centroide.setText(_translate("SICEN", "Utiliser les centroïdes pour les observations autres que ponctuelles", None))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user