Compare commits

...

149 Commits
main ... main

Author SHA1 Message Date
02681490f6 Repaire 2026-01-09 11:16:56 +01:00
4b8bc74386 test de push 2026-01-09 10:25:55 +01:00
9a85e9aaae test maj new pc 2026-01-09 10:19:23 +01:00
910ba14dc9 test maj new pc 2026-01-09 10:07:07 +01:00
d9f27eaa0f maj 2025-12-18 15:49:14 +01:00
2842526605 nouvelle image 2025-12-18 15:40:03 +01:00
ec677ffc5a v2 n2000 A3 + comparaison 2025-12-17 10:20:32 +01:00
3c9a6a8b88 v2 n2000 landscape simple 2025-12-16 17:25:27 +01:00
06321e4e26 check droit user sigdb only to check all db 2025-12-15 16:05:12 +01:00
83e22782f7 maj n2000 landscape 2025-12-15 15:03:34 +01:00
43acfca13b n2000 landscape 2025-12-15 14:29:31 +01:00
102fd30686 MAJ 2025-12-15 12:00:16 +01:00
b3186f6e16 nouvelle mise en page pour n2000 v2 2025-12-15 11:49:42 +01:00
8e93f7051a loading parametre for old file 2025-12-12 17:04:52 +01:00
b893764961 flake8 + parametrage suplementaire 2025-12-12 16:02:56 +01:00
4051a6855b mise en page pour N2000 2025-12-12 12:14:17 +01:00
42f33f619c Verification nom de couche dans DB 2025-12-09 17:04:20 +01:00
e4725c4ece Merge branch 'main' of ssh://gitea.cenra-outils.org:2222/CEN-RA/Plugin_QGIS 2025-12-09 10:40:03 +01:00
28ee42d3ea fusion 2025-12-09 10:38:43 +01:00
2d2337057f maj 2025-12-08 17:13:56 +01:00
ce6f30ea2c message d'erreur pour les droits 2025-12-08 17:12:24 +01:00
d50f601bd9 Show psql grands 2025-12-08 11:59:04 +01:00
26678fb257 clean 2025-12-01 15:51:40 +01:00
cef46278bc correctif mineur 2025-09-25 13:50:17 +02:00
f34842bfac utf-8 fix 2025-09-05 10:03:50 +02:00
897ed3ae58 v1.14 2025-09-05 10:00:03 +02:00
2236123050 Open QGIS project from psql 2025-09-05 09:52:59 +02:00
9ad5baa4ed MAJ 2025-07-30 10:18:44 +02:00
36de24532a flake8 and Qt6 fix 2025-07-30 09:57:09 +02:00
6c1af3c61c flake8 issues 2025-07-29 17:01:59 +02:00
d7267c0542 flake8 metabase 2025-07-29 16:56:54 +02:00
fd5d516f14 flake8 sicen 2025-07-29 15:19:47 +02:00
ca1d895eb1 flake8 sicen 2025-07-29 15:16:03 +02:00
e503423e49 flake8 pagerender 2025-07-29 14:34:32 +02:00
3564209574 flake8 copie 2025-07-29 13:58:00 +02:00
7df08ae02a flake8 postgis 2025-07-29 13:35:11 +02:00
133e785568 flake8 automap 2025-07-29 10:53:30 +02:00
9b7ab9ab15 3.5 flux 2025-07-29 10:24:51 +02:00
c02da75f0b bug fix pg no raster_columnes views 2025-07-29 10:17:45 +02:00
d4b181ff61 flake8 2025-07-28 16:53:26 +02:00
7a3814a429 flake8 2025-07-28 16:45:44 +02:00
1cd816c706 flake8 2025-07-28 16:23:25 +02:00
94cac31fbb Vue du type vecteur ou raster dans SIG 2025-07-23 16:15:28 +02:00
2690220a02 Vue du type vecteur ou raster dans SIG 2025-07-23 16:00:36 +02:00
3719456f04 Optimisation et Compatibiliter Qt6 2025-07-23 11:59:48 +02:00
bea31c870b Ouverture de Raster en base psql 2025-07-22 16:55:07 +02:00
2d04e34ed2 Ouverture de Raster en base psql 2025-07-22 16:52:32 +02:00
ac070f866e Nouvelle version 2025-07-21 11:48:35 +02:00
4851339008 Fix Erreur sur QMessageBox 2025-07-21 11:27:11 +02:00
f2d11a64e4 PyQt5 & PyQt6 2025-05-19 15:38:35 +02:00
4c52c85efb v1.7 2025-05-19 14:03:49 +02:00
3ef37aa696 Plugin PyQt5 and PyQt6 compatible & CenRa_Copie bug fix 2025-05-19 14:00:58 +02:00
3b0758ea5c v1.6 2025-04-11 10:28:16 +02:00
852301a537 bug correctif 2025-04-11 10:26:02 +02:00
b3451773be v1.6 2025-04-09 15:42:06 +02:00
72a4a8a7b7 Suite maj TT 2025-04-09 15:36:24 +02:00
c809c12c9f Optimisation pour TT 2025-04-09 11:44:05 +02:00
bc538524fb releases to latest 2025-04-07 17:30:36 +02:00
23f21a4c39 releases to latest 2025-04-07 17:29:22 +02:00
2b00cf9106 debug 2025-04-07 16:06:33 +02:00
ad49b80b5a Actualiser README.md 2025-04-03 15:24:23 +02:00
dbe918cfcf Mise à jour de sécurité 2025-04-03 12:45:32 +02:00
f692414698 MAJ 2025-04-02 10:27:18 +02:00
75ec1c0191 Security MAJ 2025-04-02 10:24:29 +02:00
ca79b96958 MAJ 2025-04-02 10:23:08 +02:00
ce85b09e11 Security MAJ 2025-04-02 10:20:48 +02:00
8e84d39165 Sécurity MAJ 2025-04-02 10:17:53 +02:00
72e91a527a Supprimer CenRa_FLUX/tools/PythonSQL.py 2025-04-02 10:15:55 +02:00
b3eeb2d60c mouse wheel scolling 2025-03-20 16:23:11 +01:00
ea6fb7c870 Actualiser README.md 2025-03-20 15:39:14 +01:00
1aee5d90d7 fix visuel pour les utilisateurs incompétent. 2025-03-20 15:37:11 +01:00
901d1b9441 DockWidget import vector & theme 2025-02-25 17:12:09 +01:00
cd4d320614 Sécurité et restriction en plus 2025-02-13 15:45:23 +01:00
c7ff62c717 Sécurité et restriction en plus 2025-02-13 15:18:56 +01:00
49b78e58ac Sécurité et restriction en plus 2025-02-13 15:13:58 +01:00
1a17bb7d7c UI de Flux auto scale 2025-02-13 13:59:26 +01:00
e2e062ed12 outils de rename pour bd psql 2025-02-12 17:28:52 +01:00
a90a45a0b9 fonction de filtre par empris du canva QGIS 2025-02-05 14:33:42 +01:00
80a563357d fix bug 2025-02-04 16:56:19 +01:00
be3a082f93 Gestion multi-composeur 2025-01-28 16:49:14 +01:00
cbe6952c9a Nom Prénom, sécurité d'ecrasement, police 2025-01-27 17:14:31 +01:00
bbb41400e5 Merge branch 'main' of ssh://gitea.cenra-outils.org:2222/CEN-RA/Plugin_QGIS
?
2025-01-24 15:53:14 +01:00
d92744fe6b Switch serveur IP 2025-01-24 15:52:21 +01:00
a7d7ea83f4 Actualiser README.md 2025-01-24 15:51:06 +01:00
622a54e7b9 Actualiser README.md 2025-01-23 15:58:49 +01:00
55b0826248 Actualiser README.md 2025-01-23 15:56:44 +01:00
3141ccb15c correctif et allégement 2025-01-23 15:45:54 +01:00
3301c1395d Block la création de shema sans table 2025-01-22 07:39:57 +01:00
7c46818923 Réorganisation du code 2025-01-21 14:41:20 +01:00
b05a047a87 add variable pour recupéré le gid_seq 2025-01-21 14:40:23 +01:00
65b24ff13d CopieAboutForm en trop 2025-01-13 10:34:12 +01:00
ec175643bc erreur de push à réparé 2025-01-13 10:28:50 +01:00
08dda9ebb0 Correctif Erreur en qu'a de group 2025-01-13 09:46:23 +01:00
1fbfb009cf ByPass du certif ssl si erreur 2025-01-07 13:43:41 +01:00
1c6eaa82be disable plugin avec 'qgis.utils.plugins[#]' 2025-01-06 14:47:53 +01:00
50902b8664 maj maj 2024-12-19 16:58:58 +01:00
3490c51112 date maj maj 2024-12-19 16:47:52 +01:00
f79642c826 nouvelle vesion 0.1.5 pour metadata 2024-12-19 16:45:13 +01:00
f59fac229e Désactive le plugin si la premier connection echou 2024-12-19 16:41:51 +01:00
a3cf4248cf Actualiser CenRa_FLUX/README.md 2024-12-19 13:49:28 +01:00
94d4ff85ab Actualiser CenRa_AUTOMAP/README.md 2024-12-19 13:46:19 +01:00
947a6ddd18 Actualiser README.md 2024-12-19 13:42:08 +01:00
cf4cfc4636 Actualiser README.md 2024-12-19 13:34:46 +01:00
ea796cf346 Actualiser README.md 2024-12-19 13:28:29 +01:00
a37e46cfc9 Actualiser README.md 2024-12-19 12:11:00 +01:00
9129ad279b Actualiser README.md 2024-12-19 12:09:34 +01:00
a02ab6376e Actualiser README.md 2024-12-19 12:09:07 +01:00
69da8e8e82 Téléverser les fichiers vers "CenRa_METABASE/tools/icons" 2024-12-19 11:58:16 +01:00
161505e4a1 Téléverser les fichiers vers "CenRa_METABASE/tools/images" 2024-12-19 11:57:57 +01:00
873a2a0ec7 Téléverser les fichiers vers "CenRa_METABASE/tools" 2024-12-19 11:57:27 +01:00
df07e9ffdb Téléverser les fichiers vers "CenRa_METABASE" 2024-12-19 11:57:12 +01:00
36f1145d81 Actualiser CenRa_METABASE/tools/html/contact.html 2024-12-19 11:56:43 +01:00
9519dee924 Actualiser CenRa_METABASE/tools/html/link.html 2024-12-19 11:56:22 +01:00
0e2e8a555d Actualiser CenRa_METABASE/tools/html/main.html 2024-12-19 11:56:00 +01:00
bff19fd919 Actualiser CenRa_METABASE/tools/css/dock.css 2024-12-19 11:55:43 +01:00
ff71cdf577 Supprimer CenRa_Metabase/tools/icons/icon.png 2024-12-19 11:55:19 +01:00
a7c2f6c169 Supprimer CenRa_Metabase/tools/icons/icon_2.png 2024-12-19 11:55:15 +01:00
2377238e8c Supprimer CenRa_Metabase/tools/icons/CEN_RA.png 2024-12-19 11:55:11 +01:00
bd82fb6745 Supprimer CenRa_Metabase/tools/icons/auto_add.png 2024-12-19 11:55:07 +01:00
a08679f0fa Supprimer CenRa_Metabase/tools/images/must_be_a_file.png 2024-12-19 11:55:02 +01:00
66e0ddc496 Actualiser CenRa_METABASE/tools/ui/CenRa_Metabase_editorwidget_base.ui 2024-12-19 11:54:47 +01:00
99f059b649 Actualiser CenRa_METABASE/tools/ui/CenRa_Metabase_dockwidget_base.ui 2024-12-19 11:54:32 +01:00
87a1b82ee9 Actualiser CenRa_METABASE/tools/ui/CenRa_Metabase_about_form.ui 2024-12-19 11:54:15 +01:00
7c38bc1326 Actualiser CenRa_METABASE/tools/ui/CenRa_IssuesSend.ui 2024-12-19 11:53:52 +01:00
36e55f268c Actualiser CenRa_METABASE/tools/xml/publisher.xml 2024-12-19 11:53:29 +01:00
7dd203f520 Actualiser CenRa_METABASE/tools/xml/distribution.xml 2024-12-19 11:53:08 +01:00
7fceab83bb Actualiser CenRa_METABASE/tools/xml/dcat.xml 2024-12-19 11:52:43 +01:00
ef182560a6 Supprimer CenRa_Metabase/tools/lecture_sql.py 2024-12-19 11:52:18 +01:00
1b7803a33f Actualiser CenRa_METABASE/tools/PythonSQL.py 2024-12-19 11:51:53 +01:00
32a4f593a8 Actualiser CenRa_METABASE/tools/resources.py 2024-12-19 11:51:19 +01:00
97c7702312 Actualiser CenRa_METABASE/metadata.txt 2024-12-19 11:50:33 +01:00
972e815f1e Actualiser CenRa_METABASE/issues.py 2024-12-19 11:50:25 +01:00
17d56dd4dc Supprimer CenRa_Metabase/icon.png 2024-12-19 11:50:15 +01:00
d25ce2b893 Actualiser CenRa_METABASE/editor.py 2024-12-19 11:49:57 +01:00
5570519e0d Actualiser CenRa_METABASE/dock.py 2024-12-19 11:49:49 +01:00
7a3f223024 Actualiser CenRa_METABASE/CenRa_Metabase.py 2024-12-19 11:49:40 +01:00
5e71a891d0 Actualiser CenRa_METABASE/about_form.py 2024-12-19 11:49:29 +01:00
0f6b4224c3 Actualiser CenRa_METABASE/__init__.py 2024-12-19 11:48:43 +01:00
d2cc8e2802 Actualiser CenRa_METABASE/README.md 2024-12-19 11:47:51 +01:00
c1b771cef6 Actualiser README.md 2024-12-19 11:45:56 +01:00
1458982089 Actualiser README.md 2024-12-19 11:36:29 +01:00
af7a63e728 Actualiser README.md 2024-12-19 11:34:53 +01:00
89b5e326d1 Actualiser README.md 2024-12-19 11:17:27 +01:00
94eaa2e272 Actualiser README.md 2024-12-19 10:55:56 +01:00
e6d7917a35 Add eval et exec pour rendre automatique le from import des modele de carte 2024-12-19 10:42:35 +01:00
da1309f415 Crash QGIS Fix 2024-12-12 16:51:58 +01:00
e566ce6015 correctif de bug sur la overview 2024-12-11 10:16:54 +01:00
6169664ae4 création d'un nouveau modell 2024-12-10 17:02:59 +01:00
654a8f579f Ajout de fonctionnaliter mollet et mouse dragging 2024-11-14 17:16:23 +01:00
109 changed files with 8707 additions and 7123 deletions

4
.gitignore vendored
View File

@ -16,4 +16,6 @@
#ReIgnore #ReIgnore
**/__pycache__ **/__pycache__
**/test/ **/test/
PythonSQL.py
StyleLayer.py

View File

@ -4,14 +4,14 @@ __email__ = "info@3liz.org"
from qgis.core import QgsApplication from qgis.core import QgsApplication
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl from qgis.PyQt.QtCore import Qt, QUrl
from qgis.PyQt.QtGui import QDesktopServices, QIcon from qgis.PyQt.QtGui import QDesktopServices, QIcon
from qgis.PyQt.QtWidgets import QAction, QMessageBox from qgis.PyQt.QtWidgets import QAction
from qgis.utils import iface from qgis.utils import iface
import qgis import qgis
#include <QSettings> # include <QSettings>
''' '''
from pg_metadata.connection_manager import ( from pg_metadata.connection_manager import (
store_connections, store_connections,
@ -24,38 +24,43 @@ from pg_metadata.processing.provider import PgMetadataProvider
from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger
''' '''
import os import os
from qgis.PyQt.QtCore import QSettings
from .about_form import AboutDialog
from .tools.resources import ( from .tools.resources import (
plugin_path, # plugin_path,
resources_path, resources_path,
pyperclip,
maj_verif, maj_verif,
) )
from .canvas_editor import AutoMap_Editor pyperclip()
from .about_form import AutoMapAboutDialog
from .canvas_editor import AutoMap_Editor
from .style_invoke import AutoMap_Style
from PyQt5.QtCore import *
class PgAutoMap: class PgAutoMap:
def __init__(self): def __init__(self):
""" Constructor. """ """ Constructor. """
self.canvas_editor = None self.canvas_editor = None
self.style_dock = None
# self.issues = None # self.issues = None
self.provider = None self.provider = None
self.locator_filter = None self.locator_filter = None
self.dock_action = None self.dock_action = None
self.help_action = None self.help_action = None
plugin_dir = os.path.dirname(__file__) plugin_dir = os.path.dirname(__file__)
end_find = plugin_dir.rfind('\\')+1 end_find = plugin_dir.rfind('\\') + 1
global NAME global NAME
NAME = plugin_dir[end_find:] NAME = plugin_dir[end_find:]
maj_verif(NAME) maj_verif(NAME)
# Display About window on first use # Display About window on first use
version = qgis.utils.pluginMetadata('CenRa_AUTOMAP','version') version = qgis.utils.pluginMetadata('CenRa_AUTOMAP', 'version')
s = QSettings() s = QSettings()
versionUse = s.value("automap/version", 1, type=str) versionUse = s.value("automap/version", 1, type=str)
if str(versionUse) != str(version) : if str(versionUse) != str(version):
s.setValue("automap/version", str(version)) s.setValue("automap/version", str(version))
print(versionUse,version) print(versionUse, version)
self.open_about_dialog() self.open_about_dialog()
def initGui(self): def initGui(self):
@ -73,49 +78,23 @@ class PgAutoMap:
if not self.canvas_editor: if not self.canvas_editor:
self.canvas_editor = AutoMap_Editor() self.canvas_editor = AutoMap_Editor()
self.automap_action = QAction(icon, 'CenRa_AutoMap', None)
self.automap_action = QAction(icon, 'CenRa_AutoMap',None)
self.toolBar.addAction(self.automap_action) self.toolBar.addAction(self.automap_action)
self.automap_action.triggered.connect(self.open_editor) self.automap_action.triggered.connect(self.open_editor)
'''
if not self.locator_filter:
self.locator_filter = LocatorFilter(iface)
iface.registerLocatorFilter(self.locator_filter)
@staticmethod if not self.style_dock:
def check_invalid_connection_names(): self.style_dock = AutoMap_Style()
""" Check for invalid connection names in the QgsSettings. """
valid, invalid = validate_connections_names()
n_invalid = len(invalid)
if n_invalid == 0: if os.environ['USERNAME'] == 'tlaveille' or os.environ['USERNAME'] == 'lpoulin' or os.environ['USERNAME'] == 'rclement':
return iface.addDockWidget(Qt.DockWidgetArea(0x1), self.style_dock)
invalid_text = ', '.join(invalid)
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)
msg.setWindowTitle(tr('PgMetadata: Database connection(s) not available'))
msg.setText(tr(
f'{n_invalid} connection(s) listed in PgMetadatas settings are invalid or '
f'no longer available: {invalid_text}'))
msg.setInformativeText(tr(
'Do you want to remove these connection(s) from the PgMetadata settings? '
'(You can also do this later with the “Set Connections” tool.)'))
msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
clicked = msg.exec()
if clicked == QMessageBox.Yes:
iface.messageBar().pushSuccess('PgMetadata', tr(f'{n_invalid} invalid connection(s) removed.'))
store_connections(valid)
if clicked == QMessageBox.No:
iface.messageBar().pushInfo('PgMetadata', tr(f'Keeping {n_invalid} invalid connections.'))
'''
def open_about_dialog(self): def open_about_dialog(self):
""" """
About dialog About dialog
""" """
dialog = AutoMapAboutDialog(iface) dialog = AboutDialog(iface)
dialog.exec_() dialog.exec()
def open_help(): def open_help():
""" Open the online help. """ """ Open the online help. """
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/')) QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
@ -127,7 +106,7 @@ class PgAutoMap:
def unload(self): def unload(self):
""" Unload the plugin. """ """ Unload the plugin. """
if self.canvas_editor: if self.canvas_editor:
iface.removePluginMenu('CenRa_AutoMap',self.automap_action) iface.removePluginMenu('CenRa_AutoMap', self.automap_action)
if self.provider: if self.provider:
QgsApplication.processingRegistry().removeProvider(self.provider) QgsApplication.processingRegistry().removeProvider(self.provider)

View File

@ -2,3 +2,5 @@
--- ---
Outil de création de mise en page, Outil de création de mise en page,
Permet de préprogramé des mise en page pour les mêtre à disposition des collégue. Permet de préprogramé des mise en page pour les mêtre à disposition des collégue.
> [Point de départ de création du plugin](https://github.com/CEN-Nouvelle-Aquitaine/MapCEN)

View File

@ -3,7 +3,7 @@ import os.path
from pathlib import Path from pathlib import Path
from qgis.PyQt import uic from qgis.PyQt import uic
from qgis.PyQt.QtGui import QPixmap # from qgis.PyQt.QtGui import QPixmap
from qgis.PyQt.QtWidgets import QDialog from qgis.PyQt.QtWidgets import QDialog
from .tools.resources import devlog from .tools.resources import devlog
@ -12,12 +12,12 @@ ABOUT_FORM_CLASS, _ = uic.loadUiType(
os.path.join( os.path.join(
str(Path(__file__).resolve().parent), str(Path(__file__).resolve().parent),
'tools/ui', 'tools/ui',
'CenRa_AutoMap_about_form.ui' 'CenRa_about_form.ui'
) )
) )
class AutoMapAboutDialog(QDialog, ABOUT_FORM_CLASS): class AboutDialog(QDialog, ABOUT_FORM_CLASS):
""" About - Let the user display the about dialog. """ """ About - Let the user display the about dialog. """
@ -43,4 +43,4 @@ class AutoMapAboutDialog(QDialog, ABOUT_FORM_CLASS):
Run some actions when Run some actions when
the user closes the dialog the user closes the dialog
""" """
self.close() self.close()

View File

@ -1,78 +1,42 @@
import logging import logging
import os import os
from PyQt5.QtCore import QSettings
from collections import namedtuple
from enum import Enum
from functools import partial
from pathlib import Path
from xml.dom.minidom import parseString
from qgis.gui import *
import qgis
from importlib import import_module
from qgis.core import ( from qgis.core import (
NULL, QgsScaleBarSettings,
QgsApplication,
QgsScaleBarSettings,
QgsDataSourceUri,
QgsProject, QgsProject,
QgsProviderConnectionException,
QgsProviderRegistry,
QgsRasterLayer, QgsRasterLayer,
QgsSettings, QgsSettings,
QgsVectorLayer, QgsVectorLayer,
QgsGeometry,
QgsPrintLayout, QgsPrintLayout,
QgsReadWriteContext, QgsReadWriteContext,
QgsLayoutItemMap, QgsLayoutItemMap,
QgsLayoutItemPage, QgsLayoutItemPage,
QgsLayoutSize,
QgsUnitTypes, QgsUnitTypes,
QgsLayoutPoint,
QgsLayoutItemLabel, QgsLayoutItemLabel,
QgsLayoutItemPicture, QgsLayoutItemPicture,
QgsLayoutItemLegend, QgsLayoutItemLegend,
QgsLayoutItem,
QgsLegendStyle, QgsLegendStyle,
QgsLayoutItemScaleBar, QgsLayoutItemScaleBar,
QgsLayerTreeGroup, QgsLayerTreeGroup,
QgsCoordinateReferenceSystem,
QgsCoordinateTransform,
QgsLayerTree,
QgsLayoutTableColumn,
QgsRectangle, QgsRectangle,
QgsLayoutItemMapOverviewStack,
) )
from qgis.PyQt.QtCore import QLocale, QUrl, QDateTime, Qt from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtGui import QDesktopServices, QIcon, QColor, QFont, QMovie from qgis.PyQt.QtGui import QColor, QFont
from qgis.PyQt.QtPrintSupport import QPrinter
from qgis.PyQt.QtWebKitWidgets import QWebPage
from qgis.PyQt.QtWidgets import ( from qgis.PyQt.QtWidgets import (
QDialog, QDialog,
QAction, QMessageBox,
QDockWidget, QPushButton,
QFileDialog, QFileDialog,
QInputDialog,
QMenu,
QToolButton,
QTableWidget,
QTableWidgetItem,
QVBoxLayout,
) )
from PyQt5 import QtGui from qgis.PyQt.QtCore import QSettings
from qgis.PyQt import QtGui
from qgis.PyQt.QtXml import QDomDocument from qgis.PyQt.QtXml import QDomDocument
from qgis.utils import iface from qgis.utils import iface
import glob import glob
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base,
send_issues,
) )
from .issues import CenRa_Issues
from .tools.mises_en_pages import carto_standard
from .tools.mises_en_pages import full_page
from .tools.mises_en_pages import demo
from datetime import date from datetime import date
EDITOR_CLASS = load_ui('CenRa_AutoMap_base.ui') EDITOR_CLASS = load_ui('CenRa_AutoMap_base.ui')
@ -82,49 +46,50 @@ url_ortho = 'http://tiles.craig.fr/ortho/service/?crs=EPSG:2154&featureCount=10&
url_mnt = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=relief&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt' url_mnt = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=relief&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
url_pente = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=pente&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt' url_pente = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=pente&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
data_source = [ data_source = [
'CENRA', 'CENRA',
'IGN', 'IGN',
'CRAIG', 'CRAIG',
'OpenStreetMap', 'OpenStreetMap',
'Sandre', 'Sandre',
'BRGM', 'BRGM',
'MUSÉUM NATIONAL DHISTOIRE NATURELLE', 'MUSÉUM NATIONAL DHISTOIRE NATURELLE',
"Muséum national d'Histoire naturelle", "Muséum national d'Histoire naturelle",
'ONF', 'ONF',
'20xx LPO', '20xx LPO',
'ofb.gouv.fr', 'ofb.gouv.fr',
'Stamen Design', 'Stamen Design',
'MTES', 'MTES',
'MTES', 'MTES',
'FEDER', 'FEDER',
'DREAL Auvergne-Rhône-Alpes', 'DREAL Auvergne-Rhône-Alpes',
'INSEE', 'INSEE',
'DGFiP', 'DGFiP',
'Fédération des Conservatoires despaces naturels', 'Fédération des Conservatoires despaces naturels',
'Plan cadastral informatisé - Etalab - juillet 202X', 'Plan cadastral informatisé - Etalab - juillet 202X',
'Parcellaire Express - IGN - 202X', 'Parcellaire Express - IGN - 202X',
] ]
A4_size = {'Portrait':{'RIGHT':210,'LEFT':0,'TOP':0,'BOTTOM':297},'Landscape':{'RIGHT':297,'LEFT':0,'TOP':0,'BOTTOM':210}} A4_size = {'Portrait': {'RIGHT': 210, 'LEFT': 0, 'TOP': 0, 'BOTTOM': 297}, 'Landscape': {'RIGHT': 297, 'LEFT': 0, 'TOP': 0, 'BOTTOM': 210}}
A3_size = {'Portrait':{'RIGHT':298,'LEFT':0,'TOP':0,'BOTTOM':420},'Landscape':{'RIGHT':420,'LEFT':0,'TOP':0,'BOTTOM':298}} A3_size = {'Portrait': {'RIGHT': 298, 'LEFT': 0, 'TOP': 0, 'BOTTOM': 420}, 'Landscape': {'RIGHT': 420, 'LEFT': 0, 'TOP': 0, 'BOTTOM': 298}}
class AutoMap_Editor(QDialog, EDITOR_CLASS): class AutoMap_Editor(QDialog, EDITOR_CLASS):
def __init__(self, parent=None): def __init__(self, parent=None):
_ = parent _ = parent
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.settings = QgsSettings() self.settings = QgsSettings()
self.s = QSettings() self.s = QSettings()
self.setWindowIcon(QtGui.QIcon(resources_path('icons','icon.png'))) self.setWindowIcon(QtGui.QIcon(resources_path('icons', 'icon.png')))
path = '' path = ''
ix = 0 ix = 0
plugin_dir = str(os.path.dirname(os.path.abspath(__file__))).split(os.sep) plugin_dir = str(os.path.dirname(os.path.abspath(__file__))).split(os.sep)
for i in plugin_dir[1:]: for i in plugin_dir[1:]:
ix = ix+1 ix = ix + 1
path = path+'/'+i path = path + '/' + i
self.tabWidget.setStyleSheet('background-image: url('+path+'/tools/bg/Capture.png);') # self.tabWidget.setStyleSheet('background-image: url('+path+'/tools/bg/Capture.png);')
self.verticalScrollBar.hide()
self.commandLinkButton.clicked.connect(self.chargement_qpt) self.commandLinkButton.clicked.connect(self.chargement_qpt)
self.radioButton_9.clicked.connect(self.statu_atlas) self.radioButton_9.clicked.connect(self.statu_atlas)
self.radioButton_10.clicked.connect(self.statu_source) self.radioButton_10.clicked.connect(self.statu_source)
@ -135,14 +100,14 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.commandLinkButton_2.clicked.connect(self.load_ortho) self.commandLinkButton_2.clicked.connect(self.load_ortho)
self.commandLinkButton_3.clicked.connect(self.load_osm) self.commandLinkButton_3.clicked.connect(self.load_osm)
self.CustomeLogo.clicked.connect(self.deflogoteck) self.CustomeLogo.clicked.connect(self.deflogoteck)
self.verticalScrollBar.valueChanged.connect(self.moveFrame)
## On ajoute le nom des templates à la liste déroulante de l'onglet "mises en page" : # On ajoute le nom des templates à la liste déroulante de l'onglet "mises en page" :
mises_en_page = [] mises_en_page = []
for filename in glob.glob(resources_path("mises_en_pages","*.py")): for filename in glob.glob(resources_path("mises_en_pages", "*.py")):
mises_en_page.append(filename) mises_en_page.append(filename)
for i, filename in enumerate(mises_en_page): for i, filename in enumerate(mises_en_page):
nom_fichier = os.path.basename(filename) nom_fichier = os.path.basename(filename)
self.comboBox.addItem(nom_fichier) self.comboBox.addItem(nom_fichier)
@ -150,35 +115,41 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.template_parameters = { self.template_parameters = {
'Carte_size': None, 'Carte_size': None,
'Carte_locals' : None, 'Carte_locals': None,
'Carte_rotate':None, 'Carte_rotate': None,
'Carte_2_size' : None, 'Carte_frame': None,
'Carte_2_locals' : None, 'Carte_2_size': None,
'Carte_2_rotate':None, 'Carte_2_locals': None,
'Carte_2_rotate': None,
'Legande_size': None, 'Legande_size': None,
'Legande_locals': None, 'Legande_locals': None,
'Legande_rotate':None, 'Legande_rotate': None,
'Legande_frame': None,
'Arrow_size': None, 'Arrow_size': None,
'Arrow_locals': None, 'Arrow_locals': None,
'Arrow_rotate':None, 'Arrow_rotate': None,
'Arrow_background': None,
'Arrow_path': None,
'Echelle_size': None, 'Echelle_size': None,
'Echelle_locals': None, 'Echelle_locals': None,
'Echelle_rotate':None, 'Echelle_rotate': None,
'Logo_size': None, 'Logo_size': None,
'Logo_locals': None, 'Logo_locals': None,
'Logo_rotate':None, 'Logo_rotate': None,
'Titre_size':None, 'Titre_size': None,
'Titre_locals':None, 'Titre_locals': None,
'Titre_rotate':None, 'Titre_rotate': None,
'Sous_titre_size':None, 'Sous_titre_size': None,
'Sous_titre_locals':None, 'Sous_titre_locals': None,
'Sous_titre_rotate':None, 'Sous_titre_rotate': None,
'Credit_size': None, 'Credit_size': None,
'Credit_locals': None, 'Credit_locals': None,
'Credit_rotate':None, 'Credit_rotate': None,
'Credit_alignment': None,
'Source_size': None, 'Source_size': None,
'Source_locals': None, 'Source_locals': None,
'Source_rotate':None, 'Source_rotate': None,
'Source_alignment': None,
'Logo_2_size': None, 'Logo_2_size': None,
'Logo_2_locals': None, 'Logo_2_locals': None,
'Logo_2_rotate': None, 'Logo_2_rotate': None,
@ -194,15 +165,25 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.hide_source() self.hide_source()
self.hide_atlas() self.hide_atlas()
def wheelEvent(self, event):
if (event.angleDelta().y() >= 1):
vsb = self.verticalScrollBar.value() + 20
else:
vsb = self.verticalScrollBar.value() - 20
self.verticalScrollBar.setValue(vsb)
def moveFrame(self):
self.frame.move(self.frame.x(), self.verticalScrollBar.value())
def update_logo_library(self): def update_logo_library(self):
self.mComboBox_4.clear() self.mComboBox_4.clear()
logo_library = [] logo_library = []
custome_bibliotech = glob.glob(self.s.value("automap/logoteck", 1, type=str)+'*.*') custome_bibliotech = glob.glob(self.s.value("automap/logoteck", 1, type=str) + '*.*')
for l,logo_x in enumerate(custome_bibliotech): for number, logo_x in enumerate(custome_bibliotech):
logo_library.append(' '+os.path.basename(logo_x)) logo_library.append(' ' + os.path.basename(logo_x))
bibliotech = glob.glob(resources_path("logo_library","*.png")) bibliotech = glob.glob(resources_path("logo_library", "*.png"))
for l,logo_x in enumerate(bibliotech): for number, logo_x in enumerate(bibliotech):
logo_library.append(os.path.basename(logo_x)) logo_library.append(os.path.basename(logo_x))
self.mComboBox_4.addItems(sorted(logo_library)) self.mComboBox_4.addItems(sorted(logo_library))
@ -210,7 +191,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
options = QFileDialog.Options() options = QFileDialog.Options()
options |= QFileDialog.ShowDirsOnly options |= QFileDialog.ShowDirsOnly
folder = QFileDialog.getExistingDirectory(self, "Sélection du dossier parent", options=options) folder = QFileDialog.getExistingDirectory(self, "Sélection du dossier parent", options=options)
return folder+'/' return folder + '/'
def deflogoteck(self): def deflogoteck(self):
folder = self.select_file() folder = self.select_file()
@ -225,16 +206,20 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
try: try:
layout_subtitle = project_subtitle.layoutManager().layoutByName(self.comboBox_7.currentText()) layout_subtitle = project_subtitle.layoutManager().layoutByName(self.comboBox_7.currentText())
self.lineEdit_3.setText(layout_subtitle.itemById("SubTitle").text()) self.lineEdit_3.setText(layout_subtitle.itemById("SubTitle").text())
except: except NameError:
print("") print("")
def load_ortho(self): def load_ortho(self):
global myGroup,last_group global myGroup, last_group
runing = False runing = False
try: myGroup try:
except NameError: runing = True myGroup
try: last_group except NameError:
except NameError: last_group = '' runing = True
try:
last_group
except NameError:
last_group = ''
if runing or (last_group != '' and last_group != 'ortho'): if runing or (last_group != '' and last_group != 'ortho'):
layername = False layername = False
layerAll = QgsProject.instance().layerTreeRoot().children() layerAll = QgsProject.instance().layerTreeRoot().children()
@ -243,7 +228,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
if layeritem.name() == 'SuperFont': if layeritem.name() == 'SuperFont':
myGroup = layerAll[xl] myGroup = layerAll[xl]
layername = True layername = True
xl = xl+1 xl = xl + 1
if layername: if layername:
(QgsProject.instance().layerTreeRoot()).removeChildNode(myGroup) (QgsProject.instance().layerTreeRoot()).removeChildNode(myGroup)
runing = True runing = True
@ -253,32 +238,36 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
myGroup = (QgsProject.instance().layerTreeRoot()).addGroup("SuperFont") myGroup = (QgsProject.instance().layerTreeRoot()).addGroup("SuperFont")
last_group = 'ortho' last_group = 'ortho'
#OSM_RASTER = QgsRasterLayer(url_osm, 'OpenStreetMap Backgound', 'wms') # OSM_RASTER = QgsRasterLayer(url_osm, 'OpenStreetMap Backgound', 'wms')
ORTHO_RASTER = QgsRasterLayer(url_ortho, 'Orthophoto AURA', 'wms') ORTHO_RASTER = QgsRasterLayer(url_ortho, 'Orthophoto AURA', 'wms')
MNT_RASTER = QgsRasterLayer(url_mnt, 'MNT RGE Alti (<= 1:100000)', 'wms') MNT_RASTER = QgsRasterLayer(url_mnt, 'MNT RGE Alti (<= 1:100000)', 'wms')
PENTE_RASTER = QgsRasterLayer(url_pente, 'Pente RGE Alti 0 à 90°(<= 1:100000)', 'wms') PENTE_RASTER = QgsRasterLayer(url_pente, 'Pente RGE Alti 0 à 90°(<= 1:100000)', 'wms')
#OSM_RASTER.loadNamedStyle(resources_path("font","osm_background.qml")) # OSM_RASTER.loadNamedStyle(resources_path("font", "osm_background.qml"))
ORTHO_RASTER.loadNamedStyle(resources_path("font","ortho_aura.qml")) ORTHO_RASTER.loadNamedStyle(resources_path("font", "ortho_aura.qml"))
MNT_RASTER.loadNamedStyle(resources_path("font","mnt_alti.qml")) MNT_RASTER.loadNamedStyle(resources_path("font", "mnt_alti.qml"))
#QgsProject.instance().addMapLayer(OSM_RASTER,False) # QgsProject.instance().addMapLayer(OSM_RASTER,False)
QgsProject.instance().addMapLayer(ORTHO_RASTER,False) QgsProject.instance().addMapLayer(ORTHO_RASTER, False)
QgsProject.instance().addMapLayer(MNT_RASTER,False) QgsProject.instance().addMapLayer(MNT_RASTER, False)
QgsProject.instance().addMapLayer(PENTE_RASTER,False) QgsProject.instance().addMapLayer(PENTE_RASTER, False)
#myGroup.addLayer(OSM_RASTER) # myGroup.addLayer(OSM_RASTER)
myGroup.addLayer(ORTHO_RASTER) myGroup.addLayer(ORTHO_RASTER)
myGroup.addLayer(MNT_RASTER) myGroup.addLayer(MNT_RASTER)
myGroup.addLayer(PENTE_RASTER) myGroup.addLayer(PENTE_RASTER)
def load_osm(self): def load_osm(self):
global myGroup,last_group global myGroup, last_group
runing = False runing = False
try: myGroup try:
except NameError: runing = True myGroup
try: last_group except NameError:
except NameError: last_group = '' runing = True
try:
last_group
except NameError:
last_group = ''
if runing or (last_group != '' and last_group != 'osm'): if runing or (last_group != '' and last_group != 'osm'):
layername = False layername = False
layerAll = QgsProject.instance().layerTreeRoot().children() layerAll = QgsProject.instance().layerTreeRoot().children()
@ -287,7 +276,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
if layeritem.name() == 'SuperFont': if layeritem.name() == 'SuperFont':
myGroup = layerAll[xl] myGroup = layerAll[xl]
layername = True layername = True
xl = xl+1 xl = xl + 1
if layername: if layername:
(QgsProject.instance().layerTreeRoot()).removeChildNode(myGroup) (QgsProject.instance().layerTreeRoot()).removeChildNode(myGroup)
runing = True runing = True
@ -297,21 +286,21 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
last_group = 'osm' last_group = 'osm'
OSM_RASTER = QgsRasterLayer(url_osm, 'OpenStreetMap Backgound', 'wms') OSM_RASTER = QgsRasterLayer(url_osm, 'OpenStreetMap Backgound', 'wms')
#ORTHO_RASTER = QgsRasterLayer(url_ortho, 'Orthophoto AURA', 'wms') # ORTHO_RASTER = QgsRasterLayer(url_ortho, 'Orthophoto AURA', 'wms')
MNT_RASTER = QgsRasterLayer(url_mnt, 'MNT RGE Alti (<= 1:100000)', 'wms') MNT_RASTER = QgsRasterLayer(url_mnt, 'MNT RGE Alti (<= 1:100000)', 'wms')
PENTE_RASTER = QgsRasterLayer(url_pente, 'Pente RGE Alti 0 à 90°(<= 1:100000)', 'wms') PENTE_RASTER = QgsRasterLayer(url_pente, 'Pente RGE Alti 0 à 90°(<= 1:100000)', 'wms')
OSM_RASTER.loadNamedStyle(resources_path("font","osm_background.qml")) OSM_RASTER.loadNamedStyle(resources_path("font", "osm_background.qml"))
#ORTHO_RASTER.loadNamedStyle(resources_path("font","ortho_aura.qml")) # ORTHO_RASTER.loadNamedStyle(resources_path("font","ortho_aura.qml"))
MNT_RASTER.loadNamedStyle(resources_path("font","mnt_alti.qml")) MNT_RASTER.loadNamedStyle(resources_path("font", "mnt_alti.qml"))
QgsProject.instance().addMapLayer(OSM_RASTER,False) QgsProject.instance().addMapLayer(OSM_RASTER, False)
#QgsProject.instance().addMapLayer(ORTHO_RASTER,False) # QgsProject.instance().addMapLayer(ORTHO_RASTER,False)
QgsProject.instance().addMapLayer(MNT_RASTER,False) QgsProject.instance().addMapLayer(MNT_RASTER, False)
QgsProject.instance().addMapLayer(PENTE_RASTER,False) QgsProject.instance().addMapLayer(PENTE_RASTER, False)
myGroup.addLayer(OSM_RASTER) myGroup.addLayer(OSM_RASTER)
#myGroup.addLayer(ORTHO_RASTER) # myGroup.addLayer(ORTHO_RASTER)
myGroup.addLayer(MNT_RASTER) myGroup.addLayer(MNT_RASTER)
myGroup.addLayer(PENTE_RASTER) myGroup.addLayer(PENTE_RASTER)
@ -325,6 +314,8 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.comboBox_6.clear() self.comboBox_6.clear()
self.comboBox_7.clear() self.comboBox_7.clear()
if (self.s.value("automap/prenom_nom", "1", type=str) != "1"):
self.lineEdit_5.setText(self.s.value("automap/prenom_nom", 1, type=str))
couches = [] couches = []
couche_vecteur = [''] couche_vecteur = ['']
mapThemes = [''] mapThemes = ['']
@ -351,6 +342,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.show_map() self.show_map()
else: else:
self.hide_map() self.hide_map()
def show_map(self): def show_map(self):
self.groupBox_3.setEnabled(True) self.groupBox_3.setEnabled(True)
self.groupBox_3.show() self.groupBox_3.show()
@ -364,6 +356,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.show_titre() self.show_titre()
else: else:
self.hide_titre() self.hide_titre()
def show_titre(self): def show_titre(self):
self.lineEdit_2.setEnabled(False) self.lineEdit_2.setEnabled(False)
self.lineEdit_2.hide() self.lineEdit_2.hide()
@ -381,6 +374,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.show_source() self.show_source()
else: else:
self.hide_source() self.hide_source()
def show_source(self): def show_source(self):
self.lineEdit_4.setEnabled(False) self.lineEdit_4.setEnabled(False)
self.lineEdit_4.hide() self.lineEdit_4.hide()
@ -413,7 +407,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.comboBox_4.clear() self.comboBox_4.clear()
if self.comboBox_2.currentText() != '': if self.comboBox_2.currentText() != '':
layer = QgsProject.instance().mapLayersByName(self.comboBox_2.currentText())[0] layer = QgsProject.instance().mapLayersByName(self.comboBox_2.currentText())[0]
#BUG sur layer.fields() pas défini sur ce qui est pas vecteur # BUG sur layer.fields() pas défini sur ce qui est pas vecteur
for vfields in layer.fields(): for vfields in layer.fields():
fields.append(vfields.name()) fields.append(vfields.name())
self.comboBox_3.addItems(sorted(fields)) self.comboBox_3.addItems(sorted(fields))
@ -427,18 +421,29 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
layout_name = self.comboBox_7.currentText() layout_name = self.comboBox_7.currentText()
else: else:
layout_name = self.lineEdit_2.text() layout_name = self.lineEdit_2.text()
layouts_list = self.manager.printLayouts() # layouts_list = self.manager.printLayouts()
for filename in glob.glob(resources_path("mises_en_pages","*.qpt")): for filename in glob.glob(resources_path("mises_en_pages", "*.qpt")):
with open(os.path.join(os.getcwd(), filename), 'r') as f: with open(os.path.join(os.getcwd(), filename), 'r') as f:
self.layout = QgsPrintLayout(project) self.layout = QgsPrintLayout(project)
self.layout.initializeDefaults() self.layout.initializeDefaults()
myAtlas=self.layout.atlas() # myAtlas = self.layout.atlas()
template_content = f.read() template_content = f.read()
doc = QDomDocument() doc = QDomDocument()
doc.setContent(template_content) doc.setContent(template_content)
self.layout.loadFromTemplate(doc, QgsReadWriteContext(), True) self.layout.loadFromTemplate(doc, QgsReadWriteContext(), True)
self.layout.setName(layout_name)
try:
cutLayout = layout_name.index("")
except ValueError:
cutLayout = 0
if cutLayout >= 1:
self.layout.setName(layout_name)
titre_layout_name = layout_name[:cutLayout]
else:
self.layout.setName(layout_name)
titre_layout_name = layout_name
if self.radioButton_6.isChecked() and self.radioButton_7.isChecked(): if self.radioButton_6.isChecked() and self.radioButton_7.isChecked():
logo_div = A4_size['Portrait']['RIGHT'] logo_div = A4_size['Portrait']['RIGHT']
@ -448,11 +453,12 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
logo_div = A3_size['Portrait']['RIGHT'] logo_div = A3_size['Portrait']['RIGHT']
if self.radioButton_5.isChecked() and self.radioButton_8.isChecked(): if self.radioButton_5.isChecked() and self.radioButton_8.isChecked():
logo_div = A3_size['Portrait']['BOTTOM'] logo_div = A3_size['Portrait']['BOTTOM']
if True:#os.path.basename(filename) == "1. Modèle carto standard (consolidé).qpt": # os.path.basename(filename) == "1. Modèle carto standard (consolidé).qpt":
if True:
self.actualisation_mise_en_page() self.actualisation_mise_en_page()
## Add map to layout # Add map to layout
self.map_modele_test = QgsLayoutItemMap(self.layout) self.map_modele_test = QgsLayoutItemMap(self.layout)
# Charger une carte vide # Charger une carte vide
self.map_modele_test.setRect(20, 20, 20, 20) self.map_modele_test.setRect(20, 20, 20, 20)
@ -460,7 +466,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.map_modele_test.setExtent(iface.mapCanvas().extent()) self.map_modele_test.setExtent(iface.mapCanvas().extent())
# Position de la carte dans le composeur # Position de la carte dans le composeur
self.map_modele_test.setItemRotation(self.template_parameters['Carte_rotate']) self.map_modele_test.setMapRotation(self.template_parameters['Carte_rotate'])
self.map_modele_test.attemptResize(self.template_parameters['Carte_size']) self.map_modele_test.attemptResize(self.template_parameters['Carte_size'])
self.map_modele_test.attemptMove(self.template_parameters['Carte_locals']) self.map_modele_test.attemptMove(self.template_parameters['Carte_locals'])
# on dimensionne le rendu de la carte (pour référence la page totale est une page A4 donc 297*210) # on dimensionne le rendu de la carte (pour référence la page totale est une page A4 donc 297*210)
@ -474,37 +480,42 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
if self.radioButton_12.isChecked() == 1: if self.radioButton_12.isChecked() == 1:
self.position_map = QgsLayoutItemMap(self.layout) self.position_map = QgsLayoutItemMap(self.layout)
self.position_map.setRect(20, 20, 20, 20) self.position_map.setRect(20, 20, 20, 20)
self.position_map.setExtent(QgsRectangle(641552,6647386, 995856,6331104)) self.position_map.setExtent(QgsRectangle(618704, 6329245, 1018704, 6649245))
# self.position_map.setExtent(QgsRectangle(641552, 6647386, 995856, 6331104))
self.position_map.setFollowVisibilityPreset(True) self.position_map.setFollowVisibilityPreset(True)
self.position_map.setFollowVisibilityPresetName(self.comboBox_6.currentText()) self.position_map.setFollowVisibilityPresetName(self.comboBox_6.currentText())
self.position_map.setItemRotation(self.template_parameters['Carte_2_rotate']) self.position_map.setItemRotation(self.template_parameters['Carte_2_rotate'])
self.position_map.attemptResize(self.template_parameters['Carte_2_size']) self.position_map.attemptResize(self.template_parameters['Carte_2_size'])
self.position_map.attemptMove(self.template_parameters['Carte_2_locals']) self.position_map.attemptMove(self.template_parameters['Carte_2_locals'])
overviewitem = QgsLayoutItemMapOverviewStack(self.position_map) self.position_map.overview().setLinkedMap(self.map_modele_test)
map_overview = self.position_map.overview() # overviewitem = QgsLayoutItemMapOverviewStack(self.position_map)
map_overview.setLinkedMap(self.map_modele_test) # map_overview = self.position_map.overview()
map_overview.setCentered(True) # map_overview.setLinkedMap(self.map_modele_test)
overviewitem.addOverview(map_overview) # map_overview.setCentered(True)
# overviewitem.addOverview(map_overview)
self.position_map.refresh() self.position_map.refresh()
self.map_modele_test.setFrameEnabled(True) self.map_modele_test.setFrameEnabled(self.template_parameters['Carte_frame'])
self.position_map.setFrameEnabled(self.template_parameters['Carte_2_frame'])
self.layout.addLayoutItem(self.position_map) self.layout.addLayoutItem(self.position_map)
self.position_map.setId("Carte_locals") self.position_map.setId("Carte_locals")
self.map_modele_test.refresh() self.map_modele_test.refresh()
self.map_modele_test.setBackgroundColor(QColor(255, 255, 255, 255)) self.map_modele_test.setBackgroundColor(QColor(255, 255, 255, 255))
self.map_modele_test.setFrameEnabled(True) self.map_modele_test.setFrameEnabled(self.template_parameters['Carte_frame'])
if self.radioButton_9.isChecked() == 1: if self.radioButton_9.isChecked() == 1:
self.map_modele_test.setAtlasDriven(True) self.map_modele_test.setAtlasDriven(True)
self.layout.addLayoutItem(self.map_modele_test) self.layout.addLayoutItem(self.map_modele_test)
self.map_modele_test.setId("carte_principale") self.map_modele_test.setId("carte_principale")
## Ajout d'un titre à la mise en page # Ajout d'un titre à la mise en page
title = QgsLayoutItemLabel(self.layout) title = QgsLayoutItemLabel(self.layout)
self.layout.addLayoutItem(title) self.layout.addLayoutItem(title)
titre = layout_name titre = titre_layout_name
title.setText(titre) title.setText(titre)
title.setFont(QFont("Calibri", 15, QFont.Bold)) Font = QFont("Calibri", 15, False)
Font.setBold(True)
title.setFont(Font)
title.setItemRotation(self.template_parameters['Titre_rotate']) title.setItemRotation(self.template_parameters['Titre_rotate'])
title.attemptResize(self.template_parameters['Titre_size']) title.attemptResize(self.template_parameters['Titre_size'])
title.attemptMove(self.template_parameters['Titre_locals']) title.attemptMove(self.template_parameters['Titre_locals'])
@ -513,18 +524,17 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
title.setBackgroundColor(QColor(255, 255, 255, 130)) title.setBackgroundColor(QColor(255, 255, 255, 130))
self.layout.addItem(title) self.layout.addItem(title)
# title.adjustSizeToText() on n'utilise plutot setFixedSize pour pouvoir centrer le titre de manière plus optimale ici # title.adjustSizeToText() on n'utilise plutot setFixedSize pour pouvoir centrer le titre de manière plus optimale ici
title.setHAlign(Qt.AlignHCenter) title.setHAlign(Qt.AlignmentFlag(0x0004))
title.setVAlign(Qt.AlignVCenter) title.setVAlign(Qt.AlignmentFlag(0x0080))
# Ajout d'un sous titre à la mise en page
## Ajout d'un sous titre à la mise en page
subtitle = QgsLayoutItemLabel(self.layout) subtitle = QgsLayoutItemLabel(self.layout)
self.layout.addLayoutItem(subtitle) self.layout.addLayoutItem(subtitle)
titre = self.lineEdit_3.text() titre = self.lineEdit_3.text()
if self.radioButton_9.isChecked() == 1: if self.radioButton_9.isChecked() == 1:
titre = titre + ' [%' + self.comboBox_4.currentText() + '%]' titre = titre + ' [%' + self.comboBox_4.currentText() + '%]'
subtitle.setText(titre) subtitle.setText(titre)
subtitle.setFont(QFont("MS Shell Dlg 2", 10)) subtitle.setFont(QFont("Calibri", 10))
subtitle.setItemRotation(self.template_parameters['Sous_titre_rotate']) subtitle.setItemRotation(self.template_parameters['Sous_titre_rotate'])
subtitle.attemptResize(self.template_parameters['Sous_titre_size']) subtitle.attemptResize(self.template_parameters['Sous_titre_size'])
subtitle.attemptMove(self.template_parameters['Sous_titre_locals']) subtitle.attemptMove(self.template_parameters['Sous_titre_locals'])
@ -532,29 +542,28 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
subtitle.setBackgroundEnabled(True) subtitle.setBackgroundEnabled(True)
subtitle.setBackgroundColor(QColor(255, 255, 255, 130)) subtitle.setBackgroundColor(QColor(255, 255, 255, 130))
self.layout.addItem(subtitle) self.layout.addItem(subtitle)
subtitle.setHAlign(Qt.AlignHCenter) subtitle.setHAlign(Qt.AlignmentFlag(0x0004))
subtitle.setVAlign(Qt.AlignVCenter) subtitle.setVAlign(Qt.AlignmentFlag(0x0080))
# Ajout du logo CEN NA en haut à gauche de la page
## Ajout du logo CEN NA en haut à gauche de la page
logo = QgsLayoutItemPicture(self.layout) logo = QgsLayoutItemPicture(self.layout)
logo.setResizeMode(QgsLayoutItemPicture.Zoom) logo.setResizeMode(QgsLayoutItemPicture.Zoom)
logo.setPictureAnchor(QgsLayoutItem.ReferencePoint(4))
logo.setMode(QgsLayoutItemPicture.FormatRaster) logo.setMode(QgsLayoutItemPicture.FormatRaster)
logo.setItemRotation(self.template_parameters['Logo_rotate']) logo.setItemRotation(self.template_parameters['Logo_rotate'])
logo.setFixedSize(self.template_parameters['Logo_size']) logo.setFixedSize(self.template_parameters['Logo_size'])
logo.attemptMove(self.template_parameters['Logo_locals']) logo.attemptMove(self.template_parameters['Logo_locals'])
logo.setPicturePath(resources_path("icons","CEN_RA.png")) logo.setPicturePath(resources_path("icons", "CEN_RA.png"))
logo.setId('logo') logo.setId('logo')
self.layout.addLayoutItem(logo) self.layout.addLayoutItem(logo)
# Ajout de la legende :
## Ajout de la legende :
legend = QgsLayoutItemLegend(self.layout) legend = QgsLayoutItemLegend(self.layout)
legend.setId('legende_model1') legend.setId('legende_model1')
# legend.setTitle('Legende') # legend.setTitle('Legende')
legend.adjustBoxSize() legend.adjustBoxSize()
legend.setFrameEnabled(False) legend.setFrameEnabled(self.template_parameters['Legande_frame'])
legend.setAutoUpdateModel(False) legend.setAutoUpdateModel(False)
legend.setLinkedMap(self.map_modele_test) legend.setLinkedMap(self.map_modele_test)
@ -593,7 +602,8 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
layertreelayer = root.findLayer(layer.id()) layertreelayer = root.findLayer(layer.id())
# get the parent of the layer tree layer (layer tree root, or group) # get the parent of the layer tree layer (layer tree root, or group)
parent = layertreelayer.parent() if layertreelayer is not None:
parent = layertreelayer.parent()
# if the parent is a group and has a name, find it and remove the layer # if the parent is a group and has a name, find it and remove the layer
if isinstance(parent, QgsLayerTreeGroup) and parent.name(): if isinstance(parent, QgsLayerTreeGroup) and parent.name():
@ -603,7 +613,6 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
else: else:
root_group.removeLayer(layer) root_group.removeLayer(layer)
legend.setEqualColumnWidth(True) legend.setEqualColumnWidth(True)
legend.setSplitLayer(True) legend.setSplitLayer(True)
legend.setColumnSpace(5) legend.setColumnSpace(5)
@ -611,6 +620,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
legend.rstyle(QgsLegendStyle.Group).setMargin(QgsLegendStyle.Top, 3) legend.rstyle(QgsLegendStyle.Group).setMargin(QgsLegendStyle.Top, 3)
legend.rstyle(QgsLegendStyle.Subgroup).setMargin(QgsLegendStyle.Top, 3) legend.rstyle(QgsLegendStyle.Subgroup).setMargin(QgsLegendStyle.Top, 3)
legend.setColumnCount(self.spinBox.value()) legend.setColumnCount(self.spinBox.value())
legend.setItemRotation(self.template_parameters['Legande_rotate'])
legend.adjustBoxSize() legend.adjustBoxSize()
legend.setBackgroundEnabled(True) legend.setBackgroundEnabled(True)
@ -620,7 +630,7 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
legend.updateLegend() legend.updateLegend()
legend.attemptMove(self.template_parameters['Legande_locals']) legend.attemptMove(self.template_parameters['Legande_locals'])
## Ajout de l'échelle numeric à la mise en page # Ajout de l'échelle numeric à la mise en page
self.scalebarnumeric_qpt = QgsLayoutItemScaleBar(self.layout) self.scalebarnumeric_qpt = QgsLayoutItemScaleBar(self.layout)
self.scalebarnumeric_qpt.setStyle('Numeric') self.scalebarnumeric_qpt.setStyle('Numeric')
self.scalebarnumeric_qpt.setLinkedMap(self.map_modele_test) self.scalebarnumeric_qpt.setLinkedMap(self.map_modele_test)
@ -630,28 +640,31 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
self.scalebarnumeric_qpt.setNumberOfSegments(2) self.scalebarnumeric_qpt.setNumberOfSegments(2)
self.scalebarnumeric_qpt.setNumberOfSegmentsLeft(0) self.scalebarnumeric_qpt.setNumberOfSegmentsLeft(0)
self.scalebarnumeric_qpt.setFont(QFont("Calibri", 12))
self.scalebarnumeric_qpt.setItemRotation(self.template_parameters['Echelle_rotate'])
self.scalebarnumeric_qpt.attemptMove(self.template_parameters['Echelle_locals']) self.scalebarnumeric_qpt.attemptMove(self.template_parameters['Echelle_locals'])
self.scalebarnumeric_qpt.attemptResize(self.template_parameters['Echelle_size']) self.scalebarnumeric_qpt.attemptResize(self.template_parameters['Echelle_size'])
self.scalebarnumeric_qpt.setItemRotation(self.template_parameters['Echelle_rotate'])
self.scalebarnumeric_qpt.setAlignment(QgsScaleBarSettings.Alignment(1)) self.scalebarnumeric_qpt.setAlignment(QgsScaleBarSettings.Alignment(1))
self.scalebarnumeric_qpt.setBackgroundEnabled(True) self.scalebarnumeric_qpt.setBackgroundEnabled(True)
self.scalebarnumeric_qpt.setBackgroundColor(QColor(255, 255, 255, 130)) self.scalebarnumeric_qpt.setBackgroundColor(QColor(255, 255, 255, 130))
self.layout.addLayoutItem(self.scalebarnumeric_qpt) self.layout.addLayoutItem(self.scalebarnumeric_qpt)
## Ajout de l'échelle à la mise en page # Ajout de l'échelle à la mise en page
self.scalebar_qpt = QgsLayoutItemScaleBar(self.layout) self.scalebar_qpt = QgsLayoutItemScaleBar(self.layout)
self.scalebar_qpt.setStyle('Single Box') self.scalebar_qpt.setStyle('Single Box')
self.scalebar_qpt.setLinkedMap(self.map_modele_test) self.scalebar_qpt.setLinkedMap(self.map_modele_test)
self.scalebar_qpt.setFillColor(QColor(144, 144, 144, 255))
self.scalebar_qpt.applyDefaultSize() self.scalebar_qpt.applyDefaultSize()
self.scalebar_qpt.applyDefaultSettings() self.scalebar_qpt.applyDefaultSettings()
self.scalebar_qpt.setNumberOfSegments(2) self.scalebar_qpt.setNumberOfSegments(2)
self.scalebar_qpt.setNumberOfSegmentsLeft(0) self.scalebar_qpt.setNumberOfSegmentsLeft(0)
self.scalebar_qpt.setFont(QFont("Calibri", 12))
self.scalebar_qpt.setItemRotation(self.template_parameters['Echelle_2_rotate'])
self.scalebar_qpt.attemptMove(self.template_parameters['Echelle_2_locals']) self.scalebar_qpt.attemptMove(self.template_parameters['Echelle_2_locals'])
self.scalebar_qpt.attemptResize(self.template_parameters['Echelle_2_size']) self.scalebar_qpt.attemptResize(self.template_parameters['Echelle_2_size'])
self.scalebar_qpt.setItemRotation(self.template_parameters['Echelle_2_rotate'])
self.scalebar_qpt.setAlignment(QgsScaleBarSettings.Alignment(1)) self.scalebar_qpt.setAlignment(QgsScaleBarSettings.Alignment(1))
self.scalebar_qpt.setBackgroundEnabled(True) self.scalebar_qpt.setBackgroundEnabled(True)
self.scalebar_qpt.setBackgroundColor(QColor(255, 255, 255, 130)) self.scalebar_qpt.setBackgroundColor(QColor(255, 255, 255, 130))
@ -661,54 +674,75 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
# ajout de la fleche du Nord # ajout de la fleche du Nord
north = QgsLayoutItemPicture(self.layout) north = QgsLayoutItemPicture(self.layout)
north.setPicturePath(resources_path("mises_en_pages","NorthArrow_02.svg")) north.setPicturePath(resources_path("mises_en_pages", self.template_parameters['Arrow_path']))
north.setLinkedMap(self.map_modele_test)
self.layout.addLayoutItem(north) self.layout.addLayoutItem(north)
north.setPictureAnchor(QgsLayoutItem.ReferencePoint(4))
north.setItemRotation(self.template_parameters['Arrow_rotate'])
north.attemptMove(self.template_parameters['Arrow_locals']) north.attemptMove(self.template_parameters['Arrow_locals'])
north.attemptResize(self.template_parameters['Arrow_size']) north.attemptResize(self.template_parameters['Arrow_size'])
north.setItemRotation(self.template_parameters['Arrow_rotate']) north.setSvgStrokeColor(QColor(255, 255, 255, 255))
north.setSvgFillColor(QColor(76, 76, 76, 255))
north.setBackgroundEnabled(self.template_parameters['Arrow_background'])
north.setBackgroundColor(QColor(255, 255, 255, 130))
if self.radioButton_10.isChecked() == 1: if self.radioButton_10.isChecked() == 1:
info_text = ["Source : " + self.mComboBox_3.currentText()][0] text_source = ' '
for Item_mComboBox_3 in self.mComboBox_3.checkedItems():
text_source = text_source + Item_mComboBox_3 + ','
text_source = text_source[:-1]
info_text = ["Source :" + text_source][0]
else: else:
info_text = ["Source : " + self.lineEdit_4.text()][0] info_text = ["Source : " + self.lineEdit_4.text()][0]
# ajout note info: # ajout note info:
info = ["Réalisation : " + "CEN Rhône-Alpes (" + date.today().strftime( if self.radioButton_14.isChecked() == 1:
"%d/%m/%Y") + ")"] self.s.setValue("automap/prenom_nom", self.lineEdit_5.text())
prenom_nom = self.s.value("automap/prenom_nom", 1, type=str)
info = ["Réalisation : " + "CEN Rhône-Alpes (" + date.today().strftime("%d/%m/%Y") + ") par " + prenom_nom]
else:
info = ["Réalisation : " + "CEN Rhône-Alpes (" + date.today().strftime("%d/%m/%Y") + ")"]
credit_text = QgsLayoutItemLabel(self.layout) credit_text = QgsLayoutItemLabel(self.layout)
credit_text.setText(info[0]) credit_text.setText(info[0])
credit_text.setFont(QFont("Calibri", 9)) credit_text.setFont(QFont("Calibri", 9))
credit_text.setHAlign(Qt.AlignRight) credit_text.setHAlign(Qt.AlignmentFlag(self.template_parameters['Credit_alignment']))
credit_text.setVAlign(Qt.AlignVCenter) credit_text.setVAlign(Qt.AlignmentFlag(0x0080))
credit_text.setMarginX(2)
credit_text.setBackgroundEnabled(True)
credit_text.setBackgroundColor(QColor(255, 255, 255, 130))
credit_text2 = QgsLayoutItemLabel(self.layout) credit_text2 = QgsLayoutItemLabel(self.layout)
credit_text2.setText(info_text) credit_text2.setText(info_text)
credit_text2.setFont(QFont("Calibri", 9)) credit_text2.setFont(QFont("Calibri", 9))
credit_text2.setHAlign(Qt.AlignRight) credit_text2.setHAlign(Qt.AlignmentFlag(self.template_parameters['Source_alignment']))
credit_text2.setVAlign(Qt.AlignVCenter) credit_text2.setVAlign(Qt.AlignmentFlag(0x0080))
credit_text2.setMarginX(2)
credit_text.setItemRotation(self.template_parameters['Credit_rotate']) credit_text.setItemRotation(self.template_parameters['Credit_rotate'])
credit_text.attemptResize(self.template_parameters['Credit_size']) credit_text.attemptResize(self.template_parameters['Credit_size'])
credit_text.attemptMove(self.template_parameters['Credit_locals']) credit_text.attemptMove(self.template_parameters['Credit_locals'])
credit_text2.setItemRotation(self.template_parameters['Source_rotate']) credit_text2.setItemRotation(self.template_parameters['Source_rotate'])
credit_text2.attemptResize(self.template_parameters['Source_size']) credit_text2.attemptResize(self.template_parameters['Source_size'])
credit_text2.attemptMove(self.template_parameters['Source_locals']) credit_text2.attemptMove(self.template_parameters['Source_locals'])
credit_text2.setBackgroundEnabled(True)
credit_text2.setBackgroundColor(QColor(255, 255, 255, 130))
self.layout.addLayoutItem(credit_text) self.layout.addLayoutItem(credit_text)
self.layout.addLayoutItem(credit_text2) self.layout.addLayoutItem(credit_text2)
## Ajout du logo credit en bas à droit de la page # Ajout du logo credit en bas à droit de la page
len_item = (len(self.mComboBox_4.checkedItems())) len_item = (len(self.mComboBox_4.checkedItems()))
for logo_run in self.mComboBox_4.checkedItems(): for logo_run in self.mComboBox_4.checkedItems():
logo_credit = QgsLayoutItemPicture(self.layout) logo_credit = QgsLayoutItemPicture(self.layout)
logo_credit.setResizeMode(QgsLayoutItemPicture.Zoom) logo_credit.setResizeMode(QgsLayoutItemPicture.Zoom)
logo_credit.setPictureAnchor(QgsLayoutItem.ReferencePoint(4))
logo_credit.setMode(QgsLayoutItemPicture.FormatRaster) logo_credit.setMode(QgsLayoutItemPicture.FormatRaster)
cur_x = self.template_parameters['Logo_2_locals'].x() cur_x = self.template_parameters['Logo_2_locals'].x()
logo_credit.setItemRotation(self.template_parameters['Logo_2_rotate'])
logo_credit.attemptMove(self.template_parameters['Logo_2_locals']) logo_credit.attemptMove(self.template_parameters['Logo_2_locals'])
logo_credit.setPictureAnchor(4) self.template_parameters['Logo_2_locals'].setX(cur_x + (logo_div / len_item))
self.template_parameters['Logo_2_locals'].setX(cur_x+(logo_div/len_item))
logo_credit.setFixedSize(self.template_parameters['Logo_2_size']) logo_credit.setFixedSize(self.template_parameters['Logo_2_size'])
if logo_run[0] == ' ': if logo_run[0] == ' ':
logo_credit.setPicturePath(self.s.value("automap/logoteck", 1, type=str)+logo_run[1:]) logo_credit.setPicturePath(self.s.value("automap/logoteck", 1, type=str) + logo_run[1:])
else: else:
logo_credit.setPicturePath(resources_path("logo_library",logo_run)) logo_credit.setPicturePath(resources_path("logo_library", logo_run))
logo_credit.setId('logo_'+logo_run) logo_credit.setId('logo_' + logo_run)
logo_credit.setBackgroundEnabled(True) logo_credit.setBackgroundEnabled(True)
logo_credit.setBackgroundColor(QColor(255, 255, 255, 130)) logo_credit.setBackgroundColor(QColor(255, 255, 255, 130))
self.layout.addLayoutItem(logo_credit) self.layout.addLayoutItem(logo_credit)
@ -719,12 +753,34 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
existing_layout = project.layoutManager().layoutByName(self.layout.name()) existing_layout = project.layoutManager().layoutByName(self.layout.name())
if existing_layout: if existing_layout:
if self.radioButton_12.isChecked() != 1: self.QMBquestion = QMessageBox()
self.QMBquestion.setWindowTitle(u"Attention !")
self.QMBquestion.setIcon(QMessageBox.Icon.Warning)
self.QMBquestion.setText("Mise en page existante, la mise en page va être écrasée !")
self.QMBquestion.setStandardButtons(QMessageBox.StandardButton(0x00004000) | QMessageBox.StandardButton(0x00010000))
self.QMBquestion.addButton(QPushButton('Autre mise en page'), QMessageBox.ButtonRole(0))
self.QMBquestion = self.QMBquestion.exec()
# if self.radioButton_12.isChecked() != 1:
if self.QMBquestion == QMessageBox.StandardButton(0x00004000):
project.layoutManager().removeLayout(existing_layout) project.layoutManager().removeLayout(existing_layout)
# result = project.layoutManager().addLayout(self.layout)
elif self.QMBquestion != QMessageBox.StandardButton(0x00010000):
LayoutCOUNT = 0
arrayManager = []
for AddArrayManager in project.layoutManager().layouts():
arrayManager.append(AddArrayManager.name())
arrayManager.sort()
for LayoutNAME in arrayManager:
if LayoutNAME == layout_name:
LayoutCOUNT = LayoutCOUNT + 1
if LayoutNAME == layout_name + "" + str(LayoutCOUNT):
LayoutCOUNT = LayoutCOUNT + 1
layout_name = (layout_name + "" + str(LayoutCOUNT))
self.layout.setName(layout_name)
result = project.layoutManager().addLayout(self.layout) else:
existing_layout = True
self.manager.addLayout(self.layout) self.manager.addLayout(self.layout)
if self.radioButton_9.isChecked() == 1: if self.radioButton_9.isChecked() == 1:
@ -735,8 +791,24 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
fichier_mise_en_page = layout_name fichier_mise_en_page = layout_name
layout_modifie = QgsProject.instance().layoutManager().layoutByName(fichier_mise_en_page) layout_modifie = QgsProject.instance().layoutManager().layoutByName(fichier_mise_en_page)
iface.openLayoutDesigner(layout_modifie) try:
self.close() if (self.QMBquestion == QMessageBox.AcceptRole):
TryMessage = (self.QMBquestion == QMessageBox.AcceptRole)
elif (self.QMBquestion == QMessageBox.Yes):
TryMessage = (self.QMBquestion == QMessageBox.Yes)
else:
TryMessage = False
del self.QMBquestion
except ValueError:
TryMessage = True
except AttributeError:
TryMessage = True
if TryMessage is True:
iface.openLayoutDesigner(layout_modifie)
self.close()
else:
self.activateWindow()
def actualisation_mise_en_page(self): def actualisation_mise_en_page(self):
values_page = self.comboBox.currentText() values_page = self.comboBox.currentText()
@ -757,24 +829,19 @@ class AutoMap_Editor(QDialog, EDITOR_CLASS):
pc = self.layout.pageCollection() pc = self.layout.pageCollection()
pc.pages()[0].setPageSize('A3', QgsLayoutItemPage.Landscape) pc.pages()[0].setPageSize('A3', QgsLayoutItemPage.Landscape)
if values_page == "demo.py": values_page_import = values_page[:-3]
self.template_parameters = demo.fletch_canvas(self) eval("exec('from .tools.mises_en_pages import ' + values_page_import)")
if values_page == "carto_standard.py": eval("exec('self.template_parameters = '+ values_page_import + '.fletch_canvas(self)')")
self.template_parameters = carto_standard.fletch_canvas(self)
if values_page == "full_page.py":
self.template_parameters = full_page.fletch_canvas(self)
def bar_echelle_auto(self, echelle, bar_echelle): def bar_echelle_auto(self, echelle, bar_echelle):
if True: if True:
if echelle.scale() >= 40000: if echelle.scale() >= 40000:
bar_echelle.setUnits(QgsUnitTypes.DistanceKilometers) bar_echelle.setUnits(QgsUnitTypes.DistanceKilometers)
bar_echelle.setUnitLabel("km") bar_echelle.setUnitLabel("km")
bar_echelle.setUnitsPerSegment(round((echelle.scale()*0.04)/1000)) bar_echelle.setUnitsPerSegment(round((echelle.scale() * 0.04) / 1000))
else: else:
bar_echelle.setUnits(QgsUnitTypes.DistanceMeters) bar_echelle.setUnits(QgsUnitTypes.DistanceMeters)
bar_echelle.setUnitLabel("m") bar_echelle.setUnitLabel("m")
bar_echelle.setUnitsPerSegment(round(echelle.scale()*0.04)) bar_echelle.setUnitsPerSegment(round(echelle.scale() * 0.04))
bar_echelle.update() bar_echelle.update()

View File

@ -1,10 +1,4 @@
import os import os
plugin_dir = os.path.dirname(__file__)
end_find = plugin_dir.rfind('\\')+1
NAME = plugin_dir[end_find:]
#print(NAME)
from qgis.gui import * from qgis.gui import *
from qgis.core import ( from qgis.core import (
@ -27,7 +21,7 @@ from qgis.PyQt.QtWidgets import (
QInputDialog, QInputDialog,
QMenu, QMenu,
QToolButton, QToolButton,
QTableWidget, QTableWidget,
QTableWidgetItem, QTableWidgetItem,
) )
from qgis.utils import iface from qgis.utils import iface
@ -35,21 +29,27 @@ from qgis.utils import iface
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, # resources_path,
send_issues, send_issues,
) )
plugin_dir = os.path.dirname(__file__)
end_find = plugin_dir.rfind('\\') + 1
NAME = plugin_dir[end_find:]
# print(NAME)
EDITOR_CLASS = load_ui('CenRa_IssuesSend.ui') EDITOR_CLASS = load_ui('CenRa_IssuesSend.ui')
class CenRa_Issues(QDialog, EDITOR_CLASS):
class CenRa_Issues(QDialog, EDITOR_CLASS):
def __init__(self, parent=None): def __init__(self, parent=None):
_ = parent _ = parent
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.settings = QgsSettings() self.settings = QgsSettings()
#place connect here # place connect here
self.annuler_button.clicked.connect(self.close) self.annuler_button.clicked.connect(self.close)
self.ok_button.clicked.connect(self.run_sendissues) self.ok_button.clicked.connect(self.run_sendissues)
@ -63,17 +63,22 @@ class CenRa_Issues(QDialog, EDITOR_CLASS):
statu_autre = self.check_autre.isChecked() statu_autre = self.check_autre.isChecked()
statu = [] statu = []
if statu_bug == True : statu = statu + [1] if statu_bug is True:
if statu_aide == True : statu = statu + [3] statu = statu + [1]
if statu_question == True : statu = statu + [5] if statu_aide is True:
if statu_amelioration == True : statu = statu + [2] statu = statu + [3]
if statu_autre == True : statu = statu + [6] if statu_question is True:
statu = statu + [5]
if statu_amelioration is True:
statu = statu + [2]
if statu_autre is True:
statu = statu + [6]
if len(statu) >= 1: if len(statu) >= 1:
import qgis import qgis
url = qgis.utils.pluginMetadata(NAME,'tracker') url = qgis.utils.pluginMetadata(NAME, 'tracker')
print(text_message) print(text_message)
send_info = send_issues(url,text_titre,text_message,statu) send_info = send_issues(url, text_titre, text_message, statu)
code = send_info.status_code code = send_info.status_code
print(code) print(code)
else: else:

View File

@ -5,8 +5,9 @@
[general] [general]
name=CenRa_AutoMap name=CenRa_AutoMap
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
supportsQt6=True
description=CenRa_AutoMap description=CenRa_AutoMap
version=1.7 version=2.7
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@ -21,7 +22,7 @@ tracker=https://gitea.cenra-outils.org/api/v1/repos/CEN-RA/Plugin_QGIS/issues
hasProcessingProvider=no hasProcessingProvider=no
# Uncomment the following line and add your changelog: # Uncomment the following line and add your changelog:
changelog=<h2>CenRa_AutoMap:</h2></br><p><h3>21/10/2024 - Version 1.7: </h3> - Epurations du code.</p></br><p><h3>07/10/2024 - Version 1.6: </h3> - Option de bibliotheque de logo custome.</p></br><p><h3>03/10/2024 - Version 1.5: </h3> - Remonte la fênetre dans la pille.</br> - Gestion du nombre de colonne dans la légend.</br></p></br><p><h3>02/10/2024 - Version 1.4: </h3> - Mise en page plein écrant.</br></p></br><p><h3>01/10/2024 - Version 1.3: </h3> - Récupération du titre et sous-titre pour mise en page existente.</br> - Integration de bibliotheque de logo.</br> - Integration de gestionaire pour les source de donnée.</br> - Mise en place d'une bar d'echelle adaptative. </br></p></br><p><h3>30/09/2024 - Version 1.2: </h3> - Activation du thème. </br> - Ajouter une carte de suivie. </br><p></br><h3>27/09/2024 - Version 1.1: </h3> - Ajout d'une liste déroulante pour les sources de données. </br>- Bouton pour ajouter des fonts de carte customisés. </br>- Fonctionnalité de génération d'atlas. </p></br><p><h3>26/09/2024 - Version 1.0: </h3> - Lancement du plugin CenRa_AutoMap avec une seul mise en page. </p></br> changelog=<h2>CenRa_AUTOMAP:</h2></br><p><h3>18/12/2025 - Version 2.7: </h3> - fix de bug gitea.</p></br><p><h3>18/12/2025 - Version 2.6: </h3> - ajoue du logo n2000 et region.</p></br><p><h3>17/12/2025 - Version 2.5: </h3> - Carte n2000 mise a jour landscape et portrait.</p></br><p><h3>15/12/2025 - Version 2.4: </h3> - Landescape pour n2000.</p></br><p><h3>15/12/2025 - Version 2.3: </h3> - nouvelle mise en page n2000.</p></br><p><h3>12/12/2025 - Version 2.2: </h3> - nouvelle mise en page pour n2000.</p></br><p><h3>30/07/2025 - Version 2.1: </h3> - Correctife de bug.</p></br><p><h3>19/05/2025 - Version 2.0: </h3> - Compatible PyQt5 et PyQt6</p></br><p><h3>11/04/2025 - Version 1.7: </h3> - Correctif d'orthographe.</p></br><p><h3>09/04/2025 - Version 1.6: </h3> - Correctif bug en TT.</p></br><p><h3>09/04/2025 - Version 1.5: </h3> - Optimisation pour le TT.</p></br><p><h3>03/04/2025 - Version 1.4: </h3> - Mise a jour de securite.</p></br><p><h3>20/03/2025 - Version 1.3: </h3> - Fenêtre redimensionnable avec déplaçable avec la mollette sourit.</p></br><p><h3>25/02/2025 - Version 1.2: </h3> - DockWidget pour ouverture de couche avec theme.</p></br><p><h3>28/01/2025 - Version 1.1: </h3> - Multi-Composeur pris en charge.</p></br><p><h3>27/01/2025 - Version 1.0: </h3> - Version releases.</br> - Ajoute un message d'avertissement au moment d'écraser la mise en page.</br> - Ajoute prénom et nom dans la réalisation.</br> - Utilisation de Calibri.</p></br><p><h3>13/01/2025 - Version 0.1.10: </h3> - Correctif.</p></br><p><h3>07/01/2025 - Version 0.1.9: </h3> - ByPass du certif ssl ci erreur.</p></br><p><h3>19/12/2024 - Version 0.1.8: </h3> - Nouvelle mise en page.</br> - Incrémentation automatique de nouveau modele de mise en page. </br> - Correctif de bug.</p></br><p><h3>21/10/2024 - Version 0.1.7: </h3> - Epurations du code.</p></br><p><h3>07/10/2024 - Version 0.1.6: </h3> - Option de bibliotheque de logo custome.</p></br><p><h3>03/10/2024 - Version 0.1.5: </h3> - Remonte la fênetre dans la pille.</br> - Gestion du nombre de colonne dans la légend.</br></p></br><p><h3>02/10/2024 - Version 0.1.4: </h3> - Mise en page plein écrant.</br></p></br><p><h3>01/10/2024 - Version 0.1.3: </h3> - Récupération du titre et sous-titre pour mise en page existente.</br> - Integration de bibliotheque de logo.</br> - Integration de gestionaire pour les source de donnée.</br> - Mise en place d'une bar d'echelle adaptative. </br></p></br><p><h3>30/09/2024 - Version 0.1.2: </h3> - Activation du thème. </br> - Ajouter une carte de suivie. </br><p></br><h3>27/09/2024 - Version 0.1.1: </h3> - Ajout d'une liste déroulante pour les sources de données. </br>- Bouton pour ajouter des fonts de carte customisés. </br>- Fonctionnalité de génération d'atlas. </p></br><p><h3>26/09/2024 - Version 0.1.0: </h3> - Lancement du plugin CenRa_AutoMap avec une seul mise en page. </p></br>
# Tags are comma separated with spaces allowed # Tags are comma separated with spaces allowed
tags=python tags=python

View File

@ -0,0 +1,151 @@
import logging
# from qgis.gui import *
from qgis.core import (
QgsDataSourceUri,
QgsProject,
QgsSettings,
QgsVectorLayer,
QgsMapThemeCollection,
)
from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtWidgets import (
QDockWidget,
QInputDialog,
)
from qgis.PyQt.QtXml import QDomDocument
try:
Enabled = True
from .tools.StyleLayer import host, port, dbname, os_user
except ValueError:
Enabled = False
from .tools.resources import (
load_ui,
resources_path,
# send_issues,
)
# from .issues import CenRa_Issues
# from datetime import date
EDITOR_CLASS = load_ui('CenRa_AutoMapStyle_base.ui')
LOGGER = logging.getLogger('CenRa_AutoMapStyle')
class AutoMap_Style(QDockWidget, EDITOR_CLASS):
def __init__(self, parent=None):
_ = parent
super().__init__()
self.setupUi(self)
self.settings = QgsSettings()
self.s = QSettings()
self.toolButton.setIcon(QIcon(resources_path('icons', 'loader.png')))
self.loadComboBox()
self.toolButton.clicked.connect(self.loadStyle)
def loadComboBox(self):
style = self.comboBox
style.clear()
style.addItem('')
style.addItem('Foncier')
style.addItem('Administratif')
def loadStyle(self):
style = self.comboBox.currentText()
if style == 'Foncier':
self.loadFoncier()
if style == 'Administratif':
self.loadAdministratif()
def loginfo(self):
InputDialog = QInputDialog()
mdp = InputDialog.getText(None, 'Foncier', 'Mot de pass base foncier:')
return mdp
def loadAdministratif(self):
mtc = QgsProject.instance().mapThemeCollection()
theme_name = 'Administratif'
theme_state = mtc.mapThemeState(theme_name)
mdp = self.loginfo()[0]
if mdp != '':
# couche = [['_form_power_rename','_form_power_rename_contour_2025'],['_42_bois_du_roy','_42_bois_du_roy_habitat_2021']]
couche = [['administratif', 'departements2024', 'gid'], ['administratif', 'v_communes', 'id']]
for schema_table in couche:
schema = schema_table[0]
table = schema_table[1]
key = schema_table[2]
uri = QgsDataSourceUri()
uri.setConnection(host, port, dbname, os_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(key)
layer = QgsVectorLayer(uri.uri(), table, "postgres")
if layer.isValid() is True:
layerName = layer.name()
listStyle = layer.listStylesInDatabase()
try:
StyleExist = True
indexStyle = (listStyle[2].index(layerName))
except ValueError:
StyleExist = False
if StyleExist:
StyleId = (listStyle[1][indexStyle])
styleTuple = layer.getStyleFromDatabase(StyleId)
styleqml = styleTuple[0]
styledoc = QDomDocument()
styledoc.setContent(styleqml)
layer.importNamedStyle(styledoc)
# Ajout de la couche au canevas QGIS
QgsProject.instance().addMapLayer(layer)
layer_record = QgsMapThemeCollection.MapThemeLayerRecord(layer)
theme_state.addLayerRecord(layer_record)
mtc.insert(theme_name, theme_state)
def loadFoncier(self):
mtc = QgsProject.instance().mapThemeCollection()
theme_name = 'Foncier'
theme_state = mtc.mapThemeState(theme_name)
mdp = self.loginfo()[0]
if mdp != '':
# couche = [['_form_power_rename','_form_power_rename_contour_2025'],['_42_bois_du_roy','_42_bois_du_roy_habitat_2021']]
couche = [['sites', 'v_sites_parcelles'], ['sites', 'v_sites'], ['inventaires', 'suivi_zh'], ['inventaires', 'suivi_ps']]
for schema_table in couche:
schema = schema_table[0]
table = schema_table[1]
uri = QgsDataSourceUri()
uri.setConnection(host, port, dbname, os_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')
layer = QgsVectorLayer(uri.uri(), table, "postgres")
if layer.isValid() is True:
layerName = layer.name()
listStyle = layer.listStylesInDatabase()
try:
StyleExist = True
indexStyle = (listStyle[2].index(layerName))
except ValueError:
StyleExist = False
if StyleExist:
StyleId = (listStyle[1][indexStyle])
styleTuple = layer.getStyleFromDatabase(StyleId)
styleqml = styleTuple[0]
styledoc = QDomDocument()
styledoc.setContent(styleqml)
layer.importNamedStyle(styledoc)
# Ajout de la couche au canevas QGIS
QgsProject.instance().addMapLayer(layer)
layer_record = QgsMapThemeCollection.MapThemeLayerRecord(layer)
theme_state.addLayerRecord(layer_record)
mtc.insert(theme_name, theme_state)

View File

@ -1,34 +0,0 @@
import sys
import socket
import os
IPAddr=socket.gethostbyname(socket.gethostname())
#print(IPAddr)
if IPAddr[0:11] == "100.100.100": #4269
host = "100.100.100.81"
port = "5432"
dbname = "sig4269"
sigdb="sig4269"
refdb="ref_geo4269"
password = "McVities"
if IPAddr[0:9] == "192.168.0": #01
host = "192.168.0.201"
port = "5432"
dbname = "sig01"
sigdb="sig01"
refdb="ref_geo01"
password = "McVities"
if IPAddr[0:9] == "192.168.1": #0726
host = "192.168.1.201"
port = "5432"
dbname = "sig0726"
sigdb="sig0726"
refdb="ref_geo0726"
password = "McVities"
if sys.platform == 'linux':
os_user = os.environ['USER']
else:
os_user = os.environ['USERNAME']
if os_user == 'STAGE':
os_user='stage'
if os_user == 'Administrateur':
os_user='stage'

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -1,168 +1,198 @@
from qgis.core import ( from qgis.core import (
QgsLayoutSize, QgsLayoutSize,
QgsUnitTypes, QgsUnitTypes,
QgsLayoutPoint, QgsLayoutPoint,
) )
def fletch_canvas(self): def fletch_canvas(self):
if self.radioButton_6.isChecked(): if self.radioButton_6.isChecked():
values_page = 'A4' values_page = 'A4'
else: else:
values_page = 'A3' values_page = 'A3'
if self.radioButton_7.isChecked(): if self.radioButton_7.isChecked():
page_rotate = 'Portrait' page_rotate = 'Portrait'
else: else:
page_rotate = 'Landscape' page_rotate = 'Landscape'
if page_rotate == 'Portrait': if page_rotate == 'Portrait':
if values_page == 'A4': if values_page == 'A4':
self.template_parameters['Carte_2_size'] = QgsLayoutSize(50, 50, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_size'] = QgsLayoutSize(198.85714285714286, 175, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(2.5, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_locals'] = QgsLayoutPoint(5, 25, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_size'] = QgsLayoutSize(199, 175, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_rotate'] = 0.0
self.template_parameters['Carte_locals'] = QgsLayoutPoint(5, 25, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_frame'] = True
self.template_parameters['Titre_size'] = QgsLayoutSize(200, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_size'] = QgsLayoutSize(50.0, 50, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(5, 25, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(200, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_rotate'] = 0.0
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 12, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_frame'] = False
self.template_parameters['Logo_size'] = QgsLayoutSize(46, 16, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_size'] = QgsLayoutSize(198.85714285714286, 90, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_locals'] = QgsLayoutPoint(5, 205, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_rotate'] = 0.0
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 275, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_frame'] = False
self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_size'] = QgsLayoutSize(12.0, 12, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(5, 205, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_locals'] = QgsLayoutPoint(191, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_size'] = QgsLayoutSize(55, 5, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_rotate'] = 0.0
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(145, 228, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_background'] = True
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(55, 15, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(145, 215, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_size'] = QgsLayoutSize(54.857142857142854, 5, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_size'] = QgsLayoutSize(12, 12, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_locals'] = QgsLayoutPoint(145, 229, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(193, 214, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_rotate'] = 0.0
self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_size'] = QgsLayoutSize(46.0, 16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(205, 125, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_rotate'] = 0.0
self.template_parameters['Source_locals'] = QgsLayoutPoint(104, 201, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_size'] = QgsLayoutSize(198.85714285714286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0 self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0 self.template_parameters['Titre_rotate'] = 0.0
self.template_parameters['Legande_rotate'] = 0 self.template_parameters['Credit_size'] = QgsLayoutSize(100.0, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0 self.template_parameters['Credit_locals'] = QgsLayoutPoint(205, 158.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0 self.template_parameters['Credit_rotate'] = 270.0
self.template_parameters['Logo_rotate'] = 0 self.template_parameters['Credit_alignment'] = 0x0002
self.template_parameters['Titre_rotate'] = 0 self.template_parameters['Source_size'] = QgsLayoutSize(100.0, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 270 self.template_parameters['Source_locals'] = QgsLayoutPoint(104, 200, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0 self.template_parameters['Source_rotate'] = 0.0
self.template_parameters['Sous_titre_rotate'] = 0 self.template_parameters['Source_alignment'] = 0x0002
self.template_parameters['Echelle_2_rotate'] = 0 self.template_parameters['Sous_titre_size'] = QgsLayoutSize(198.85714285714286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0 self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 12, QgsUnitTypes.LayoutMillimeters)
if values_page == 'A3': self.template_parameters['Sous_titre_rotate'] = 0.0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(50, 50, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_size'] = QgsLayoutSize(54.857142857142854, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(2.5, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(145, 215, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_size'] = QgsLayoutSize(285, 260, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_rotate'] = 0.0
self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_size'] = QgsLayoutSize(50.0, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 275, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_rotate'] = 0.0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters) if values_page == 'A3':
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_size'] = QgsLayoutSize(280, 247, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_size'] = QgsLayoutSize(46, 16, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_locals'] = QgsLayoutPoint(7, 35, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_rotate'] = 0.0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_frame'] = True
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 395, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_size'] = QgsLayoutSize(70, 70, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(7, 35, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(5, 284, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_rotate'] = 0.0
self.template_parameters['Echelle_size'] = QgsLayoutSize(50, 15, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_frame'] = False
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(207, 310, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_size'] = QgsLayoutSize(280, 127, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(50, 15, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_locals'] = QgsLayoutPoint(7, 289, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(207, 298, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_rotate'] = 0.0
self.template_parameters['Arrow_size'] = QgsLayoutSize(8.4, 12.5, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_frame'] = False
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(273, 297, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_size'] = QgsLayoutSize(17, 17, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_locals'] = QgsLayoutPoint(269, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(291.5, 123, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_rotate'] = 0.0
self.template_parameters['Source_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_background'] = True
self.template_parameters['Source_locals'] = QgsLayoutPoint(189, 284, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
self.template_parameters['Carte_rotate'] = 0 self.template_parameters['Echelle_size'] = QgsLayoutSize(77, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0 self.template_parameters['Echelle_locals'] = QgsLayoutPoint(205, 323, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0 self.template_parameters['Echelle_rotate'] = 0.0
self.template_parameters['Arrow_rotate'] = 0 self.template_parameters['Logo_size'] = QgsLayoutSize(65, 23, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0 self.template_parameters['Logo_locals'] = QgsLayoutPoint(7, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0 self.template_parameters['Logo_rotate'] = 0.0
self.template_parameters['Titre_rotate'] = 0 self.template_parameters['Titre_size'] = QgsLayoutSize(280, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 270 self.template_parameters['Titre_locals'] = QgsLayoutPoint(7, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0 self.template_parameters['Titre_rotate'] = 0.0
self.template_parameters['Sous_titre_rotate'] = 0 self.template_parameters['Credit_size'] = QgsLayoutSize(141, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0 self.template_parameters['Credit_locals'] = QgsLayoutPoint(289, 223, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0 self.template_parameters['Credit_rotate'] = 270.0
self.template_parameters['Credit_alignment'] = 0x0002
self.template_parameters['Source_size'] = QgsLayoutSize(141, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(147, 282, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0.0
self.template_parameters['Source_alignment'] = 0x0002
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(280, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(7, 17, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0.0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(77, 21, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(205, 303, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0.0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(70, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(7, 388, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0.0
if page_rotate == 'Landscape': if page_rotate == 'Landscape':
if values_page == 'A4': if values_page == 'A4':
self.template_parameters['Carte_size'] = QgsLayoutSize(285, 145, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_size'] = QgsLayoutSize(285.14285714285717, 145, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_size'] = QgsLayoutSize(100, 100, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_rotate'] = 0.0
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_frame'] = True
self.template_parameters['Titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_size'] = QgsLayoutSize(100.0, 100, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_rotate'] = 0.0
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_frame'] = False
self.template_parameters['Logo_size'] = QgsLayoutSize(46, 16, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_size'] = QgsLayoutSize(285.14285714285717, 41, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_locals'] = QgsLayoutPoint(6, 168, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_rotate'] = 0.0
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 185, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_frame'] = False
self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_size'] = QgsLayoutSize(13.142857142857142, 12, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(5, 168, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_locals'] = QgsLayoutPoint(277, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_size'] = QgsLayoutSize(55, 15, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_rotate'] = 0.0
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(207, 193, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_background'] = True
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(55, 15, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(207, 180, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_size'] = QgsLayoutSize(54.857142857142854, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_size'] = QgsLayoutSize(8.4, 12.5, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_locals'] = QgsLayoutPoint(232, 193, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(273, 182, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_rotate'] = 0.0
self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_size'] = QgsLayoutSize(46.0, 16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(291.5, 123, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_rotate'] = 0.0
self.template_parameters['Source_locals'] = QgsLayoutPoint(189, 168.5, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_size'] = QgsLayoutSize(286.0, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0 self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0 self.template_parameters['Titre_rotate'] = 0.0
self.template_parameters['Legande_rotate'] = 0 self.template_parameters['Credit_size'] = QgsLayoutSize(100.0, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0 self.template_parameters['Credit_locals'] = QgsLayoutPoint(291, 127.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0 self.template_parameters['Credit_rotate'] = 270.0
self.template_parameters['Logo_rotate'] = 0 self.template_parameters['Credit_alignment'] = 0x0002
self.template_parameters['Titre_rotate'] = 0 self.template_parameters['Source_size'] = QgsLayoutSize(100.0, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 270 self.template_parameters['Source_locals'] = QgsLayoutPoint(189, 169, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0 self.template_parameters['Source_rotate'] = 0.0
self.template_parameters['Sous_titre_rotate'] = 0 self.template_parameters['Source_alignment'] = 0x0002
self.template_parameters['Echelle_2_rotate'] = 0 self.template_parameters['Sous_titre_size'] = QgsLayoutSize(286.0, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0 self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 12, QgsUnitTypes.LayoutMillimeters)
if values_page == 'A3': self.template_parameters['Sous_titre_rotate'] = 0.0
self.template_parameters['Carte_size'] = QgsLayoutSize(408.5, 222, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_size'] = QgsLayoutSize(54.857142857142854, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(5, 23.5, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(232, 179, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_size'] = QgsLayoutSize(100, 100, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_rotate'] = 0.0
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_size'] = QgsLayoutSize(50.0, 50, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_size'] = QgsLayoutSize(409, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(6, 118, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_rotate'] = 0.0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(409, 8, QgsUnitTypes.LayoutMillimeters) if values_page == 'A3':
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_size'] = QgsLayoutSize(402, 205, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_size'] = QgsLayoutSize(46, 16, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 32, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_rotate'] = 0.0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_frame'] = True
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 275, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_size'] = QgsLayoutSize(141, 141, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(8, 32, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(5, 249, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_rotate'] = 0.0
self.template_parameters['Echelle_size'] = QgsLayoutSize(55, 15, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_frame'] = False
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(323, 282, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_size'] = QgsLayoutSize(402, 58, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(55, 15, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_locals'] = QgsLayoutPoint(8, 237, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(323, 270, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_rotate'] = 0.0
self.template_parameters['Arrow_size'] = QgsLayoutSize(8.4, 12.5, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_frame'] = False
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(402, 270, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_size'] = QgsLayoutSize(19, 17, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_locals'] = QgsLayoutPoint(391, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(415, 123, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_rotate'] = 0.0
self.template_parameters['Source_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_background'] = True
self.template_parameters['Source_locals'] = QgsLayoutPoint(313, 247, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
self.template_parameters['Carte_rotate'] = 0 self.template_parameters['Echelle_size'] = QgsLayoutSize(77, 21, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0 self.template_parameters['Echelle_locals'] = QgsLayoutPoint(327, 272, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0 self.template_parameters['Echelle_rotate'] = 0.0
self.template_parameters['Arrow_rotate'] = 0 self.template_parameters['Logo_size'] = QgsLayoutSize(65, 23, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0 self.template_parameters['Logo_locals'] = QgsLayoutPoint(7, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0 self.template_parameters['Logo_rotate'] = 0.0
self.template_parameters['Titre_rotate'] = 0 self.template_parameters['Titre_size'] = QgsLayoutSize(403, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 270 self.template_parameters['Titre_locals'] = QgsLayoutPoint(7, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0 self.template_parameters['Titre_rotate'] = 0.0
self.template_parameters['Sous_titre_rotate'] = 0 self.template_parameters['Credit_size'] = QgsLayoutSize(141, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0 self.template_parameters['Credit_locals'] = QgsLayoutPoint(410, 179, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0 self.template_parameters['Credit_rotate'] = 270.0
self.template_parameters['Credit_alignment'] = 0x0002
self.template_parameters['Source_size'] = QgsLayoutSize(141, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(267, 238, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0.0
self.template_parameters['Source_alignment'] = 0x0002
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(403, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(7, 17, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0.0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(77, 21, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(327, 252, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0.0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(70, 70, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(8, 166, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0.0
return self.template_parameters return self.template_parameters

View File

@ -1,167 +0,0 @@
from qgis.core import (
QgsLayoutSize,
QgsUnitTypes,
QgsLayoutPoint,
)
def fletch_canvas(self):
if self.radioButton_6.isChecked():
values_page = 'A4'
else:
values_page = 'A3'
if self.radioButton_7.isChecked():
page_rotate = 'Portrait'
else:
page_rotate = 'Landscape'
if page_rotate == 'Portrait':
if values_page == 'A4':
self.template_parameters['Carte_size'] = QgsLayoutSize(200.0,200, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(80.0,80, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(126, 210, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(86.0,86, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(6, 208, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286,14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(189, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_size'] = QgsLayoutSize(51.42857142857143,7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(9, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(45.714285714285715,11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(154.28571428571428,11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(51, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(151, 210, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Source_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(229, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(125.71428571428571,14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(60, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(51.42857142857143,13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(9, 184, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(28.571428571428573,29, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(9, 151, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
if values_page == 'A3':
self.template_parameters['Carte_size'] = QgsLayoutSize(282,282, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(113,113, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(178, 296, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(121,121, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(8, 293, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(20,20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(267, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_size'] = QgsLayoutSize(73,10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(13, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(64,16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(218,16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(72, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(213, 296, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Source_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(323, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(177,20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(85, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(73,18, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(13, 259, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40,40, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(13, 213, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
if page_rotate == 'Landscape':
if values_page == 'A4':
self.template_parameters['Carte_size'] = QgsLayoutSize(200.0,200, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(85.71428571428571,69, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(209, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(85.71428571428571,131, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(209, 74, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286,14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(189, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_size'] = QgsLayoutSize(51.42857142857143,7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(9, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(45.714285714285715,11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(154.28571428571428,11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(51, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(151, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Source_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(229, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(125.71428571428571,14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(60, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(51.42857142857143,13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(9, 184, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(28.571428571428573,29, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(9, 151, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
if values_page == 'A3':
self.template_parameters['Carte_size'] = QgsLayoutSize(282,282, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(121,97, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(294, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(121,185, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(294, 105, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(20,20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(266, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_size'] = QgsLayoutSize(73,10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(12, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(64,16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(218,16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(73, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(214, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Source_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(322, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(177,20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(85, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(73,18, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(12, 260, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40,40, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(12, 214, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
return self.template_parameters

View File

@ -1,170 +1,203 @@
from qgis.core import ( from qgis.core import (
QgsLayoutSize, QgsLayoutSize,
QgsUnitTypes, QgsUnitTypes,
QgsLayoutPoint, QgsLayoutPoint,
) )
def fletch_canvas(self): def fletch_canvas(self):
if self.radioButton_6.isChecked(): if self.radioButton_6.isChecked():
values_page = 'A4' values_page = 'A4'
else: else:
values_page = 'A3' values_page = 'A3'
if self.radioButton_7.isChecked(): if self.radioButton_7.isChecked():
page_rotate = 'Portrait' page_rotate = 'Portrait'
else: else:
page_rotate = 'Landscape' page_rotate = 'Landscape'
if page_rotate == 'Portrait': if page_rotate == 'Portrait':
if values_page == 'A4': if values_page == 'A4':
self.template_parameters['Carte_2_size'] = QgsLayoutSize(50, 50, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_size'] = QgsLayoutSize(50, 50, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(2.5, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(2.5, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_size'] = QgsLayoutSize(210, 297, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_size'] = QgsLayoutSize(210, 297, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_locals'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_size'] = QgsLayoutSize(200, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_size'] = QgsLayoutSize(200, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(200, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_size'] = QgsLayoutSize(200, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_position'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 275, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 275, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(133, 215, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_locals'] = QgsLayoutPoint(133, 215, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(3, 288, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_locals'] = QgsLayoutPoint(3, 288, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(3, 273, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(3, 273, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_size'] = QgsLayoutSize(12, 12, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_size'] = QgsLayoutSize(12, 12, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(196, 283, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_locals'] = QgsLayoutPoint(196, 283, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(205, 125, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_locals'] = QgsLayoutPoint(205, 125, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Source_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(55, 292, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Source_locals'] = QgsLayoutPoint(55, 292, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0 self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_rotate'] = 0 self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_rotate'] = 0 self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_rotate'] = 0 self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_rotate'] = 0 self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_rotate'] = 0 self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_rotate'] = 0 self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_rotate'] = 270 self.template_parameters['Credit_rotate'] = 270
self.template_parameters['Source_rotate'] = 0 self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_rotate'] = 0 self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_rotate'] = 0 self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0 self.template_parameters['Logo_2_rotate'] = 0
if values_page == 'A3': self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_size'] = QgsLayoutSize(50, 50, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_frame'] = False
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(2.5, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_frame'] = False
self.template_parameters['Carte_size'] = QgsLayoutSize(297, 420, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_background'] = True
self.template_parameters['Carte_locals'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
self.template_parameters['Titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_alignment'] = 0x0002
self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Source_alignment'] = 0x0002
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters) if values_page == 'A3':
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_size'] = QgsLayoutSize(50, 50, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(2.5, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_size'] = QgsLayoutSize(297, 420, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_locals'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 370, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(219, 324, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(3, 410, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(3, 395, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_size'] = QgsLayoutSize(24, 24, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 370, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(271, 394, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_locals'] = QgsLayoutPoint(219, 324, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(291, 125, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_locals'] = QgsLayoutPoint(3, 410, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(98, 414, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0 self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(3, 395, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0 self.template_parameters['Arrow_size'] = QgsLayoutSize(24, 24, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0 self.template_parameters['Arrow_locals'] = QgsLayoutPoint(271, 394, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0 self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0 self.template_parameters['Credit_locals'] = QgsLayoutPoint(291, 125, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0 self.template_parameters['Source_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0 self.template_parameters['Source_locals'] = QgsLayoutPoint(98, 414, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 270 self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Source_rotate'] = 0 self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Sous_titre_rotate'] = 0 self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Echelle_2_rotate'] = 0 self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0 self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_rotate'] = 270
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_frame'] = False
self.template_parameters['Legande_frame'] = False
self.template_parameters['Arrow_background'] = True
self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
self.template_parameters['Credit_alignment'] = 0x0002
self.template_parameters['Source_alignment'] = 0x0002
if page_rotate == 'Landscape': if page_rotate == 'Landscape':
if values_page == 'A4': if values_page == 'A3':
self.template_parameters['Carte_2_size'] = QgsLayoutSize(100, 100, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_size'] = QgsLayoutSize(100, 100, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_size'] = QgsLayoutSize(420, 297, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_size'] = QgsLayoutSize(420, 297, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_locals'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_size'] = QgsLayoutSize(411, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_size'] = QgsLayoutSize(411, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(411, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_size'] = QgsLayoutSize(411, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 247, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 247, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(341, 196, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_locals'] = QgsLayoutPoint(341, 196, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(3, 287, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_locals'] = QgsLayoutPoint(3, 287, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(3, 272, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(3, 272, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_size'] = QgsLayoutSize(24, 24, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_size'] = QgsLayoutSize(24, 24, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(394, 271, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_locals'] = QgsLayoutPoint(394, 271, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(414, 123, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_locals'] = QgsLayoutPoint(414, 123, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Source_size'] = QgsLayoutSize(100, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(185, 292, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Source_locals'] = QgsLayoutPoint(185, 292, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0 self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_rotate'] = 0 self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_rotate'] = 0 self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_rotate'] = 0 self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_rotate'] = 0 self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_rotate'] = 0 self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_rotate'] = 0 self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_rotate'] = 270 self.template_parameters['Credit_rotate'] = 270
self.template_parameters['Source_rotate'] = 0 self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_rotate'] = 0 self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_rotate'] = 0 self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0 self.template_parameters['Logo_2_rotate'] = 0
if values_page == 'A3': self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(100, 100, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_frame'] = False
self.template_parameters['Carte_size'] = QgsLayoutSize(297, 210, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_frame'] = False
self.template_parameters['Carte_locals'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_background'] = True
self.template_parameters['Titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_alignment'] = 0x0002
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Source_alignment'] = 0x0002
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters) if values_page == 'A4':
self.template_parameters['Logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_size'] = QgsLayoutSize(100, 100, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(6, 23, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_size'] = QgsLayoutSize(297, 210, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 185, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_locals'] = QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(231, 135, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_size'] = QgsLayoutSize(286, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(3, 201, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(5, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_size'] = QgsLayoutSize(48, 17, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(3, 186, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_locals'] = QgsLayoutPoint(5, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_size'] = QgsLayoutSize(12, 12, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_size'] = QgsLayoutSize(50, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(283, 196, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(5, 185, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_size'] = QgsLayoutSize(405, 203, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(291.5, 123, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_locals'] = QgsLayoutPoint(231, 135, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_size'] = QgsLayoutSize(64, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(98, 205, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_locals'] = QgsLayoutPoint(3, 201, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0 self.template_parameters['Echelle_2_size'] = QgsLayoutSize(65, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0 self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(3, 186, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0 self.template_parameters['Arrow_size'] = QgsLayoutSize(12, 12, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0 self.template_parameters['Arrow_locals'] = QgsLayoutPoint(283, 196, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0 self.template_parameters['Credit_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0 self.template_parameters['Credit_locals'] = QgsLayoutPoint(291.5, 123, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0 self.template_parameters['Source_size'] = QgsLayoutSize(100, 3.9, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 270 self.template_parameters['Source_locals'] = QgsLayoutPoint(98, 205, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0 self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Sous_titre_rotate'] = 0 self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Echelle_2_rotate'] = 0 self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0 self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_rotate'] = 270
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_frame'] = False
self.template_parameters['Legande_frame'] = False
self.template_parameters['Arrow_background'] = True
self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
self.template_parameters['Credit_alignment'] = 0x0002
self.template_parameters['Source_alignment'] = 0x0002
# Retour des info # # Retour des info #
return self.template_parameters return self.template_parameters

View File

@ -0,0 +1,203 @@
from qgis.core import (
QgsLayoutSize,
QgsUnitTypes,
QgsLayoutPoint,
)
def fletch_canvas(self):
if self.radioButton_6.isChecked():
values_page = 'A4'
else:
values_page = 'A3'
if self.radioButton_7.isChecked():
page_rotate = 'Portrait'
else:
page_rotate = 'Landscape'
if page_rotate == 'Portrait':
if values_page == 'A4':
self.template_parameters['Carte_size'] = QgsLayoutSize(168.0, 262, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(41, 1, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(78.85714285714286, 70, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(130, 1, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(168.0, 32, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(41, 264, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(13, 254, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_size'] = QgsLayoutSize(38.857142857142854, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(1, 289, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(34.857142857142854, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 139, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(38.857142857142854, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(1, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(74.85714285714286, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(43, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Source_size'] = QgsLayoutSize(104.0, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(104, 256, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(38.857142857142854, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(1, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(38.857142857142854, 13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(1, 276, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(30.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(41, 233, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_frame'] = False
self.template_parameters['Legande_frame'] = False
self.template_parameters['Arrow_background'] = True
self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
self.template_parameters['Credit_alignment'] = 0x0002
self.template_parameters['Source_alignment'] = 0x0002
if values_page == 'A3':
self.template_parameters['Carte_size'] = QgsLayoutSize(237, 369, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(58, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(111, 99, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(183, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(237, 45, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(58, 372, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(20, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(19, 358, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_size'] = QgsLayoutSize(55, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(2, 408, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(49, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 196, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(55, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(2, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(106, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(60, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Source_size'] = QgsLayoutSize(147, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(147, 361, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(55, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(2, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(55, 19, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(2, 389, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(42, 42, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(58, 329, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_frame'] = False
self.template_parameters['Legande_frame'] = False
self.template_parameters['Arrow_background'] = True
self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
self.template_parameters['Credit_alignment'] = 0x0002
self.template_parameters['Source_alignment'] = 0x0002
if page_rotate == 'Landscape':
if values_page == 'A4':
self.template_parameters['Carte_size'] = QgsLayoutSize(254.85714285714286, 175, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(41, 1, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(78.85714285714286, 70, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(217, 1, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(254.85714285714286, 32, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(41, 177, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(13, 168, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_size'] = QgsLayoutSize(38.857142857142854, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(1, 202, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(34.857142857142854, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 94, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(38.857142857142854, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(1, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(74.85714285714286, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(43, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Source_size'] = QgsLayoutSize(104.0, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(190, 169, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(38.857142857142854, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(1, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(38.857142857142854, 13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(1, 189, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(30.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(41, 146, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_frame'] = False
self.template_parameters['Legande_frame'] = False
self.template_parameters['Arrow_background'] = True
self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
self.template_parameters['Credit_alignment'] = 0x0002
self.template_parameters['Source_alignment'] = 0x0002
if values_page == 'A3':
self.template_parameters['Carte_size'] = QgsLayoutSize(359, 247, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(58, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(111, 99, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(306, 2, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(359, 45, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(58, 250, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(20, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(19, 237, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Echelle_size'] = QgsLayoutSize(55, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(2, 285, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(49, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 133, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(55, 15, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(2, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(106, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(60, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Source_size'] = QgsLayoutSize(147, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(268, 238, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(55, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(2, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(55, 19, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(2, 267, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(42, 42, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(58, 206, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_frame'] = False
self.template_parameters['Legande_frame'] = False
self.template_parameters['Arrow_background'] = True
self.template_parameters['Arrow_path'] = "NorthArrow_02.svg"
self.template_parameters['Credit_alignment'] = 0x0002
self.template_parameters['Source_alignment'] = 0x0002
return self.template_parameters

View File

@ -0,0 +1,197 @@
from qgis.core import (
QgsLayoutSize,
QgsUnitTypes,
QgsLayoutPoint,
)
def fletch_canvas(self):
if self.radioButton_6.isChecked():
values_page = 'A4'
else:
values_page = 'A3'
if self.radioButton_7.isChecked():
page_rotate = 'Portrait'
else:
page_rotate = 'Landscape'
if page_rotate == 'Portrait':
if values_page == 'A4':
self.template_parameters['Carte_size'] = QgsLayoutSize(206.0, 200, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(2, 29, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_size'] = QgsLayoutSize(58.857142857142854, 40, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(146, 218, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Carte_2_frame'] = True
self.template_parameters['Legande_size'] = QgsLayoutSize(198.85714285714286, 36, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(6, 260, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Legande_frame'] = True
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.0, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(191, 32, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Arrow_background'] = False
self.template_parameters['Arrow_path'] = "NorthArrow_03.svg"
self.template_parameters['Echelle_size'] = QgsLayoutSize(50.0, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(90, 244, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(40.0, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(6, 234, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(206.0, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(2, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(198.0, 5, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(3, 228.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 270
self.template_parameters['Credit_alignment'] = 0x0001
self.template_parameters['Source_size'] = QgsLayoutSize(198.0, 5, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(8, 228.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 270
self.template_parameters['Source_alignment'] = 0x0001
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(202.0, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(4, 13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(50.0, 13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(90, 233, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40.0, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(48, 234, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
if values_page == 'A3':
self.template_parameters['Carte_size'] = QgsLayoutSize(290, 282, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(3, 41, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_size'] = QgsLayoutSize(83, 56, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(206, 307, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Carte_2_frame'] = True
self.template_parameters['Legande_size'] = QgsLayoutSize(280, 51, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(8, 367, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Legande_frame'] = True
self.template_parameters['Arrow_size'] = QgsLayoutSize(20, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(269, 45, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Arrow_background'] = False
self.template_parameters['Arrow_path'] = "NorthArrow_03.svg"
self.template_parameters['Echelle_size'] = QgsLayoutSize(70, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(125, 350, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(56, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(8, 330, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(290, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(3, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(280, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(4, 322, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 270
self.template_parameters['Credit_alignment'] = 0x0001
self.template_parameters['Source_size'] = QgsLayoutSize(280, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(11, 322, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 270
self.template_parameters['Source_alignment'] = 0x0001
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(285, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(6, 19, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(70, 19, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(125, 330, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(56, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(68, 330, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
if page_rotate == 'Landscape':
if values_page == 'A4':
self.template_parameters['Carte_size'] = QgsLayoutSize(189.0, 189, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(9, 18.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_size'] = QgsLayoutSize(50.0, 40, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(194, 20.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Carte_2_frame'] = True
self.template_parameters['Legande_size'] = QgsLayoutSize(203.0, 62, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(199, 63.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Legande_frame'] = True
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.0, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(177, 20.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Arrow_background'] = False
self.template_parameters['Arrow_path'] = "NorthArrow_03.svg"
self.template_parameters['Echelle_size'] = QgsLayoutSize(50, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(247, 43, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(40.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(209, 174.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(289.0, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(3, 1.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(191, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(8, 201, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Credit_alignment'] = 0x0001
self.template_parameters['Source_size'] = QgsLayoutSize(191, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(8, 195, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Source_alignment'] = 0x0001
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(289.0, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(3, 12.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(50, 13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(249, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(252, 174, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
if values_page == 'A3':
self.template_parameters['Carte_size'] = QgsLayoutSize(305.0, 273, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(9, 18.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_size'] = QgsLayoutSize(50.0, 40, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(311, 20.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Carte_2_frame'] = True
self.template_parameters['Legande_size'] = QgsLayoutSize(203.0, 62, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(317, 63.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Legande_frame'] = True
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.0, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(296, 20.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Arrow_background'] = False
self.template_parameters['Arrow_path'] = "NorthArrow_03.svg"
self.template_parameters['Echelle_size'] = QgsLayoutSize(50, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(364, 43, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(40.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(320, 264.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(413.0, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(3, 1.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(306, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(8, 285, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Credit_alignment'] = 0x0001
self.template_parameters['Source_size'] = QgsLayoutSize(306, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(8, 279, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Source_alignment'] = 0x0001
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(413.0, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(3, 12.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(50, 13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(366, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(369, 264, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
return self.template_parameters

View File

@ -0,0 +1,197 @@
from qgis.core import (
QgsLayoutSize,
QgsUnitTypes,
QgsLayoutPoint,
)
def fletch_canvas(self):
if self.radioButton_6.isChecked():
values_page = 'A4'
else:
values_page = 'A3'
if self.radioButton_7.isChecked():
page_rotate = 'Portrait'
else:
page_rotate = 'Landscape'
if page_rotate == 'Portrait':
if values_page == 'A4':
self.template_parameters['Carte_size'] = QgsLayoutSize(145.0, 135, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(4, 18, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_size'] = QgsLayoutSize(50, 40, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(146, 21, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Carte_2_frame'] = True
self.template_parameters['Legande_size'] = QgsLayoutSize(198.85714285714286, 36, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(153, 64, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Legande_frame'] = True
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.0, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(6, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Arrow_background'] = False
self.template_parameters['Arrow_path'] = "NorthArrow_03.svg"
self.template_parameters['Echelle_size'] = QgsLayoutSize(50.0, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(154, 220, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(40.0, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(160, 264, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(205.0, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(2, 1, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(145.0, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(4, 147.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Credit_alignment'] = 0x0001
self.template_parameters['Source_size'] = QgsLayoutSize(145.0, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(4, 141.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Source_alignment'] = 0x0001
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(205, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(2, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(50.0, 13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(162, 208, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40.0, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(160, 234, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
if values_page == 'A3':
self.template_parameters['Carte_size'] = QgsLayoutSize(233.0, 192, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(4, 18, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_size'] = QgsLayoutSize(50, 40, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(234, 21, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Carte_2_frame'] = True
self.template_parameters['Legande_size'] = QgsLayoutSize(190, 36, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(242, 64, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Legande_frame'] = True
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.0, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(6, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Arrow_background'] = False
self.template_parameters['Arrow_path'] = "NorthArrow_03.svg"
self.template_parameters['Echelle_size'] = QgsLayoutSize(50.0, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(154, 220, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(40.0, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(248, 386, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(293.0, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(2, 1, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(233.0, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(4, 204.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Credit_alignment'] = 0x0001
self.template_parameters['Source_size'] = QgsLayoutSize(233.0, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(4, 198.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Source_alignment'] = 0x0001
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(293, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(2, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(50.0, 13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(252, 330, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40.0, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(160, 234, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
if page_rotate == 'Landscape':
if values_page == 'A4':
self.template_parameters['Carte_size'] = QgsLayoutSize(145.0, 140, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(150, 27.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_size'] = QgsLayoutSize(40.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(253, 144.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Carte_2_frame'] = True
self.template_parameters['Legande_size'] = QgsLayoutSize(110.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(183, 175.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Legande_frame'] = True
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.0, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(278, 29.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Arrow_background'] = False
self.template_parameters['Arrow_path'] = "NorthArrow_03.svg"
self.template_parameters['Echelle_size'] = QgsLayoutSize(50, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(110, 191, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(40.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(7, 175.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(288.0, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(3, 1.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(140, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(150, 167, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 270
self.template_parameters['Credit_alignment'] = 0x0001
self.template_parameters['Source_size'] = QgsLayoutSize(140, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(156, 167, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 270
self.template_parameters['Source_alignment'] = 0x0001
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(288.0, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(3, 11.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(50, 13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(110, 180, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(52, 175, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
if values_page == 'A3':
self.template_parameters['Carte_size'] = QgsLayoutSize(200.0, 230, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(216, 27.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Carte_frame'] = True
self.template_parameters['Carte_2_size'] = QgsLayoutSize(40.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(373, 234.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Carte_2_frame'] = True
self.template_parameters['Legande_size'] = QgsLayoutSize(110.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(253, 264.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Legande_frame'] = True
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.0, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(401, 29.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Arrow_background'] = False
self.template_parameters['Arrow_path'] = "NorthArrow_03.svg"
self.template_parameters['Echelle_size'] = QgsLayoutSize(50, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(150, 281, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Logo_size'] = QgsLayoutSize(40.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(7, 265.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Titre_size'] = QgsLayoutSize(413.0, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(3, 1.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Credit_size'] = QgsLayoutSize(230, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(216, 257, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_rotate'] = 270
self.template_parameters['Credit_alignment'] = 0x0001
self.template_parameters['Source_size'] = QgsLayoutSize(230, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(222, 257, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 270
self.template_parameters['Source_alignment'] = 0x0001
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(413.0, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(3, 11.0, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(50, 13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(150, 270, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40.0, 30, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(72, 265, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
return self.template_parameters

View File

@ -4,6 +4,7 @@ import configparser
import shutil import shutil
import tempfile import tempfile
import base64 import base64
import os
import psycopg2 import psycopg2
import psycopg2.extras import psycopg2.extras
from os.path import abspath, join, pardir, dirname from os.path import abspath, join, pardir, dirname
@ -107,25 +108,15 @@ def load_ui(*args):
return ui_class return ui_class
def login_base(take=None): def pyperclip():
from CenRa_METABASE.tools.PythonSQL import host,port,dbname,password,os_user dst = dirname(dirname(__file__))+"\\tools\\"
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) if os.access('N:/',os.R_OK):
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/StyleLayer.py'
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") try:
res_ident = first_cur.fetchone() shutil.copy(src, dst)
except:
print('404')
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take:
return cur,con
else:
return cur
def send_issues(url,titre,body,labels): def send_issues(url,titre,body,labels):
import requests import requests
import json import json
@ -158,7 +149,7 @@ def maj_verif(NAME):
url = qgis.utils.pluginMetadata(NAME,'repository') url = qgis.utils.pluginMetadata(NAME,'repository')
#URL = url+'/raw/branch/main/plugins.xml' #URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version) len_version = len(version)
@ -168,12 +159,15 @@ def maj_verif(NAME):
except: except:
binar = False binar = False
if binar: if binar:
version_web = str(urllib.request.urlopen(URL).read()) try:
plugin_num = version_web.find(NAME) version_web = str(urllib.request.urlopen(URL).read())
valeur_version_web = version_web.find('<version>',plugin_num)+9 plugin_num = version_web.find(NAME)
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version] valeur_version_web = version_web.find('<version>',plugin_num)+9
if version_plugin != version: version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30) if version_plugin != version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
except:
print("error gitea version ssl")
else: else:
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30) iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CenRa_AutoMapStyle</class>
<widget class="QDockWidget" name="CenRa_AutoMapStyle">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>48</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="floating">
<bool>false</bool>
</property>
<property name="features">
<set>QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable</set>
</property>
<property name="windowTitle">
<string>CenRa_AutoMap</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>5</number>
</property>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox">
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Style:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="toolButton">
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>SICEN</string> <string>Journal des modifications</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset>
@ -29,9 +29,6 @@
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -41,7 +38,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>453</width> <width>453</width>
<height>547</height> <height>570</height>
</rect> </rect>
</property> </property>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
@ -56,7 +53,7 @@
<property name="title"> <property name="title">
<string>DevLog</string> <string>DevLog</string>
</property> </property>
<widget class="QWebView" name="viewer" native="true"> <widget class="QTextBrowser" name="viewer">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
@ -65,11 +62,6 @@
<height>511</height> <height>511</height>
</rect> </rect>
</property> </property>
<property name="url" stdset="0">
<url>
<string>about:blank</string>
</url>
</property>
</widget> </widget>
</widget> </widget>
</widget> </widget>
@ -78,19 +70,12 @@
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Ok</set> <set>QDialogButtonBox::NoButton</set>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header location="global">QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -4,25 +4,25 @@ __email__ = "info@3liz.org"
from qgis.core import QgsApplication from qgis.core import QgsApplication
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl from qgis.PyQt.QtCore import QSettings, QUrl
from qgis.PyQt.QtGui import QDesktopServices, QIcon from qgis.PyQt.QtGui import QDesktopServices, QIcon
from qgis.PyQt.QtWidgets import QAction, QMessageBox from qgis.PyQt.QtWidgets import QAction
from qgis.utils import iface from qgis.utils import iface
import qgis import qgis
#include <QSettings> # include <QSettings>
import os import os
from .about_form import AboutDialog
from .tools.resources import ( from .tools.resources import (
plugin_path, # plugin_path,
pyperclip,
resources_path, resources_path,
maj_verif, maj_verif,
) )
pyperclip()
from .copie_editor import Copie_Editor from .copie_editor import Copie_Editor
from .about_form import CopieAboutDialog
from PyQt5.QtCore import *
class PgCopie: class PgCopie:
def __init__(self): def __init__(self):
@ -34,18 +34,18 @@ class PgCopie:
self.dock_action = None self.dock_action = None
self.help_action = None self.help_action = None
plugin_dir = os.path.dirname(__file__) plugin_dir = os.path.dirname(__file__)
end_find = plugin_dir.rfind('\\')+1 end_find = plugin_dir.rfind('\\') + 1
global NAME global NAME
NAME = plugin_dir[end_find:] NAME = plugin_dir[end_find:]
maj_verif(NAME) maj_verif(NAME)
# Display About window on first use # Display About window on first use
version = qgis.utils.pluginMetadata('CenRa_Copie','version') version = qgis.utils.pluginMetadata('CenRa_COPIE', 'version')
s = QSettings() s = QSettings()
versionUse = s.value("copie/version", 1, type=str) versionUse = s.value("copie/version", 1, type=str)
if str(versionUse) != str(version) : if str(versionUse) != str(version):
s.setValue("copie/version", str(version)) s.setValue("copie/version", str(version))
print(versionUse,version) print(versionUse, version)
self.open_about_dialog() self.open_about_dialog()
def initGui(self): def initGui(self):
@ -63,16 +63,21 @@ class PgCopie:
if not self.action_editor: if not self.action_editor:
self.action_editor = Copie_Editor() self.action_editor = Copie_Editor()
self.copie_editor = QAction(icon, 'Copie',None) self.copie_editor = QAction(icon, 'Copie', None)
self.toolBar.addAction(self.copie_editor) self.toolBar.addAction(self.copie_editor)
self.copie_editor.triggered.connect(self.open_editor) self.copie_editor.triggered.connect(self.open_editor)
self.copie_editor.setEnabled(False)
# IPAddr = socket.gethostbyname(socket.gethostname())
if os.access('N:/', os.R_OK):
self.copie_editor.setEnabled(True)
def open_about_dialog(self): def open_about_dialog(self):
""" """
About dialog About dialog
""" """
dialog = CopieAboutDialog(iface) dialog = AboutDialog(iface)
dialog.exec_() dialog.exec()
def open_help(): def open_help():
""" Open the online help. """ """ Open the online help. """
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/')) QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
@ -84,8 +89,7 @@ class PgCopie:
def unload(self): def unload(self):
""" Unload the plugin. """ """ Unload the plugin. """
if self.action_editor: if self.action_editor:
iface.removePluginMenu('CenRa_Copie',self.copie_editor) iface.removePluginMenu('CenRa_Copie', self.copie_editor)
if self.provider: if self.provider:
QgsApplication.processingRegistry().removeProvider(self.provider) QgsApplication.processingRegistry().removeProvider(self.provider)

View File

@ -3,7 +3,7 @@ import os.path
from pathlib import Path from pathlib import Path
from qgis.PyQt import uic from qgis.PyQt import uic
from qgis.PyQt.QtGui import QPixmap # from qgis.PyQt.QtGui import QPixmap
from qgis.PyQt.QtWidgets import QDialog from qgis.PyQt.QtWidgets import QDialog
from .tools.resources import devlog from .tools.resources import devlog
@ -17,7 +17,7 @@ ABOUT_FORM_CLASS, _ = uic.loadUiType(
) )
class CopieAboutDialog(QDialog, ABOUT_FORM_CLASS): class AboutDialog(QDialog, ABOUT_FORM_CLASS):
""" About - Let the user display the about dialog. """ """ About - Let the user display the about dialog. """
@ -43,4 +43,4 @@ class CopieAboutDialog(QDialog, ABOUT_FORM_CLASS):
Run some actions when Run some actions when
the user closes the dialog the user closes the dialog
""" """
self.close() self.close()

View File

@ -4,81 +4,80 @@ from __future__ import absolute_import
# Import the PyQt and QGIS libraries # Import the PyQt and QGIS libraries
from builtins import next from builtins import next
from builtins import str from builtins import str
from builtins import object # from builtins import object
import qgis # import qgis
from qgis.PyQt.QtCore import QSettings from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtWidgets import QAction, QMenu, QDialog from qgis.PyQt.QtWidgets import QDialog, QMessageBox
from qgis.PyQt.QtGui import QIcon from qgis.PyQt import QtGui
from PyQt5.QtCore import * from qgis.core import QgsDataSourceUri, QgsSettings, QgsWkbTypes, Qgis
from PyQt5.QtGui import *
from PyQt5 import QtGui try:
from qgis.core import * from .tools.PythonSQL import login_base
from qgis.core import QgsDataSourceUri except ValueError:
print('Pas de fichier PythonSQL')
from .tools.PythonSQL import *
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base, # send_issues,
send_issues,
) )
from .issues import CenRa_Issues # from .issues import CenRa_Issues
from qgis.utils import iface from qgis.utils import iface
import os.path # import os
import webbrowser, os # import os.path
import psycopg2 # import webbrowser
import psycopg2.extras # import psycopg2
import base64 # import psycopg2.extras
# import base64
EDITOR_CLASS = load_ui('CenRa_Copie_base.ui') EDITOR_CLASS = load_ui('CenRa_Copie_base.ui')
class Copie_Editor(QDialog, EDITOR_CLASS):
class Copie_Editor(QDialog, EDITOR_CLASS):
def __init__(self, parent=None): def __init__(self, parent=None):
_ = parent _ = parent
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.settings = QgsSettings() self.settings = QgsSettings()
self.s = QSettings() self.s = QSettings()
self.setWindowIcon(QtGui.QIcon(resources_path('icons','icon.png'))) self.setWindowIcon(QtGui.QIcon(resources_path('icons', 'icon.png')))
self.iface = iface self.iface = iface
def raise_(self): def raise_(self):
"""Run method that performs all the real work""" """Run method that performs all the real work"""
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=Qgis.Warning, duration=5)
else : else:
# Récupération des sources de la couche active # Récupération des sources de la couche active
list_sources = layer.source().split(" ") list_sources = layer.source().split(" ")
# dbname # dbname
source_db = [s for s in list_sources if "dbname" in s][0].split("'")[1] source_db = [s for s in list_sources if "dbname" in s][0].split("'")[1]
# schema # schema
source_schema = [s for s in list_sources if "table" in s][0].split('"')[1] source_schema = [s for s in list_sources if "table" in s][0].split('"')[1]
# tablename # tablename
source_tablename = [s for s in list_sources if "table" in s][0].split('"')[3] source_tablename = [s for s in list_sources if "table" in s][0].split('"')[3]
account = login_base("account")
sigdb = account[5]
if source_db != sigdb: if source_db != sigdb:
#self.iface.messageBar().pushMessage(u"Un référentiel ne peut être copié, utilisez les filtres !", level=QgsMessageBar.CRITICAL, duration=10) # self.iface.messageBar().pushMessage(u"Un référentiel ne peut être copié, utilisez les filtres !", level=QgsMessageBar.CRITICAL, duration=10)
self.iface.messageBar().pushMessage("Ooops", u"Vous ne pouvez copier des couches que dans sigXX", level=Qgis.Critical, duration=5) self.iface.messageBar().pushMessage("Ooops", u"Vous ne pouvez copier des couches que dans sigXX", level=Qgis.Critical, duration=5)
else:
user = account[0]
mdp = account[1]
host = account[2]
port = account[3]
dbname = account[4]
cur = account[7]
con = account[8]
else : # Creation de la liste des schemas de la base de donnees
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
# Creation de la liste des schemas de la base de donnees
SQL = """WITH list_schema AS ( SQL = """WITH list_schema AS (
SELECT catalog_name, schema_name SELECT catalog_name, schema_name
FROM information_schema.schemata FROM information_schema.schemata
@ -95,81 +94,79 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
list_brut = str(next(cur)) list_brut = str(next(cur))
list = list_brut [2:-3] list = list_brut[2:-3]
listItems = list.split(",") listItems = list.split(",")
con.close() con.close()
self.schema.clear() self.schema.clear()
self.schema.addItems(listItems) self.schema.addItems(listItems)
self.schema.setCurrentIndex(-1) # Pour ne pas commencer la liste au premier schema # Pour ne pas commencer la liste au premier schema
self.schema.setCurrentIndex(-1)
# Affiche le nom de la table source
self.table_source.setText(source_schema + "." + source_tablename) # Affiche le nom de la table source self.table_source.setText(source_schema + "." + source_tablename)
# show the dialog # show the dialog
self.show() self.show()
# Run the dialog event loop # Run the dialog event loop
result = self.exec_() result = self.exec()
# See if OK was pressed # See if OK was pressed
if result: if result:
#******************************debut script********************************* # ******************************debut script*********************************
account = login_base("account")
user = account[0]
mdp = account[1]
host = account[2]
port = account[3]
dbname = account[4]
cur = account[7]
con = account[8]
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
# Récupération de la couche active # Récupération de la couche active
layer = self.iface.activeLayer() layer = self.iface.activeLayer()
# Récupération des sources de la couche active # Récupération des sources de la couche active
list_sources = layer.source().split(" ") list_sources = layer.source().split(" ")
# dbname # dbname
source_db = [s for s in list_sources if "dbname" in s][0].split("'")[1] source_db = [s for s in list_sources if "dbname" in s][0].split("'")[1]
# schema # schema
source_schema = [s for s in list_sources if "table" in s][0].split('"')[1] source_schema = [s for s in list_sources if "table" in s][0].split('"')[1]
# tablename # tablename
source_tablename = [s for s in list_sources if "table" in s][0].split('"')[3] source_tablename = [s for s in list_sources if "table" in s][0].split('"')[3]
if self.schema.currentIndex() == -1 : if self.schema.currentIndex() == - 1:
QMessageBox.warning(None, "Oups :", "Veuillez choisir un dossier de destination.") QMessageBox.warning(None, "Oups :", "Veuillez choisir un dossier de destination.")
return return
schema = self.schema.currentText() schema = self.schema.currentText()
if self.table_destination.text() == '' : if self.table_destination.text() == '':
QMessageBox.warning(None, "Oups :", "Veuillez choisir un nom de destination.") QMessageBox.warning(None, "Oups :", "Veuillez choisir un nom de destination.")
return return
if self.annee.text() == 'aaaa' or self.annee.text() == '': if self.annee.text() == 'aaaa' or self.annee.text() == '':
tablename = schema + "_" + self.table_destination.text().lower() tablename = schema + "_" + self.table_destination.text().lower()
else : else:
tablename = schema + "_" + self.table_destination.text().lower() + "_" + self.annee.text() tablename = schema + "_" + self.table_destination.text().lower() + "_" + self.annee.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
if self.table_vide.isChecked() == 1 : if self.table_vide.isChecked() == 1:
SQL_table = "CREATE TABLE " + schema + "." + tablename + " AS SELECT * FROM " + source_schema + "." + source_tablename + " LIMIT 0;" SQL_table = "CREATE TABLE " + schema + "." + tablename + " AS SELECT * FROM " + source_schema + "." + source_tablename + " LIMIT 0;"
else : else:
SQL_table = "CREATE TABLE " + schema + "." + tablename + " AS SELECT * FROM " + source_schema + "." + source_tablename SQL_table = "CREATE TABLE " + schema + "." + tablename + " AS SELECT * FROM " + source_schema + "." + source_tablename
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)" SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_sequence_01 = "CREATE SEQUENCE " + schema + "." + tablename + "_gid_seq" + " INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;" SQL_sequence_01 = "CREATE SEQUENCE " + schema + "." + tablename + "_gid_seq" + " INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;"
SQL_sequence_02 = "ALTER TABLE " + schema + "." + tablename + " ALTER COLUMN gid SET DEFAULT nextval(\'" + schema + "." + tablename + "_gid_seq\'::regclass);" SQL_sequence_02 = "ALTER TABLE " + schema + "." + tablename + " ALTER COLUMN gid SET DEFAULT nextval(\'" + schema + "." + tablename + "_gid_seq\'::regclass);"
SQL_sequence_03 = "SELECT setval(\'" + schema + "." + tablename + "_gid_seq\'::regclass, (SELECT max(gid) AS max_gid FROM " + schema + "." + tablename + "));" SQL_sequence_03 = "SELECT setval(\'" + schema + "." + tablename + "_gid_seq\'::regclass, (SELECT max(gid) AS max_gid FROM " + schema + "." + tablename + "));"
SQL_sequence_04 = "ALTER SEQUENCE " + schema + "." + tablename + "_gid_seq" + " OWNED BY " + schema + "." + tablename + ".gid;" SQL_sequence_04 = "ALTER SEQUENCE " + schema + "." + tablename + "_gid_seq" + " OWNED BY " + schema + "." + tablename + ".gid;"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();" SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();" SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();" SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();" SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();" SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
cur.execute(SQL_table) cur.execute(SQL_table)
cur.execute(SQL_pkey) cur.execute(SQL_pkey)
@ -178,31 +175,38 @@ class Copie_Editor(QDialog, EDITOR_CLASS):
cur.execute(SQL_sequence_03) cur.execute(SQL_sequence_03)
cur.execute(SQL_sequence_04) cur.execute(SQL_sequence_04)
if layer.wkbType() == QgsWkbTypes.PointGeometry : RETURNE = "SELECT pg_get_serial_sequence('" + schema + "." + tablename + "','gid')"
cur.execute(RETURNE)
sequence_name = cur.fetchone()[0]
print(sequence_name)
SQL_GRANT_TABLE = "GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename + " TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename + " TO grp_sig;GRANT ALL ON SEQUENCE " + sequence_name + " TO grp_qgis;"
cur.execute(SQL_GRANT_TABLE)
if layer.wkbType() == QgsWkbTypes.PointGeometry:
cur.execute(SQL_trigger_coordonnees) cur.execute(SQL_trigger_coordonnees)
if layer.wkbType() == QgsWkbTypes.LineGeometry : if layer.wkbType() == QgsWkbTypes.LineGeometry:
cur.execute(SQL_trigger_length_m) cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km) cur.execute(SQL_trigger_length_km)
if layer.wkbType() == QgsWkbTypes.PolygonGeometry : if layer.wkbType() == QgsWkbTypes.PolygonGeometry:
cur.execute(SQL_trigger_area_m2) cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha) cur.execute(SQL_trigger_area_ha)
con.commit() con.commit()
### Affichage de la table # Affichage de la table
uri = QgsDataSourceUri() uri = QgsDataSourceUri()
# set host name, port, database name, username and password # set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp) uri.setConnection(host, port, dbname, user, mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause) # set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom) uri.setDataSource(schema, tablename, "geom")
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres") layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
con.commit() con.commit()
con.close() con.close()
#self.iface.messageBar().pushMessage("Table \"" + source_schema + "." + source_tablename + u"\" copiée dans \"" + schema + "." + tablename + "\"." , level=QgsMessageBar.INFO, duration=10) # self.iface.messageBar().pushMessage("Table \"" + source_schema + "." + source_tablename + u"\" copiée dans \"" + schema + "." + tablename + "\"." , level=QgsMessageBar.INFO, duration=10)
self.iface.messageBar().pushMessage("Bravo!", "Table \"" + source_schema + "." + source_tablename + u"\" copiée dans \"" + schema + "." + tablename + "\".", level=Qgis.Success, duration=5) self.iface.messageBar().pushMessage("Bravo!", "Table \"" + source_schema + "." + source_tablename + u"\" copiée dans \"" + schema + "." + tablename + "\".", level=Qgis.Info, duration=5)
pass pass

View File

@ -9,8 +9,9 @@
[general] [general]
name=CenRA_COPIE name=CenRA_COPIE
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
supportsQt6=True
description=Permet la copie d'une table dans une base PostGis description=Permet la copie d'une table dans une base PostGis
version=2.0 version=3.1
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@ -19,7 +20,7 @@ email=si_besoin@cen-rhonealpes.fr
# Recommended items: # Recommended items:
# Uncomment the following line and add your changelog: # Uncomment the following line and add your changelog:
changelog=<h2>CenRa_COPIE:</h2></br><p><h3>22/10/2024 - Version 2:</h3>- Refonte du code.</p></br><p><h3>13/09/2024 - Version 1.5:</h3>- Ajoute d'un changelog et vérification de mise à jour.</p> changelog=<h2>CenRa_COPIE:</h2></br><p><h3>30/07/2025 - Version 3.1: </h3> - Correctife de bug.</p></br><p><h3>19/05/2025 - Version 3.0: </h3> - Compatible PyQt5 et PyQt6</p></br><p><h3>11/04/2025 - Version 2.5: </h3> - Correctif de bug.</p></br><p><h3>09/04/2025 - Version 2.4: </h3> - Correctif bug en TT.</p></br><p><h3>09/04/2025 - Version 2.3: </h3> - Optimisation pour le TT.</p></br><p><h3>03/04/2025 - Version 2.2: </h3> - Mise a jour de securite.</p></br><p><h3>07/01/2025 - Version 2.1: </h3> - ByPass du certif ssl ci erreur.</br></p><p><h3>22/10/2024 - Version 2:</h3>- Refonte du code.</p></br><p><h3>13/09/2024 - Version 1.5:</h3>- Ajoute d'un changelog et vérification de mise à jour.</p>
# Tags are comma separated with spaces allowed # Tags are comma separated with spaces allowed
tags=cenra, database, table tags=cenra, database, table

View File

@ -3,9 +3,10 @@
import configparser import configparser
import shutil import shutil
import tempfile import tempfile
import base64 # import base64
import psycopg2 # import psycopg2
import psycopg2.extras # import psycopg2.extras
import os
from os.path import abspath, join, pardir, dirname from os.path import abspath, join, pardir, dirname
from qgis.PyQt import uic from qgis.PyQt import uic
@ -89,7 +90,7 @@ def resources_path(*args):
:return: Absolute path to the resources folder. :return: Absolute path to the resources folder.
:rtype: str :rtype: str
""" """
path = abspath(abspath(join(plugin_path(), "CenRa_Copie\\tools"))) path = abspath(abspath(join(plugin_path(), "CenRa_COPIE\\tools")))
for item in args: for item in args:
path = abspath(join(path, item)) path = abspath(join(path, item))
return path return path
@ -107,77 +108,77 @@ def load_ui(*args):
return ui_class return ui_class
def login_base(take=None):
from CenRa_Metabase.resources.PythonSQL import host,port,dbname,password,os_user
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) def pyperclip():
dst = dirname(dirname(__file__)) + "\\tools\\"
if os.access('N:/', os.R_OK):
src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
try:
shutil.copy(src, dst)
except FileNotFoundError:
print('404')
except UnboundLocalError:
print('404')
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take: def send_issues(url, titre, body, labels):
return cur,con
else:
return cur
def send_issues(url,titre,body,labels):
import requests import requests
import urllib.request
import json import json
import os # import os
import qgis # import qgis
usr = os.environ['USERNAME'] # usr = os.environ['USERNAME']
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112' token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
url=url+'?token='+token url = url + '?token=' + token
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
headers = {'Authorization': 'token ' + token, 'accept': 'application/json', 'Content-Type': 'application/json'}
payload = {'title': titre, 'body': body, 'labels': labels} payload = {'title': titre, 'body': body, 'labels': labels}
try: try:
urllib.request.urlopen('https://google.com') urllib.request.urlopen('https://google.com')
binar = True binar = True
except: except ValueError:
binar = False binar = False
r = '' r = ''
if binar: if binar:
r = requests.post(url, data=json.dumps(payload), headers=headers) r = requests.post(url, data=json.dumps(payload), headers=headers)
return r return r
def maj_verif(NAME): def maj_verif(NAME):
import qgis import qgis
import urllib.request import urllib.request
iface = qgis.utils.iface iface = qgis.utils.iface
from qgis.core import Qgis from qgis.core import Qgis
url = qgis.utils.pluginMetadata(NAME,'repository') # url = qgis.utils.pluginMetadata(NAME, 'repository')
#URL = url+'/raw/branch/main/plugins.xml' # URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME, 'version')
len_version = len(version) len_version = len(version)
try: try:
urllib.request.urlopen('https://google.com') urllib.request.urlopen('https://google.com')
binar = True binar = True
except: except urllib.error.URLError:
binar = False binar = False
if binar: if binar:
version_web = str(urllib.request.urlopen(URL).read()) try:
plugin_num = version_web.find(NAME) version_web = str(urllib.request.urlopen(URL).read())
valeur_version_web = version_web.find('<version>',plugin_num)+9 plugin_num = version_web.find(NAME)
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version] valeur_version_web = version_web.find('<version>', plugin_num) + 9
if version_plugin != version: version_plugin = version_web[valeur_version_web:valeur_version_web + len_version]
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30) if version_plugin != version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
except urllib.error.URLError:
print("error gitea version ssl")
else: else:
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30) iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
def devlog(NAME): def devlog(NAME):
import qgis import qgis
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>' devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
devmaj = devmaj+qgis.utils.pluginMetadata(NAME,'changelog') devmaj = devmaj + qgis.utils.pluginMetadata(NAME, 'changelog')
return devmaj return devmaj

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Metabase</string> <string>Journal des modifications</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset>
@ -29,9 +29,6 @@
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -41,7 +38,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>453</width> <width>453</width>
<height>547</height> <height>570</height>
</rect> </rect>
</property> </property>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
@ -56,7 +53,7 @@
<property name="title"> <property name="title">
<string>DevLog</string> <string>DevLog</string>
</property> </property>
<widget class="QWebView" name="viewer" native="true"> <widget class="QTextBrowser" name="viewer">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
@ -65,11 +62,6 @@
<height>511</height> <height>511</height>
</rect> </rect>
</property> </property>
<property name="url" stdset="0">
<url>
<string>about:blank</string>
</url>
</property>
</widget> </widget>
</widget> </widget>
</widget> </widget>
@ -78,19 +70,12 @@
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Ok</set> <set>QDialogButtonBox::NoButton</set>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header location="global">QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -4,25 +4,24 @@ __email__ = "info@3liz.org"
from qgis.core import QgsApplication from qgis.core import QgsApplication
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl from qgis.PyQt.QtCore import QUrl, QSettings
from qgis.PyQt.QtGui import QDesktopServices, QIcon from qgis.PyQt.QtGui import QDesktopServices, QIcon
from qgis.PyQt.QtWidgets import QAction, QMessageBox from qgis.PyQt.QtWidgets import QAction
from qgis.utils import iface from qgis.utils import iface
import qgis import qgis
# include <QSettings>
#include <QSettings> from .about_form import AboutDialog
import os import os
from .tools.resources import ( from .tools.resources import (
plugin_path, pyperclip,
resources_path, resources_path,
maj_verif, maj_verif,
) )
from .flux_editor import Flux_Editor pyperclip()
from .about_form import FluxAboutDialog
from .flux_editor import Flux_Editor
from PyQt5.QtCore import *
class PgFlux: class PgFlux:
def __init__(self): def __init__(self):
@ -34,18 +33,18 @@ class PgFlux:
self.dock_action = None self.dock_action = None
self.help_action = None self.help_action = None
plugin_dir = os.path.dirname(__file__) plugin_dir = os.path.dirname(__file__)
end_find = plugin_dir.rfind('\\')+1 end_find = plugin_dir.rfind('\\') + 1
global NAME global NAME
NAME = plugin_dir[end_find:] NAME = plugin_dir[end_find:]
maj_verif(NAME) maj_verif(NAME)
# Display About window on first use # Display About window on first use
version = qgis.utils.pluginMetadata('CenRa_Flux','version') version = qgis.utils.pluginMetadata('CenRa_FLUX', 'version')
s = QSettings() s = QSettings()
versionUse = s.value("flux/version", 1, type=str) versionUse = s.value("flux/version", 1, type=str)
if str(versionUse) != str(version) : if str(versionUse) != str(version):
s.setValue("flux/version", str(version)) s.setValue("flux/version", str(version))
print(versionUse,version) print(versionUse, version)
self.open_about_dialog() self.open_about_dialog()
def initGui(self): def initGui(self):
@ -62,17 +61,20 @@ class PgFlux:
self.help_action.triggered.connect(self.open_help) self.help_action.triggered.connect(self.open_help)
if not self.action_editor: if not self.action_editor:
self.action_editor = Flux_Editor() self.action_editor = Flux_Editor()
self.flux_editor = QAction(icon, 'SigCEN', None)
self.flux_editor = QAction(icon, 'SigCEN',None)
self.toolBar.addAction(self.flux_editor) self.toolBar.addAction(self.flux_editor)
self.flux_editor.triggered.connect(self.open_editor) self.flux_editor.triggered.connect(self.open_editor)
self.flux_editor.setEnabled(False)
if os.access('N:/', os.R_OK):
self.flux_editor.setEnabled(True)
def open_about_dialog(self): def open_about_dialog(self):
""" """
About dialog About dialog
""" """
dialog = CopieAboutDialog(iface) dialog = AboutDialog(iface)
dialog.exec_() dialog.exec()
def open_help(): def open_help():
""" Open the online help. """ """ Open the online help. """
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/')) QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
@ -84,8 +86,7 @@ class PgFlux:
def unload(self): def unload(self):
""" Unload the plugin. """ """ Unload the plugin. """
if self.action_editor: if self.action_editor:
iface.removePluginMenu('CenRa_Flux',self.flux_editor) iface.removePluginMenu('CenRa_Flux', self.flux_editor)
if self.provider: if self.provider:
QgsApplication.processingRegistry().removeProvider(self.provider) QgsApplication.processingRegistry().removeProvider(self.provider)

View File

@ -1,60 +1,6 @@
# <p align="center">FluxCEN</p>
<img align="left" src=https://raw.githubusercontent.com/CEN-Nouvelle-Aquitaine/fluxcen/main/icon.png width="220"/>
<br>
<br>
<br>
Le plugin QGIS FluxCEN permet d'accéder rapidement à un large éventail de flux WFS/WMS organisés par catégories et interrogeables sous forme de mots-clés.
<br>
<br>
Il évite ainsi d'avoir à gérer dans QGIS une multitude de connexions.
<br>
<br>
<br>
## 🧐 Features
- Sélection rapide des ressources par autocomplétion
- Regroupement des flux au sein de catégories
- Gestion des styles par défaut à l'ouverture dans QGIS pour les données WFS
- Centralisation et gestion des flux simplifiée dans un fichier .csv
- Code et ressources attachées gérées directement via le git
- Prise en charge des flux Geoserver et Mapserver
- Lien direct vers la fiche de métadonnées de la ressource
## Composition du fichier .csv
* service : type de service utilisé (WFS ou WMS)
* categorie : categorie de la couche pour affichage et recherche dans le plugin
* Nom_couche_plugin : nom de la couche qui s'affichera dans le plugin
* nom_technique : nom technique de la couche utilisé sur le serveur source (caché dans le plugin)
* url : URL du serveur pour accéder à la couche
* source : Source de la donnée
* style : nom du fichier de style pour affichage à l'ouverture dans QGIS
* metadonnees : URL d'accès à la fiche de métadonnées liée à la resource
Exemple pour accéder à la BD ORTHO® :
| service | categorie | Nom_couche_plugin | nom_technique | url | source | style |
| -------- | -------- | -------- | -------- | -------- |-------- | -------- |
| WMS Raster| Fonds cartos | BD ORTHO® | HR.ORTHOIMAGERY.ORTHOPHOTOS |https://wxs.ign.fr/ortho/geoportail/r/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities| IGN | |
## Style des couches
Le dossier *styles_couches* stocke les styles QGIS au format .qml afin d'appliquer par défaut ce style à l'ouverture de la couche dans QGIS. L'ajout d'un style dans ce dossier nécessite de reporter le nom du fichier .qml dans le champ "style" du csv.
## Accès aux données protégées
Si l'accès à la majorité des ressources reste public, certaines peuvent être protégées par un mot de passe (données métier confidentielles par exemple).
Cette authentification est gérée via le serveur cartographique qui génère les flux.
Pour y accéder, il faut créer en amont une authentification dans QGIS. L'ouverture des données protégées se fera alors à partir de la première authentification enregistrée dans QGIS (pas de gestion multi-authentification pour le moment)
## Interface du plugin:
<img align="center" src=https://raw.githubusercontent.com/CEN-Nouvelle-Aquitaine/fluxcen/main/fluxcen_interface.PNG width="600"/>
> [Point de départ de création du plugin](https://github.com/CEN-Nouvelle-Aquitaine/MapCEN)
Le plugin QGIS CenRa_FLUX permet d'accéder rapidement à un large éventail de données organisés dans PostGIS par catégories et interrogeables sous forme de mots-clés.
Il évite ainsi d'avoir à gérer dans QGIS une multitude de connexions.

View File

@ -3,7 +3,7 @@ import os.path
from pathlib import Path from pathlib import Path
from qgis.PyQt import uic from qgis.PyQt import uic
from qgis.PyQt.QtGui import QPixmap # from qgis.PyQt.QtGui import QPixmap
from qgis.PyQt.QtWidgets import QDialog from qgis.PyQt.QtWidgets import QDialog
from .tools.resources import devlog from .tools.resources import devlog
@ -17,7 +17,7 @@ ABOUT_FORM_CLASS, _ = uic.loadUiType(
) )
class FluxAboutDialog(QDialog, ABOUT_FORM_CLASS): class AboutDialog(QDialog, ABOUT_FORM_CLASS):
""" About - Let the user display the about dialog. """ """ About - Let the user display the about dialog. """
@ -43,4 +43,4 @@ class FluxAboutDialog(QDialog, ABOUT_FORM_CLASS):
Run some actions when Run some actions when
the user closes the dialog the user closes the dialog
""" """
self.close() self.close()

View File

@ -2,100 +2,177 @@
from __future__ import absolute_import from __future__ import absolute_import
# Import the PyQt and QGIS libraries # Import the PyQt and QGIS libraries
from builtins import next # from builtins import next
from builtins import str from builtins import str
from builtins import object # from builtins import object
import qgis
from qgis.PyQt import QtCore from qgis.PyQt import QtCore, QtGui
from qgis.PyQt.QtCore import QSettings from qgis.PyQt.QtCore import QSettings
from qgis.PyQt import QtWidgets from qgis.PyQt import QtWidgets
from qgis.PyQt.QtWidgets import QAction, QMenu, QDialog # from qgis.PyQt.QtWidgets import QDialog
from qgis.PyQt.QtGui import QIcon from qgis.PyQt.QtGui import QIcon
from PyQt5.QtCore import *
from PyQt5.QtGui import * # from qgis.PyQt.QtCore import *
from PyQt5 import QtGui
from qgis.core import * # from qgis.core import QgsCoordinateReferenceSystem, QgsCoordinateTransform, QgsProject, QgsSettings
from qgis.core import QgsDataSourceUri from qgis.core import QgsDataSourceUri, QgsCoordinateReferenceSystem, QgsCoordinateTransform, QgsProject, QgsSettings, QgsApplication, QgsVectorLayer, QgsRasterLayer, QgsWkbTypes
from qgis.PyQt.QtWidgets import ( from qgis.PyQt.QtWidgets import (
QDialog, QDialog,
QAction, # QAction,
QDockWidget, # QDockWidget,
QFileDialog, # QFileDialog,
QInputDialog, # QInputDialog,
QMenu, # QMenu,
QToolButton, # QToolButton,
QTableWidget, # QTableWidget,
QTableWidgetItem, QTableWidgetItem,
QMessageBox, QMessageBox,
QVBoxLayout, QVBoxLayout,
) )
from .tools.PythonSQL import * from .tools.SQLRequet import schemaname_list, schemaname_list_ref, schemaname_distinct
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base, # send_issues,
send_issues,
) )
from .issues import CenRa_Issues try:
from .tools.PythonSQL import login_base
except NameError:
print('Pas de fichier PythonSQL')
# from .issues import CenRa_Issues
# from ast import literal_eval
from qgis.utils import iface from qgis.utils import iface
import os.path # import os.path
import webbrowser, os # import os
# import webbrowser
import psycopg2 import psycopg2
import psycopg2.extras import psycopg2.extras
import base64 # import base64
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) global DeBUG
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) DeBUG = 0
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone() itemIconRaster = QTableWidgetItem()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') icon = QIcon()
user = res_ident[1] icon.addPixmap(QtGui.QPixmap(resources_path('icons', 'mIconRaster.svg')), QIcon.Mode(0), QIcon.State(1))
first_conn.close() itemIconRaster.setIcon(icon)
itemIconVecteur = QTableWidgetItem()
icon = QIcon()
icon.addPixmap(QtGui.QPixmap(resources_path('icons', 'mIconVecteur.svg')), QIcon.Mode(0), QIcon.State(1))
itemIconVecteur.setIcon(icon)
try:
account = login_base('account')
user = account[0]
mdp = account[1]
host = account[2]
port = account[3]
dbname = account[4]
sigdb = account[5]
refdb = account[6]
except NameError:
print('Fails to login DB for account')
EDITOR_CLASS = load_ui('CenRa_Flux_base.ui') EDITOR_CLASS = load_ui('CenRa_Flux_base.ui')
class Flux_Editor(QDialog, EDITOR_CLASS): targetCrs = QgsCoordinateReferenceSystem('EPSG:4326')
layerCrs = QgsCoordinateReferenceSystem('EPSG:2154')
TranformCRS = QgsCoordinateTransform(layerCrs, targetCrs, QgsProject.instance())
class Flux_Editor(QDialog, EDITOR_CLASS):
def __init__(self, parent=None): def __init__(self, parent=None):
_ = parent _ = parent
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.settings = QgsSettings() self.settings = QgsSettings()
self.s = QSettings() self.s = QSettings()
self.setWindowIcon(QtGui.QIcon(resources_path('icons','icon.png'))) self.setWindowIcon(QtGui.QIcon(resources_path('icons', 'icon.png')))
self.first_start = None self.first_start = None
self.iface = iface self.iface = iface
self.label_3.setPixmap(QtGui.QPixmap(resources_path('ui','logo.png'))) self.label_3.setPixmap(QtGui.QPixmap(resources_path('ui', 'logo.png')))
self.commandLinkButton.setIcon(QtGui.QIcon(resources_path('ui','arrow-bottom.png'))) self.commandLinkButton.setIcon(QtGui.QIcon(resources_path('ui', 'arrow-bottom.png')))
self.commandLinkButton_2.setIcon(QtGui.QIcon(resources_path('ui','arrow-up.png'))) self.commandLinkButton_2.setIcon(QtGui.QIcon(resources_path('ui', 'arrow-up.png')))
self.tableWidget.setSelectionBehavior(QTableWidget.SelectRows) self.tableWidget.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger(0))
self.tableWidget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.toolButton.setIcon(QtGui.QIcon(resources_path('ui', 'find.png')))
self.comboBox_2.addItem("SIG") self.comboBox_2.addItem("SIG")
self.comboBox_2.addItem('REF') self.comboBox_2.addItem('REF')
self.comboBox.currentIndexChanged.connect(self.initialisation_flux)
self.commandLinkButton.clicked.connect(self.selection_flux) self.commandLinkButton.clicked.connect(self.selection_flux)
self.tableWidget.itemDoubleClicked.connect(self.selection_flux) self.tableWidget.itemDoubleClicked.connect(self.selection_flux)
self.pushButton_2.clicked.connect(self.limite_flux) self.pushButton_2.clicked.connect(self.limite_flux)
self.commandLinkButton_2.clicked.connect(self.suppression_flux) self.commandLinkButton_2.clicked.connect(self.suppression_flux)
self.tableWidget_2.itemDoubleClicked.connect(self.suppression_flux) self.tableWidget_2.itemDoubleClicked.connect(self.suppression_flux)
self.comboBox_2.currentIndexChanged.connect(self.bd_source) self.comboBox_2.currentIndexChanged.connect(self.bd_source)
self.checkBox.hide()
# self.checkBox.stateChanged.connect(self.modeCarte)
self.toolButton.clicked.connect(self.getCanevas)
layout = QVBoxLayout() layout = QVBoxLayout()
self.lineEdit.textChanged.connect(self.filtre_dynamique) self.lineEdit.textChanged.connect(self.filtre_dynamique)
# self.viewer.textChanged.connect(self.NewTitle)
layout.addWidget(self.lineEdit) layout.addWidget(self.lineEdit)
#self.lineEdit.mousePressEvent = self._mousePressEvent self.viewer.hide()
self.DeBUG.addItem('')
self.DeBUG.addItem('Dev')
self.DeBUG.addItem('01')
self.DeBUG.addItem('0726')
self.DeBUG.addItem('4269')
self.comboBox.currentIndexChanged.connect(self.initialisation_flux)
#metadonnees_plugin = open(self.plugin_path + '/metadata.txt') self.DeBUG.currentIndexChanged.connect(self.SwitchDEBUG)
#infos_metadonnees = metadonnees_plugin.readlines() self.DeBUG.hide()
def raise_(self): def raise_(self):
"""Run method that performs all the real work""" """Run method that performs all the real work"""
self.bd_source() self.bd_source()
def SwitchDEBUG(self):
try:
global user, mdp, host, port, dbname, sigdb, refdb
account = login_base(self.DeBUG.currentText())
user = account[0]
mdp = account[1]
host = account[2]
port = account[3]
dbname = account[4]
sigdb = account[5]
refdb = account[6]
self.bd_source()
except NameError:
print('Fails to switch DB for account')
def ModeDeBUG(self):
self.DeBUG.show()
def mousePressEvent(self, event):
global DeBUG
if 330 <= event.pos().x() <= 560 and 5 <= event.pos().y() <= 75:
DeBUG = DeBUG + 1
if DeBUG == 3:
DeBUG = 0
self.ModeDeBUG()
else:
DeBUG = 0
self.DeBUG.hide()
"""
def NewTitle(self):
if self.viewer.title() != '':
Tsplit = ((self.viewer.title()).split('.'))
print(Tsplit[0], Tsplit[1])
self.openPostGIS(Tsplit[0], Tsplit[1])
"""
def bd_source(self): def bd_source(self):
self.activateWindow() self.activateWindow()
bd_origine=self.comboBox_2.currentText() bd_origine = self.comboBox_2.currentText()
if bd_origine == 'REF': if bd_origine == 'REF':
self.run_ref() self.run_ref()
if bd_origine == 'SIG': if bd_origine == 'SIG':
@ -104,22 +181,22 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
def run_ref(self): def run_ref(self):
"""Run method that performs all the real work""" """Run method that performs all the real work"""
while self.tableWidget_2.rowCount() > 0: while self.tableWidget_2.rowCount() > 0:
self.tableWidget_2.removeRow(self.tableWidget_2.rowCount()-1) self.tableWidget_2.removeRow(self.tableWidget_2.rowCount() - 1)
# print(self.tableWidget_2.rowCount()) # print(self.tableWidget_2.rowCount())
global cur,con,dbtype global cur, con, dbtype
dbtype=refdb dbtype = refdb
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbtype+" user=" + user + " password=" + mdp) con = psycopg2.connect("host=" + host + " port=" + port + " dbname=" + dbtype + " user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor) cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
self.initialisation_flux()
self.combobox_custom() self.combobox_custom()
# self.initialisation_flux()
# Create the dialog with elements (after translation) and keep reference # Create the dialog with elements (after translation) and keep reference
# Only create GUI ONCE in callback, so that it will only load when the plugin is started # Only create GUI ONCE in callback, so that it will only load when the plugin is started
if self.first_start == True: if self.first_start is True:
self.first_start = False self.first_start = False
# show the dialog # show the dialog
self.show() self.show()
# Run the dialog event loop # Run the dialog event loop
result = self.exec_() result = self.exec()
# See if OK was pressed # See if OK was pressed
if result: if result:
# Do something useful here - delete the line containing pass and # Do something useful here - delete the line containing pass and
@ -129,138 +206,250 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
def run_sig(self): def run_sig(self):
"""Run method that performs all the real work""" """Run method that performs all the real work"""
while self.tableWidget_2.rowCount() > 0: while self.tableWidget_2.rowCount() > 0:
self.tableWidget_2.removeRow(self.tableWidget_2.rowCount()-1) self.tableWidget_2.removeRow(self.tableWidget_2.rowCount() - 1)
global cur,con,dbtype global cur, con, dbtype
dbtype=sigdb dbtype = sigdb
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbtype+" user=" + user + " password=" + mdp) con = psycopg2.connect("host=" + host + " port=" + port + " dbname=" + dbtype + " user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor) cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
self.initialisation_flux()
self.combobox_custom() self.combobox_custom()
# self.initialisation_flux()
# Create the dialog with elements (after translation) and keep reference # Create the dialog with elements (after translation) and keep reference
# Only create GUI ONCE in callback, so that it will only load when the plugin is started # Only create GUI ONCE in callback, so that it will only load when the plugin is started
if self.first_start == True: if self.first_start is True:
self.first_start = False self.first_start = False
# show the dialog # show the dialog
self.show() # self.show()
# Run the dialog event loop # Run the dialog event loop
result = self.exec_() # result = self.exec()
# See if OK was pressed # See if OK was pressed
if result: # if result:
# Do something useful here - delete the line containing pass and # Do something useful here - delete the line containing pass and
# substitute with your code. # substitute with your code.
pass # pass
def suppression_flux(self): def suppression_flux(self):
self.tableWidget_2.removeRow(self.tableWidget_2.currentRow()) self.tableWidget_2.removeRow(self.tableWidget_2.currentRow())
def open_url(self, item):
url = item.data(Qt.UserRole)
def initialisation_flux(self): def initialisation_flux(self):
print('run')
if dbtype == sigdb: if dbtype == sigdb:
# self.toolButton.setEnabled(1)
if self.comboBox.currentText() == 'toutes les catégories': if self.comboBox.currentText() == 'toutes les catégories':
custom_list=schemaname_list custom_list = schemaname_list
elif self.comboBox.currentText() == 'travaux': elif self.comboBox.currentText() == 'travaux':
custom_list="""(SELECT schemaname,tablename from pg_catalog.pg_tables custom_list = """(SELECT schemaname,tablename from pg_catalog.pg_tables
where schemaname like '"""+ str(self.comboBox.currentText()) +"""%' order by schemaname,tablename) UNION (SELECT schemaname,matviewname AS tablename FROM pg_catalog.pg_matviews where schemaname like '"""+ str(self.comboBox.currentText()) +"""%' order by schemaname,tablename) order by schemaname,tablename;""" where schemaname like '""" + str(self.comboBox.currentText()) + """%' order by schemaname,tablename) UNION (SELECT schemaname,matviewname AS tablename FROM pg_catalog.pg_matviews where schemaname like '""" + str(self.comboBox.currentText()) + """%' order by schemaname,tablename) order by schemaname,tablename;"""
else: else:
custom_list="""(SELECT schemaname,tablename from pg_catalog.pg_tables custom_list = """(SELECT schemaname,tablename from pg_catalog.pg_tables
where schemaname like '\_"""+ str(self.comboBox.currentText()) +"""%' order by schemaname,tablename) UNION (SELECT schemaname,matviewname AS tablename FROM pg_catalog.pg_matviews where schemaname like '\_"""+ str(self.comboBox.currentText()) +"""%' order by schemaname,tablename) order by schemaname,tablename;""" where schemaname like '\\_""" + str(self.comboBox.currentText()) + """%' order by schemaname,tablename) UNION (SELECT schemaname,matviewname AS tablename FROM pg_catalog.pg_matviews where schemaname like '\\_""" + str(self.comboBox.currentText()) + """%' order by schemaname,tablename) order by schemaname,tablename;"""
else: else:
if self.comboBox.currentText() == 'toutes les catégories': if self.comboBox.currentText() == 'toutes les catégories':
custom_list=schemaname_list_ref custom_list = schemaname_list_ref
else: else:
custom_list="""SELECT schemaname,tablename from pg_catalog.pg_tables custom_list = """SELECT schemaname, tablename from pg_catalog.pg_tables WHERE schemaname LIKE '""" + str(self.comboBox.currentText()) + """' AND tablename NOT LIKE 'qgis_projects' order by schemaname, tablename;"""
where schemaname like '"""+ str(self.comboBox.currentText()) +"""' order by schemaname,tablename;"""
cur.execute(custom_list) cur.execute(custom_list)
list_schema = cur.fetchall() list_schema = cur.fetchall()
SQLcountRaster = """SELECT schemaname,viewname FROM pg_catalog.pg_views
WHERE schemaname LIKE 'public' AND viewname LIKE 'raster_columns';"""
cur.execute(SQLcountRaster)
RasterIF = len(cur.fetchall())
if RasterIF == 1:
SQLloadRaster = """SELECT concat(r_table_schema,'.',r_table_name) from public.raster_columns; """
cur.execute(SQLloadRaster)
list_raster = cur.fetchall()
RasterList = []
for rasterFind in list_raster:
RasterList.append(rasterFind[0])
else:
RasterList = []
SQLprojects = """SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE tablename LIKE 'qgis_projects'"""
cur.execute(SQLprojects)
list_projects = cur.fetchall()
list_projects_qgis = []
if len(list_projects) <= 1:
for ProjectName in list_projects:
SQLProjectsQgis = """SELECT name, metadata, content FROM """ + '"' + ProjectName[0] + '"."' + ProjectName[1] + '"'
cur.execute(SQLProjectsQgis)
list_projects_qgis.append(cur.fetchall())
if self.comboBox.currentText() == 'toutes les catégories':
SQLGrands = """SELECT concat(table_schema,'.',table_name) FROM information_schema.role_table_grants WHERE grantee in(SELECT rolname FROM pg_catalog.pg_roles WHERE oid in(SELECT roleid FROM pg_auth_members WHERE member = (SELECT usesysid FROM pg_catalog.pg_user WHERE usename = '""" + user + """'))) and privilege_type = 'SELECT';"""
else:
SQLGrands = """SELECT concat(table_schema,'.',table_name) FROM information_schema.role_table_grants WHERE grantee in(SELECT rolname FROM pg_catalog.pg_roles WHERE oid in(SELECT roleid FROM pg_auth_members WHERE member = (SELECT usesysid FROM pg_catalog.pg_user WHERE usename = '""" + user + """'))) and privilege_type = 'SELECT' AND table_schema LIKE '_""" + str(self.comboBox.currentText()) + """_%';"""
cur.execute(SQLGrands)
list_grands = cur.fetchall()
GrandUser = []
for grandsFind in list_grands:
GrandUser.append(grandsFind[0])
self.tableWidget.setRowCount(len(list_schema)) self.tableWidget.setRowCount(len(list_schema))
self.tableWidget.setColumnCount(3) self.tableWidget.setColumnCount(4)
i=0 i = 0
for value in list_schema: for value in list_schema:
if dbtype == sigdb: if dbtype == sigdb:
type_val = str(value[0])[1:3] type_val = str(value[0])[1:3]
schema_name=str(value[0])[4:] schema_name = str(value[0])[4:]
table_name=str(value[1]) table_name = str(value[1][len(value[0]) + 1:])
if value[0] == value[1][:len(value[0])]:
table_name = str(value[1][len(value[0]) + 1:])
else:
table_name = str(value[1])
else: else:
type_val = '' type_val = ''
schema_name=str(value[0]) schema_name = str(value[0])
table_name=str(value[1]) table_name = str(value[1])
if type_val == 'fo': if type_val == 'fo':
type_val=str(value[0])[1:5] type_val = str(value[0])[1:5]
schema_name=str(value[0])[6:] schema_name = str(value[0])[6:]
table_name=str(value[1]) if value[0] == value[1][:len(value[0])]:
table_name = str(value[1][len(value[0]) + 1:])
else:
table_name = str(value[1])
elif type_val == 'ra': elif type_val == 'ra':
type_val='travaux' type_val = 'travaux'
schema_name=str(value[0]) schema_name = str(value[0])
table_name=str(value[1]) table_name = str(value[1])
elif type_val != '00' and type_val != '01' and type_val != '07' and type_val != '26' and type_val != '42' and type_val != '69' and type_val != 'ra': elif type_val != '00' and type_val != '01' and type_val != '07' and type_val != '26' and type_val != '42' and type_val != '69' and type_val != 'ra':
type_val='agregation' type_val = 'agregation'
schema_name=str(value[0]) schema_name = str(value[0])
table_name=str(value[1]) table_name = str(value[1])
if (str(value[0]) + '.' + str(value[1])) in RasterList:
SVG = 'mIconRaster.svg'
else:
SVG = 'mIconVecteur.svg'
itemIcon = QTableWidgetItem()
icon = QIcon()
icon.addPixmap(QtGui.QPixmap(resources_path('icons', SVG)), QIcon.Mode(0), QIcon.State(1))
itemIcon.setIcon(icon)
self.tableWidget.setItem(i, 0, itemIcon)
item = QTableWidgetItem(type_val) item = QTableWidgetItem(type_val)
self.tableWidget.setItem(i,0,item) self.tableWidget.setItem(i, 1, item)
item = QTableWidgetItem(schema_name) item = QTableWidgetItem(schema_name)
self.tableWidget.setItem(i,1,item) self.tableWidget.setItem(i, 2, item)
item = QTableWidgetItem(table_name) item = QTableWidgetItem(table_name)
self.tableWidget.setItem(i,2,item) self.tableWidget.setItem(i, 3, item)
i=i+1
if True:
if (str(value[0]) + '.' + str(value[1])) in GrandUser:
pass
else:
# print(str(value[0]) + '.' + str(value[1]), 'bad')
for j in range(self.tableWidget.columnCount()):
self.tableWidget.item(i, j).setBackground(QtGui.QColor(187, 134, 192, 50))
self.tableWidget.item(i, j).setToolTip('Droit insuffisant pour ouvrire la couche !')
i = i + 1
if self.comboBox.currentText() == 'toutes les catégories':
SQLprojects = """SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE tablename LIKE 'qgis_projects'"""
else:
SQLprojects = """SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE tablename LIKE 'qgis_projects' AND schemaname LIKE '""" + str(self.comboBox.currentText()) + """';"""
cur.execute(SQLprojects)
list_projects = cur.fetchall()
list_projects_qgis = []
if len(list_projects) >= 1:
for ProjectName in list_projects:
SQLProjectsQgis = """SELECT name, metadata, content FROM """ + '"' + ProjectName[0] + '"."' + ProjectName[1] + '"'
cur.execute(SQLProjectsQgis)
list_projects_qgis = cur.fetchall()
for Project in list_projects_qgis:
self.tableWidget.setRowCount(i + 1)
itemIcon = QTableWidgetItem()
icon = QIcon()
icon.addPixmap(QtGui.QPixmap(resources_path('icons', 'mIconQgis.svg')), QIcon.Mode(0), QIcon.State(1))
itemIcon.setIcon(icon)
self.tableWidget.setItem(i, 0, itemIcon)
item = QTableWidgetItem('qgis')
self.tableWidget.setItem(i, 1, item)
item = QTableWidgetItem(ProjectName[0])
self.tableWidget.setItem(i, 2, item)
item = QTableWidgetItem(Project[0])
self.tableWidget.setItem(i, 3, item)
i = i + 1
self.tableWidget.setColumnWidth(0, 20) self.tableWidget.setColumnWidth(0, 20)
self.tableWidget.setColumnWidth(1, 300) self.tableWidget.setColumnWidth(1, 70)
self.tableWidget.setColumnWidth(2, 300) self.tableWidget.setColumnWidth(2, 300)
self.tableWidget.setHorizontalHeaderLabels(["Code","Schema","Table"]) self.tableWidget.setColumnWidth(3, 300)
self.tableWidget.setHorizontalHeaderLabels(["Type", "Code", "Schema", "Table"])
def selection_flux(self): def selection_flux(self):
selected_row = 0 selected_row = 0
selected_items = self.tableWidget.selectedItems() selected_items = self.tableWidget.selectedItems()
# Assuming you want to compare items in the first column for uniqueness # Assuming you want to compare items in the first column for uniqueness
new_item_text = selected_items[2].text() # svgTake = (selected_items[2].tableWidget().cellWidget(0,0))
new_item_text = selected_items[3].text()
if not self.item_already_exists(new_item_text): if not self.item_already_exists(new_item_text):
self.tableWidget_2.insertRow(selected_row) self.tableWidget_2.insertRow(selected_row)
for column in range(self.tableWidget.columnCount()): for column in range(self.tableWidget.columnCount()):
cloned_item = selected_items[column].clone() cloned_item = selected_items[column].clone()
self.tableWidget_2.setHorizontalHeaderLabels(["Code","Schema", "Table"]) self.tableWidget_2.setHorizontalHeaderLabels(["Type", "Code", "Schema", "Table"])
self.tableWidget_2.setColumnCount(3) self.tableWidget_2.setColumnCount(4)
self.tableWidget_2.setItem(selected_row, column, cloned_item) self.tableWidget_2.setItem(selected_row, column, cloned_item)
self.tableWidget_2.setColumnWidth(0, 50) self.tableWidget_2.setColumnWidth(0, 20)
self.tableWidget_2.setColumnWidth(1, 300) self.tableWidget_2.setColumnWidth(1, 70)
self.tableWidget_2.setColumnWidth(2, 300) self.tableWidget_2.setColumnWidth(2, 300)
self.tableWidget_2.setColumnWidth(3, 300)
def item_already_exists(self, new_item_text): def item_already_exists(self, new_item_text):
# Assuming you want to compare items in the first column for uniqueness # Assuming you want to compare items in the first column for uniqueness
existing_items = self.tableWidget_2.findItems(new_item_text, QtCore.Qt.MatchExactly) existing_items = self.tableWidget_2.findItems(new_item_text, QtCore.Qt.MatchFlag(0))
# Check if there are any existing items with the same text in the first column # Check if there are any existing items with the same text in the first column
return len(existing_items) > 0 return len(existing_items) > 0
def limite_flux(self): def limite_flux(self):
if self.tableWidget_2.rowCount() > 5: if self.tableWidget_2.rowCount() > 5:
self.QMBquestion = QMessageBox.question(iface.mainWindow(), u"Attention !", self.QMBquestion = QMessageBox.question(iface.mainWindow(), u"Attention !",
"Le nombre de flux à charger en une seule fois est limité à 5 pour des questions de performances. Souhaitez vous tout de même charger les " + str( "Le nombre de flux à charger en une seule fois est limité à 5 pour des questions de performances. Souhaitez vous tout de même charger les " + str(
self.tableWidget_2.rowCount()) + " flux sélectionnés ? (risque de plantage de QGIS)", self.tableWidget_2.rowCount()) + " flux sélectionnés ? (risque de plantage de QGIS)",
QMessageBox.Yes | QMessageBox.No) QMessageBox.StandardButton(0x00004000) | QMessageBox.StandardButton(0x00010000))
if self.QMBquestion == QMessageBox.Yes: if self.QMBquestion == QMessageBox.StandardButton(0x00004000):
self.chargement_flux() self.chargement_flux()
if self.QMBquestion == QMessageBox.No: if self.QMBquestion == QMessageBox.StandardButton(0x00001000):
print("Annulation du chargement des couches") print("Annulation du chargement des couches")
if self.tableWidget_2.rowCount() <= 5: if self.tableWidget_2.rowCount() <= 5:
self.chargement_flux() self.chargement_flux()
def chargement_flux(self): """
def openPostGIS(self, schema, table):
uri = QgsDataSourceUri()
uri.setConnection(host, port, sigdb, user, mdp)
if (schema + '.' + table) in LRasterList:
uri.setDataSource(schema, table, "rast")
uri.setKeyColumn('rid')
uri.setSrid('2154')
layer = QgsRasterLayer(uri.uri(), table, "postgresraster")
else:
uri.setDataSource(schema, table, "geom")
uri.setKeyColumn('gid')
uri.setSrid('2154')
layer = QgsVectorLayer(uri.uri(), table, "postgres")
# Ajout de la couche au canevas QGIS
QgsProject.instance().addMapLayer(layer)
"""
def chargement_flux(self):
managerAU = QgsApplication.authManager() managerAU = QgsApplication.authManager()
k = managerAU.availableAuthMethodConfigs().keys() managerAU.availableAuthMethodConfigs().keys()
def REQUEST(type): def REQUEST(type):
switcher = { switcher = {
@ -272,61 +461,110 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
} }
return switcher.get(type, "nothing") return switcher.get(type, "nothing")
# def displayOnWindows(type, uri, name):
# p = []
def displayOnWindows(type, uri, name): SQLloadRaster = """SELECT concat(r_table_schema,'.',r_table_name) from public.raster_columns; """
p = [] SQLextension = """SELECT count(extname) FROM pg_catalog.pg_extension WHERE extname LIKE 'postgis_raster';"""
cur.execute(SQLextension)
count_extension = cur.fetchall()[0][0]
if count_extension == 1:
cur.execute(SQLloadRaster)
list_raster = cur.fetchall()
else:
list_raster = []
RasterList = []
for rasterFind in list_raster:
RasterList.append(rasterFind[0])
for row in range(0, self.tableWidget_2.rowCount()): for row in range(0, self.tableWidget_2.rowCount()):
## supression de la partie de l'url après le point d'interrogation color_rgba_db = 855030089
color_rgba_droit = 851150528
# print(self.tableWidget_2.item(row, 1).background().color().rgba())
if self.tableWidget_2.item(row, 1).background().color().rgba() == color_rgba_droit:
self.QMBquestion = QMessageBox.question(iface.mainWindow(), u"Attention !", "Vous ne disposez pas des droit pour la couche «" + str(self.tableWidget_2.item(row, 1).text()) + ' ' + str(self.tableWidget_2.item(row, 2).text()) + "» !", QMessageBox.StandardButton(0x00004000))
elif self.tableWidget_2.item(row, 1).background().color().rgba() != color_rgba_db:
# supression de la partie de l'url après le point d'interrogation
if dbtype == sigdb: if dbtype == sigdb:
code = self.tableWidget_2.item(row,0).text() code = self.tableWidget_2.item(row, 1).text()
schema = '_'+code+'_'+self.tableWidget_2.item(row,1).text() schema = '_' + code + '_' + self.tableWidget_2.item(row, 2).text()
if code == 'travaux' or code == 'agregation': if code == 'travaux' or code == 'agregation':
schema = self.tableWidget_2.item(row,1).text() schema = self.tableWidget_2.item(row, 2).text()
table = self.tableWidget_2.item(row,2).text()#.split("?", 1)[0] table = self.tableWidget_2.item(row, 3).text()
if dbtype == refdb: elif code == '00':
# code = self.tableWidget_2.item(row,0).text() table = self.tableWidget_2.item(row, 3).text()
schema = self.tableWidget_2.item(row,1).text() else:
table = self.tableWidget_2.item(row,2).text()#.split("?", 1)[0] table = self.tableWidget_2.item(row, 3).text()
table = schema + '_' + table
elif dbtype == refdb:
code = self.tableWidget_2.item(row, 1).text()
schema = self.tableWidget_2.item(row, 2).text()
table = self.tableWidget_2.item(row, 3).text()
# .split("?", 1)[0]
uri = QgsDataSourceUri() uri = QgsDataSourceUri()
uri.setConnection(host ,port ,dbtype ,user ,mdp) 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
if (schema + '.' + table) in RasterList:
uri.setDataSource(schema, table, "rast")
uri.setKeyColumn('rid')
uri.setSrid('2154')
layer = QgsRasterLayer(uri.uri(), table, "postgresraster")
QgsProject.instance().addMapLayer(layer)
elif code == 'qgis':
schema = self.tableWidget_2.item(row, 2).text()
print(schema)
table = self.tableWidget_2.item(row, 3).text()
uri_project = 'postgresql://' + user + ':' + mdp + '@' + host + ':' + port + '?sslmode=disable&dbname=' + dbtype + "&schema=" + schema + '&project=' + table
QgsProject.instance().read(uri_project)
else:
uri.setDataSource(schema, table, "geom")
uri.setKeyColumn('gid')
# nom du schéma à remplacer: "hydrographie" à supprimer et mettre "couches_collaboratives" lorsqu'on aura regroupé les couches à modifier dans un même schéma # Chargement de la couche PostGIS
geom_type = 'SELECT right(st_geometrytype(geom),-3) as a FROM ' + schema + '.' + table + ' GROUP BY a'
uri.setDataSource(schema, table, "geom") try:
uri.setKeyColumn('gid') cur.execute(geom_type)
list_typegeom = cur.fetchall()
# Chargement de la couche PostGIS UndefinedTable = True
geom_type ='SELECT right(st_geometrytype(geom),-3) as a FROM '+schema+'.'+table+' GROUP BY a' except psycopg2.errors.UndefinedTable:
cur.execute(geom_type) print("Error table name")
list_typegeom = cur.fetchall() list_typegeom = ''
print(len(list_typegeom)) UndefinedTable = False
if len(list_typegeom) > 1: if len(list_typegeom) > 1:
for typegeom in list_typegeom: for typegeom in list_typegeom:
if typegeom[0] == 'MultiPolygon': if typegeom[0] == 'MultiPolygon':
uri.setWkbType(QgsWkbTypes.MultiPolygon) uri.setWkbType(QgsWkbTypes.MultiPolygon)
elif typegeom[0] == 'MultiLineString': elif typegeom[0] == 'MultiLineString':
uri.setWkbType(QgsWkbTypes.MultiLineString) uri.setWkbType(QgsWkbTypes.MultiLineString)
elif typegeom[0] == 'Point': elif typegeom[0] == 'Point':
uri.setWkbType(QgsWkbTypes.Point) uri.setWkbType(QgsWkbTypes.Point)
if typegeom[0] == 'Polygon': if typegeom[0] == 'Polygon':
uri.setWkbType(QgsWkbTypes.Polygon) uri.setWkbType(QgsWkbTypes.Polygon)
elif typegeom[0] == 'LineString': elif typegeom[0] == 'LineString':
uri.setWkbType(QgsWkbTypes.LineString) uri.setWkbType(QgsWkbTypes.LineString)
elif typegeom[0] == 'MultiPoint': elif typegeom[0] == 'MultiPoint':
uri.setWkbType(QgsWkbTypes.MultiPoint) uri.setWkbType(QgsWkbTypes.MultiPoint)
if (typegeom[0] != None and typegeom[0] != 'Polygon'): if (typegeom[0] is not None and typegeom[0] != 'Polygon'):
uri.setSrid('2154') uri.setSrid('2154')
layer = QgsVectorLayer(uri.uri(), table, "postgres")
# Ajout de la couche au canevas QGIS
QgsProject.instance().addMapLayer(layer)
else:
if UndefinedTable:
layer = QgsVectorLayer(uri.uri(), table, "postgres") layer = QgsVectorLayer(uri.uri(), table, "postgres")
# Ajout de la couche au canevas QGIS # Ajout de la couche au canevas QGIS
QgsProject.instance().addMapLayer(layer) QgsProject.instance().addMapLayer(layer)
else: else:
layer = QgsVectorLayer(uri.uri(), table, "postgres") self.QMBquestion = QMessageBox.question(iface.mainWindow(), u"Attention !", "La couche «" + str(self.tableWidget_2.item(row, 1).text()) + ' ' + str(self.tableWidget_2.item(row, 2).text()) + "» semble ne pas avoir le même nom dans la BD, merci de contacter votre administrateur pour régler le problème !", QMessageBox.StandardButton(0x00004000))
# Ajout de la couche au canevas QGIS else:
QgsProject.instance().addMapLayer(layer) self.QMBquestion = QMessageBox.question(iface.mainWindow(), u"Attention !", "La couche «" + str(self.tableWidget_2.item(row, 1).text()) + ' ' + str(self.tableWidget_2.item(row, 2).text()) + "» ne ce trouve pas dans cette BD !", QMessageBox.StandardButton(0x00004000))
def combobox_custom(self): def combobox_custom(self):
if dbtype == sigdb: if dbtype == sigdb:
self.toolButton.setEnabled(1)
self.comboBox.clear() self.comboBox.clear()
self.comboBox.addItem("toutes les catégories") self.comboBox.addItem("toutes les catégories")
self.comboBox.addItem('00') self.comboBox.addItem('00')
@ -337,17 +575,21 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
self.comboBox.addItem('69') self.comboBox.addItem('69')
self.comboBox.addItem('agregation') self.comboBox.addItem('agregation')
self.comboBox.addItem('travaux') self.comboBox.addItem('travaux')
self.comboBox.addItem('qgis')
self.comboBox.addItem('form') self.comboBox.addItem('form')
if dbtype == refdb: if dbtype == refdb:
custom_list=schemaname_distinct self.toolButton.setEnabled(0)
custom_list = schemaname_distinct
cur.execute(custom_list) cur.execute(custom_list)
list_schema = cur.fetchall() list_schema = cur.fetchall()
self.comboBox.clear() self.comboBox.clear()
self.comboBox.addItem("toutes les catégories") self.comboBox.addItem("toutes les catégories")
for baxval in list_schema: for baxval in list_schema:
self.comboBox.addItem(baxval[0]) self.comboBox.addItem(baxval[0])
def filtre_dynamique(self, filter_text):
def filtre_dynamique(self, filter_text):
if filter_text.find(' ') >= 0:
filter_text = filter_text.replace(" ", "_")
for i in range(self.tableWidget.rowCount()): for i in range(self.tableWidget.rowCount()):
for j in range(self.tableWidget.columnCount()): for j in range(self.tableWidget.columnCount()):
item = self.tableWidget.item(i, j) item = self.tableWidget.item(i, j)
@ -356,7 +598,71 @@ class Flux_Editor(QDialog, EDITOR_CLASS):
if not match: if not match:
break break
def popup(self): def getCanevas(self):
poly = iface.mapCanvas().extent()
geom = (str(poly.xMinimum()) + ',' + str(poly.yMinimum()) + ',' + str(poly.xMaximum()) + ',' + str(poly.yMaximum()))
self.dialog = Popup() # +++ - self SQL_GEOM_CONTOUR = """SELECT DISTINCT tschema,tname FROM "_agregation_ra"."_agreg_contour" WHERE st_intersects(geom,ST_MakeEnvelope(""" + geom + ",2154)) ORDER BY tname"
self.dialog.text_edit.show() SQL_GEOM_HABITAT = """SELECT DISTINCT tschema,tname FROM "_agregation_ra"."_agreg_habitat" WHERE st_intersects(geom,ST_MakeEnvelope(""" + geom + ",2154)) ORDER BY tname"
SQL_GEOM_EU_HABITAT = """SELECT DISTINCT tschema,tname FROM "_agregation_ra"."_agreg_eu_habitat" WHERE st_intersects(geom,ST_MakeEnvelope(""" + geom + ",2154)) ORDER BY tname"
SQL_GEOM_TRAVAUX_PREVUS_LIGNE = """SELECT DISTINCT tschema,tname FROM "_agregation_ra"."_agreg_travaux_prevus_ligne" WHERE st_intersects(geom,ST_MakeEnvelope(""" + geom + ",2154)) ORDER BY tname"
SQL_GEOM_TRAVAUX_PREVUS_POINT = """SELECT DISTINCT tschema,tname FROM "_agregation_ra"."_agreg_travaux_prevus_point" WHERE st_intersects(geom,ST_MakeEnvelope(""" + geom + ",2154)) ORDER BY tname"
SQL_GEOM_TRAVAUX_PREVUS_POLY = """SELECT DISTINCT tschema,tname FROM "_agregation_ra"."_agreg_travaux_prevus_poly" WHERE st_intersects(geom,ST_MakeEnvelope(""" + geom + ",2154)) ORDER BY tname"
cur.execute(SQL_GEOM_CONTOUR)
TableContour = cur.fetchall()
cur.execute(SQL_GEOM_HABITAT)
TableHabitat = cur.fetchall()
cur.execute(SQL_GEOM_EU_HABITAT)
TableEuHabitat = cur.fetchall()
cur.execute(SQL_GEOM_TRAVAUX_PREVUS_LIGNE)
TableTravauxLigne = cur.fetchall()
cur.execute(SQL_GEOM_TRAVAUX_PREVUS_POINT)
TableTravauxPoint = cur.fetchall()
cur.execute(SQL_GEOM_TRAVAUX_PREVUS_POLY)
TableTravauxPoly = cur.fetchall()
TableHaveGeom = sorted(TableContour + TableHabitat + TableEuHabitat + TableTravauxLigne + TableTravauxPoint + TableTravauxPoly)
row_count = 0
self.tableWidget.setRowCount(0)
for e in TableHaveGeom:
cur.execute("""SELECT DISTINCT count(*) FROM pg_catalog.pg_tables WHERE schemaname LIKE '""" + e[0] + """' AND tablename LIKE '""" + e[1] + """';""")
TableSomme = cur.fetchall()[0][0]
if e[0][1:3] != 'fo':
DepName = QTableWidgetItem(e[0][1:3])
SchemaName = QTableWidgetItem(e[0][4:])
else:
DepName = QTableWidgetItem('form')
SchemaName = QTableWidgetItem(e[0][6:])
TableName = QTableWidgetItem(e[1][len(e[0]) + 1:])
self.tableWidget.insertRow(row_count)
itemIcon = QTableWidgetItem()
icon = QIcon()
icon.addPixmap(QtGui.QPixmap(resources_path('icons', 'mIconVecteur.svg')), QIcon.Mode(0), QIcon.State(1))
itemIcon.setIcon(icon)
self.tableWidget.setItem(row_count, 0, itemIcon)
self.tableWidget.setItem(row_count, 1, DepName)
self.tableWidget.setItem(row_count, 2, SchemaName)
self.tableWidget.setItem(row_count, 3, TableName)
if TableSomme == 0:
for j in range(self.tableWidget.columnCount()):
self.tableWidget.item(row_count, j).setBackground(QtGui.QColor(246, 185, 73, 50))
self.tableWidget.item(row_count, j).setToolTip('Couche dans une autre BD !')
row_count = row_count + 1
if self.lineEdit.text() != 'Recherche par mots-clés':
self.filtre_dynamique(self.lineEdit.text())
def SwitchGeom(self, vargeom):
new_object = '['
obj = vargeom['coordinates'][0][0]
for obj_X in obj:
new_object = new_object + '[' + str(obj_X[1]) + ',' + str(obj_X[0]) + '],'
new_object = new_object[:-1] + ']'
return (new_object)
# def popup(self):
# self.dialog = Popup() # +++ - self
# self.dialog.text_edit.show()

View File

@ -1,54 +1,31 @@
import os import os
plugin_dir = os.path.dirname(__file__) # from qgis.gui import *
end_find = plugin_dir.rfind('\\')+1
NAME = plugin_dir[end_find:] from qgis.core import QgsSettings
from qgis.PyQt.QtWidgets import QDialog
from qgis.gui import *
from qgis.core import (
NULL,
QgsApplication,
QgsDataSourceUri,
QgsProject,
QgsProviderConnectionException,
QgsProviderRegistry,
QgsRasterLayer,
QgsSettings,
QgsVectorLayer,
QgsGeometry,
)
from qgis.PyQt.QtWidgets import (
QDialog,
QAction,
QDockWidget,
QFileDialog,
QInputDialog,
QMenu,
QToolButton,
QTableWidget,
QTableWidgetItem,
)
from qgis.utils import iface from qgis.utils import iface
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path,
send_issues, send_issues,
) )
plugin_dir = os.path.dirname(__file__)
end_find = plugin_dir.rfind('\\') + 1
NAME = plugin_dir[end_find:]
EDITOR_CLASS = load_ui('CenRa_IssuesSend.ui') EDITOR_CLASS = load_ui('CenRa_IssuesSend.ui')
class CenRa_Issues(QDialog, EDITOR_CLASS):
class CenRa_Issues(QDialog, EDITOR_CLASS):
def __init__(self, parent=None): def __init__(self, parent=None):
_ = parent _ = parent
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.settings = QgsSettings() self.settings = QgsSettings()
#place connect here # place connect here
self.annuler_button.clicked.connect(self.close) self.annuler_button.clicked.connect(self.close)
self.ok_button.clicked.connect(self.run_sendissues) self.ok_button.clicked.connect(self.run_sendissues)
@ -62,27 +39,32 @@ class CenRa_Issues(QDialog, EDITOR_CLASS):
statu_autre = self.check_autre.isChecked() statu_autre = self.check_autre.isChecked()
statu = [] statu = []
if statu_bug == True : statu = statu + [1] if statu_bug is True:
if statu_aide == True : statu = statu + [3] statu = statu + [1]
if statu_question == True : statu = statu + [5] if statu_aide is True:
if statu_amelioration == True : statu = statu + [2] statu = statu + [3]
if statu_autre == True : statu = statu + [6] if statu_question is True:
statu = statu + [5]
if statu_amelioration is True:
statu = statu + [2]
if statu_autre is True:
statu = statu + [6]
if len(statu) >= 1: if len(statu) >= 1:
import qgis import qgis
url = qgis.utils.pluginMetadata(NAME,'tracker') url = qgis.utils.pluginMetadata(NAME, 'tracker')
print(text_message) print(text_message)
send_info = send_issues(url,text_titre,text_message,statu) send_info = send_issues(url, text_titre, text_message, statu)
code = send_info.status_code code = send_info.status_code
print(code) print(code)
else: else:
code = 423 code = 423
if code == 201: if code == 201:
iface.messageBar().pushMessage("Envoyer :", "Votre messages à bien été envoyer.", level=Qgis.Success, duration=20) iface.messageBar().pushMessage("Envoyer :", "Votre messages à bien été envoyer.", level=0, duration=20)
self.close() self.close()
elif code == 422: elif code == 422:
iface.messageBar().pushMessage("Erreur :", "Erreur dans le contenu du messages.", level=Qgis.Critical, duration=20) iface.messageBar().pushMessage("Erreur :", "Erreur dans le contenu du messages.", level=2, duration=20)
elif code == 423: elif code == 423:
iface.messageBar().pushMessage("Erreur :", "Pas de sujet sélectionné.", level=Qgis.Critical, duration=20) iface.messageBar().pushMessage("Erreur :", "Pas de sujet sélectionné.", level=2, duration=20)
elif code == 404: elif code == 404:
iface.messageBar().pushMessage("Missing :", "Le serveur de messagerie est injoignable.", level=Qgis.Warning, duration=20) iface.messageBar().pushMessage("Missing :", "Le serveur de messagerie est injoignable.", level=1, duration=20)

View File

@ -5,8 +5,9 @@
[general] [general]
name=CenRa_FLUX name=CenRa_FLUX
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
supportsQt6=True
description=Permet d'ouvrire une table dans la base PostGis description=Permet d'ouvrire une table dans la base PostGis
version=2.1 version=3.15
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@ -18,7 +19,6 @@ email=si_besoin@cen-rhonealpes.fr
hasProcessingProvider=no hasProcessingProvider=no
# Uncomment the following line and add your changelog: # Uncomment the following line and add your changelog:
# changelog= correctif de sécurité: envoi du certificat d'authentification seulement pour les couches fonciercen et drone / intégration des styles RPG geoportail / modification des noms de couches pour plus de clarté
# Tags are comma separated with spaces allowed # Tags are comma separated with spaces allowed
tags=cenra, postgis, database tags=cenra, postgis, database
@ -32,7 +32,7 @@ icon=icon.png
# experimental flag # experimental flag
experimental=False experimental=False
changelog=<h1>CenRA_FLUX:</h1></br><p><h3>22/10/2024 - Version 2.1:</h3> - Correctif de bug.</br> - Evolution de la limit de 3 à 5. </br></p></br><p><h3>22/10/2024 - Version 2.0:</h3> - Reformatage du code.</br></p></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> changelog=<h2>CenRa_FLUX:</h2></br><p><h3>15/12/2025 - Version 3.15: </h3> - information visuel des droit d access a la donnee sur tout les base.</p></br><p><h3>08/12/2025 - Version 3.14: </h3> - message d erreur pour les drois de couche sur la DB.</p></br><p><h3>08/12/2025 - Version 3.13: </h3> - Detection des droit utilisateur.</p></br><p><h3>25/09/2025 - Version 3.12: </h3> - version +1.</p></br><p><h3>25/09/2025 - Version 3.11: </h3> - Correctife sur les code 00.</p></br><p><h3>24/09/2025 - Version 3.10: </h3> - Erreur sur l ouverture des couche raster. </p></br><p><h3>24/09/2025 - Version 3.9: </h3> - bugfix lier aux extention pgsql.</p></br><p><h3>09/09/2025 - Version 3.8: </h3> - Bug REF fix.</p></br><p><h3>05/09/2025 - Version 3.7: </h3> - Ouverture de projet QGIS contenue dans la base de donnees.</p></br><p><h3>30/07/2025 - Version 3.6: </h3> - Correctife de bug.</p></br><p><h3>29/07/2025 - Version 3.5: </h3> - Bug fix sur les donnee raster.</p></br><p><h3>23/07/2025 - Version 3.4: </h3> - Ouverture raster dans la base SIG.</p></br><p><h3>23/07/2025 - Version 3.3: </h3> - Optimisation des chargement.</p></br><p><h3>22/07/2025 - Version 3.2: </h3> - Visualisation des format raster et vecteur dans REF.</p></br><p><h3>21/07/2025 - Version 3.1: </h3> - Bug fix pour l'ouverture de plus de 5 couches.</p></br><p><h3>19/05/2025 - Version 3.0: </h3> - Compatible PyQt5 et PyQt6.</p></br><p><h3>09/04/2025 - Version 2.9: </h3> - Correctif bug en TT.</p></br><p><h3>09/04/2025 - Version 2.8: </h3> - Optimisation pour le TT.</p></br><p><h3>07/04/2025 - Version 2.7: </h3> - mode debug.</p></br><p><h3>03/04/2025 - Version 2.6: </h3> - Mise a jour de securite.</p></br><p><h3>20/03/2025 - Version 2.5: </h3> - Visualisation distincte des couches ne se trouvant pas dans l'antenne.</p></br><p><h3>13/02/2025 - Version 2.4: </h3> - Ajoute redimensionnement et déplacement mollette.</p></br><p><h3>05/02/2025 - Version 2.3: </h3> - Bouton de visualisation des couches se trouvent uniquement dans le canva de la carte.</p></br><p><h3>07/01/2025 - Version 2.2: </h3> - ByPass du certif ssl ci erreur.</p></br><p><h3>22/10/2024 - Version 2.1:</h3> - Correctif de bug.</br> - Evolution de la limit de 3 à 5. </br></p></br><p><h3>22/10/2024 - Version 2.0:</h3> - Reformatage du code.</br></p></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 flag (applies to the whole plugin, not just a single version)
deprecated=False deprecated=False
@ -45,4 +45,3 @@ deprecated=False
# If the plugin can run on QGIS Server. # If the plugin can run on QGIS Server.
server=False server=False

View File

@ -1,7 +1,8 @@
from qgis.core import QgsApplication from qgis.core import QgsApplication
def gitea(): def gitea():
file_url = QgsApplication.qgisSettingsDirPath()+'QGIS/QGIS3.ini' file_url = QgsApplication.qgisSettingsDirPath() + 'QGIS/QGIS3.ini'
recherche_1 = 'plugin_repositories\\github\\url=https://github.com/CEN-Rhone-Alpes/Plugin_QGIS/releases/latest/download/plugins.xml' recherche_1 = 'plugin_repositories\\github\\url=https://github.com/CEN-Rhone-Alpes/Plugin_QGIS/releases/latest/download/plugins.xml'
replace_1 = 'plugin_repositories\\gitea\\url=https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml' replace_1 = 'plugin_repositories\\gitea\\url=https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
@ -18,4 +19,4 @@ def gitea():
# Write the file out again # Write the file out again
with open(file_url, 'w') as file: with open(file_url, 'w') as file:
file.write(filedata) file.write(filedata)

View File

@ -1,185 +0,0 @@
import sys
import socket
import os
IPAddr=socket.gethostbyname(socket.gethostname())
print(IPAddr)
if IPAddr[0:11] == "100.100.100": #4269
host = "100.100.100.11"
port = "5432"
dbname = "sig4269"
sigdb="sig4269"
refdb="ref_geo4269"
password = "McVities"
if IPAddr[0:9] == "192.168.0": #01
host = "192.168.0.201"
port = "5432"
dbname = "sig01"
sigdb="sig01"
refdb="ref_geo01"
password = "McVities"
if IPAddr[0:9] == "192.168.1": #0726
host = "192.168.1.201"
port = "5432"
dbname = "sig0726"
sigdb="sig0726"
refdb="ref_geo0726"
password = "McVities"
if sys.platform == 'linux':
os_user = os.environ['USER']
else:
os_user = os.environ['USERNAME']
if os_user == 'STAGE':
os_user='stage'
if os_user == 'Administrateur':
os_user = 'stage'
schemaname_distinct="""SELECT DISTINCT schemaname from pg_catalog.pg_tables
WHERE schemaname NOT LIKE '_archives' AND schemaname NOT LIKE 'topology' AND schemaname NOT LIKE 'information_schema' AND schemaname NOT LIKE 'pg_catalog' and schemaname NOT LIKE 'public' AND schemaname NOT LIKE '_trier'
order by schemaname;"""
schemaname_list_ref="""SELECT schemaname,tablename from pg_catalog.pg_tables
WHERE schemaname NOT LIKE '_archives' AND schemaname NOT LIKE 'topology' AND schemaname NOT LIKE 'information_schema' AND schemaname NOT LIKE 'pg_catalog' and schemaname NOT LIKE 'public' AND schemaname NOT LIKE '_trier'
order by schemaname,tablename;"""
schemaname_list="""(SELECT schemaname,tablename from pg_catalog.pg_tables
where schemaname like 'trav%' or schemaname like '\_ag%' or schemaname like '\_00%' or schemaname like '\_01%' or schemaname like '\_07%' or schemaname like '\_26%' or schemaname like '\_form%' or schemaname like '\_42%' or schemaname like '\_69%' order by schemaname,tablename)
UNION
(SELECT schemaname,matviewname AS tablename FROM pg_catalog.pg_matviews order by schemaname,tablename) order by schemaname,tablename;"""
geom = "geom"
champ_travaux_prevus_multipolygon="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, surface_m2 double precision, surface_ha double precision, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))"""
champ_travaux_prevus_multilinestring="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, longueur_m double precision, longueur_km double precision, date_creation date, date_maj date, geom geometry(MultiLineString,2154))"""
champ_travaux_prevus_point = """(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, x_wgs84 double precision, y_wgs84 double precision, date_creation date, date_maj date, geom geometry(Point,2154))"""
champ_viergePolygone = """(gid serial NOT NULL, commentaire text, surface_m2 double precision, surface_ha double precision, geom geometry(MultiPolygon,2154))"""
champ_viergeLigne = """(gid serial NOT NULL, commentaire text, longueur_m double precision, longueur_km double precision, geom geometry(MultiLineString,2154))"""
champ_viergePoint = """(gid serial NOT NULL, commentaire text, x_wgs84 double precision, y_wgs84 double precision, geom geometry(Point,2154))"""
champ_habitat = """(gid serial NOT NULL, cd_cb_01 text, lb_cb97_fr_01 text, occupation_01 integer, cd_cb_02 text, lb_cb97_fr_02 text, occupation_02 integer, cd_cb_03 text, lb_cb97_fr_03 text, occupation_03 integer, milieu_code text, milieu_libelle text, surface_m2 double precision, surface_ha double precision, commentaire text, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))"""
champ_contour="""(gid serial NOT NULL, date_creation date, date_maj date, utilisateur character varying, dept character(2), nom character varying, surface_m2 double precision, surface_ha double precision, type_site character varying, type_milieu character varying, date_premier_pg integer, date_debut_pg integer, date_fin_pg integer, referent character varying, gestion_deleguee character varying, terrain_militaire character(3), ens character(3), zh character(3), adapt_pmr character(3), inform character(3), guide character(3), ouverture_public character(3), obs character(3), anim character(3), n2000_anim character(3), contrat_n2000_conseil character(3), n2000_op character(3), contrat_n2000_benef character(3), contrat_agri character(3), bc_habitat integer, bc_amphibien integer, bc_coleoptere integer, bc_crustace integer, bc_mammifere integer, bc_chiroptere integer, bc_mollusque integer, bc_odonate integer, bc_oiseau integer, bc_orthoptere integer, bc_poisson integer, bc_reptile integer, bc_rhopalocere integer, bc_heterocere integer, bc_autre_invertebre integer, bc_flore integer, bc_bryophyte integer, bc_champignon integer, suiv_analyse_sol character(3), suiv_piezo character(3), suiv_climat character(3), suiv_topo character(3), suiv_habitat character(3), suiv_amphibien character(3), suiv_coleoptere character(3), suiv_crustace character(3), suiv_mammifere character(3), suiv_chiroptere character(3), suiv_mollusque character(3), suiv_odonate character(3), suiv_oiseau character(3), suiv_orthoptere character(3), suiv_poisson character(3), suiv_reptile character(3), suiv_rhopalocere character(3), suiv_heterocere character(3), suiv_autre_invertebre character(3), suiv_flore character(3), suiv_bryophyte character(3), suiv_champignon character(3), suiv_analyse_eau character(3), suiv_phenologie character(3), suiv_frequentation character(3), suiv_paysager character(3), suiv_autre character(3), commentaire text, geom geometry(MultiPolygon,2154))
"""
champ_vegethab_point = """(
gid serial NOT NULL ,
cd_eu_01 character varying(254) COLLATE pg_catalog."default",
lb_eu_01 character varying(254) COLLATE pg_catalog."default",
occupati_1 bigint,
cd_eu_02 character varying(254) COLLATE pg_catalog."default",
lb_eu_02 character varying(254) COLLATE pg_catalog."default",
occupati_2 bigint,
cd_eu_03 character varying(254) COLLATE pg_catalog."default",
lb_eu_03 character varying(254) COLLATE pg_catalog."default",
occupati_3 bigint,
milieu_cod character varying(254) COLLATE pg_catalog."default",
milieu_lib character varying(254) COLLATE pg_catalog."default",
surface_m2 numeric,
surface_ha numeric,
commentair character varying(254) COLLATE pg_catalog."default",
date_creat date,
date_maj date,
num_phyto character varying(254) COLLATE pg_catalog."default",
type_unite character varying(254) COLLATE pg_catalog."default",
dynamique character varying(254) COLLATE pg_catalog."default",
gestio_obs character varying(254) COLLATE pg_catalog."default",
degrad_obs character varying(254) COLLATE pg_catalog."default",
eta_conser character varying(254) COLLATE pg_catalog."default",
clas_phyto character varying(254) COLLATE pg_catalog."default",
alli_phyto character varying(254) COLLATE pg_catalog."default",
syntaxon character varying(254) COLLATE pg_catalog."default",
n2000 character varying(254) COLLATE pg_catalog."default",
lrr_aura character varying(254) COLLATE pg_catalog."default",
lrr_cbna character varying(254) COLLATE pg_catalog."default",
lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
vege_enjeu character varying(254) COLLATE pg_catalog."default",
num_photo character varying(254) COLLATE pg_catalog."default",
nature_obs character varying(254) COLLATE pg_catalog."default",
date_sais date,
s_al_phyto character varying(254) COLLATE pg_catalog."default",
alli_name character varying(254) COLLATE pg_catalog."default",
salli_name character varying(254) COLLATE pg_catalog."default",
class_name character varying(254) COLLATE pg_catalog."default",
geom geometry(Point,2154)
)
"""
champ_vegethab_multilinestring = """(
gid serial NOT NULL ,
cd_eu_01 character varying(254) COLLATE pg_catalog."default",
lb_eu_01 character varying(254) COLLATE pg_catalog."default",
occupati_1 bigint,
cd_eu_02 character varying(254) COLLATE pg_catalog."default",
lb_eu_02 character varying(254) COLLATE pg_catalog."default",
occupati_2 bigint,
cd_eu_03 character varying(254) COLLATE pg_catalog."default",
lb_eu_03 character varying(254) COLLATE pg_catalog."default",
occupati_3 bigint,
milieu_cod character varying(254) COLLATE pg_catalog."default",
milieu_lib character varying(254) COLLATE pg_catalog."default",
surface_m2 numeric,
surface_ha numeric,
commentair character varying(254) COLLATE pg_catalog."default",
date_creat date,
date_maj date,
num_phyto character varying(254) COLLATE pg_catalog."default",
type_unite character varying(254) COLLATE pg_catalog."default",
dynamique character varying(254) COLLATE pg_catalog."default",
gestio_obs character varying(254) COLLATE pg_catalog."default",
degrad_obs character varying(254) COLLATE pg_catalog."default",
eta_conser character varying(254) COLLATE pg_catalog."default",
clas_phyto character varying(254) COLLATE pg_catalog."default",
alli_phyto character varying(254) COLLATE pg_catalog."default",
syntaxon character varying(254) COLLATE pg_catalog."default",
n2000 character varying(254) COLLATE pg_catalog."default",
lrr_aura character varying(254) COLLATE pg_catalog."default",
lrr_cbna character varying(254) COLLATE pg_catalog."default",
lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
vege_enjeu character varying(254) COLLATE pg_catalog."default",
num_photo character varying(254) COLLATE pg_catalog."default",
nature_obs character varying(254) COLLATE pg_catalog."default",
date_sais date,
s_al_phyto character varying(254) COLLATE pg_catalog."default",
alli_name character varying(254) COLLATE pg_catalog."default",
salli_name character varying(254) COLLATE pg_catalog."default",
class_name character varying(254) COLLATE pg_catalog."default",
geom geometry(MultiLineString,2154)
)
"""
champ_vegethab_multipolygon = """(
gid serial NOT NULL ,
cd_eu_01 character varying(254) COLLATE pg_catalog."default",
lb_eu_01 character varying(254) COLLATE pg_catalog."default",
occupati_1 bigint,
cd_eu_02 character varying(254) COLLATE pg_catalog."default",
lb_eu_02 character varying(254) COLLATE pg_catalog."default",
occupati_2 bigint,
cd_eu_03 character varying(254) COLLATE pg_catalog."default",
lb_eu_03 character varying(254) COLLATE pg_catalog."default",
occupati_3 bigint,
milieu_cod character varying(254) COLLATE pg_catalog."default",
milieu_lib character varying(254) COLLATE pg_catalog."default",
surface_m2 numeric,
surface_ha numeric,
commentair character varying(254) COLLATE pg_catalog."default",
date_creat date,
date_maj date,
num_phyto character varying(254) COLLATE pg_catalog."default",
type_unite character varying(254) COLLATE pg_catalog."default",
dynamique character varying(254) COLLATE pg_catalog."default",
gestio_obs character varying(254) COLLATE pg_catalog."default",
degrad_obs character varying(254) COLLATE pg_catalog."default",
eta_conser character varying(254) COLLATE pg_catalog."default",
clas_phyto character varying(254) COLLATE pg_catalog."default",
alli_phyto character varying(254) COLLATE pg_catalog."default",
syntaxon character varying(254) COLLATE pg_catalog."default",
n2000 character varying(254) COLLATE pg_catalog."default",
lrr_aura character varying(254) COLLATE pg_catalog."default",
lrr_cbna character varying(254) COLLATE pg_catalog."default",
lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
vege_enjeu character varying(254) COLLATE pg_catalog."default",
num_photo character varying(254) COLLATE pg_catalog."default",
nature_obs character varying(254) COLLATE pg_catalog."default",
date_sais date,
s_al_phyto character varying(254) COLLATE pg_catalog."default",
alli_name character varying(254) COLLATE pg_catalog."default",
salli_name character varying(254) COLLATE pg_catalog."default",
class_name character varying(254) COLLATE pg_catalog."default",
geom geometry(MultiPolygon,2154)
)
"""

View File

@ -1,172 +1,151 @@
import sys
import socket schemaname_distinct = """SELECT DISTINCT schemaname from pg_catalog.pg_tables
import os WHERE schemaname NOT LIKE '_archives' AND schemaname NOT LIKE 'topology' AND schemaname NOT LIKE 'information_schema' AND schemaname NOT LIKE 'pg_catalog' and schemaname NOT LIKE 'public' AND schemaname NOT LIKE '_trier'
IPAddr=socket.gethostbyname(socket.gethostname()) order by schemaname;"""
if IPAddr[0:11] == "100.100.100": #4269 schemaname_list_ref = """SELECT schemaname,tablename from pg_catalog.pg_tables
host = "100.100.100.11" WHERE schemaname NOT LIKE '_archives' AND schemaname NOT LIKE 'topology' AND schemaname NOT LIKE 'information_schema' AND schemaname NOT LIKE 'pg_catalog' and schemaname NOT LIKE 'public' AND schemaname NOT LIKE '_trier'
port = "5432" order by schemaname,tablename;"""
dbname = "sig4269" schemaname_list = """(SELECT schemaname,tablename from pg_catalog.pg_tables
sigdb="sig4269" where schemaname like 'trav%' or schemaname like '\\_ag%' or schemaname like '\\_00%' or schemaname like '\\_01%' or schemaname like '\\_07%' or schemaname like '\\_26%' or schemaname like '\\_form%' or schemaname like '\\_42%' or schemaname like '\\_69%' order by schemaname,tablename)
refdb="ref_geo4269" UNION
password = "McVities" (SELECT schemaname,matviewname AS tablename FROM pg_catalog.pg_matviews order by schemaname,tablename) order by schemaname,tablename;"""
if IPAddr[0:9] == "192.168.0": #01 geom = "geom"
host = "192.168.0.201" champ_travaux_prevus_multipolygon = """(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, surface_m2 double precision, surface_ha double precision, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))"""
port = "5432" champ_travaux_prevus_multilinestring = """(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, longueur_m double precision, longueur_km double precision, date_creation date, date_maj date, geom geometry(MultiLineString,2154))"""
dbname = "sig01" champ_travaux_prevus_point = """(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, x_wgs84 double precision, y_wgs84 double precision, date_creation date, date_maj date, geom geometry(Point,2154))"""
sigdb="sig01"
refdb="ref_geo01" champ_viergePolygone = """(gid serial NOT NULL, commentaire text, surface_m2 double precision, surface_ha double precision, geom geometry(MultiPolygon,2154))"""
password = "McVities" champ_viergeLigne = """(gid serial NOT NULL, commentaire text, longueur_m double precision, longueur_km double precision, geom geometry(MultiLineString,2154))"""
if IPAddr[0:9] == "192.168.1": #0726 champ_viergePoint = """(gid serial NOT NULL, commentaire text, x_wgs84 double precision, y_wgs84 double precision, geom geometry(Point,2154))"""
host = "192.168.1.201"
port = "5432" champ_habitat = """(gid serial NOT NULL, cd_cb_01 text, lb_cb97_fr_01 text, occupation_01 integer, cd_cb_02 text, lb_cb97_fr_02 text, occupation_02 integer, cd_cb_03 text, lb_cb97_fr_03 text, occupation_03 integer, milieu_code text, milieu_libelle text, surface_m2 double precision, surface_ha double precision, commentaire text, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))"""
dbname = "sig0726"
sigdb="sig0726" champ_contour = """(gid serial NOT NULL, date_creation date, date_maj date, utilisateur character varying, dept character(2), nom character varying, surface_m2 double precision, surface_ha double precision, type_site character varying, type_milieu character varying, date_premier_pg integer, date_debut_pg integer, date_fin_pg integer, referent character varying, gestion_deleguee character varying, terrain_militaire character(3), ens character(3), zh character(3), adapt_pmr character(3), inform character(3), guide character(3), ouverture_public character(3), obs character(3), anim character(3), n2000_anim character(3), contrat_n2000_conseil character(3), n2000_op character(3), contrat_n2000_benef character(3), contrat_agri character(3), bc_habitat integer, bc_amphibien integer, bc_coleoptere integer, bc_crustace integer, bc_mammifere integer, bc_chiroptere integer, bc_mollusque integer, bc_odonate integer, bc_oiseau integer, bc_orthoptere integer, bc_poisson integer, bc_reptile integer, bc_rhopalocere integer, bc_heterocere integer, bc_autre_invertebre integer, bc_flore integer, bc_bryophyte integer, bc_champignon integer, suiv_analyse_sol character(3), suiv_piezo character(3), suiv_climat character(3), suiv_topo character(3), suiv_habitat character(3), suiv_amphibien character(3), suiv_coleoptere character(3), suiv_crustace character(3), suiv_mammifere character(3), suiv_chiroptere character(3), suiv_mollusque character(3), suiv_odonate character(3), suiv_oiseau character(3), suiv_orthoptere character(3), suiv_poisson character(3), suiv_reptile character(3), suiv_rhopalocere character(3), suiv_heterocere character(3), suiv_autre_invertebre character(3), suiv_flore character(3), suiv_bryophyte character(3), suiv_champignon character(3), suiv_analyse_eau character(3), suiv_phenologie character(3), suiv_frequentation character(3), suiv_paysager character(3), suiv_autre character(3), commentaire text, geom geometry(MultiPolygon,2154))
refdb="ref_geo0726" """
password = "McVities"
if sys.platform == 'linux': champ_vegethab_point = """(
os_user = os.environ['USER'] gid serial NOT NULL ,
else: cd_eu_01 character varying(254) COLLATE pg_catalog."default",
os_user = os.environ['USERNAME'] lb_eu_01 character varying(254) COLLATE pg_catalog."default",
if os_user == 'STAGE': occupati_1 bigint,
os_user='stage' cd_eu_02 character varying(254) COLLATE pg_catalog."default",
lb_eu_02 character varying(254) COLLATE pg_catalog."default",
geom = "geom" occupati_2 bigint,
champ_travaux_prevus_multipolygon="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, surface_m2 double precision, surface_ha double precision, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))""" cd_eu_03 character varying(254) COLLATE pg_catalog."default",
champ_travaux_prevus_multilinestring="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, longueur_m double precision, longueur_km double precision, date_creation date, date_maj date, geom geometry(MultiLineString,2154))""" lb_eu_03 character varying(254) COLLATE pg_catalog."default",
champ_travaux_prevus_point = """(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, x_wgs84 double precision, y_wgs84 double precision, date_creation date, date_maj date, geom geometry(Point,2154))""" occupati_3 bigint,
milieu_cod character varying(254) COLLATE pg_catalog."default",
champ_viergePolygone = """(gid serial NOT NULL, commentaire text, surface_m2 double precision, surface_ha double precision, geom geometry(MultiPolygon,2154))""" milieu_lib character varying(254) COLLATE pg_catalog."default",
champ_viergeLigne = """(gid serial NOT NULL, commentaire text, longueur_m double precision, longueur_km double precision, geom geometry(MultiLineString,2154))""" surface_m2 numeric,
champ_viergePoint = """(gid serial NOT NULL, commentaire text, x_wgs84 double precision, y_wgs84 double precision, geom geometry(Point,2154))""" surface_ha numeric,
commentair character varying(254) COLLATE pg_catalog."default",
champ_habitat = """(gid serial NOT NULL, cd_cb_01 text, lb_cb97_fr_01 text, occupation_01 integer, cd_cb_02 text, lb_cb97_fr_02 text, occupation_02 integer, cd_cb_03 text, lb_cb97_fr_03 text, occupation_03 integer, milieu_code text, milieu_libelle text, surface_m2 double precision, surface_ha double precision, commentaire text, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))""" date_creat date,
date_maj date,
champ_contour="""(gid serial NOT NULL, date_creation date, date_maj date, utilisateur character varying, dept character(2), nom character varying, surface_m2 double precision, surface_ha double precision, type_site character varying, type_milieu character varying, date_premier_pg integer, date_debut_pg integer, date_fin_pg integer, referent character varying, gestion_deleguee character varying, terrain_militaire character(3), ens character(3), zh character(3), adapt_pmr character(3), inform character(3), guide character(3), ouverture_public character(3), obs character(3), anim character(3), n2000_anim character(3), contrat_n2000_conseil character(3), n2000_op character(3), contrat_n2000_benef character(3), contrat_agri character(3), bc_habitat integer, bc_amphibien integer, bc_coleoptere integer, bc_crustace integer, bc_mammifere integer, bc_chiroptere integer, bc_mollusque integer, bc_odonate integer, bc_oiseau integer, bc_orthoptere integer, bc_poisson integer, bc_reptile integer, bc_rhopalocere integer, bc_heterocere integer, bc_autre_invertebre integer, bc_flore integer, bc_bryophyte integer, bc_champignon integer, suiv_analyse_sol character(3), suiv_piezo character(3), suiv_climat character(3), suiv_topo character(3), suiv_habitat character(3), suiv_amphibien character(3), suiv_coleoptere character(3), suiv_crustace character(3), suiv_mammifere character(3), suiv_chiroptere character(3), suiv_mollusque character(3), suiv_odonate character(3), suiv_oiseau character(3), suiv_orthoptere character(3), suiv_poisson character(3), suiv_reptile character(3), suiv_rhopalocere character(3), suiv_heterocere character(3), suiv_autre_invertebre character(3), suiv_flore character(3), suiv_bryophyte character(3), suiv_champignon character(3), suiv_analyse_eau character(3), suiv_phenologie character(3), suiv_frequentation character(3), suiv_paysager character(3), suiv_autre character(3), commentaire text, geom geometry(MultiPolygon,2154)) num_phyto character varying(254) COLLATE pg_catalog."default",
""" type_unite character varying(254) COLLATE pg_catalog."default",
dynamique character varying(254) COLLATE pg_catalog."default",
champ_vegethab_point = """( gestio_obs character varying(254) COLLATE pg_catalog."default",
gid serial NOT NULL , degrad_obs character varying(254) COLLATE pg_catalog."default",
cd_eu_01 character varying(254) COLLATE pg_catalog."default", eta_conser character varying(254) COLLATE pg_catalog."default",
lb_eu_01 character varying(254) COLLATE pg_catalog."default", clas_phyto character varying(254) COLLATE pg_catalog."default",
occupati_1 bigint, alli_phyto character varying(254) COLLATE pg_catalog."default",
cd_eu_02 character varying(254) COLLATE pg_catalog."default", syntaxon character varying(254) COLLATE pg_catalog."default",
lb_eu_02 character varying(254) COLLATE pg_catalog."default", n2000 character varying(254) COLLATE pg_catalog."default",
occupati_2 bigint, lrr_aura character varying(254) COLLATE pg_catalog."default",
cd_eu_03 character varying(254) COLLATE pg_catalog."default", lrr_cbna character varying(254) COLLATE pg_catalog."default",
lb_eu_03 character varying(254) COLLATE pg_catalog."default", lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
occupati_3 bigint, vege_enjeu character varying(254) COLLATE pg_catalog."default",
milieu_cod character varying(254) COLLATE pg_catalog."default", num_photo character varying(254) COLLATE pg_catalog."default",
milieu_lib character varying(254) COLLATE pg_catalog."default", nature_obs character varying(254) COLLATE pg_catalog."default",
surface_m2 numeric, date_sais date,
surface_ha numeric, s_al_phyto character varying(254) COLLATE pg_catalog."default",
commentair character varying(254) COLLATE pg_catalog."default", alli_name character varying(254) COLLATE pg_catalog."default",
date_creat date, salli_name character varying(254) COLLATE pg_catalog."default",
date_maj date, class_name character varying(254) COLLATE pg_catalog."default",
num_phyto character varying(254) COLLATE pg_catalog."default", geom geometry(Point,2154)
type_unite character varying(254) COLLATE pg_catalog."default", )
dynamique character varying(254) COLLATE pg_catalog."default", """
gestio_obs character varying(254) COLLATE pg_catalog."default", champ_vegethab_multilinestring = """(
degrad_obs character varying(254) COLLATE pg_catalog."default", gid serial NOT NULL ,
eta_conser character varying(254) COLLATE pg_catalog."default", cd_eu_01 character varying(254) COLLATE pg_catalog."default",
clas_phyto character varying(254) COLLATE pg_catalog."default", lb_eu_01 character varying(254) COLLATE pg_catalog."default",
alli_phyto character varying(254) COLLATE pg_catalog."default", occupati_1 bigint,
syntaxon character varying(254) COLLATE pg_catalog."default", cd_eu_02 character varying(254) COLLATE pg_catalog."default",
n2000 character varying(254) COLLATE pg_catalog."default", lb_eu_02 character varying(254) COLLATE pg_catalog."default",
lrr_aura character varying(254) COLLATE pg_catalog."default", occupati_2 bigint,
lrr_cbna character varying(254) COLLATE pg_catalog."default", cd_eu_03 character varying(254) COLLATE pg_catalog."default",
lrr_cbnmc character varying(254) COLLATE pg_catalog."default", lb_eu_03 character varying(254) COLLATE pg_catalog."default",
vege_enjeu character varying(254) COLLATE pg_catalog."default", occupati_3 bigint,
num_photo character varying(254) COLLATE pg_catalog."default", milieu_cod character varying(254) COLLATE pg_catalog."default",
nature_obs character varying(254) COLLATE pg_catalog."default", milieu_lib character varying(254) COLLATE pg_catalog."default",
date_sais date, surface_m2 numeric,
s_al_phyto character varying(254) COLLATE pg_catalog."default", surface_ha numeric,
alli_name character varying(254) COLLATE pg_catalog."default", commentair character varying(254) COLLATE pg_catalog."default",
salli_name character varying(254) COLLATE pg_catalog."default", date_creat date,
class_name character varying(254) COLLATE pg_catalog."default", date_maj date,
geom geometry(Point,2154) num_phyto character varying(254) COLLATE pg_catalog."default",
) type_unite character varying(254) COLLATE pg_catalog."default",
""" dynamique character varying(254) COLLATE pg_catalog."default",
champ_vegethab_multilinestring = """( gestio_obs character varying(254) COLLATE pg_catalog."default",
gid serial NOT NULL , degrad_obs character varying(254) COLLATE pg_catalog."default",
cd_eu_01 character varying(254) COLLATE pg_catalog."default", eta_conser character varying(254) COLLATE pg_catalog."default",
lb_eu_01 character varying(254) COLLATE pg_catalog."default", clas_phyto character varying(254) COLLATE pg_catalog."default",
occupati_1 bigint, alli_phyto character varying(254) COLLATE pg_catalog."default",
cd_eu_02 character varying(254) COLLATE pg_catalog."default", syntaxon character varying(254) COLLATE pg_catalog."default",
lb_eu_02 character varying(254) COLLATE pg_catalog."default", n2000 character varying(254) COLLATE pg_catalog."default",
occupati_2 bigint, lrr_aura character varying(254) COLLATE pg_catalog."default",
cd_eu_03 character varying(254) COLLATE pg_catalog."default", lrr_cbna character varying(254) COLLATE pg_catalog."default",
lb_eu_03 character varying(254) COLLATE pg_catalog."default", lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
occupati_3 bigint, vege_enjeu character varying(254) COLLATE pg_catalog."default",
milieu_cod character varying(254) COLLATE pg_catalog."default", num_photo character varying(254) COLLATE pg_catalog."default",
milieu_lib character varying(254) COLLATE pg_catalog."default", nature_obs character varying(254) COLLATE pg_catalog."default",
surface_m2 numeric, date_sais date,
surface_ha numeric, s_al_phyto character varying(254) COLLATE pg_catalog."default",
commentair character varying(254) COLLATE pg_catalog."default", alli_name character varying(254) COLLATE pg_catalog."default",
date_creat date, salli_name character varying(254) COLLATE pg_catalog."default",
date_maj date, class_name character varying(254) COLLATE pg_catalog."default",
num_phyto character varying(254) COLLATE pg_catalog."default", geom geometry(MultiLineString,2154)
type_unite character varying(254) COLLATE pg_catalog."default", )
dynamique character varying(254) COLLATE pg_catalog."default", """
gestio_obs character varying(254) COLLATE pg_catalog."default", champ_vegethab_multipolygon = """(
degrad_obs character varying(254) COLLATE pg_catalog."default", gid serial NOT NULL ,
eta_conser character varying(254) COLLATE pg_catalog."default", cd_eu_01 character varying(254) COLLATE pg_catalog."default",
clas_phyto character varying(254) COLLATE pg_catalog."default", lb_eu_01 character varying(254) COLLATE pg_catalog."default",
alli_phyto character varying(254) COLLATE pg_catalog."default", occupati_1 bigint,
syntaxon character varying(254) COLLATE pg_catalog."default", cd_eu_02 character varying(254) COLLATE pg_catalog."default",
n2000 character varying(254) COLLATE pg_catalog."default", lb_eu_02 character varying(254) COLLATE pg_catalog."default",
lrr_aura character varying(254) COLLATE pg_catalog."default", occupati_2 bigint,
lrr_cbna character varying(254) COLLATE pg_catalog."default", cd_eu_03 character varying(254) COLLATE pg_catalog."default",
lrr_cbnmc character varying(254) COLLATE pg_catalog."default", lb_eu_03 character varying(254) COLLATE pg_catalog."default",
vege_enjeu character varying(254) COLLATE pg_catalog."default", occupati_3 bigint,
num_photo character varying(254) COLLATE pg_catalog."default", milieu_cod character varying(254) COLLATE pg_catalog."default",
nature_obs character varying(254) COLLATE pg_catalog."default", milieu_lib character varying(254) COLLATE pg_catalog."default",
date_sais date, surface_m2 numeric,
s_al_phyto character varying(254) COLLATE pg_catalog."default", surface_ha numeric,
alli_name character varying(254) COLLATE pg_catalog."default", commentair character varying(254) COLLATE pg_catalog."default",
salli_name character varying(254) COLLATE pg_catalog."default", date_creat date,
class_name character varying(254) COLLATE pg_catalog."default", date_maj date,
geom geometry(MultiLineString,2154) num_phyto character varying(254) COLLATE pg_catalog."default",
) type_unite character varying(254) COLLATE pg_catalog."default",
""" dynamique character varying(254) COLLATE pg_catalog."default",
champ_vegethab_multipolygon = """( gestio_obs character varying(254) COLLATE pg_catalog."default",
gid serial NOT NULL , degrad_obs character varying(254) COLLATE pg_catalog."default",
cd_eu_01 character varying(254) COLLATE pg_catalog."default", eta_conser character varying(254) COLLATE pg_catalog."default",
lb_eu_01 character varying(254) COLLATE pg_catalog."default", clas_phyto character varying(254) COLLATE pg_catalog."default",
occupati_1 bigint, alli_phyto character varying(254) COLLATE pg_catalog."default",
cd_eu_02 character varying(254) COLLATE pg_catalog."default", syntaxon character varying(254) COLLATE pg_catalog."default",
lb_eu_02 character varying(254) COLLATE pg_catalog."default", n2000 character varying(254) COLLATE pg_catalog."default",
occupati_2 bigint, lrr_aura character varying(254) COLLATE pg_catalog."default",
cd_eu_03 character varying(254) COLLATE pg_catalog."default", lrr_cbna character varying(254) COLLATE pg_catalog."default",
lb_eu_03 character varying(254) COLLATE pg_catalog."default", lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
occupati_3 bigint, vege_enjeu character varying(254) COLLATE pg_catalog."default",
milieu_cod character varying(254) COLLATE pg_catalog."default", num_photo character varying(254) COLLATE pg_catalog."default",
milieu_lib character varying(254) COLLATE pg_catalog."default", nature_obs character varying(254) COLLATE pg_catalog."default",
surface_m2 numeric, date_sais date,
surface_ha numeric, s_al_phyto character varying(254) COLLATE pg_catalog."default",
commentair character varying(254) COLLATE pg_catalog."default", alli_name character varying(254) COLLATE pg_catalog."default",
date_creat date, salli_name character varying(254) COLLATE pg_catalog."default",
date_maj date, class_name character varying(254) COLLATE pg_catalog."default",
num_phyto character varying(254) COLLATE pg_catalog."default", geom geometry(MultiPolygon,2154)
type_unite character varying(254) COLLATE pg_catalog."default", )
dynamique character varying(254) COLLATE pg_catalog."default", """
gestio_obs character varying(254) COLLATE pg_catalog."default",
degrad_obs character varying(254) COLLATE pg_catalog."default",
eta_conser character varying(254) COLLATE pg_catalog."default",
clas_phyto character varying(254) COLLATE pg_catalog."default",
alli_phyto character varying(254) COLLATE pg_catalog."default",
syntaxon character varying(254) COLLATE pg_catalog."default",
n2000 character varying(254) COLLATE pg_catalog."default",
lrr_aura character varying(254) COLLATE pg_catalog."default",
lrr_cbna character varying(254) COLLATE pg_catalog."default",
lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
vege_enjeu character varying(254) COLLATE pg_catalog."default",
num_photo character varying(254) COLLATE pg_catalog."default",
nature_obs character varying(254) COLLATE pg_catalog."default",
date_sais date,
s_al_phyto character varying(254) COLLATE pg_catalog."default",
alli_name character varying(254) COLLATE pg_catalog."default",
salli_name character varying(254) COLLATE pg_catalog."default",
class_name character varying(254) COLLATE pg_catalog."default",
geom geometry(MultiPolygon,2154)
)
"""

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="128px" height="128px" viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve">
<polygon fill="#EE7913" points="68.613,69.625 86.891,69.625 71.697,54.625 52.613,54.625 52.613,72.746 68.613,88.548 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="402.5244" y1="-220.8706" x2="400.6479" y2="-97.5023" gradientTransform="matrix(1 0 0 -1 -300.5195 -92.5547)">
<stop offset="0" style="stop-color:#589632"/>
<stop offset="1" style="stop-color:#93B023"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="126.613,109.057 94.488,77.625 76.613,77.625 76.613,96.033 107.143,126.625
126.613,126.625 "/>
<polygon fill="#F0E64A" points="76.613,77.625 94.488,77.625 86.891,69.625 68.613,69.625 68.613,88.548 76.613,96.033 "/>
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="365.4619" y1="-221.1455" x2="363.5923" y2="-98.227" gradientTransform="matrix(1 0 0 -1 -300.5195 -92.5547)">
<stop offset="0" style="stop-color:#589632"/>
<stop offset="1" style="stop-color:#93B023"/>
</linearGradient>
<path fill="url(#SVGID_2_)" d="M68.923,101.552c-1.165,0.242-1.769,0.157-4.685,0.157c-20.866,0-38.612-17.158-38.612-39.406
c0-22.248,17.551-39.027,38.612-39.027s37.833,16.78,37.833,39.027c0,3.619-0.451,7.099-1.284,10.398L120.1,92.012
c4.979-8.726,7.765-18.869,7.765-29.857c0-34.289-27.363-59.963-64.016-59.963C27.363,2.191,0,27.696,0,62.154
c0,34.625,27.363,60.638,63.848,60.638c9.417,0,16.069-1.469,23.042-3.761L68.923,101.552z"/>
<polygon opacity="0.15" fill="#FFFFFF" enable-background="new " points="53.083,54.625 71.697,54.625 126.613,109.057
126.613,126.625 "/>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,230 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24"
height="24"
id="svg5692"
version="1.1"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="mActionAddRasterLayer.svg"
inkscape:export-filename="/home/denis/Desktop/oracle.png"
inkscape:export-xdpi="67.5"
inkscape:export-ydpi="67.5">
<title
id="title2829">GIS icon theme 0.2</title>
<defs
id="defs5694">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 16 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="32 : 16 : 1"
inkscape:persp3d-origin="16 : 10.666667 : 1"
id="perspective3486" />
<inkscape:perspective
id="perspective3496"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3600"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective7871"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective8710"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective9811"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective4762"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.539029"
inkscape:cx="0.66325675"
inkscape:cy="15.235866"
inkscape:current-layer="layer2"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
borderlayer="false"
inkscape:window-width="1855"
inkscape:window-height="1056"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:snap-global="true"
showguides="true"
inkscape:guide-bbox="true"
inkscape:snap-object-midpoints="false"
inkscape:snap-grids="true"
inkscape:object-paths="false">
<inkscape:grid
type="xygrid"
id="grid5700"
empspacing="5"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
dotted="true"
originx="2.5px"
originy="2.5px" />
</sodipodi:namedview>
<metadata
id="metadata5697">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>GIS icon theme 0.2</dc:title>
<dc:creator>
<cc:Agent>
<dc:title>Robert Szczepanek</dc:title>
</cc:Agent>
</dc:creator>
<dc:rights>
<cc:Agent>
<dc:title>Robert Szczepanek</dc:title>
</cc:Agent>
</dc:rights>
<dc:subject>
<rdf:Bag>
<rdf:li>GIS icons</rdf:li>
</rdf:Bag>
</dc:subject>
<dc:coverage>GIS icons</dc:coverage>
<dc:description>http://robert.szczepanek.pl/</dc:description>
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/3.0/" />
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/3.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Layer"
style="display:inline"
transform="translate(0,-8)">
<rect
style="fill:#6e97c4;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="rect6419"
width="7.999999"
height="7.999999"
x="7.9999986"
y="7.9999995" />
<rect
style="fill:#2b3b4d;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
id="rect6419-6"
width="7.999999"
height="7.999999"
x="16.000002"
y="7.9999995" />
<rect
style="fill:#2b3b4d;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
id="rect6419-6-9"
width="7.999999"
height="7.999999"
x="7.9999986"
y="16"
inkscape:transform-center-x="-3.9999992"
inkscape:transform-center-y="-5.3333316" />
<rect
style="fill:#6d97c4;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
id="rect6419-0"
width="7.999999"
height="7.999999"
x="16.000002"
y="16" />
<rect
style="fill:#2d3e4d;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
id="rect6419-6-7"
width="7.999999"
height="7.999999"
x="-4.7683716e-07"
y="7.9999995" />
<rect
style="fill:#6d97c4;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
id="rect6419-3"
width="7.999999"
height="7.999999"
x="-4.7683716e-07"
y="16" />
<rect
style="fill:#6d97c4;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
id="rect6419-5"
width="7.999999"
height="7.999999"
x="7.9999986"
y="24.000002" />
<rect
style="fill:#2b3b4d;fill-opacity:1;fill-rule:nonzero;stroke:none;display:inline"
id="rect6419-6-6"
width="7.999999"
height="7.999999"
x="-4.7683716e-07"
y="24.000002" />
<rect
style="fill:none;stroke:none"
id="rect6554"
width="23.999998"
height="23.999998"
x="-4.7683716e-07"
y="7.9999995" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@ -0,0 +1,312 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24"
height="24"
id="svg5692"
version="1.1"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="mActionAddWfsLayer.svg"
inkscape:export-filename="/media/home1/robert/svn/graphics/trunk/toolbar-icons/32x32/layer-vector.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<title
id="title2829">GIS icon theme 0.2</title>
<defs
id="defs5694">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 16 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="32 : 16 : 1"
inkscape:persp3d-origin="16 : 10.666667 : 1"
id="perspective3486" />
<inkscape:perspective
id="perspective3496"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3600"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective7871"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective8710"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective9811"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective4762"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
id="perspective4762-4" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
id="perspective9811-2" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
id="perspective8710-0" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
id="perspective7871-7" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
id="perspective3600-9" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
id="perspective3496-4" />
<inkscape:perspective
id="perspective3486-0"
inkscape:persp3d-origin="16 : 10.666667 : 1"
inkscape:vp_z="32 : 16 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 16 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3952"
inkscape:persp3d-origin="12 : 8 : 1"
inkscape:vp_z="24 : 12 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 12 : 1"
sodipodi:type="inkscape:persp3d" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="16"
inkscape:cx="-0.094554179"
inkscape:cy="17.125349"
inkscape:current-layer="layer2"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
borderlayer="false"
inkscape:window-width="1855"
inkscape:window-height="1056"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:snap-global="true"
showguides="true"
inkscape:guide-bbox="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-grids="false"
inkscape:object-paths="false"
inkscape:snap-bbox="true"
inkscape:object-nodes="true">
<inkscape:grid
type="xygrid"
id="grid5700"
empspacing="5"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
dotted="true"
originx="2.5px"
originy="2.5px" />
</sodipodi:namedview>
<metadata
id="metadata5697">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>GIS icon theme 0.2</dc:title>
<dc:creator>
<cc:Agent>
<dc:title>Robert Szczepanek</dc:title>
</cc:Agent>
</dc:creator>
<dc:rights>
<cc:Agent>
<dc:title>Robert Szczepanek</dc:title>
</cc:Agent>
</dc:rights>
<dc:subject>
<rdf:Bag>
<rdf:li>GIS icons</rdf:li>
</rdf:Bag>
</dc:subject>
<dc:coverage>GIS icons</dc:coverage>
<dc:description>http://robert.szczepanek.pl/</dc:description>
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/3.0/" />
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/3.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Layer"
style="display:inline"
transform="translate(0,-8)">
<g
id="g3028"
transform="matrix(0.75161647,0,0,0.75161647,-0.02586348,9.4769448)">
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path3775"
d="m 16.000001,1.0775438 c 9.467477,4.6992805 8.114981,22.3215822 0,25.8460432"
style="fill:none;stroke:#749fcf;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
inkscape:connector-curvature="0"
id="path3773"
d="m 1.1225356,14.000566 29.7549294,0"
style="fill:none;stroke:#749fcf;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path3773-1"
d="m 2.9484075,6.9340877 c 7.5739815,1.0094969 18.3939565,1.0094969 25.9679385,0"
style="fill:none;stroke:#749fcf;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path3773-4"
d="m 2.9484075,21.067042 c 7.5739815,-1.009496 18.3939565,-1.009496 25.9679385,0"
style="fill:none;stroke:#749fcf;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path3777"
d="m 16.000001,1.0775438 c -8.1149812,3.5244605 -9.467478,21.1467632 0,25.8460432"
style="fill:none;stroke:#749fcf;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
transform="matrix(1.2562074,0,0,1.0871977,22.465232,-1.0129089)"
d="m 6.9656949,13.809332 c 0,6.713955 -5.4228716,12.15669 -12.1123228,12.15669 -6.6894511,0 -12.1123231,-5.442735 -12.1123231,-12.15669 0,-6.7139549 5.422872,-12.1566907 12.1123231,-12.1566907 6.6894512,0 12.1123228,5.4427358 12.1123228,12.1566907 z"
sodipodi:ry="12.156691"
sodipodi:rx="12.112323"
sodipodi:cy="13.809332"
sodipodi:cx="-5.1466279"
id="path3003"
style="fill:none;stroke:#5488c4;stroke-width:1.28353083;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
sodipodi:type="arc" />
<path
sodipodi:nodetypes="cccc"
id="path2960"
d="M 7.3400991,7.2779254 13.185401,22.026434 19.613856,7.4154701 24.89957,7.3945152"
style="color:#000000;fill:none;stroke:#172739;stroke-width:1.29794168;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
inkscape:connector-curvature="0" />
<path
transform="matrix(1.5475161,0,0,1.6212881,1.923793,-12.988176)"
d="m 4.5,12.5 c 0,0.552285 -0.4477153,1 -1,1 -0.5522847,0 -1,-0.447715 -1,-1 0,-0.552285 0.4477153,-1 1,-1 0.5522847,0 1,0.447715 1,1 z"
sodipodi:ry="1"
sodipodi:rx="1"
sodipodi:cy="12.5"
sodipodi:cx="3.5"
id="path2958"
style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#172739;stroke-width:0.94698602;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
sodipodi:type="arc" />
<path
transform="matrix(1.5839392,0,0,1.6212881,7.641614,1.7603321)"
d="m 4.5,12.5 c 0,0.552285 -0.4477153,1 -1,1 -0.5522847,0 -1,-0.447715 -1,-1 0,-0.552285 0.4477153,-1 1,-1 0.5522847,0 1,0.447715 1,1 z"
sodipodi:ry="1"
sodipodi:rx="1"
sodipodi:cy="12.5"
sodipodi:cx="3.5"
id="path2958-0"
style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#172739;stroke-width:0.93603462;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
sodipodi:type="arc" />
<path
transform="matrix(1.5475161,0,0,1.6212881,14.034218,-12.884972)"
d="m 4.5,12.5 c 0,0.552285 -0.4477153,1 -1,1 -0.5522847,0 -1,-0.447715 -1,-1 0,-0.552285 0.4477153,-1 1,-1 0.5522847,0 1,0.447715 1,1 z"
sodipodi:ry="1"
sodipodi:rx="1"
sodipodi:cy="12.5"
sodipodi:cx="3.5"
id="path2958-9"
style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#172739;stroke-width:0.94698602;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
sodipodi:type="arc" />
<path
transform="matrix(1.5475161,0,0,1.6212881,19.483264,-12.871586)"
d="m 4.5,12.5 c 0,0.552285 -0.4477153,1 -1,1 -0.5522847,0 -1,-0.447715 -1,-1 0,-0.552285 0.4477153,-1 1,-1 0.5522847,0 1,0.447715 1,1 z"
sodipodi:ry="1"
sodipodi:rx="1"
sodipodi:cy="12.5"
sodipodi:cx="3.5"
id="path2958-6"
style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#172739;stroke-width:0.94698602;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
sodipodi:type="arc" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -2,10 +2,8 @@
import configparser import configparser
import shutil import shutil
import os
import tempfile import tempfile
import base64
import psycopg2
import psycopg2.extras
from os.path import abspath, join, pardir, dirname from os.path import abspath, join, pardir, dirname
from qgis.PyQt import uic from qgis.PyQt import uic
@ -80,6 +78,16 @@ def plugin_test_data_path(*args, copy=False):
return path return path
def pyperclip():
dst = dirname(dirname(__file__)) + "\\tools\\"
if os.access('N:/', os.R_OK):
src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
try:
shutil.copy(src, dst)
except NameError:
print('404')
def resources_path(*args): def resources_path(*args):
"""Get the path to our resources folder. """Get the path to our resources folder.
@ -107,77 +115,64 @@ def load_ui(*args):
return ui_class return ui_class
def login_base(take=None):
from .tools.PythonSQL import host,port,dbname,password,os_user
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) def send_issues(url, titre, body, labels):
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take:
return cur,con
else:
return cur
def send_issues(url,titre,body,labels):
import requests import requests
import json import json
import os # import os
import qgis # import qgis
usr = os.environ['USERNAME'] # usr = os.environ['USERNAME']
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112' token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
url=url+'?token='+token url = url + '?token=' + token
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
headers = {'Authorization': 'token ' + token, 'accept': 'application/json', 'Content-Type': 'application/json'}
payload = {'title': titre, 'body': body, 'labels': labels} payload = {'title': titre, 'body': body, 'labels': labels}
try: try:
urllib.request.urlopen('https://google.com') urllib.request.urlopen('https://google.com')
binar = True binar = True
except: except NameError:
binar = False binar = False
r = '' r = ''
if binar: if binar:
r = requests.post(url, data=json.dumps(payload), headers=headers) r = requests.post(url, data=json.dumps(payload), headers=headers)
return r return r
def maj_verif(NAME): def maj_verif(NAME):
import qgis import qgis
import urllib.request import urllib.request
iface = qgis.utils.iface iface = qgis.utils.iface
from qgis.core import Qgis from qgis.core import Qgis
url = qgis.utils.pluginMetadata(NAME,'repository') # url = qgis.utils.pluginMetadata(NAME, 'repository')
#URL = url+'/raw/branch/main/plugins.xml' # URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME, 'version')
len_version = len(version) len_version = len(version)
try: try:
urllib.request.urlopen('https://google.com') urllib.request.urlopen('https://google.com')
binar = True binar = True
except: except NameError:
binar = False binar = False
if binar: if binar:
version_web = str(urllib.request.urlopen(URL).read()) try:
plugin_num = version_web.find(NAME) version_web = str(urllib.request.urlopen(URL).read())
valeur_version_web = version_web.find('<version>',plugin_num)+9 plugin_num = version_web.find(NAME)
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version] valeur_version_web = version_web.find('<version>', plugin_num) + 9
if version_plugin != version: version_plugin = version_web[valeur_version_web: valeur_version_web + len_version]
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30) if version_plugin != version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
except NameError:
print("error gitea version ssl")
else: else:
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30) iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
def devlog(NAME): def devlog(NAME):
import qgis import qgis
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>' devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
devmaj = devmaj+qgis.utils.pluginMetadata(NAME,'changelog') devmaj = devmaj + qgis.utils.pluginMetadata(NAME, 'changelog')
return devmaj return devmaj

View File

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>Dialog</class> <class>Dialog</class>
<resources>
</resources>
<widget class="QDialog" name="Dialog"> <widget class="QDialog" name="Dialog">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -65,8 +63,8 @@
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>350</x> <x>345</x>
<y>20</y> <y>10</y>
<width>221</width> <width>221</width>
<height>71</height> <height>71</height>
</rect> </rect>
@ -75,7 +73,7 @@
<string/> <string/>
</property> </property>
<property name="pixmap"> <property name="pixmap">
<pixmap resource="resources.qrc">:/plugins/CenRa_FLUX/logo.jpg</pixmap> <pixmap>:/plugins/CenRa_FLUX/logo.jpg</pixmap>
</property> </property>
<property name="scaledContents"> <property name="scaledContents">
<bool>true</bool> <bool>true</bool>
@ -139,7 +137,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="resources.qrc"> <iconset>
<normaloff>:/plugins/CenRa_FLUX/arrow-bottom.png</normaloff>:/plugins/CenRa_FLUX/arrow-bottom.png</iconset> <normaloff>:/plugins/CenRa_FLUX/arrow-bottom.png</normaloff>:/plugins/CenRa_FLUX/arrow-bottom.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -162,7 +160,7 @@
<string/> <string/>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="resources.qrc"> <iconset>
<normaloff>:/plugins/CenRa_FLUX/arrow-up.png</normaloff>:/plugins/CenRa_FLUX/arrow-up.png</iconset> <normaloff>:/plugins/CenRa_FLUX/arrow-up.png</normaloff>:/plugins/CenRa_FLUX/arrow-up.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@ -237,6 +235,18 @@
<string>Flux sélectionné(s) à charger :</string> <string>Flux sélectionné(s) à charger :</string>
</property> </property>
</widget> </widget>
<zorder>label_3</zorder>
<zorder>comboBox</zorder>
<zorder>comboBox_2</zorder>
<zorder>pushButton_2</zorder>
<zorder>tableWidget</zorder>
<zorder>tableWidget_2</zorder>
<zorder>commandLinkButton</zorder>
<zorder>commandLinkButton_2</zorder>
<zorder>lineEdit</zorder>
<zorder>label</zorder>
<zorder>label_2</zorder>
</widget> </widget>
<resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -9,243 +9,387 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>910</width> <width>890</width>
<height>800</height> <height>810</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>910</width> <width>600</width>
<height>800</height> <height>400</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>910</width> <width>890</width>
<height>800</height> <height>810</height>
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>SIG CEN-RA</string> <string>SIG CEN-RA</string>
</property> </property>
<widget class="QComboBox" name="comboBox"> <property name="sizeGripEnabled">
<property name="geometry"> <bool>false</bool>
<rect> </property>
<x>260</x> <layout class="QGridLayout" name="gridLayout">
<y>130</y> <property name="sizeConstraint">
<width>171</width> <enum>QLayout::SetMaximumSize</enum>
<height>22</height>
</rect>
</property> </property>
<property name="editable"> <property name="leftMargin">
<bool>false</bool> <number>0</number>
</property> </property>
<property name="currentText"> <property name="topMargin">
<string notr="true"/> <number>0</number>
</property> </property>
</widget> <property name="rightMargin">
<widget class="QComboBox" name="comboBox_2"> <number>0</number>
<property name="geometry">
<rect>
<x>370</x>
<y>80</y>
<width>171</width>
<height>22</height>
</rect>
</property> </property>
<property name="editable"> <property name="bottomMargin">
<bool>false</bool> <number>0</number>
</property> </property>
<property name="currentText"> <property name="spacing">
<string notr="true"/> <number>0</number>
</property> </property>
</widget> <item row="0" column="0">
<widget class="QLabel" name="label_3"> <widget class="QScrollArea" name="scrollArea">
<property name="geometry"> <property name="maximumSize">
<rect> <size>
<x>345</x> <width>890</width>
<y>10</y> <height>810</height>
<width>221</width> </size>
<height>71</height> </property>
</rect> <property name="inputMethodHints">
</property> <set>Qt::ImhNoEditMenu|Qt::ImhNoTextHandles</set>
<property name="text"> </property>
<string/> <property name="frameShape">
</property> <enum>QFrame::NoFrame</enum>
<property name="pixmap"> </property>
<pixmap>:/plugins/CenRa_FLUX/logo.jpg</pixmap> <property name="frameShadow">
</property> <enum>QFrame::Sunken</enum>
<property name="scaledContents"> </property>
<bool>true</bool> <property name="lineWidth">
</property> <number>0</number>
</widget> </property>
<widget class="QPushButton" name="pushButton_2"> <property name="midLineWidth">
<property name="geometry"> <number>0</number>
<rect> </property>
<x>370</x> <property name="verticalScrollBarPolicy">
<y>750</y> <enum>Qt::ScrollBarAlwaysOff</enum>
<width>171</width> </property>
<height>23</height> <property name="horizontalScrollBarPolicy">
</rect> <enum>Qt::ScrollBarAlwaysOff</enum>
</property> </property>
<property name="text"> <widget class="QWidget" name="scrollAreaWidgetContents_2">
<string>Charger les couches</string> <property name="geometry">
</property> <rect>
</widget> <x>0</x>
<widget class="QTableWidget" name="tableWidget"> <y>0</y>
<property name="enabled"> <width>890</width>
<bool>true</bool> <height>810</height>
</property> </rect>
<property name="geometry"> </property>
<rect> <property name="maximumSize">
<x>30</x> <size>
<y>170</y> <width>890</width>
<width>850</width> <height>810</height>
<height>281</height> </size>
</rect> </property>
</property> <widget class="QCommandLinkButton" name="commandLinkButton_2">
<property name="selectionMode"> <property name="geometry">
<enum>QAbstractItemView::SingleSelection</enum> <rect>
</property> <x>450</x>
<property name="sortingEnabled"> <y>470</y>
<bool>true</bool> <width>61</width>
</property> <height>61</height>
</widget> </rect>
<widget class="QTableWidget" name="tableWidget_2"> </property>
<property name="geometry"> <property name="text">
<rect> <string/>
<x>30</x> </property>
<y>550</y> <property name="icon">
<width>850</width> <iconset>
<height>181</height> <normaloff>:/plugins/CenRa_FLUX/arrow-up.png</normaloff>:/plugins/CenRa_FLUX/arrow-up.png</iconset>
</rect> </property>
</property> <property name="iconSize">
<property name="selectionMode"> <size>
<enum>QAbstractItemView::SingleSelection</enum> <width>50</width>
</property> <height>40</height>
</widget> </size>
<widget class="QCommandLinkButton" name="commandLinkButton"> </property>
<property name="geometry"> </widget>
<rect> <widget class="QPushButton" name="pushButton_2">
<x>400</x> <property name="geometry">
<y>470</y> <rect>
<width>61</width> <x>360</x>
<height>61</height> <y>750</y>
</rect> <width>171</width>
</property> <height>23</height>
<property name="text"> </rect>
<string/> </property>
</property> <property name="text">
<property name="icon"> <string>Charger les couches</string>
<iconset> </property>
<normaloff>:/plugins/CenRa_FLUX/arrow-bottom.png</normaloff>:/plugins/CenRa_FLUX/arrow-bottom.png</iconset> </widget>
</property> <widget class="QLabel" name="label">
<property name="iconSize"> <property name="geometry">
<size> <rect>
<width>50</width> <x>30</x>
<height>40</height> <y>150</y>
</size> <width>161</width>
</property> <height>16</height>
</widget> </rect>
<widget class="QCommandLinkButton" name="commandLinkButton_2"> </property>
<property name="geometry"> <property name="font">
<rect> <font>
<x>460</x> <family>Calibri</family>
<y>470</y> <pointsize>10</pointsize>
<width>61</width> <italic>false</italic>
<height>61</height> </font>
</rect> </property>
</property> <property name="text">
<property name="text"> <string>Liste des flux disponibles :</string>
<string/> </property>
</property> </widget>
<property name="icon"> <widget class="QTableWidget" name="tableWidget_2">
<iconset> <property name="geometry">
<normaloff>:/plugins/CenRa_FLUX/arrow-up.png</normaloff>:/plugins/CenRa_FLUX/arrow-up.png</iconset> <rect>
</property> <x>20</x>
<property name="iconSize"> <y>550</y>
<size> <width>851</width>
<width>50</width> <height>181</height>
<height>40</height> </rect>
</size> </property>
</property> <property name="inputMethodHints">
</widget> <set>Qt::ImhNoEditMenu|Qt::ImhNoTextHandles</set>
<widget class="QLineEdit" name="lineEdit"> </property>
<property name="enabled"> <property name="selectionMode">
<bool>true</bool> <enum>QAbstractItemView::SingleSelection</enum>
</property> </property>
<property name="geometry"> <property name="selectionBehavior">
<rect> <enum>QAbstractItemView::SelectRows</enum>
<x>480</x> </property>
<y>130</y> </widget>
<width>171</width> <widget class="QComboBox" name="comboBox">
<height>21</height> <property name="geometry">
</rect> <rect>
</property> <x>250</x>
<property name="text"> <y>130</y>
<string>Recherche par mots-clés</string> <width>171</width>
</property> <height>22</height>
<property name="alignment"> </rect>
<set>Qt::AlignCenter</set> </property>
</property> <property name="editable">
<property name="readOnly"> <bool>false</bool>
<bool>false</bool> </property>
</property> <property name="currentText">
<property name="clearButtonEnabled"> <string notr="true"/>
<bool>true</bool> </property>
</property> </widget>
</widget> <widget class="QLineEdit" name="lineEdit">
<widget class="QLabel" name="label"> <property name="enabled">
<property name="geometry"> <bool>true</bool>
<rect> </property>
<x>40</x> <property name="geometry">
<y>150</y> <rect>
<width>161</width> <x>470</x>
<height>16</height> <y>130</y>
</rect> <width>171</width>
</property> <height>21</height>
<property name="font"> </rect>
<font> </property>
<family>Calibri</family> <property name="text">
<pointsize>10</pointsize> <string>Recherche par mots-clés</string>
<italic>false</italic> </property>
</font> <property name="alignment">
</property> <set>Qt::AlignCenter</set>
<property name="text"> </property>
<string>Liste des flux disponibles :</string> <property name="readOnly">
</property> <bool>false</bool>
</widget> </property>
<widget class="QLabel" name="label_2"> <property name="clearButtonEnabled">
<property name="geometry"> <bool>true</bool>
<rect> </property>
<x>30</x> </widget>
<y>530</y> <widget class="QToolButton" name="toolButton">
<width>171</width> <property name="geometry">
<height>16</height> <rect>
</rect> <x>660</x>
</property> <y>130</y>
<property name="font"> <width>21</width>
<font> <height>21</height>
<family>Calibri</family> </rect>
<pointsize>10</pointsize> </property>
<italic>false</italic> <property name="text">
</font> <string/>
</property> </property>
<property name="text"> </widget>
<string>Flux sélectionné(s) à charger :</string> <widget class="QTableWidget" name="tableWidget">
</property> <property name="enabled">
</widget> <bool>true</bool>
<zorder>label_3</zorder> </property>
<zorder>comboBox</zorder> <property name="geometry">
<zorder>comboBox_2</zorder> <rect>
<zorder>pushButton_2</zorder> <x>20</x>
<zorder>tableWidget</zorder> <y>170</y>
<zorder>tableWidget_2</zorder> <width>850</width>
<zorder>commandLinkButton</zorder> <height>281</height>
<zorder>commandLinkButton_2</zorder> </rect>
<zorder>lineEdit</zorder> </property>
<zorder>label</zorder> <property name="sizePolicy">
<zorder>label_2</zorder> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editTriggers">
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>530</y>
<width>171</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<family>Calibri</family>
<pointsize>10</pointsize>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Flux sélectionné(s) à charger :</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>335</x>
<y>10</y>
<width>221</width>
<height>71</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/plugins/CenRa_FLUX/logo.jpg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QComboBox" name="comboBox_2">
<property name="geometry">
<rect>
<x>360</x>
<y>80</y>
<width>171</width>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>false</bool>
</property>
<property name="currentText">
<string notr="true"/>
</property>
</widget>
<widget class="QCommandLinkButton" name="commandLinkButton">
<property name="geometry">
<rect>
<x>390</x>
<y>470</y>
<width>61</width>
<height>61</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>:/plugins/CenRa_FLUX/arrow-bottom.png</normaloff>:/plugins/CenRa_FLUX/arrow-bottom.png</iconset>
</property>
<property name="iconSize">
<size>
<width>50</width>
<height>40</height>
</size>
</property>
</widget>
<widget class="QCheckBox" name="checkBox">
<property name="geometry">
<rect>
<x>830</x>
<y>20</y>
<width>70</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QComboBox" name="DeBUG">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>71</width>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>false</bool>
</property>
<property name="currentText">
<string notr="true"/>
</property>
</widget>
<widget class="QTextBrowser" name="viewer">
<property name="geometry">
<rect>
<x>90</x>
<y>10</y>
<width>731</width>
<height>731</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgba(255, 255, 255,0.50);</string>
</property>
</widget>
</widget>
</widget>
</item>
</layout>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Metabase</string> <string>Journal des modifications</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset>
@ -29,9 +29,6 @@
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -41,7 +38,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>453</width> <width>453</width>
<height>547</height> <height>570</height>
</rect> </rect>
</property> </property>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
@ -56,7 +53,7 @@
<property name="title"> <property name="title">
<string>DevLog</string> <string>DevLog</string>
</property> </property>
<widget class="QWebView" name="viewer" native="true"> <widget class="QTextBrowser" name="viewer">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
@ -65,11 +62,6 @@
<height>511</height> <height>511</height>
</rect> </rect>
</property> </property>
<property name="url" stdset="0">
<url>
<string>about:blank</string>
</url>
</property>
</widget> </widget>
</widget> </widget>
</widget> </widget>
@ -78,19 +70,12 @@
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Ok</set> <set>QDialogButtonBox::NoButton</set>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header location="global">QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -1,220 +1,217 @@
__copyright__ = "Copyright 2021, 3Liz" __copyright__ = "Copyright 2021, 3Liz"
__license__ = "GPL version 3" __license__ = "GPL version 3"
__email__ = "info@3liz.org" __email__ = "info@3liz.org"
from qgis.core import QgsApplication from qgis.core import QgsApplication
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl from qgis.PyQt.QtCore import Qt, QUrl, QSettings
from qgis.PyQt.QtGui import QDesktopServices, QIcon from qgis.PyQt.QtGui import QDesktopServices, QIcon
from qgis.PyQt.QtWidgets import QAction, QMessageBox from qgis.PyQt.QtWidgets import QAction
from qgis.utils import iface from qgis.utils import iface
import qgis import qgis
# include <QSettings>
#include <QSettings> '''
''' from pg_metadata.connection_manager import (
from pg_metadata.connection_manager import ( store_connections,
store_connections, validate_connections_names,
validate_connections_names, )
)
from pg_metadata.locator import LocatorFilter
from pg_metadata.locator import LocatorFilter from pg_metadata.processing.provider import PgMetadataProvider
from pg_metadata.processing.provider import PgMetadataProvider from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger
from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger '''
''' import os
import os from .about_form import MetabaseAboutDialog
from .tools.resources import ( from .tools.resources import (
plugin_path, # plugin_path,
resources_path, pyperclip,
maj_verif, resources_path,
) maj_verif,
from .dock import CenRa_Metabase )
from .editor import Metabase_Editor pyperclip()
from .about_form import MetabaseAboutDialog from .dock import CenRa_Metabase
#from CenRa_Metabase.issues import CenRa_Issues from .editor import Metabase_Editor
from PyQt5.QtCore import * # from CenRa_Metabase.issues import CenRa_Issues
class PgMetadata:
class PgMetadata: def __init__(self):
def __init__(self): """ Constructor. """
""" Constructor. """ self.dock = None
self.dock = None self.editor = None
self.editor = None # self.issues = None
# self.issues = None self.provider = None
self.provider = None self.locator_filter = None
self.locator_filter = None self.dock_action = None
self.dock_action = None self.help_action = None
self.help_action = None plugin_dir = os.path.dirname(__file__)
plugin_dir = os.path.dirname(__file__) end_find = plugin_dir.rfind('\\') + 1
end_find = plugin_dir.rfind('\\')+1 global NAME
global NAME NAME = plugin_dir[end_find:]
NAME = plugin_dir[end_find:] maj_verif(NAME)
maj_verif(NAME)
# Display About window on first use
# Display About window on first use version = qgis.utils.pluginMetadata('CenRa_METABASE', 'version')
version = qgis.utils.pluginMetadata('CenRa_METABASE','version') s = QSettings()
s = QSettings() versionUse = s.value("metadata/version", 1, type=str)
versionUse = s.value("metadata/version", 1, type=str) if str(versionUse) != str(version):
if str(versionUse) != str(version) : s.setValue("metadata/version", str(version))
s.setValue("metadata/version", str(version)) print(versionUse, version)
print(versionUse,version) self.open_about_dialog()
self.open_about_dialog() # setup_logger('pg_metadata')
# setup_logger('pg_metadata')
# locale, file_path = setup_translation(
#locale, file_path = setup_translation( # folder=plugin_path("i18n"), file_pattern="CenRa_Metabase_{}.qm")
# folder=plugin_path("i18n"), file_pattern="CenRa_Metabase_{}.qm") # if file_path:
#if file_path: # self.translator = QTranslator()
# self.translator = QTranslator() # self.translator.load(file_path)
# self.translator.load(file_path) # noinspection PyCallByClass,PyArgumentList
# noinspection PyCallByClass,PyArgumentList # QCoreApplication.installTranslator(self.translator)
# QCoreApplication.installTranslator(self.translator)
# noinspection PyPep8Naming
# noinspection PyPep8Naming # def initProcessing(self):
#def initProcessing(self): # """ Add the QGIS Processing provider. """
#""" Add the QGIS Processing provider. """ # if not self.provider:
#if not self.provider: # self.provider = PgMetadataProvider()
#self.provider = PgMetadataProvider() # QgsApplication.processingRegistry().addProvider(self.provider)
#QgsApplication.processingRegistry().addProvider(self.provider)
# noinspection PyPep8Naming
# noinspection PyPep8Naming def initGui(self):
def initGui(self): """ Build the plugin GUI. """
""" Build the plugin GUI. """ # self.initProcessing()
#self.initProcessing()
# self.check_invalid_connection_names()
#self.check_invalid_connection_names()
self.toolBar = iface.addToolBar("CenRa_Metabase")
self.toolBar = iface.addToolBar("CenRa_Metabase") self.toolBar.setObjectName("CenRa_Metabase")
self.toolBar.setObjectName("CenRa_Metabase")
icon = QIcon(resources_path('icons', 'icon.png'))
icon = QIcon(resources_path('icons', 'icon.png')) icon2 = QIcon(resources_path('icons', 'icon_2.png'))
icon2 = QIcon(resources_path('icons', 'icon_2.png'))
# Open the online help
# Open the online help self.help_action = QAction(icon, 'CenRa_Metabase', iface.mainWindow())
self.help_action = QAction(icon, 'CenRa_Metabase', iface.mainWindow()) iface.pluginHelpMenu().addAction(self.help_action)
iface.pluginHelpMenu().addAction(self.help_action) self.help_action.triggered.connect(self.open_help)
self.help_action.triggered.connect(self.open_help) if not self.editor:
if not self.editor: self.editor = Metabase_Editor()
self.editor = Metabase_Editor()
self.editor_action = QAction(icon2, 'CenRa_Metabase', None)
self.toolBar.addAction(self.editor_action)
self.editor_action = QAction(icon2, 'CenRa_Metabase',None) self.editor_action.triggered.connect(self.open_editor)
self.toolBar.addAction(self.editor_action)
self.editor_action.triggered.connect(self.open_editor) if not self.dock:
self.dock = CenRa_Metabase()
if not self.dock: iface.addDockWidget(Qt.DockWidgetArea(0x2), self.dock)
self.dock = CenRa_Metabase()
iface.addDockWidget(Qt.RightDockWidgetArea, self.dock) # Open/close the dock from plugin menu
self.dock_action = QAction(icon, 'CenRa_Metabase', iface.mainWindow())
# Open/close the dock from plugin menu iface.pluginMenu().addAction(self.dock_action)
self.dock_action = QAction(icon, 'CenRa_Metabase', iface.mainWindow()) self.dock_action.triggered.connect(self.open_dock)
iface.pluginMenu().addAction(self.dock_action) # if not self.issues:
self.dock_action.triggered.connect(self.open_dock) # self.issues = CenRa_Issues()
# if not self.issues:
# self.issues = CenRa_Issues()
# self.issues_action = QAction(icon, 'CenRa_Metabase',None)
# self.toolBar.addAction(self.issues_action)
# self.issues_action = QAction(icon, 'CenRa_Metabase',None) # self.issues_action.triggered.connect(self.open_issues)
# self.toolBar.addAction(self.issues_action) '''
# self.issues_action.triggered.connect(self.open_issues) if not self.locator_filter:
''' self.locator_filter = LocatorFilter(iface)
if not self.locator_filter: iface.registerLocatorFilter(self.locator_filter)
self.locator_filter = LocatorFilter(iface)
iface.registerLocatorFilter(self.locator_filter) @staticmethod
def check_invalid_connection_names():
@staticmethod """ Check for invalid connection names in the QgsSettings. """
def check_invalid_connection_names(): valid, invalid = validate_connections_names()
""" Check for invalid connection names in the QgsSettings. """ n_invalid = len(invalid)
valid, invalid = validate_connections_names()
n_invalid = len(invalid) if n_invalid == 0:
return
if n_invalid == 0:
return invalid_text = ', '.join(invalid)
msg = QMessageBox()
invalid_text = ', '.join(invalid) msg.setIcon(QMessageBox.Warning)
msg = QMessageBox() msg.setWindowTitle(tr('PgMetadata: Database connection(s) not available'))
msg.setIcon(QMessageBox.Warning) msg.setText(tr(
msg.setWindowTitle(tr('PgMetadata: Database connection(s) not available')) f'{n_invalid} connection(s) listed in PgMetadatas settings are invalid or '
msg.setText(tr( f'no longer available: {invalid_text}'))
f'{n_invalid} connection(s) listed in PgMetadatas settings are invalid or ' msg.setInformativeText(tr(
f'no longer available: {invalid_text}')) 'Do you want to remove these connection(s) from the PgMetadata settings? '
msg.setInformativeText(tr( '(You can also do this later with the “Set Connections” tool.)'))
'Do you want to remove these connection(s) from the PgMetadata settings? ' msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
'(You can also do this later with the “Set Connections” tool.)')) clicked = msg.exec()
msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
clicked = msg.exec() if clicked == QMessageBox.Yes:
iface.messageBar().pushSuccess('PgMetadata', tr(f'{n_invalid} invalid connection(s) removed.'))
if clicked == QMessageBox.Yes: store_connections(valid)
iface.messageBar().pushSuccess('PgMetadata', tr(f'{n_invalid} invalid connection(s) removed.')) if clicked == QMessageBox.No:
store_connections(valid) iface.messageBar().pushInfo('PgMetadata', tr(f'Keeping {n_invalid} invalid connections.'))
if clicked == QMessageBox.No: '''
iface.messageBar().pushInfo('PgMetadata', tr(f'Keeping {n_invalid} invalid connections.')) def open_about_dialog(self):
''' """
def open_about_dialog(self): About dialog
""" """
About dialog dialog = MetabaseAboutDialog(iface)
""" dialog.exec()
dialog = MetabaseAboutDialog(iface)
dialog.exec_() def open_help():
def open_help(): """ Open the online help. """
""" Open the online help. """ QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
def open_dock(self):
def open_dock(self): """ Open the dock. """
""" Open the dock. """ self.dock.show()
self.dock.show() self.dock.raise_()
self.dock.raise_()
def open_editor(self):
def open_editor(self): self.editor.show()
self.editor.show() self.editor.raise_()
self.editor.raise_()
# def open_issues(self):
# def open_issues(self): # self.issues.show()
# self.issues.show() # self.issues.raise_()
# self.issues.raise_()
def unload(self):
def unload(self): """ Unload the plugin. """
""" Unload the plugin. """ # if self.editor:
if self.editor: # iface.removePluginMenu('CenRa_Metabase',self.editor_action)
iface.removePluginMenu('CenRa_Metabase',self.editor_action) # self.editor.removeToolBarIcon(self.editor_action)
#self.editor.removeToolBarIcon(self.editor_action)
if self.dock:
iface.removeDockWidget(self.dock)
self.dock.deleteLater()
if self.dock:
iface.removeDockWidget(self.dock) if self.provider:
self.dock.deleteLater() QgsApplication.processingRegistry().removeProvider(self.provider)
del self.provider
if self.provider:
QgsApplication.processingRegistry().removeProvider(self.provider) if self.locator_filter:
del self.provider iface.deregisterLocatorFilter(self.locator_filter)
del self.locator_filter
if self.locator_filter:
iface.deregisterLocatorFilter(self.locator_filter) if self.help_action:
del self.locator_filter iface.pluginHelpMenu().removeAction(self.help_action)
del self.help_action
if self.dock_action:
iface.pluginMenu().removeAction(self.dock_action) if self.dock_action:
del self.dock_action iface.pluginMenu().removeAction(self.dock_action)
del self.dock_action
if self.help_action:
iface.pluginHelpMenu().removeAction(self.help_action) @staticmethod
del self.help_action def run_tests(pattern='test_*.py', package=None):
"""Run the test inside QGIS."""
@staticmethod try:
def run_tests(pattern='test_*.py', package=None): from pathlib import Path
"""Run the test inside QGIS."""
try: from pg_metadata.qgis_plugin_tools.infrastructure.test_runner import (
from pathlib import Path test_package,
)
from pg_metadata.qgis_plugin_tools.infrastructure.test_runner import ( if package is None:
test_package, package = '{}.__init__'.format(Path(__file__).parent.name)
) test_package(package, pattern)
if package is None: except (AttributeError, ModuleNotFoundError):
package = '{}.__init__'.format(Path(__file__).parent.name) message = 'Could not load tests. Are you using a production package?'
test_package(package, pattern) print(message) # NOQA
except (AttributeError, ModuleNotFoundError):
message = 'Could not load tests. Are you using a production package?'
print(message) # NOQA

View File

@ -3,7 +3,7 @@ import os.path
from pathlib import Path from pathlib import Path
from qgis.PyQt import uic from qgis.PyQt import uic
from qgis.PyQt.QtGui import QPixmap # from qgis.PyQt.QtGui import QPixmap
from qgis.PyQt.QtWidgets import QDialog from qgis.PyQt.QtWidgets import QDialog
from .tools.resources import devlog from .tools.resources import devlog
@ -12,7 +12,7 @@ ABOUT_FORM_CLASS, _ = uic.loadUiType(
os.path.join( os.path.join(
str(Path(__file__).resolve().parent), str(Path(__file__).resolve().parent),
'tools/ui', 'tools/ui',
'CenRa_Metabase_about_form.ui' 'CenRa_about_form.ui'
) )
) )
@ -43,4 +43,4 @@ class MetabaseAboutDialog(QDialog, ABOUT_FORM_CLASS):
Run some actions when Run some actions when
the user closes the dialog the user closes the dialog
""" """
self.close() self.close()

View File

@ -1,488 +1,453 @@
"""Dock file.""" """Dock file."""
__copyright__ = 'Copyright 2020, 3Liz' __copyright__ = 'Copyright 2020, 3Liz'
__license__ = 'GPL version 3' __license__ = 'GPL version 3'
__email__ = 'info@3liz.org' __email__ = 'info@3liz.org'
import logging import logging
import os import os
from collections import namedtuple from collections import namedtuple
from enum import Enum from enum import Enum
from functools import partial from functools import partial
from pathlib import Path from pathlib import Path
from xml.dom.minidom import parseString from xml.dom.minidom import parseString
from qgis.core import ( from qgis.core import (
NULL, QgsApplication,
QgsApplication, QgsProviderRegistry,
QgsDataSourceUri, QgsSettings,
QgsProject, )
QgsProviderConnectionException, from qgis.PyQt.QtCore import QLocale, QUrl
QgsProviderRegistry, from qgis.PyQt.QtGui import QDesktopServices, QIcon
QgsRasterLayer, from qgis.PyQt.QtPrintSupport import QPrinter
QgsSettings, # from qgis.PyQt.QtWebKitWidgets import QWebPage
QgsVectorLayer, from qgis.PyQt.QtWidgets import (
) QAction,
from qgis.PyQt.QtCore import QLocale, QUrl QDockWidget,
from qgis.PyQt.QtGui import QDesktopServices, QIcon QFileDialog,
from qgis.PyQt.QtPrintSupport import QPrinter QMenu,
from qgis.PyQt.QtWebKitWidgets import QWebPage QToolButton,
from qgis.PyQt.QtWidgets import ( )
QDialog, from qgis.utils import iface
QAction, import qgis
QDockWidget, from .tools.resources import (
QFileDialog, load_ui,
QInputDialog, resources_path,
QMenu, )
QToolButton, try:
) from .tools.PythonSQL import login_base
from qgis.gui import * except ValueError:
from qgis.utils import iface print('Pas de fichier PythonSQL')
'''
from pg_metadata.connection_manager import ( DOCK_CLASS = load_ui('CenRa_Metabase_dockwidget_base.ui')
check_pgmetadata_is_installed, LOGGER = logging.getLogger('CenRa_Metabase')
connections_list,
settings_connections_names,
) class Format(namedtuple('Format', ['label', 'ext'])):
''' """ Format available for exporting metadata. """
pass
from .tools.resources import (
load_ui,
resources_path, class OutputFormats(Format, Enum):
login_base, """ Output format for a metadata sheet. """
) PDF = Format(label='PDF', ext='pdf')
HTML = Format(label='HTML', ext='html')
DOCK_CLASS = load_ui('CenRa_Metabase_dockwidget_base.ui') DCAT = Format(label='DCAT', ext='xml')
LOGGER = logging.getLogger('CenRa_Metabase')
class CenRa_Metabase(QDockWidget, DOCK_CLASS):
class Format(namedtuple('Format', ['label', 'ext'])):
""" Format available for exporting metadata. """ def __init__(self, parent=None):
pass _ = parent
super().__init__()
self.setupUi(self)
class OutputFormats(Format, Enum): self.settings = QgsSettings()
""" Output format for a metadata sheet. """
PDF = Format(label='PDF', ext='pdf') self.current_datasource_uri = None
HTML = Format(label='HTML', ext='html') self.current_connection = None
DCAT = Format(label='DCAT', ext='xml')
# self.viewer.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
# self.viewer.page().linkClicked.connect(self.open_link)
class CenRa_Metabase(QDockWidget, DOCK_CLASS):
# Help button
def __init__(self, parent=None): self.external_help.setText('')
_ = parent self.external_help.setIcon(QIcon(QgsApplication.iconPath('mActionHelpContents.svg')))
super().__init__() self.external_help.clicked.connect(self.open_external_help)
self.setupUi(self)
self.settings = QgsSettings() # Flat table button
self.flatten_dataset_table.setText('')
self.current_datasource_uri = None # self.flatten_dataset_table.setToolTip(tr("Add the catalog table"))
self.current_connection = None self.flatten_dataset_table.setIcon(QgsApplication.getThemeIcon("/mActionAddHtml.svg"))
# self.flatten_dataset_table.clicked.connect(self.add_flatten_dataset_table)
self.viewer.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
self.viewer.page().linkClicked.connect(self.open_link) # Settings menu
self.config.setAutoRaise(True)
# Help button # self.config.setToolTip(tr("Settings"))
self.external_help.setText('') self.config.setPopupMode(QToolButton.ToolButtonPopupMode(2))
self.external_help.setIcon(QIcon(QgsApplication.iconPath('mActionHelpContents.svg'))) self.config.setIcon(QgsApplication.getThemeIcon("/mActionOptions.svg"))
self.external_help.clicked.connect(self.open_external_help)
self.auto_open_dock_action = QAction(
# Flat table button ("Dommage, cette option n'existe pas encore."),
self.flatten_dataset_table.setText('') iface.mainWindow())
#self.flatten_dataset_table.setToolTip(tr("Add the catalog table")) self.auto_open_dock_action.setCheckable(True)
self.flatten_dataset_table.setIcon(QgsApplication.getThemeIcon("/mActionAddHtml.svg")) self.auto_open_dock_action.setChecked(
#self.flatten_dataset_table.clicked.connect(self.add_flatten_dataset_table) self.settings.value("pgmetadata/auto_open_dock", True, type=bool)
)
# Settings menu self.auto_open_dock_action.triggered.connect(self.save_auto_open_dock)
self.config.setAutoRaise(True) menu = QMenu()
#self.config.setToolTip(tr("Settings")) menu.addAction(self.auto_open_dock_action)
self.config.setPopupMode(QToolButton.InstantPopup) self.config.setMenu(menu)
self.config.setIcon(QgsApplication.getThemeIcon("/mActionOptions.svg"))
# Setting PDF/HTML menu
self.auto_open_dock_action = QAction( self.save_button.setAutoRaise(True)
("Dommage, cette option n'existe pas encore."), # self.save_button.setToolTip(tr("Save metadata"))
iface.mainWindow()) self.save_button.setPopupMode(QToolButton.ToolButtonPopupMode(2))
self.auto_open_dock_action.setCheckable(True) self.save_button.setIcon(QIcon(QgsApplication.iconPath('mActionFileSave.svg')))
self.auto_open_dock_action.setChecked(
self.settings.value("pgmetadata/auto_open_dock", True, type=bool) self.save_as_pdf = QAction(
) ('Enregistrer en PDF') + '',
self.auto_open_dock_action.triggered.connect(self.save_auto_open_dock) iface.mainWindow())
menu = QMenu() self.save_as_pdf.triggered.connect(partial(self.export_dock_content, OutputFormats.PDF))
menu.addAction(self.auto_open_dock_action)
self.config.setMenu(menu) self.save_as_html = QAction(
('Enregistrer en HTML') + '',
# Setting PDF/HTML menu iface.mainWindow())
self.save_button.setAutoRaise(True) self.save_as_html.triggered.connect(partial(self.export_dock_content, OutputFormats.HTML))
#self.save_button.setToolTip(tr("Save metadata")) self.save_as_dcat = QAction(
self.save_button.setPopupMode(QToolButton.InstantPopup) ('Enregistrer en DCAT') + '',
self.save_button.setIcon(QIcon(QgsApplication.iconPath('mActionFileSave.svg'))) iface.mainWindow())
self.save_as_dcat.triggered.connect(partial(self.export_dock_content, OutputFormats.DCAT))
self.save_as_pdf = QAction(
('Enregistrer en PDF') + '', self.menu_save = QMenu()
iface.mainWindow()) self.menu_save.addAction(self.save_as_pdf)
self.save_as_pdf.triggered.connect(partial(self.export_dock_content, OutputFormats.PDF)) self.menu_save.addAction(self.save_as_html)
self.menu_save.addAction(self.save_as_dcat)
self.save_as_html = QAction( self.save_button.setMenu(self.menu_save)
('Enregistrer en HTML') + '', self.save_button.setEnabled(False)
iface.mainWindow())
self.save_as_html.triggered.connect(partial(self.export_dock_content, OutputFormats.HTML)) self.metadata = QgsProviderRegistry.instance().providerMetadata('postgres')
self.save_as_dcat = QAction(
('Enregistrer en DCAT') + '', # Display message in the dock
iface.mainWindow()) # if not settings_connections_names():
self.save_as_dcat.triggered.connect(partial(self.export_dock_content, OutputFormats.DCAT)) # self.default_html_content_not_installed()
# else:
self.menu_save = QMenu() self.default_html_content_not_pg_layer()
self.menu_save.addAction(self.save_as_pdf) iface.layerTreeView().currentLayerChanged.connect(self.layer_changed)
self.menu_save.addAction(self.save_as_html) try:
self.menu_save.addAction(self.save_as_dcat) login_base()
self.save_button.setMenu(self.menu_save) iface.layerTreeView().currentLayerChanged.connect(self.layer_changed)
self.save_button.setEnabled(False) except ValueError:
# qgis.utils.plugins['CenRa_METABASE'].initGui()
self.metadata = QgsProviderRegistry.instance().providerMetadata('postgres') qgis.utils.plugins['CenRa_METABASE'].unload()
# self.default_html_content_not_pg_layer()
# Display message in the dock
#if not settings_connections_names(): if iface.activeLayer():
#self.default_html_content_not_installed() layer = iface.activeLayer()
#else: iface.layerTreeView().setCurrentLayer(None)
self.default_html_content_not_pg_layer() iface.layerTreeView().setCurrentLayer(layer)
iface.layerTreeView().currentLayerChanged.connect(self.layer_changed) def export_dock_content(self, output_format: OutputFormats):
""" Export the current displayed metadata sheet to the given format. """
if iface.activeLayer(): layer_name = iface.activeLayer().name()
layer=iface.activeLayer()
iface.layerTreeView().setCurrentLayer(None) file_path = os.path.join(
iface.layerTreeView().setCurrentLayer(layer) os.environ['USERPROFILE'],
'Desktop\\{name}.{ext}'.format(name=layer_name, ext=output_format.ext)
def export_dock_content(self, output_format: OutputFormats): )
""" Export the current displayed metadata sheet to the given format. """ output_file = QFileDialog.getSaveFileName(
layer_name = iface.activeLayer().name() self,
("Enregistrer en {format}").format(format=output_format.label),
file_path = os.path.join( file_path,
os.environ['USERPROFILE'], "{label} (*.{ext})".format(
'Desktop\\{name}.{ext}'.format(name=layer_name, ext=output_format.ext) label=output_format.label,
) ext=output_format.ext,
output_file = QFileDialog.getSaveFileName( )
self, )
("Enregistrer en {format}").format(format=output_format.label), if output_file[0] == '':
file_path, return
"{label} (*.{ext})".format(
label=output_format.label, self.settings.setValue("UI/lastFileNameWidgetDir", os.path.dirname(output_file[0]))
ext=output_format.ext,
) output_file_path = output_file[0]
) parent_folder = str(Path(output_file_path).parent)
if output_file[0] == '':
return if output_format == OutputFormats.PDF:
printer = QPrinter()
self.settings.setValue("UI/lastFileNameWidgetDir", os.path.dirname(output_file[0])) printer.setOutputFormat(QPrinter.OutputFormat(1))
# printer.setPageMargins(20,20,20,20,QPrinter.Unit(0))
output_file_path = output_file[0] printer.setOutputFileName(output_file_path)
parent_folder = str(Path(output_file_path).parent) self.viewer.print(printer)
iface.messageBar().pushSuccess(
if output_format == OutputFormats.PDF: ("Export PDF"),
printer = QPrinter() (
printer.setOutputFormat(QPrinter.PdfFormat) "The metadata has been exported as PDF successfully in "
printer.setPageMargins(20, 20, 20, 20, QPrinter.Millimeter) "<a href=\"{}\">{}</a>").format(parent_folder, output_file_path)
printer.setOutputFileName(output_file_path) )
self.viewer.print(printer)
iface.messageBar().pushSuccess( elif output_format in [OutputFormats.HTML, OutputFormats.DCAT]:
("Export PDF"), if output_format == OutputFormats.HTML:
( data_str = self.viewer.page().currentFrame().toHtml()
"The metadata has been exported as PDF successfully in " else:
"<a href=\"{}\">{}</a>").format(parent_folder, output_file_path) layer = iface.activeLayer()
) uri = layer.dataProvider().uri()
dataall = self.sql_info(uri)
elif output_format in [OutputFormats.HTML,OutputFormats.DCAT]: data = self.sql_to_xml(dataall)
if output_format == OutputFormats.HTML:
data_str = self.viewer.page().currentFrame().toHtml() with open(resources_path('xml', 'dcat.xml'), encoding='utf8') as xml_file:
else: xml_template = xml_file.read()
layer = iface.activeLayer()
uri = layer.dataProvider().uri() xml = parseString(xml_template.format(language=data[0][0], content=data[0][1]))
dataall = self.sql_info(uri)
data = self.sql_to_xml(dataall) data_str = xml.toprettyxml()
with open(resources_path('xml', 'dcat.xml'), encoding='utf8') as xml_file: with open(output_file[0], "w", encoding='utf8') as file_writer:
xml_template = xml_file.read() file_writer.write(data_str)
iface.messageBar().pushSuccess(
xml = parseString(xml_template.format(language=data[0][0], content=data[0][1])) ("Export") + ' ' + output_format.label,
(
data_str = xml.toprettyxml() "The metadata has been exported as {format} successfully in "
"<a href=\"{folder}\">{path}</a>").format(
with open(output_file[0], "w", encoding='utf8') as file_writer: format=output_format.label, folder=parent_folder, path=output_file_path)
file_writer.write(data_str) )
iface.messageBar().pushSuccess(
("Export") + ' ' + output_format.label, def save_auto_open_dock(self):
( """ Save settings about the dock. """
"The metadata has been exported as {format} successfully in " self.settings.setValue("pgmetadata/auto_open_dock", self.auto_open_dock_action.isChecked())
"<a href=\"{folder}\">{path}</a>").format(
format=output_format.label, folder=parent_folder, path=output_file_path) def sql_to_xml(self, dataall):
) distribution = ''
for y in dataall[1]:
def save_auto_open_dock(self): distribution = distribution + ('<dcat:distribution>' + '<dcat:Distribution>' + '<dct:title>{data}</dct:title>'.format(data=y[0]) + '<dcat:downloadURL>{data}</dcat:downloadURL>'.format(data=y[1]) + '<dcat:mediaType>{data}</dcat:mediaType>'.format(data=y[2]) + '<dct:format>{data}</dct:format>'.format(data=y[3]) + '<dct:bytesize>{data}</dct:bytesize>'.format(data=y[4]) + '</dcat:Distribution>' + '</dcat:distribution>')
""" Save settings about the dock. """ publisher = ''
self.settings.setValue("pgmetadata/auto_open_dock", self.auto_open_dock_action.isChecked()) for z in dataall[2]:
def sql_to_xml(self,dataall): publisher = publisher + ('<dct:publisher>' + '<foaf:Organization>' + '<foaf:name>{data}</foaf:name>'.format(data=z[1]) + '<foaf:mbox>{data}</foaf:mbox>'.format(data=z[3]) + '</foaf:Organization>' + '</dct:publisher>')
distribution='' data_str = [[dataall[0][26], '<dct:identifier>{data}</dct:identifier>'.format(data=dataall[0][1]) + '<dct:title>{data}</dct:title>'.format(data=dataall[0][4]) + '<dct:description>{data}</dct:description>'.format(data=dataall[0][5]) + '<dct:language>{data}</dct:language>'.format(data=dataall[0][26]) + '<dct:spatial>{data}</dct:spatial>'.format(data=dataall[0][28]) + '<dct:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">{data}</dct:created>'.format(data=dataall[0][20]) + '<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">{data}</dct:issued>'.format(data=dataall[0][11]) + '<dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">{data}</dct:modified>'.format(data=dataall[0][21]) + '<dct:license>{data}</dct:license>'.format(data=dataall[0][13]) + distribution + publisher + '<dcat:theme>{data}</dcat:theme>'.format(data=", ".join(str(x) for x in dataall[0][24])) + '<dcat:keyword>{data}</dcat:keyword>'.format(data=", ".join(str(x) for x in dataall[0][6])) + '<dct:accrualPeriodicity>{data}</dct:accrualPeriodicity>'.format(data=dataall[0][12])]]
for y in dataall[1]:
distribution = distribution + ( return data_str
'<dcat:distribution>'+
'<dcat:Distribution>'+ @staticmethod
'<dct:title>{data}</dct:title>'.format(data=y[0])+ def sql_for_layer(uri, output_format: OutputFormats):
'<dcat:downloadURL>{data}</dcat:downloadURL>'.format(data=y[1])+ """ Get the SQL query for a given layer and output format. """
'<dcat:mediaType>{data}</dcat:mediaType>'.format(data=y[2])+ locale = QgsSettings().value("locale/userLocale", QLocale().name())
'<dct:format>{data}</dct:format>'.format(data=y[3])+ locale = locale.split('_')[0].lower()
'<dct:bytesize>{data}</dct:bytesize>'.format(data=y[4])+
'</dcat:Distribution>'+ if output_format == [OutputFormats.HTML, OutputFormats.DCAT]:
'</dcat:distribution>') sql = (
publisher='' "SELECT pgmetadata.get_dataset_item_html_content('{schema}', '{table}', '{locale}');"
for z in dataall[2]: ).format(schema=uri.schema(), table=uri.table(), locale=locale)
publisher = publisher + ( else:
'<dct:publisher>'+ raise NotImplementedError('Output format is not yet implemented.')
'<foaf:Organization>'+
'<foaf:name>{data}</foaf:name>'.format(data=z[1])+ return sql
'<foaf:mbox>{data}</foaf:mbox>'.format(data=z[3])+
'</foaf:Organization>'+ def layer_changed(self, layer):
'</dct:publisher>') """ When the layer has changed in the legend, we must check this new layer. """
data_str = [[dataall[0][26], self.current_datasource_uri = None
'<dct:identifier>{data}</dct:identifier>'.format(data=dataall[0][1])+ self.current_connection = None
'<dct:title>{data}</dct:title>'.format(data=dataall[0][4])+ self.ce_trouve_dans_psql(layer)
'<dct:description>{data}</dct:description>'.format(data=dataall[0][5])+
'<dct:language>{data}</dct:language>'.format(data=dataall[0][26])+ def add_flatten_dataset_table(self):
'<dct:spatial>{data}</dct:spatial>'.format(data=dataall[0][28])+ """ Add a flatten dataset table with all links and contacts. """
'<dct:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">{data}</dct:created>'.format(data=dataall[0][20])+ '''
'<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">{data}</dct:issued>'.format(data=dataall[0][11])+ connections, message = connections_list()
'<dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">{data}</dct:modified>'.format(data=dataall[0][21])+ if not connections:
'<dct:license>{data}</dct:license>'.format(data=dataall[0][13])+ LOGGER.critical(message)
distribution+ self.set_html_content('PgMetadata', message)
publisher+ return
'<dcat:theme>{data}</dcat:theme>'.format(data=", ".join(str(x) for x in dataall[0][24]))+
'<dcat:keyword>{data}</dcat:keyword>'.format(data=", ".join(str(x) for x in dataall[0][6]))+ if len(connections) > 1:
'<dct:accrualPeriodicity>{data}</dct:accrualPeriodicity>'.format(data=dataall[0][12])]] dialog = QInputDialog()
dialog.setComboBoxItems(connections)
return data_str dialog.setWindowTitle(tr("Database"))
dialog.setLabelText(tr("Choose the database to add the catalog"))
@staticmethod if not dialog.exec_():
def sql_for_layer(uri, output_format: OutputFormats): return
""" Get the SQL query for a given layer and output format. """ connection_name = dialog.textValue()
locale = QgsSettings().value("locale/userLocale", QLocale().name()) else:
locale = locale.split('_')[0].lower() connection_name = connections[0]
if output_format == [OutputFormats.HTML,OutputFormats.DCAT]: metadata = QgsProviderRegistry.instance().providerMetadata('postgres')
sql = ( connection = metadata.findConnection(connection_name)
"SELECT pgmetadata.get_dataset_item_html_content('{schema}', '{table}', '{locale}');"
).format(schema=uri.schema(), table=uri.table(), locale=locale) locale = QgsSettings().value("locale/userLocale", QLocale().name())
else: locale = locale.split('_')[0].lower()
raise NotImplementedError('Output format is not yet implemented.')
uri = QgsDataSourceUri(connection.uri())
return sql uri.setTable(f'(SELECT * FROM pgmetadata.export_datasets_as_flat_table(\'{locale}\'))')
uri.setKeyColumn('uid')
def layer_changed(self, layer):
""" When the layer has changed in the legend, we must check this new layer. """ layer = QgsVectorLayer(uri.uri(), '{} - {}'.format(tr("Catalog"), connection_name), 'postgres')
self.current_datasource_uri = None QgsProject.instance().addMapLayer(layer)
self.current_connection = None '''
self.ce_trouve_dans_psql(layer)
@staticmethod
def open_external_help():
def add_flatten_dataset_table(self): QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
""" Add a flatten dataset table with all links and contacts. """
''' @staticmethod
connections, message = connections_list() def open_link(url):
if not connections: QDesktopServices.openUrl(url)
LOGGER.critical(message)
self.set_html_content('PgMetadata', message) def set_html_content(self, title=None, body=None):
return """ Set the content in the dock. """
# ink_logo=resources_path('icons', 'CEN_RA.png')
if len(connections) > 1: css_file = resources_path('css', 'dock.css')
dialog = QInputDialog() with open(css_file, 'r', encoding='utf8') as f:
dialog.setComboBoxItems(connections) css = f.read()
dialog.setWindowTitle(tr("Database"))
dialog.setLabelText(tr("Choose the database to add the catalog")) html = '<html><head>'
if not dialog.exec_(): # html += '<script src="http://ignf.github.io/geoportal-sdk/latest/dist/2d/GpSDK2D.js" defer ></script>'
return html += '<style>{css}</style></head><body>'.format(css=css)
connection_name = dialog.textValue() # html += '<link rel="stylesheet" href="http://ignf.github.io/geoportal-sdk/latest/dist/2d/GpSDK2D.css" >'
else: # html += '<script src="file:///C:/Users/tlaveille/Desktop/maps.js" defer></script>'
connection_name = connections[0] # html += '<noscript>Your browser does not support JavaScript!</noscript>'
if title:
metadata = QgsProviderRegistry.instance().providerMetadata('postgres') html += '<h2>{title} <img class=logo src=https://i2.wp.com/www.cen-rhonealpes.fr/wp-content/uploads/2013/04/cen-rhonealpes-couleurs1.jpg?w=340&ssl=1></h2>'.format(title=title)
connection = metadata.findConnection(connection_name) if body:
html += body
locale = QgsSettings().value("locale/userLocale", QLocale().name())
locale = locale.split('_')[0].lower() html += '</body></html>'
uri = QgsDataSourceUri(connection.uri()) # It must be a file, even if it does not exist on the file system.
uri.setTable(f'(SELECT * FROM pgmetadata.export_datasets_as_flat_table(\'{locale}\'))') # base_url = QUrl.fromLocalFile(resources_path('images', 'must_be_a_file.png'))
uri.setKeyColumn('uid') self.viewer.setHtml(html)
layer = QgsVectorLayer(uri.uri(), '{} - {}'.format(tr("Catalog"), connection_name), 'postgres') def ce_trouve_dans_psql(self, layer):
QgsProject.instance().addMapLayer(layer) try:
''' uri = layer.dataProvider().uri()
except AttributeError:
@staticmethod self.default_html_content_not_pg_layer()
def open_external_help(): self.save_button.setEnabled(False)
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/')) uri = ''
if uri != '':
@staticmethod if not uri.table():
def open_link(url): layertype = layer.providerType().lower()
QDesktopServices.openUrl(url) if layertype == 'wms' or layertype == 'wfs':
self.set_html_to_wms(layer)
def set_html_content(self, title=None, body=None): else:
""" Set the content in the dock. """ self.default_html_content_not_pg_layer()
#link_logo=resources_path('icons', 'CEN_RA.png') self.save_button.setEnabled(False)
css_file = resources_path('css', 'dock.css') else:
with open(css_file, 'r', encoding='utf8') as f: data_count = self.sql_check(uri)
css = f.read() # print(data_count)
if data_count == 0:
html = '<html><head>' self.default_html_content_not_metadata()
#html += '<script src="http://ignf.github.io/geoportal-sdk/latest/dist/2d/GpSDK2D.js" defer ></script>' self.save_button.setEnabled(False)
html += '<style>{css}</style></head><body>'.format(css=css) else:
#html += '<link rel="stylesheet" href="http://ignf.github.io/geoportal-sdk/latest/dist/2d/GpSDK2D.css" >' self.build_html_content(layer, uri)
#html += '<script src="file:///C:/Users/tlaveille/Desktop/maps.js" defer></script>' self.save_button.setEnabled(True)
#html += '<noscript>Your browser does not support JavaScript!</noscript>'
if title: def build_html_content(self, layer, uri):
html += '<h2>{title} <img class=logo src=https://i2.wp.com/www.cen-rhonealpes.fr/wp-content/uploads/2013/04/cen-rhonealpes-couleurs1.jpg?w=340&ssl=1></h2>'.format(title=title) body = ''
if body:
html += body dataall = self.sql_info(uri)
data = dataall[0]
html += '</body></html>' data_url = dataall[1]
data_contact = dataall[2]
# It must be a file, even if it does not exist on the file system. # print(len(data_url))
base_url = QUrl.fromLocalFile(resources_path('images', 'must_be_a_file.png')) # data_collonne = [field.name() for field in layer.dataProvider().fields()]
self.viewer.setHtml(html, base_url)
body += '<div><h3>Identification</h3><table class="table table-condensed">'
def ce_trouve_dans_psql(self,layer): body += '<tr><th>Titre</th><td>{data[4]}</td></tr>'.format(data=data)
try: body += '<tr><th>Description</th><td>{data[5]}</td></tr>'.format(data=data)
uri = layer.dataProvider().uri() body += '<tr><th>Categories</th><td>{data}</td></tr>'.format(data=(", ".join(str(x) for x in data[6])))
except: body += '<tr><th>Thèmes</th><td>{data}</td></tr>'.format(data=(", ".join(str(x) for x in data[24])))
self.default_html_content_not_pg_layer() body += '<tr><th>Mots-clés</th><td>{data[7]}</td></tr>'.format(data=data)
self.save_button.setEnabled(False) body += '<tr><th>Dernier mise à jour</th><td>{data[23]}</td></tr>'.format(data=data)
uri='' body += '<tr><th>Langue</th><td>{data[26]}</td></tr>'.format(data=data)
if uri != '': body += '</table></div>'
if not uri.table():
layertype = layer.providerType().lower() body += '<div><h3>Properties spatial</h3><table class="table table-condensed">'
if layertype == 'wms' or layertype == 'wfs': body += '<tr><th>Niveau</th><td>{data[8]}</td></tr>'.format(data=data)
self.set_html_to_wms(layer) body += '<tr><th>Echelle minimum</th><td>{data[9]}</td></tr>'.format(data=data)
else: body += '<tr><th>Echelle maximum</th><td>{data[10]}</td></tr>'.format(data=data)
self.default_html_content_not_pg_layer() body += '<tr><th>Nombre d\'entités </th><td>{data[15]}</td></tr>'.format(data=data)
self.save_button.setEnabled(False) body += '<tr><th>Type de géométrie</th><td>{data[16]}</td></tr>'.format(data=data)
else: body += '<tr><th>Nom de projection</th><td>{data[17]}</td></tr>'.format(data=data)
data_count = self.sql_check(uri) body += '<tr><th>ID de projection</th><td>{data[18]}</td></tr>'.format(data=data)
#print(data_count) body += '<tr><th>Emprise</th><td>{data[28]}</td></tr>'.format(data=data)
if data_count == 0: body += '</table></div>'
self.default_html_content_not_metadata()
self.save_button.setEnabled(False) # body += '<div id="map"></div>'
else:
self.build_html_content(layer,uri) body += '<div><h3>Publication</h3><table class="table table-condensed">'
self.save_button.setEnabled(True) body += '<tr><th>Date</th><td>{data[11]}</td></tr>'.format(data=data)
body += '<tr><th>Fréquence de mise à jour</th><td>{data[12]}</td></tr>'.format(data=data)
def build_html_content(self,layer,uri): body += '<tr><th>Licence</th><td>{data[13]}</td></tr>'.format(data=data)
body = '' body += '<tr><th>Licence attribué</th><td>{data[25]}</td></tr>'.format(data=data)
body += '<tr><th>Restriction</th><td>{data[14]}</td></tr>'.format(data=data)
dataall=self.sql_info(uri) body += '</table></div>'
data=dataall[0]
data_url=dataall[1] body += '<div><h3>Lien</h3><table class="table table-condensed table-striped table-bordered">'
data_contact=dataall[2] body += '<tr><th>Type</th><th>URL</th><th>Type MIME</th><th>Format</th><th>Taille</th></tr>'
#print(len(data_url)) for value_url in data_url:
data_collonne=[field.name() for field in layer.dataProvider().fields()] body += '<tr><td>{value_url[0]}</td><td>{value_url[1]}</td><td>{value_url[2]}</td><td>{value_url[3]}</td><td>{value_url[4]}</td></tr>'.format(value_url=value_url)
body += '</table></div>'
body += '<div><h3>Identification</h3><table class="table table-condensed">' '''
body += '<tr><th>Titre</th><td>{data[4]}</td></tr>'.format(data=data) body += '<div><h3>Liste des champs</h3><table class="table table-condensed table-striped table-bordered">'
body += '<tr><th>Description</th><td>{data[5]}</td></tr>'.format(data=data) for collonne in data_collonne:
body += '<tr><th>Categories</th><td>{data}</td></tr>'.format(data=(", ".join(str(x) for x in data[6]))) body += '<tr><th>{collonne}</th><td>{defini}</td></tr>'.format(collonne=collonne,defini='')
body += '<tr><th>Thèmes</th><td>{data}</td></tr>'.format(data=(", ".join(str(x) for x in data[24]))) body += '</table></div>'
body += '<tr><th>Mots-clés</th><td>{data[7]}</td></tr>'.format(data=data) '''
body += '<tr><th>Dernier mise à jour</th><td>{data[23]}</td></tr>'.format(data=data) body += '<div><h3>Contacts</h3><table class="table table-condensed table-striped table-bordered">'
body += '<tr><th>Langue</th><td>{data[26]}</td></tr>'.format(data=data) body += '<tr><th>Rôle</th><th>Nom</th><th>Organisation</th><th>Email</th><th>Télèphone</th></tr>'
body += '</table></div>' for value_contact in data_contact:
body += '<tr><td>{value_contact[0]}</td><td>{value_contact[1]}</td><td>{value_contact[2]}</td><td>{value_contact[3]}</td><td>{value_contact[4]}</td></tr>'.format(value_contact=value_contact)
body += '<div><h3>Properties spatial</h3><table class="table table-condensed">' body += '</table></div>'
body += '<tr><th>Niveau</th><td>{data[8]}</td></tr>'.format(data=data)
body += '<tr><th>Echelle minimum</th><td>{data[9]}</td></tr>'.format(data=data) body += '<div><h3>Metadata</h3><table class="table table-condensed">'
body += '<tr><th>Echelle maximum</th><td>{data[10]}</td></tr>'.format(data=data) body += '<tr><th>Table</th><td>{data[2]}</td></tr>'.format(data=data)
body += '<tr><th>Nombre d\'entités </th><td>{data[15]}</td></tr>'.format(data=data) body += '<tr><th>Schema</th><td>{data[3]}</td></tr>'.format(data=data)
body += '<tr><th>Type de géométrie</th><td>{data[16]}</td></tr>'.format(data=data) body += '<tr><th>Date de création</th><td>{data[20]}</td></tr>'.format(data=data)
body += '<tr><th>Nom de projection</th><td>{data[17]}</td></tr>'.format(data=data) body += '<tr><th>Date de modification</th><td>{data[21]}</td></tr>'.format(data=data)
body += '<tr><th>ID de projection</th><td>{data[18]}</td></tr>'.format(data=data) body += '<tr><th>Encodage</th><td>{data[27]}</td></tr>'.format(data=data)
body += '<tr><th>Emprise</th><td>{data[28]}</td></tr>'.format(data=data) body += '<tr><th>UUID</th><td>{data[1]}</td></tr>'.format(data=data)
body += '</table></div>' body += '</table></div>'
#body += '<div id="map"></div>' self.set_html_content(
layer.name(), body)
body += '<div><h3>Publication</h3><table class="table table-condensed">'
body += '<tr><th>Date</th><td>{data[11]}</td></tr>'.format(data=data) def set_html_to_wms(self, layer):
body += '<tr><th>Fréquence de mise à jour</th><td>{data[12]}</td></tr>'.format(data=data) self.set_html_content(
body += '<tr><th>Licence</th><td>{data[13]}</td></tr>'.format(data=data) 'CenRa Metadata', (layer.htmlMetadata()))
body += '<tr><th>Licence attribué</th><td>{data[25]}</td></tr>'.format(data=data)
body += '<tr><th>Restriction</th><td>{data[14]}</td></tr>'.format(data=data) def default_html_content_not_pg_layer(self):
body += '</table></div>' """ When it's not a PostgreSQL layer. """
self.set_html_content(
body += '<div><h3>Lien</h3><table class="table table-condensed table-striped table-bordered">' 'CenRa Metadata', ('Vous devez cliquer sur une couche dans la légende qui est stockée dans PostgreSQL.'))
body += '<tr><th>Type</th><th>URL</th><th>Type MIME</th><th>Format</th><th>Taille</th></tr>'
for value_url in data_url: def default_html_content_not_metadata(self):
body += '<tr><td>{value_url[0]}</td><td>{value_url[1]}</td><td>{value_url[2]}</td><td>{value_url[3]}</td><td>{value_url[4]}</td></tr>'.format(value_url=value_url) self.set_html_content(
body += '</table></div>' 'CenRa Metadata', ('La couche ne contien pas de métadonnée.'))
'''
body += '<div><h3>Liste des champs</h3><table class="table table-condensed table-striped table-bordered">' def sql_check(self, uri):
for collonne in data_collonne: cur = login_base()
body += '<tr><th>{collonne}</th><td>{defini}</td></tr>'.format(collonne=collonne,defini='') table = uri.table()
body += '</table></div>' schema = uri.schema()
'''
body += '<div><h3>Contacts</h3><table class="table table-condensed table-striped table-bordered">' sql_count = """SELECT count(uid) FROM metadata.dataset
body += '<tr><th>Rôle</th><th>Nom</th><th>Organisation</th><th>Email</th><th>Télèphone</th></tr>' WHERE schema_name LIKE '""" + schema + """' AND table_name LIKE '""" + table + """';"""
for value_contact in data_contact:
body += '<tr><td>{value_contact[0]}</td><td>{value_contact[1]}</td><td>{value_contact[2]}</td><td>{value_contact[3]}</td><td>{value_contact[4]}</td></tr>'.format(value_contact=value_contact) cur.execute(sql_count)
body += '</table></div>' data_count = cur.fetchall()
cur.close()
body += '<div><h3>Metadata</h3><table class="table table-condensed">' return data_count[0][0]
body += '<tr><th>Table</th><td>{data[2]}</td></tr>'.format(data=data)
body += '<tr><th>Schema</th><td>{data[3]}</td></tr>'.format(data=data) def sql_info(self, uri):
body += '<tr><th>Date de création</th><td>{data[20]}</td></tr>'.format(data=data) cur = login_base()
body += '<tr><th>Date de modification</th><td>{data[21]}</td></tr>'.format(data=data) table = uri.table()
body += '<tr><th>Encodage</th><td>{data[27]}</td></tr>'.format(data=data) schema = uri.schema()
body += '<tr><th>UUID</th><td>{data[1]}</td></tr>'.format(data=data) # [s for s in iface.activeLayer().source().split(" ") if "dbname" in s][0].split("'")[1]
body += '</table></div>' sql_find = """SELECT *,right(left(st_astext(geom,2),-2),-9) FROM metadata.dataset
WHERE schema_name LIKE '""" + schema + """' AND table_name LIKE '""" + table + """';"""
self.set_html_content( cur.execute(sql_find)
layer.name(), body) data_general = cur.fetchall()
sql_findurl = """SELECT type,url,mime,format,taille FROM metadata.dataurl WHERE schema_name LIKE '""" + schema + """' AND table_name LIKE '""" + table + """';"""
def set_html_to_wms(self,layer): cur.execute(sql_findurl)
self.set_html_content( data_url = cur.fetchall()
'CenRa Metadata',(layer.htmlMetadata())) sql_findcontact = """SELECT role,nom,organisation,email,telephone FROM metadata.datacontact WHERE schema_name LIKE '""" + schema + """' AND table_name LIKE '""" + table + """';"""
def default_html_content_not_pg_layer(self): cur.execute(sql_findcontact)
""" When it's not a PostgreSQL layer. """ data_contact = cur.fetchall()
self.set_html_content( cur.close()
'CenRa Metadata', ('Vous devez cliquer sur une couche dans la légende qui est stockée dans PostgreSQL.')) return data_general[0], data_url, data_contact
def default_html_content_not_metadata(self):
self.set_html_content(
'CenRa Metadata', ('La couche ne contien pas de métadonnée.'))
def sql_check(self,uri):
cur=login_base()
table = uri.table()
schema = uri.schema()
sql_count = """SELECT count(uid) FROM metadata.dataset
WHERE schema_name LIKE '"""+schema+"""' AND table_name LIKE '"""+table+"""';"""
cur.execute(sql_count)
data_count = cur.fetchall()
cur.close()
return data_count[0][0]
def sql_info(self,uri):
cur=login_base()
table = uri.table()
schema = uri.schema()
#[s for s in iface.activeLayer().source().split(" ") if "dbname" in s][0].split("'")[1]
sql_find = """SELECT *,right(left(st_astext(geom,2),-2),-9) FROM metadata.dataset
WHERE schema_name LIKE '"""+schema+"""' AND table_name LIKE '"""+table+"""';"""
cur.execute(sql_find)
data_general = cur.fetchall()
sql_findurl = """SELECT type,url,mime,format,taille FROM metadata.dataurl WHERE schema_name LIKE '"""+schema+"""' AND table_name LIKE '"""+table+"""';"""
cur.execute(sql_findurl)
data_url = cur.fetchall()
sql_findcontact = """SELECT role,nom,organisation,email,telephone FROM metadata.datacontact WHERE schema_name LIKE '"""+schema+"""' AND table_name LIKE '"""+table+"""';"""
cur.execute(sql_findcontact)
data_contact = cur.fetchall()
cur.close()
return data_general[0],data_url,data_contact

File diff suppressed because it is too large Load Diff

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -1,89 +1,89 @@
import os import os
plugin_dir = os.path.dirname(__file__) plugin_dir = os.path.dirname(__file__)
end_find = plugin_dir.rfind('\\')+1 end_find = plugin_dir.rfind('\\')+1
NAME = plugin_dir[end_find:] NAME = plugin_dir[end_find:]
#print(NAME) #print(NAME)
from qgis.gui import * from qgis.gui import *
from qgis.core import ( from qgis.core import (
NULL, NULL,
QgsApplication, QgsApplication,
QgsDataSourceUri, QgsDataSourceUri,
QgsProject, QgsProject,
QgsProviderConnectionException, QgsProviderConnectionException,
QgsProviderRegistry, QgsProviderRegistry,
QgsRasterLayer, QgsRasterLayer,
QgsSettings, QgsSettings,
QgsVectorLayer, QgsVectorLayer,
QgsGeometry, QgsGeometry,
) )
from qgis.PyQt.QtWidgets import ( from qgis.PyQt.QtWidgets import (
QDialog, QDialog,
QAction, QAction,
QDockWidget, QDockWidget,
QFileDialog, QFileDialog,
QInputDialog, QInputDialog,
QMenu, QMenu,
QToolButton, QToolButton,
QTableWidget, QTableWidget,
QTableWidgetItem, QTableWidgetItem,
) )
from qgis.utils import iface from qgis.utils import iface
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
send_issues, send_issues,
) )
EDITOR_CLASS = load_ui('CenRa_IssuesSend.ui') EDITOR_CLASS = load_ui('CenRa_IssuesSend.ui')
class CenRa_Issues(QDialog, EDITOR_CLASS): class CenRa_Issues(QDialog, EDITOR_CLASS):
def __init__(self, parent=None): def __init__(self, parent=None):
_ = parent _ = parent
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.settings = QgsSettings() self.settings = QgsSettings()
#place connect here #place connect here
self.annuler_button.clicked.connect(self.close) self.annuler_button.clicked.connect(self.close)
self.ok_button.clicked.connect(self.run_sendissues) self.ok_button.clicked.connect(self.run_sendissues)
def run_sendissues(self): def run_sendissues(self):
text_titre = self.titre_line.text() text_titre = self.titre_line.text()
text_message = self.messages_plain.toPlainText() text_message = self.messages_plain.toPlainText()
statu_bug = self.check_bug.isChecked() statu_bug = self.check_bug.isChecked()
statu_aide = self.check_aide.isChecked() statu_aide = self.check_aide.isChecked()
statu_question = self.check_question.isChecked() statu_question = self.check_question.isChecked()
statu_amelioration = self.check_amelioration.isChecked() statu_amelioration = self.check_amelioration.isChecked()
statu_autre = self.check_autre.isChecked() statu_autre = self.check_autre.isChecked()
statu = [] statu = []
if statu_bug == True : statu = statu + [1] if statu_bug == True : statu = statu + [1]
if statu_aide == True : statu = statu + [3] if statu_aide == True : statu = statu + [3]
if statu_question == True : statu = statu + [5] if statu_question == True : statu = statu + [5]
if statu_amelioration == True : statu = statu + [2] if statu_amelioration == True : statu = statu + [2]
if statu_autre == True : statu = statu + [6] if statu_autre == True : statu = statu + [6]
if len(statu) >= 1: if len(statu) >= 1:
import qgis import qgis
url = qgis.utils.pluginMetadata(NAME,'tracker') url = qgis.utils.pluginMetadata(NAME,'tracker')
print(text_message) print(text_message)
send_info = send_issues(url,text_titre,text_message,statu) send_info = send_issues(url,text_titre,text_message,statu)
code = send_info.status_code code = send_info.status_code
print(code) print(code)
else: else:
code = 423 code = 423
if code == 201: if code == 201:
iface.messageBar().pushMessage("Envoyer :", "Votre messages à bien été envoyer.", level=Qgis.Success, duration=20) iface.messageBar().pushMessage("Envoyer :", "Votre messages à bien été envoyer.", level=Qgis.Success, duration=20)
self.close() self.close()
elif code == 422: elif code == 422:
iface.messageBar().pushMessage("Erreur :", "Erreur dans le contenu du messages.", level=Qgis.Critical, duration=20) iface.messageBar().pushMessage("Erreur :", "Erreur dans le contenu du messages.", level=Qgis.Critical, duration=20)
elif code == 423: elif code == 423:
iface.messageBar().pushMessage("Erreur :", "Pas de sujet sélectionné.", level=Qgis.Critical, duration=20) iface.messageBar().pushMessage("Erreur :", "Pas de sujet sélectionné.", level=Qgis.Critical, duration=20)
elif code == 404: elif code == 404:
iface.messageBar().pushMessage("Missing :", "Le serveur de messagerie est injoignable.", level=Qgis.Warning, duration=20) iface.messageBar().pushMessage("Missing :", "Le serveur de messagerie est injoignable.", level=Qgis.Warning, duration=20)

View File

@ -1,48 +1,49 @@
# This file contains metadata for your plugin. # This file contains metadata for your plugin.
# This file should be included when you package your plugin.# Mandatory items: # This file should be included when you package your plugin.# Mandatory items:
[general] [general]
name=CenRa_Metabase name=CenRa_Metabase
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
description=CenRa_METABASE supportsQt6=True
version=1.3 description=CenRa_METABASE
author=Conservatoire d'Espaces Naturels de Rhône-Alpes version=0.3.1
email=si_besoin@cen-rhonealpes.fr author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr
about=Permet de saisire et de visualisé les information lier à la metadonné d'une couche ce trouvent sur PostgreSQL
about=Permet de saisire et de visualisé les information lier à la metadonné d'une couche ce trouvent sur PostgreSQL
repository=https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS
homepage=https://plateformesig.cenra-outils.org/ repository=https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS
tracker=https://gitea.cenra-outils.org/api/v1/repos/CEN-RA/Plugin_QGIS/issues homepage=https://plateformesig.cenra-outils.org/
# End of mandatory metadata tracker=https://gitea.cenra-outils.org/api/v1/repos/CEN-RA/Plugin_QGIS/issues
# End of mandatory metadata
# Recommended items:
# Recommended items:
hasProcessingProvider=no
# Uncomment the following line and add your changelog: hasProcessingProvider=no
changelog=<h2>CenRa_Metabase:</h2></br><p><h3>08/10/2024 - Version 1.3: </h3> - Lecture de métadonnée des flux WMS/WFS.</p></br><p><h3>07/10/2024 - Version 1.2: </h3> - Correctif de bug.</p></br><p><h3>03/10/2024 - Version 1.1: </h3> - Remonte la fênetre dans la pille.</p></br><p><h3>26/08/2024 - Version 1.0: </h3> - Lancement du plugin CenRa_Metabase </p></br> # Uncomment the following line and add your changelog:
changelog=<h2>CenRa_METABASE:</h2></br><p><h3>30/07/2025 - Version 0.3.1: </h3> - Correctife de bug.</p></br><p><h3>19/05/2025 - Version 0.3.0: </h3> - Compatible PyQt5 et PyQt6</p></br><p><h3>09/04/2025 - Version 0.2.3: </h3> - Correctif bug en TT.</p></br><p><h3>09/04/2025 - Version 0.2.2: </h3> - Optimisation pour le TT.</p></br><p><h3>03/04/2025 - Version 0.2.1: </h3> - Mise a jour de securite.</p></br><p><h3>07/01/2025 - Version 0.2.0: </h3> - Deployment sur serveur SIG.</p></br><p><h3>07/01/2025 - Version 0.1.6: </h3> - ByPass du certif ssl ci erreur</p></br><p><h3>19/12/2024 - Version 0.1.5: </h3> - Fix les problem de lenteur qu'en la base est down.</p></br><p><h3>12/12/2024 - Version 0.1.4: </h3> - Crash Fix .</p></br><p><h3>08/10/2024 - Version 0.1.3: </h3> - Lecture de métadonnée des flux WMS/WFS.</p></br><p><h3>07/10/2024 - Version 0.1.2: </h3> - Correctif de bug.</p></br><p><h3>03/10/2024 - Version 0.1.1: </h3> - Remonte la fênetre dans la pille.</p></br><p><h3>26/08/2024 - Version 0.1.0: </h3> - Lancement du plugin CenRa_Metabase </p>
# Tags are comma separated with spaces allowed
tags=python # Tags are comma separated with spaces allowed
tags=python
category=Plugins
icon=icon.png category=Plugins
# experimental flag icon=icon.png
experimental=True # experimental flag
experimental=True
# deprecated flag (applies to the whole plugin, not just a single version)
deprecated=False # deprecated flag (applies to the whole plugin, not just a single version)
deprecated=False
# Since QGIS 3.8, a comma separated list of plugins to be installed
# (or upgraded) can be specified. # Since QGIS 3.8, a comma separated list of plugins to be installed
# Check the documentation for more information. # (or upgraded) can be specified.
# plugin_dependencies= # Check the documentation for more information.
# plugin_dependencies=
Category of the plugin: Raster, Vector, Database or Web
# category=cenra,database,metadata Category of the plugin: Raster, Vector, Database or Web
# category=cenra,database,metadata
# If the plugin can run on QGIS Server.
server=False # If the plugin can run on QGIS Server.
server=False

View File

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -3,11 +3,12 @@
import configparser import configparser
import shutil import shutil
import tempfile import tempfile
import base64 # import base64
import psycopg2 # import psycopg2
import psycopg2.extras # import psycopg2.extras
import os
from os.path import abspath, join, pardir, dirname from os.path import abspath, join, pardir, dirname
from qgis.PyQt.QtWidgets import QApplication
from qgis.PyQt import uic from qgis.PyQt import uic
__copyright__ = "Copyright 2019, 3Liz" __copyright__ = "Copyright 2019, 3Liz"
@ -107,81 +108,77 @@ def load_ui(*args):
return ui_class return ui_class
def login_base(take=None):
from CenRa_METABASE.tools.PythonSQL import host,port,dbname,password,os_user
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') def pyperclip():
user = res_ident[1] dst = dirname(dirname(__file__)) + "\\tools\\"
if os.access('N:/', os.R_OK):
src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
try:
shutil.copy(src, dst)
except FileNotFoundError:
print('404')
except UnboundLocalError:
print('404')
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take: def send_issues(url, titre, body, labels):
return cur,con
else:
return cur
def send_issues(url,titre,body,labels):
import requests import requests
import urllib.request
import json import json
import os # import os
import qgis # import qgis
usr = os.environ['USERNAME'] # usr = os.environ['USERNAME']
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112' token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
url=url+'?token='+token url = url + '?token=' + token
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
headers = {'Authorization': 'token ' + token, 'accept': 'application/json', 'Content-Type': 'application/json'}
payload = {'title': titre, 'body': body, 'labels': labels} payload = {'title': titre, 'body': body, 'labels': labels}
try: try:
urllib.request.urlopen('https://google.com') urllib.request.urlopen('https://google.com')
binar = True binar = True
except: except ValueError:
binar = False binar = False
r = '' r = ''
if binar: if binar:
r = requests.post(url, data=json.dumps(payload), headers=headers) r = requests.post(url, data=json.dumps(payload), headers=headers)
return r return r
def maj_verif(NAME): def maj_verif(NAME):
import qgis import qgis
import urllib.request import urllib.request
iface = qgis.utils.iface iface = qgis.utils.iface
from qgis.core import Qgis from qgis.core import Qgis
url = qgis.utils.pluginMetadata(NAME,'repository') # url = qgis.utils.pluginMetadata(NAME, 'repository')
#URL = url+'/raw/branch/main/plugins.xml' # URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME, 'version')
len_version = len(version) len_version = len(version)
try: try:
urllib.request.urlopen('https://google.com') urllib.request.urlopen('https://google.com')
binar = True binar = True
except: except urllib.error.URLError:
binar = False binar = False
if binar: if binar:
version_web = str(urllib.request.urlopen(URL).read()) try:
plugin_num = version_web.find(NAME) version_web = str(urllib.request.urlopen(URL).read())
valeur_version_web = version_web.find('<version>',plugin_num)+9 plugin_num = version_web.find(NAME)
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version] valeur_version_web = version_web.find('<version>', plugin_num) + 9
if version_plugin != version: version_plugin = version_web[valeur_version_web:valeur_version_web + len_version]
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30) if version_plugin != version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
except urllib.error.URLError:
print("error gitea version ssl")
else: else:
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30) iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
def tr(text, context="@default"):
return QApplication.translate(context, text)
def devlog(NAME): def devlog(NAME):
import qgis import qgis
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>' devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
devmaj = devmaj+qgis.utils.pluginMetadata(NAME,'changelog') devmaj = devmaj + qgis.utils.pluginMetadata(NAME, 'changelog')
return devmaj return devmaj

View File

@ -64,24 +64,11 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QWebView" name="viewer" native="true"> <widget class="QTextBrowser" name="viewer"/>
<property name="url" stdset="0">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header location="global">QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Metabase</string> <string>Journal des modifications</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset>
@ -29,9 +29,6 @@
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -41,7 +38,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>453</width> <width>453</width>
<height>547</height> <height>570</height>
</rect> </rect>
</property> </property>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
@ -56,7 +53,7 @@
<property name="title"> <property name="title">
<string>DevLog</string> <string>DevLog</string>
</property> </property>
<widget class="QWebView" name="viewer" native="true"> <widget class="QTextBrowser" name="viewer">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
@ -65,11 +62,6 @@
<height>511</height> <height>511</height>
</rect> </rect>
</property> </property>
<property name="url" stdset="0">
<url>
<string>about:blank</string>
</url>
</property>
</widget> </widget>
</widget> </widget>
</widget> </widget>
@ -78,19 +70,12 @@
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Ok</set> <set>QDialogButtonBox::NoButton</set>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header location="global">QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -1,34 +0,0 @@
import sys
import socket
import os
IPAddr=socket.gethostbyname(socket.gethostname())
#print(IPAddr)
if IPAddr[0:11] == "100.100.100": #4269
host = "100.100.100.81"
port = "5432"
dbname = "sig4269"
sigdb="sig4269"
refdb="ref_geo4269"
password = "McVities"
if IPAddr[0:9] == "192.168.0": #01
host = "192.168.0.201"
port = "5432"
dbname = "sig01"
sigdb="sig01"
refdb="ref_geo01"
password = "McVities"
if IPAddr[0:9] == "192.168.1": #0726
host = "192.168.1.201"
port = "5432"
dbname = "sig0726"
sigdb="sig0726"
refdb="ref_geo0726"
password = "McVities"
if sys.platform == 'linux':
os_user = os.environ['USER']
else:
os_user = os.environ['USERNAME']
if os_user == 'STAGE':
os_user='stage'
if os_user == 'Administrateur':
os_user='stage'

Binary file not shown.

View File

@ -4,14 +4,14 @@ __email__ = "info@3liz.org"
from qgis.core import QgsApplication from qgis.core import QgsApplication
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl from qgis.PyQt.QtCore import QUrl, QSettings
from qgis.PyQt.QtGui import QDesktopServices, QIcon from qgis.PyQt.QtGui import QDesktopServices, QIcon
from qgis.PyQt.QtWidgets import QAction, QMessageBox from qgis.PyQt.QtWidgets import QAction
from qgis.utils import iface from qgis.utils import iface
import qgis import qgis
#include <QSettings> # include <QSettings>
''' '''
from pg_metadata.connection_manager import ( from pg_metadata.connection_manager import (
store_connections, store_connections,
@ -25,14 +25,13 @@ from pg_metadata.qgis_plugin_tools.tools.custom_logging import setup_logger
''' '''
import os import os
from .tools.resources import ( from .tools.resources import (
plugin_path, # plugin_path,
resources_path, resources_path,
maj_verif, maj_verif,
) )
from .canvas_editor import PageRender_Editor from .canvas_editor import PageRender_Editor
from .about_form import PageRenderAboutDialog from .about_form import AboutDialog
from PyQt5.QtCore import *
class PgPageRender: class PgPageRender:
def __init__(self): def __init__(self):
@ -44,18 +43,18 @@ class PgPageRender:
self.dock_action = None self.dock_action = None
self.help_action = None self.help_action = None
plugin_dir = os.path.dirname(__file__) plugin_dir = os.path.dirname(__file__)
end_find = plugin_dir.rfind('\\')+1 end_find = plugin_dir.rfind('\\') + 1
global NAME global NAME
NAME = plugin_dir[end_find:] NAME = plugin_dir[end_find:]
maj_verif(NAME) maj_verif(NAME)
# Display About window on first use # Display About window on first use
version = qgis.utils.pluginMetadata('CenRa_PAGERENDER','version') version = qgis.utils.pluginMetadata('CenRa_PAGERENDER', 'version')
s = QSettings() s = QSettings()
versionUse = s.value("pagerender/version", 1, type=str) versionUse = s.value("pagerender/version", 1, type=str)
if str(versionUse) != str(version) : if str(versionUse) != str(version):
s.setValue("pagerender/version", str(version)) s.setValue("pagerender/version", str(version))
print(versionUse,version) print(versionUse, version)
self.open_about_dialog() self.open_about_dialog()
def initGui(self): def initGui(self):
@ -73,8 +72,7 @@ class PgPageRender:
if not self.canvas_editor: if not self.canvas_editor:
self.canvas_editor = PageRender_Editor() self.canvas_editor = PageRender_Editor()
self.pagerender_action = QAction(icon, 'CenRa_PAGERENDER', None)
self.pagerender_action = QAction(icon, 'CenRa_PAGERENDER',None)
self.toolBar.addAction(self.pagerender_action) self.toolBar.addAction(self.pagerender_action)
self.pagerender_action.triggered.connect(self.open_editor) self.pagerender_action.triggered.connect(self.open_editor)
''' '''
@ -114,8 +112,9 @@ class PgPageRender:
""" """
About dialog About dialog
""" """
dialog = PageRenderAboutDialog(iface) dialog = AboutDialog(iface)
dialog.exec_() dialog.exec()
def open_help(): def open_help():
""" Open the online help. """ """ Open the online help. """
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/')) QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
@ -127,7 +126,7 @@ class PgPageRender:
def unload(self): def unload(self):
""" Unload the plugin. """ """ Unload the plugin. """
if self.canvas_editor: if self.canvas_editor:
iface.removePluginMenu('CenRa_PAGERENDER',self.pagerender_action) iface.removePluginMenu('CenRa_PAGERENDER', self.pagerender_action)
if self.provider: if self.provider:
QgsApplication.processingRegistry().removeProvider(self.provider) QgsApplication.processingRegistry().removeProvider(self.provider)

View File

@ -3,7 +3,7 @@ import os.path
from pathlib import Path from pathlib import Path
from qgis.PyQt import uic from qgis.PyQt import uic
from qgis.PyQt.QtGui import QPixmap # from qgis.PyQt.QtGui import QPixmap
from qgis.PyQt.QtWidgets import QDialog from qgis.PyQt.QtWidgets import QDialog
from .tools.resources import devlog from .tools.resources import devlog
@ -12,12 +12,12 @@ ABOUT_FORM_CLASS, _ = uic.loadUiType(
os.path.join( os.path.join(
str(Path(__file__).resolve().parent), str(Path(__file__).resolve().parent),
'tools/ui', 'tools/ui',
'CenRa_PageRender_about_form.ui' 'CenRa_about_form.ui'
) )
) )
class PageRenderAboutDialog(QDialog, ABOUT_FORM_CLASS): class AboutDialog(QDialog, ABOUT_FORM_CLASS):
""" About - Let the user display the about dialog. """ """ About - Let the user display the about dialog. """
@ -43,4 +43,4 @@ class PageRenderAboutDialog(QDialog, ABOUT_FORM_CLASS):
Run some actions when Run some actions when
the user closes the dialog the user closes the dialog
""" """
self.close() self.close()

View File

@ -1,145 +1,90 @@
import logging import logging
import os import os
from PyQt5.QtCore import QSettings # from collections import namedtuple
from collections import namedtuple # from enum import Enum
from enum import Enum # from functools import partial
from functools import partial # from pathlib import Path
from pathlib import Path # from xml.dom.minidom import parseString
from xml.dom.minidom import parseString # from qgis.gui import *
from qgis.gui import * # import qgis
import qgis from qgis.core import QgsSettings
from qgis.core import ( from qgis.PyQt.QtCore import Qt
NULL, # from qgis.PyQt.QtPrintSupport import QPrinter
QgsApplication, # from qgis.PyQt.QtWebKitWidgets import QWebPage
QgsScaleBarSettings,
QgsDataSourceUri,
QgsProject,
QgsProviderConnectionException,
QgsProviderRegistry,
QgsRasterLayer,
QgsSettings,
QgsVectorLayer,
QgsGeometry,
QgsPrintLayout,
QgsReadWriteContext,
QgsLayoutItemMap,
QgsLayoutItemPage,
QgsLayoutSize,
QgsUnitTypes,
QgsLayoutPoint,
QgsLayoutItemLabel,
QgsLayoutItemPicture,
QgsLayoutItemLegend,
QgsLegendStyle,
QgsLayoutItemScaleBar,
QgsLayerTreeGroup,
QgsCoordinateReferenceSystem,
QgsCoordinateTransform,
QgsLayerTree,
QgsLayoutTableColumn,
QgsRectangle,
QgsLayoutItemMapOverviewStack,
)
from qgis.PyQt.QtCore import QLocale, QUrl, QDateTime, Qt
from qgis.PyQt.QtGui import QDesktopServices, QIcon, QColor, QFont, QMovie
from qgis.PyQt.QtPrintSupport import QPrinter
from qgis.PyQt.QtWebKitWidgets import QWebPage
from qgis.PyQt.QtWidgets import ( from qgis.PyQt.QtWidgets import (
QDialog, QDialog,
QAction,
QDockWidget,
QFileDialog, QFileDialog,
QInputDialog,
QMenu,
QToolButton,
QTableWidget,
QTableWidgetItem, QTableWidgetItem,
QVBoxLayout,
) )
from PyQt5 import QtGui
from qgis.PyQt.QtXml import QDomDocument from qgis.PyQt import QtGui
from qgis.utils import iface from qgis.PyQt.QtWidgets import QApplication
import glob from qgis.PyQt.QtCore import QSettings
# from qgis.PyQt.QtXml import QDomDocument
# from qgis.utils import iface
# import glob
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base, # send_issues,
send_issues,
) )
from .issues import CenRa_Issues # from .issues import CenRa_Issues
from datetime import date # from datetime import date
last_select = None last_select = None
maxV=210 maxV = 210
maxH=296 maxH = 296
EDITOR_CLASS = load_ui('CenRa_PageRender_base.ui') EDITOR_CLASS = load_ui('CenRa_PageRender_base.ui')
LOGGER = logging.getLogger('CenRa_PageRender') LOGGER = logging.getLogger('CenRa_PageRender')
url_osm = 'https://osm.datagrandest.fr/mapcache/?crs=EPSG:2154&featureCount=10&format=image/png&layers=pure&maxHeight=256&maxWidth=256&styles=&url=https://osm.datagrandest.fr/mapcache' url_osm = 'https://osm.datagrandest.fr/mapcache/?crs=EPSG:2154&featureCount=10&format=image/png&layers=pure&maxHeight=256&maxWidth=256&styles=&url=https://osm.datagrandest.fr/mapcache'
url_ortho = 'http://tiles.craig.fr/ortho/service/?crs=EPSG:2154&featureCount=10&format=image/jpeg&layers=ortho&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/ortho/service' url_ortho = 'http://tiles.craig.fr/ortho/service/?crs=EPSG:2154&featureCount=10&format=image/jpeg&layers=ortho&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/ortho/service'
url_mnt = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=relief&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt' url_mnt = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=relief&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
url_pente = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=pente&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt' url_pente = 'http://tiles.craig.fr/mnt/crs=EPSG:2154&featureCount=10&format=image/png&layers=pente&maxHeight=256&maxWidth=256&styles=&url=http://tiles.craig.fr/mnt'
data_source = [ data_source = ['CENRA', 'IGN', 'CRAIG', 'OpenStreetMap', 'Sandre', 'BRGM', 'MUSÉUM NATIONAL DHISTOIRE NATURELLE', "Muséum national d'Histoire naturelle", 'ONF', '20xx LPO', 'ofb.gouv.fr', 'Stamen Design', 'MTES', 'MTES', 'FEDER', 'DREAL Auvergne-Rhône-Alpes', 'INSEE', 'DGFiP', 'Fédération des Conservatoires despaces naturels', 'Plan cadastral informatisé - Etalab - juillet 202X', 'Parcellaire Express - IGN - 202X']
'CENRA',
'IGN',
'CRAIG',
'OpenStreetMap',
'Sandre',
'BRGM',
'MUSÉUM NATIONAL DHISTOIRE NATURELLE',
"Muséum national d'Histoire naturelle",
'ONF',
'20xx LPO',
'ofb.gouv.fr',
'Stamen Design',
'MTES',
'MTES',
'FEDER',
'DREAL Auvergne-Rhône-Alpes',
'INSEE',
'DGFiP',
'Fédération des Conservatoires despaces naturels',
'Plan cadastral informatisé - Etalab - juillet 202X',
'Parcellaire Express - IGN - 202X',
]
class PageRender_Editor(QDialog, EDITOR_CLASS):
class PageRender_Editor(QDialog, EDITOR_CLASS):
def __init__(self, parent=None): def __init__(self, parent=None):
_ = parent _ = parent
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.settings = QgsSettings() self.settings = QgsSettings()
self.s = QSettings() self.s = QSettings()
self.setWindowIcon(QtGui.QIcon(resources_path('icons','icon.png'))) self.setWindowIcon(QtGui.QIcon(resources_path('icons', 'icon.png')))
self.varLandscape = {} self.varLandscape = {}
self.varPortrait = {} self.varPortrait = {}
self.rotate_object = { self.rotate_object = {
'Titre':0, 'Titre': 0,
'Sous_titre':0, 'Sous_titre': 0,
'Carte':0, 'Carte': 0,
'Carte_2':0, 'Carte_2': 0,
'Legande':0, 'Legande': 0,
'Arrow':0, 'Arrow': 0,
'Echelle':0, 'Echelle': 0,
'Logo':0, 'Logo': 0,
'Credit':0, 'Credit': 0,
'Source':0, 'Source': 0,
'Echelle_2':0, 'Echelle_2': 0,
'Logo_2':0,} 'Logo_2': 0}
self.varObject = {}
path = '' path = ''
ix = 0 ix = 0
plugin_dir = str(os.path.dirname(os.path.abspath(__file__))).split(os.sep) plugin_dir = str(os.path.dirname(os.path.abspath(__file__))).split(os.sep)
for i in plugin_dir: for i in plugin_dir:
ix = ix+1 ix = ix + 1
path = path+'\\'+i path = path + '\\' + i
self.path = path[1:]+'\\demoV2.py' self.path = path[1:] + '\\demoV2.py'
#self.tabWidget.setStyleSheet('background-image: url('+path+'/tools/bg/Capture.png);') # self.tabWidget.setStyleSheet('background-image: url('+path+'/tools/bg/Capture.png);')
self.toolButton.setIcon(QtGui.QIcon(resources_path('ui','rotate.png'))) self.toolButton.setIcon(QtGui.QIcon(resources_path('ui', 'rotate.png')))
self.horizontalSlider.valueChanged.connect(self.horizontal) self.horizontalSlider.valueChanged.connect(self.horizontal)
self.verticalSlider.valueChanged.connect(self.vertical) self.verticalSlider.valueChanged.connect(self.vertical)
self.tableWidget.itemSelectionChanged.connect(self.setSlider) self.tableWidget.itemSelectionChanged.connect(self.setSlider)
self.tableWidget_2.cellChanged.connect(self.setObject)
self.radioButton.toggled.connect(self.setSlider) self.radioButton.toggled.connect(self.setSlider)
self.pushButton.clicked.connect(self.export) self.pushButton.clicked.connect(self.export)
self.spinBox.editingFinished.connect(self.valueSlider) self.spinBox.editingFinished.connect(self.valueSlider)
@ -148,62 +93,154 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
self.toolButton_2.clicked.connect(self.type_page) self.toolButton_2.clicked.connect(self.type_page)
self.pushButton_2.clicked.connect(self.load) self.pushButton_2.clicked.connect(self.load)
self.verticalScrollBar.valueChanged.connect(self.moveFrame) self.verticalScrollBar.valueChanged.connect(self.moveFrame)
# self.setAcceptHoverEvents(True)
self.tableWidget.setTabKeyNavigation(False)
def raise_(self): def raise_(self):
self.activateWindow() self.activateWindow()
self.setNavigator() self.setNavigator()
self.verticalScrollBar.setValue(self.frame.y()) self.verticalScrollBar.setValue(self.frame.y())
def mousePressEvent(self, event):
if self.tableWidget.currentItem() is not None:
QApplication.setOverrideCursor(Qt.CursorShape(18))
global lastPos
lastPos = {'x': event.pos().x(), 'y': event.pos().y()}
def moveFrame(self): def moveFrame(self):
self.frame.move(self.frame.x(),self.verticalScrollBar.value()) self.frame.move(self.frame.x(), self.verticalScrollBar.value())
def keyPressEvent(self, event):
# if event.modifiers() & Qt.ControlModifier:
if event.key() == Qt.Key(0x01000015):
self.verticalSlider.setValue(self.spinBox_2.value() + 1)
if event.key() == Qt.Key(0x01000013):
self.verticalSlider.setValue(self.spinBox_2.value() - 1)
if event.key() == Qt.Key(0x01000014):
self.horizontalSlider.setValue(self.spinBox.value() + 1)
if event.key() == Qt.Key(0x01000012):
self.horizontalSlider.setValue(self.spinBox.value() - 1)
def wheelEvent(self, event):
if (event.angleDelta().y() >= 1):
vsb = self.verticalScrollBar.value() + 50
else:
vsb = self.verticalScrollBar.value() - 50
self.verticalScrollBar.setValue(vsb)
def mouseMoveEvent(self, event):
updated_cursor_position = event.pos()
if self.tableWidget.currentItem() is not None:
selection_name = (self.tableWidget.currentItem()).text()
all_children = self.frame.children()
selection = 0
for children in all_children:
if selection_name == children.objectName():
selection = children
frame_x = self.frame.x()
frame_y = self.frame.y()
frame_w = self.frame.width() + frame_x
frame_h = self.frame.height() + frame_y
global lastPos
orig_position_w = selection.width()
orig_position_h = selection.height()
if (frame_x <= round(updated_cursor_position.x()) <= frame_w and self.radioButton.isChecked() is True):
updated_cursor_position_x = orig_position_w + (round(updated_cursor_position.x() - lastPos['x']))
lastPos['x'] = event.pos().x()
selection.resize(updated_cursor_position_x, orig_position_h)
self.horizontalSlider.setValue(round(updated_cursor_position_x / 3.5))
orig_position_w = selection.width()
orig_position_h = selection.height()
if (frame_y <= round(updated_cursor_position.y()) <= frame_h and self.radioButton.isChecked() is True):
updated_cursor_position_y = orig_position_h + (round(updated_cursor_position.y() - lastPos['y']))
lastPos['y'] = event.pos().y()
selection.resize(orig_position_w, updated_cursor_position_y)
self.verticalSlider.setValue(round(updated_cursor_position_y / 3.5))
orig_position_x = selection.pos().x()
orig_position_y = selection.pos().y()
if (frame_x <= round(updated_cursor_position.x()) <= frame_w and self.radioButton.isChecked() is False):
updated_cursor_position_x = orig_position_x + (round(updated_cursor_position.x() - lastPos['x']))
lastPos['x'] = event.pos().x()
# print(updated_cursor_position_x)
selection.move(updated_cursor_position_x, orig_position_y)
self.horizontalSlider.setValue(round(updated_cursor_position_x / 3.5))
orig_position_x = selection.pos().x()
orig_position_y = selection.pos().y()
if (frame_y <= round(updated_cursor_position.y()) <= frame_h and self.radioButton.isChecked() is False):
updated_cursor_position_y = orig_position_y + (round(updated_cursor_position.y() - lastPos['y']))
lastPos['y'] = event.pos().y()
# print(updated_cursor_position_y)
selection.move(orig_position_x, updated_cursor_position_y)
self.verticalSlider.setValue(round(updated_cursor_position_y / 3.5))
def mouseReleaseEvent(self, event):
# print('x: {0}, y: {1}'.format(event.pos().x(), event.pos().y()))
if self.tableWidget.currentItem() is not None:
QApplication.restoreOverrideCursor()
def select_file(self): def select_file(self):
options = QFileDialog.Options() # options = QFileDialog.Options()
options |= QFileDialog.ShowDirsOnly # options |= QFileDialog.getExistingDirectory()
folder = QFileDialog.getOpenFileName(self, "Sélection du fichier ",'','Python(*.py)') folder = QFileDialog.getOpenFileName(self, "Sélection du fichier ", '', 'Python(*.py)')
if folder[0] != '': if folder[0] != '':
return folder[0] return folder[0]
else: else:
return '' return ''
def load(self): def load(self):
folder = self.select_file() folder = self.select_file()
logopath = folder logopath = folder
if logopath != '': if logopath != '':
#logopath = (os.path.dirname(logopath).split('/')) # logopath = (os.path.dirname(logopath).split('/'))
sourcefile = open(logopath, 'r') sourcefile = open(logopath, 'r')
splitsource = sourcefile.read().splitlines() splitsource = sourcefile.read().splitlines()
all_children = self.frame.children() all_children = self.frame.children()
all_element = ['_locals','_size','_rotate'] all_element = ['_locals', '_size', '_rotate', '_frame', '_background', '_path']
for children in all_children: for children in all_children:
flen = 0 flen = 0
for element in all_element: for element in all_element:
flen = 0 flen = 0
recherche_element = children.objectName()+element recherche_element = children.objectName() + element
for find_it in splitsource: for find_it in splitsource:
if find_it.find(recherche_element) != -1: if find_it.find(recherche_element) != -1:
flen = flen+1 flen = flen + 1
if flen == 1: if flen == 1:
if element != '_rotate': if element == '_frame' or element == '_background' or element == '_path':
value_find = (find_it[find_it[:].find('(')+1:-33]).split(',') value_find = (find_it.split('=')[1]).replace('"', '')
if children.objectName() in self.varObject:
if element[1:] in self.varObject[children.objectName()]:
self.varObject[children.objectName()][element[1:]] = value_find
else:
self.varObject[children.objectName()].update({element[1:]: value_find})
else:
self.varObject.update({children.objectName(): {element[1:]: value_find}})
# print(self.varObject)
elif element != '_rotate':
value_find = (find_it[find_it[:].find('(') + 1:-33]).split(',')
if element == '_size': if element == '_size':
Psize_h = float(value_find[0])*3.5 Psize_h = float(value_find[0]) * 3.5
Psize_w = float(value_find[1])*3.5 Psize_w = float(value_find[1]) * 3.5
if element == '_locals': if element == '_locals':
Plocals_h = float(value_find[0])*3.5 Plocals_h = float(value_find[0]) * 3.5
Plocals_w = float(value_find[1])*3.5 Plocals_w = float(value_find[1]) * 3.5
else: else:
Protate = float((find_it[find_it[:].find('=')+2:]).split(',')[0]) Protate = float((find_it[find_it[:].find('=') + 2:]).split(',')[0])
if flen == 3: if flen == 3:
if element != '_rotate': if element != '_rotate':
value_find = (find_it[find_it[:].find('(')+1:-33]).split(',') value_find = (find_it[find_it[:].find('(') + 1:-33]).split(',')
if element == '_size': if element == '_size':
Lsize_h = float(value_find[0])*3.5 Lsize_h = float(value_find[0]) * 3.5
Lsize_w = float(value_find[1])*3.5 Lsize_w = float(value_find[1]) * 3.5
if element == '_locals': if element == '_locals':
Llocals_h = float(value_find[0])*3.5 Llocals_h = float(value_find[0]) * 3.5
Llocals_w = float(value_find[1])*3.5 Llocals_w = float(value_find[1]) * 3.5
else: else:
Lrotate = float((find_it[find_it[:].find('=')+2:]).split(',')[0]) Lrotate = float((find_it[find_it[:].find('=') + 2:]).split(',')[0])
#print('sh',Psize_h,',sw',Psize_w,',lh',Plocals_h,',lw',Plocals_w,',r',Protate) # print('sh',Psize_h,',sw',Psize_w,',lh',Plocals_h,',lw',Plocals_w,',r',Protate)
if Lrotate == 90 or Lrotate == 270: if Lrotate == 90 or Lrotate == 270:
old = Lsize_w old = Lsize_w
Lsize_w = Lsize_h Lsize_w = Lsize_h
@ -213,12 +250,12 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
Psize_w = Psize_h Psize_w = Psize_h
Psize_h = old Psize_h = old
if self.toolButton_2.text() == 'Landscape': if self.toolButton_2.text() == 'Landscape':
children.resize(round(Lsize_h),round(Lsize_w)) children.resize(round(Lsize_h), round(Lsize_w))
children.move(round(Llocals_h),round(Llocals_w)) children.move(round(Llocals_h), round(Llocals_w))
self.rotate_object[children.objectName()] = Lrotate self.rotate_object[children.objectName()] = Lrotate
if self.toolButton_2.text() == 'Portrait': if self.toolButton_2.text() == 'Portrait':
children.resize(round(Psize_h),round(Psize_w)) children.resize(round(Psize_h), round(Psize_w))
children.move(round(Plocals_h),round(Plocals_w)) children.move(round(Plocals_h), round(Plocals_w))
self.rotate_object[children.objectName()] = Protate self.rotate_object[children.objectName()] = Protate
def valueSlider(self): def valueSlider(self):
@ -227,52 +264,65 @@ class PageRender_Editor(QDialog, EDITOR_CLASS):
def setNavigator(self): def setNavigator(self):
all_children = self.frame.children() all_children = self.frame.children()
xR=0 xR = 0
baseRow = self.tableWidget.rowCount() baseRow = self.tableWidget.rowCount()
while baseRow >= xR: while baseRow >= xR:
self.tableWidget.removeRow(0) self.tableWidget.removeRow(0)
xR = xR+1 xR = xR + 1
self.tableWidget.clear() self.tableWidget.clear()
id=0 # id = 0
for children in all_children: for children in all_children:
position = self.tableWidget.rowCount() position = self.tableWidget.rowCount()
self.tableWidget.insertRow(position) self.tableWidget.insertRow(position)
self.tableWidget.setItem(position,0,QTableWidgetItem(children.objectName())) self.tableWidget.setItem(position, 0, QTableWidgetItem(children.objectName()))
#print(children.objectName()) # print(children.objectName())
def export(self): def export(self):
self.type_page() self.type_page()
self.type_page() self.type_page()
all_children = self.frame.children() all_children = self.frame.children()
#selection_name = (self.tableWidget.currentItem()).text() # selection_name = (self.tableWidget.currentItem()).text()
export_str = """ export_str = """
from qgis.core import ( from qgis.core import (
QgsLayoutSize, QgsLayoutSize,
QgsUnitTypes, QgsUnitTypes,
QgsLayoutPoint, QgsLayoutPoint,
) )
def fletch_canvas(self): def fletch_canvas(self):
if self.radioButton_6.isChecked(): if self.radioButton_6.isChecked():
values_page = 'A4' values_page = 'A4'
else: else:
values_page = 'A3' values_page = 'A3'
if self.radioButton_7.isChecked(): if self.radioButton_7.isChecked():
page_rotate = 'Portrait' page_rotate = 'Portrait'
else: else:
page_rotate = 'Landscape' page_rotate = 'Landscape'
""" """
type = ["Portrait","Landscape"] type = ["Portrait", "Landscape"]
page = ["A4","A3"] page = ["A4", "A3"]
for page_type in type: for page_type in type:
export_str = export_str+""" export_str = export_str + """
if page_rotate == '"""+page_type+"""':""" if page_rotate == '""" + page_type + """':"""
for page_size in page: for page_size in page:
export_str = export_str+""" export_str = export_str + """
if values_page == '"""+page_size+"""':""" if values_page == '""" + page_size + """':"""
for children in all_children: for children in all_children:
selection = children selection = children
if selection.objectName() in self.varObject:
for parametre_object in self.varObject[selection.objectName()]:
if str(selection.objectName()) != "Arrow" and str(parametre_object) != "path":
export_str = export_str + """
self.template_parameters['""" + str(selection.objectName()) + '_' + str(parametre_object) + """'] = """ + str(self.varObject[selection.objectName()][parametre_object])
elif str(selection.objectName()) == "Arrow" and str(parametre_object) == "path":
if str(self.varObject[selection.objectName()][parametre_object]) == "":
self.varObject[selection.objectName()][parametre_object] = "NorthArrow_02.svg"
export_str = export_str + """
self.template_parameters['""" + str(selection.objectName()) + '_' + str(parametre_object) + """'] = '""" + str(self.varObject[selection.objectName()][parametre_object]) + "'"
if page_type == 'Portrait': if page_type == 'Portrait':
item_rotate_object=self.varPortrait[selection.objectName()+'_rotate'][0] item_rotate_object = self.varPortrait[selection.objectName() + '_rotate'][0]
if item_rotate_object == 0 or item_rotate_object == 180: if item_rotate_object == 0 or item_rotate_object == 180:
sw = 0 sw = 0
sh = 1 sh = 1
@ -280,17 +330,17 @@ def fletch_canvas(self):
sw = 1 sw = 1
sh = 0 sh = 0
if page_size == 'A3': if page_size == 'A3':
size_w = (round((self.varPortrait[selection.objectName()+'_size'][sw]/3.5)*1.41)) size_w = (round((self.varPortrait[selection.objectName() + '_size'][sw] / 3.5) * 1.41))
size_h = (round((self.varPortrait[selection.objectName()+'_size'][sh]/3.5)*1.41)) size_h = (round((self.varPortrait[selection.objectName() + '_size'][sh] / 3.5) * 1.41))
locals_w = (round((self.varPortrait[selection.objectName()+'_locals'][1]/3.5)*1.41)) locals_w = (round((self.varPortrait[selection.objectName() + '_locals'][1] / 3.5) * 1.41))
locals_h = (round((self.varPortrait[selection.objectName()+'_locals'][0]/3.5)*1.41)) locals_h = (round((self.varPortrait[selection.objectName() + '_locals'][0] / 3.5) * 1.41))
else: else:
size_w = (round(self.varPortrait[selection.objectName()+'_size'][sw])/3.5) size_w = (round(self.varPortrait[selection.objectName() + '_size'][sw]) / 3.5)
size_h = (round(self.varPortrait[selection.objectName()+'_size'][sh]/3.5)) size_h = (round(self.varPortrait[selection.objectName() + '_size'][sh] / 3.5))
locals_w = (round(self.varPortrait[selection.objectName()+'_locals'][1]/3.5)) locals_w = (round(self.varPortrait[selection.objectName() + '_locals'][1] / 3.5))
locals_h = (round(self.varPortrait[selection.objectName()+'_locals'][0]/3.5)) locals_h = (round(self.varPortrait[selection.objectName() + '_locals'][0] / 3.5))
if page_type == 'Landscape': if page_type == 'Landscape':
item_rotate_object=self.varLandscape[selection.objectName()+'_rotate'][0] item_rotate_object = self.varLandscape[selection.objectName() + '_rotate'][0]
if item_rotate_object == 0 or item_rotate_object == 180: if item_rotate_object == 0 or item_rotate_object == 180:
sw = 0 sw = 0
sh = 1 sh = 1
@ -298,42 +348,43 @@ def fletch_canvas(self):
sw = 1 sw = 1
sh = 0 sh = 0
if page_size == 'A3': if page_size == 'A3':
size_w = (round((self.varLandscape[selection.objectName()+'_size'][sw]/3.5)*1.41)) size_w = (round((self.varLandscape[selection.objectName() + '_size'][sw] / 3.5) * 1.41))
size_h = (round((self.varLandscape[selection.objectName()+'_size'][sh]/3.5)*1.41)) size_h = (round((self.varLandscape[selection.objectName() + '_size'][sh] / 3.5) * 1.41))
locals_w = (round((self.varLandscape[selection.objectName()+'_locals'][1]/3.5)*1.41)) locals_w = (round((self.varLandscape[selection.objectName() + '_locals'][1] / 3.5) * 1.41))
locals_h = (round((self.varLandscape[selection.objectName()+'_locals'][0]/3.5)*1.41)) locals_h = (round((self.varLandscape[selection.objectName() + '_locals'][0] / 3.5) * 1.41))
else: else:
size_w = (round(self.varLandscape[selection.objectName()+'_size'][sw])/3.5) size_w = (round(self.varLandscape[selection.objectName() + '_size'][sw]) / 3.5)
size_h = (round(self.varLandscape[selection.objectName()+'_size'][sh]/3.5)) size_h = (round(self.varLandscape[selection.objectName() + '_size'][sh] / 3.5))
locals_w = (round(self.varLandscape[selection.objectName()+'_locals'][1]/3.5)) locals_w = (round(self.varLandscape[selection.objectName() + '_locals'][1] / 3.5))
locals_h = (round(self.varLandscape[selection.objectName()+'_locals'][0]/3.5)) locals_h = (round(self.varLandscape[selection.objectName() + '_locals'][0] / 3.5))
if item_rotate_object == 270: if item_rotate_object == 270:
locals_h= locals_h + size_w locals_h = locals_h + size_w
if item_rotate_object == 180: if item_rotate_object == 180:
locals_h= locals_h + size_h locals_h = locals_h + size_h
locals_w= locals_w + size_w locals_w = locals_w + size_w
size_w = str(size_w) size_w = str(size_w)
size_h = str(size_h) size_h = str(size_h)
locals_w = str(locals_w) locals_w = str(locals_w)
locals_h = str(locals_h) locals_h = str(locals_h)
export_str = export_str+""" export_str = export_str + """
self.template_parameters['"""+selection.objectName()+"""_size'] = QgsLayoutSize("""+size_w+""","""+ size_h+""", QgsUnitTypes.LayoutMillimeters) self.template_parameters['""" + selection.objectName() + """_size'] = QgsLayoutSize(""" + size_w + """, """ + size_h + """, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['"""+selection.objectName()+"""_locals'] = QgsLayoutPoint("""+locals_w+""", """+locals_h+""", QgsUnitTypes.LayoutMillimeters) self.template_parameters['""" + selection.objectName() + """_locals'] = QgsLayoutPoint(""" + locals_w + """, """ + locals_h + """, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['"""+selection.objectName()+"""_rotate'] = """+str(item_rotate_object) self.template_parameters['""" + selection.objectName() + """_rotate'] = """ + str(item_rotate_object)
export_str= export_str+""" export_str = export_str + """
return self.template_parameters""" return self.template_parameters"""
sourceFile = open(self.path,'w') sourceFile = open(self.path, 'w')
print(export_str, file = sourceFile) print(export_str, file=sourceFile)
sourceFile.close() sourceFile.close()
def type_page(self): def type_page(self):
all_children = self.frame.children() all_children = self.frame.children()
if self.toolButton_2.text() == 'Landscape': if self.toolButton_2.text() == 'Landscape':
self.horizontalSlider.setMaximum(maxV) self.horizontalSlider.setMaximum(maxV)
self.verticalSlider.setMaximum(maxH) self.verticalSlider.setMaximum(maxH)
last_children=0 last_children = 0
for children in all_children: for children in all_children:
selection = children selection = children
size_w = selection.size().width() size_w = selection.size().width()
@ -341,20 +392,20 @@ def fletch_canvas(self):
locals_h = selection.x() locals_h = selection.x()
locals_w = selection.y() locals_w = selection.y()
item_rotate_object = self.rotate_object[selection.objectName()] item_rotate_object = self.rotate_object[selection.objectName()]
self.varLandscape[selection.objectName()+'_size'] = [size_w,size_h] self.varLandscape[selection.objectName() + '_size'] = [size_w, size_h]
self.varLandscape[selection.objectName()+'_locals'] = [locals_w,locals_h] self.varLandscape[selection.objectName() + '_locals'] = [locals_w, locals_h]
self.varLandscape[selection.objectName()+'_rotate'] = [item_rotate_object] self.varLandscape[selection.objectName() + '_rotate'] = [item_rotate_object]
if self.varPortrait != {}: if self.varPortrait != {}:
selection.move(self.varPortrait[selection.objectName()+'_locals'][1],self.varPortrait[selection.objectName()+'_locals'][0]) selection.move(self.varPortrait[selection.objectName() + '_locals'][1], self.varPortrait[selection.objectName() + '_locals'][0])
selection.resize(self.varPortrait[selection.objectName()+'_size'][0],self.varPortrait[selection.objectName()+'_size'][1]) selection.resize(self.varPortrait[selection.objectName() + '_size'][0], self.varPortrait[selection.objectName() + '_size'][1])
self.rotate_object[selection.objectName()] = self.varPortrait[selection.objectName()+'_rotate'][0] self.rotate_object[selection.objectName()] = self.varPortrait[selection.objectName() + '_rotate'][0]
self.rotate_color(selection,last_children) self.rotate_color(selection, last_children)
last_children = selection last_children = selection
self.toolButton_2.setText('Portrait') self.toolButton_2.setText('Portrait')
elif self.toolButton_2.text() == 'Portrait': elif self.toolButton_2.text() == 'Portrait':
self.horizontalSlider.setMaximum(maxV) self.horizontalSlider.setMaximum(maxH)
self.verticalSlider.setMaximum(maxH) self.verticalSlider.setMaximum(maxV)
last_children=0 last_children = 0
for children in all_children: for children in all_children:
selection = children selection = children
size_w = selection.size().width() size_w = selection.size().width()
@ -362,24 +413,46 @@ def fletch_canvas(self):
locals_h = selection.x() locals_h = selection.x()
locals_w = selection.y() locals_w = selection.y()
item_rotate_object = self.rotate_object[selection.objectName()] item_rotate_object = self.rotate_object[selection.objectName()]
self.varPortrait[selection.objectName()+'_size'] = [size_w,size_h] self.varPortrait[selection.objectName() + '_size'] = [size_w, size_h]
self.varPortrait[selection.objectName()+'_locals'] = [locals_w,locals_h] self.varPortrait[selection.objectName() + '_locals'] = [locals_w, locals_h]
self.varPortrait[selection.objectName()+'_rotate'] = [item_rotate_object] self.varPortrait[selection.objectName() + '_rotate'] = [item_rotate_object]
if self.varLandscape != {}: if self.varLandscape != {}:
selection.move(self.varLandscape[selection.objectName()+'_locals'][1],self.varLandscape[selection.objectName()+'_locals'][0]) selection.move(self.varLandscape[selection.objectName() + '_locals'][1], self.varLandscape[selection.objectName() + '_locals'][0])
selection.resize(self.varLandscape[selection.objectName()+'_size'][0],self.varLandscape[selection.objectName()+'_size'][1]) selection.resize(self.varLandscape[selection.objectName() + '_size'][0], self.varLandscape[selection.objectName() + '_size'][1])
self.rotate_object[selection.objectName()] = self.varLandscape[selection.objectName()+'_rotate'][0] self.rotate_object[selection.objectName()] = self.varLandscape[selection.objectName() + '_rotate'][0]
self.rotate_color(selection,last_children) self.rotate_color(selection, last_children)
last_children = selection last_children = selection
self.toolButton_2.setText('Landscape') self.toolButton_2.setText('Landscape')
frame_w = self.frame.width() frame_w = self.frame.width()
frame_h = self.frame.height() frame_h = self.frame.height()
self.frame.resize(frame_h,frame_w) self.frame.resize(frame_h, frame_w)
frame_x = round(frame_w / 3) frame_x = round(frame_w / 3)
frame_y = self.frame.y() frame_y = self.frame.y()
self.frame.move(frame_x,frame_y) self.frame.move(frame_x, frame_y)
def setParameter(self, selection_name):
if selection_name in self.varObject:
for table2Range in range(0, self.tableWidget_2.rowCount()):
rowName = self.tableWidget_2.item(table2Range, 0).text()
if rowName in self.varObject[selection_name]:
self.tableWidget_2.setItem(table2Range, 1, QTableWidgetItem(str(self.varObject[selection_name][rowName])))
else:
self.varObject[selection_name].update({rowName: ""})
self.tableWidget_2.setItem(table2Range, 1, QTableWidgetItem(''))
else:
self.varObject.update({selection_name: {"frame": "", "background": "", "path": ""}})
self.tableWidget_2.setItem(1, 1, QTableWidgetItem(''))
self.tableWidget_2.setItem(2, 1, QTableWidgetItem(''))
self.tableWidget_2.setItem(3, 1, QTableWidgetItem(''))
def setObject(self, event):
selection_name = (self.tableWidget.currentItem()).text()
rowName = self.tableWidget_2.item(event, 0).text()
rowValue = self.tableWidget_2.item(event, 1).text()
self.varObject[selection_name][rowName] = rowValue
def setSlider(self): def setSlider(self):
if self.tableWidget.currentItem() != None: if self.tableWidget.currentItem() is not None:
selection_name = (self.tableWidget.currentItem()).text() selection_name = (self.tableWidget.currentItem()).text()
all_children = self.frame.children() all_children = self.frame.children()
selection = 0 selection = 0
@ -390,37 +463,42 @@ def fletch_canvas(self):
if selection_name == children.objectName(): if selection_name == children.objectName():
selection = children selection = children
if selection != 0: if selection != 0:
self.rotate_color(selection,last_children) self.rotate_color(selection, last_children)
if self.radioButton.isChecked() == False: if self.radioButton.isChecked() is False:
xx = round(selection.x()/3.5) xx = round(selection.x() / 3.5)
yy = round(selection.y()/3.5) yy = round(selection.y() / 3.5)
else: else:
xx = round(selection.size().width()/3.5) xx = round(selection.size().width() / 3.5)
yy = round(selection.size().height()/3.5) yy = round(selection.size().height() / 3.5)
#print(xx,yy) # print(xx,yy)
self.horizontalSlider.setValue(xx) self.horizontalSlider.setValue(xx)
self.verticalSlider.setValue(yy) self.verticalSlider.setValue(yy)
self.spinBox.setValue(xx) self.spinBox.setValue(xx)
self.spinBox_2.setValue(yy) self.spinBox_2.setValue(yy)
self.setParameter(selection_name)
def rotate_color(self,selection,last_children): def rotate_color(self, selection, last_children):
global last_select global last_select
if self.radioButton.isChecked() is False:
ColorCode = "10, 10, 80, 50"
else:
ColorCode = "249, 238, 148, 50"
if self.rotate_object[selection.objectName()] == 0: if self.rotate_object[selection.objectName()] == 0:
selection.setStyleSheet("border: 2px solid;border-color:red;border-bottom-color: blue;background-color: rgb(10, 10, 80, 50)") selection.setStyleSheet("border: 2px solid;border-color:red;border-bottom-color: blue;background-color: rgba(" + ColorCode + ")")
elif self.rotate_object[selection.objectName()] == 90: elif self.rotate_object[selection.objectName()] == 90:
selection.setStyleSheet("border: 2px solid;border-color:red;border-left-color: blue;background-color: rgb(10, 10, 80, 50)") selection.setStyleSheet("border: 2px solid;border-color:red;border-left-color: blue;background-color: rgba(" + ColorCode + ")")
elif self.rotate_object[selection.objectName()] == 180: elif self.rotate_object[selection.objectName()] == 180:
selection.setStyleSheet("border: 2px solid;border-color:red;border-top-color: blue;background-color: rgb(10, 10, 80, 50)") selection.setStyleSheet("border: 2px solid;border-color:red;border-top-color: blue;background-color: rgba(" + ColorCode + ")")
elif self.rotate_object[selection.objectName()] == 270: elif self.rotate_object[selection.objectName()] == 270:
selection.setStyleSheet("border: 2px solid;border-color:red;border-right-color: blue;background-color: rgb(10, 10, 80, 50)") selection.setStyleSheet("border: 2px solid;border-color:red;border-right-color: blue;background-color: rgba(" + ColorCode + ")")
if last_children != 0: if last_children != 0:
if last_select != selection.objectName(): if last_select != selection.objectName():
last_children.setStyleSheet("background-color: rgb(10, 10, 10, 50)") last_children.setStyleSheet("background-color: rgba(10, 10, 10, 50)")
last_select = selection.objectName() last_select = selection.objectName()
def rotate(self): def rotate(self):
if self.tableWidget.currentItem() != None: if self.tableWidget.currentItem() is not None:
selection_name = (self.tableWidget.currentItem()).text() selection_name = (self.tableWidget.currentItem()).text()
all_children = self.frame.children() all_children = self.frame.children()
selection = 0 selection = 0
@ -433,21 +511,21 @@ def fletch_canvas(self):
if selection != 0: if selection != 0:
xx = round(selection.size().width()) xx = round(selection.size().width())
yy = round(selection.size().height()) yy = round(selection.size().height())
selection.resize(round(yy),round(xx)) selection.resize(round(yy), round(xx))
if self.radioButton.isChecked() == True: if self.radioButton.isChecked() is True:
self.spinBox.setValue(yy) self.spinBox.setValue(yy)
self.spinBox_2.setValue(xx) self.spinBox_2.setValue(xx)
self.horizontalSlider.setValue(round(yy/3.5)) self.horizontalSlider.setValue(round(yy / 3.5))
self.verticalSlider.setValue(round(xx/3.5)) self.verticalSlider.setValue(round(xx / 3.5))
if self.rotate_object[selection.objectName()] == 270: if self.rotate_object[selection.objectName()] == 270:
self.rotate_object[selection.objectName()] = 0 self.rotate_object[selection.objectName()] = 0
else: else:
self.rotate_object[selection.objectName()] = self.rotate_object[selection.objectName()] + 90 self.rotate_object[selection.objectName()] = self.rotate_object[selection.objectName()] + 90
self.rotate_color(selection,last_children) self.rotate_color(selection, last_children)
def vertical(self): def vertical(self):
if self.tableWidget.currentItem() != None: if self.tableWidget.currentItem() is not None:
selection_name = (self.tableWidget.currentItem()).text() selection_name = (self.tableWidget.currentItem()).text()
all_children = self.frame.children() all_children = self.frame.children()
selection = 0 selection = 0
@ -455,15 +533,15 @@ def fletch_canvas(self):
if selection_name == children.objectName(): if selection_name == children.objectName():
selection = children selection = children
if selection != 0: if selection != 0:
if self.radioButton.isChecked() == False: if self.radioButton.isChecked() is False:
selection.move(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5)) selection.move(round(self.horizontalSlider.value() * 3.5), round(self.verticalSlider.value() * 3.5))
else: else:
selection.resize(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5)) selection.resize(round(self.horizontalSlider.value() * 3.5), round(self.verticalSlider.value() * 3.5))
self.spinBox.setValue(round(self.horizontalSlider.value())) self.spinBox.setValue(round(self.horizontalSlider.value()))
self.spinBox_2.setValue(round(self.verticalSlider.value())) self.spinBox_2.setValue(round(self.verticalSlider.value()))
def horizontal(self): def horizontal(self):
if self.tableWidget.currentItem() != None: if self.tableWidget.currentItem() is not None:
selection_name = (self.tableWidget.currentItem()).text() selection_name = (self.tableWidget.currentItem()).text()
all_children = self.frame.children() all_children = self.frame.children()
selection = 0 selection = 0
@ -471,10 +549,9 @@ def fletch_canvas(self):
if selection_name == children.objectName(): if selection_name == children.objectName():
selection = children selection = children
if selection != 0: if selection != 0:
if self.radioButton.isChecked() == False: if self.radioButton.isChecked() is False:
selection.move(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5)) selection.move(round(self.horizontalSlider.value() * 3.5), round(self.verticalSlider.value() * 3.5))
else: else:
selection.resize(round(self.horizontalSlider.value()*3.5),round(self.verticalSlider.value()*3.5)) selection.resize(round(self.horizontalSlider.value() * 3.5), round(self.verticalSlider.value() * 3.5))
self.spinBox.setValue(round(self.horizontalSlider.value())) self.spinBox.setValue(round(self.horizontalSlider.value()))
self.spinBox_2.setValue(round(self.verticalSlider.value())) self.spinBox_2.setValue(round(self.verticalSlider.value()))

View File

@ -1,167 +1,169 @@
from qgis.core import ( from qgis.core import (
QgsLayoutSize, QgsLayoutSize,
QgsUnitTypes, QgsUnitTypes,
QgsLayoutPoint, QgsLayoutPoint,
) )
def fletch_canvas(self):
if self.radioButton_6.isChecked():
values_page = 'A4'
else:
values_page = 'A3'
if self.radioButton_7.isChecked():
page_rotate = 'Portrait'
else:
page_rotate = 'Landscape'
if page_rotate == 'Portrait':
if values_page == 'A4': def fletch_canvas(self):
self.template_parameters['Carte_size'] = QgsLayoutSize(200.0,200, QgsUnitTypes.LayoutMillimeters) if self.radioButton_6.isChecked():
self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 6, QgsUnitTypes.LayoutMillimeters) values_page = 'A4'
self.template_parameters['Carte_rotate'] = 0 else:
self.template_parameters['Carte_2_size'] = QgsLayoutSize(80.0,80, QgsUnitTypes.LayoutMillimeters) values_page = 'A3'
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(126, 210, QgsUnitTypes.LayoutMillimeters) if self.radioButton_7.isChecked():
self.template_parameters['Carte_2_rotate'] = 0 page_rotate = 'Portrait'
self.template_parameters['Legande_size'] = QgsLayoutSize(86.0,86, QgsUnitTypes.LayoutMillimeters) else:
self.template_parameters['Legande_locals'] = QgsLayoutPoint(6, 208, QgsUnitTypes.LayoutMillimeters) page_rotate = 'Landscape'
self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286,14, QgsUnitTypes.LayoutMillimeters) if page_rotate == 'Portrait':
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(189, 20, QgsUnitTypes.LayoutMillimeters) if values_page == 'A4':
self.template_parameters['Arrow_rotate'] = 0 self.template_parameters['Carte_size'] = QgsLayoutSize(200.0, 200, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_size'] = QgsLayoutSize(51.42857142857143,7, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(9, 197, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Echelle_rotate'] = 0 self.template_parameters['Carte_2_size'] = QgsLayoutSize(85.71428571428571, 69, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_size'] = QgsLayoutSize(45.714285714285715,11, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(209, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 3, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Logo_rotate'] = 0 self.template_parameters['Legande_size'] = QgsLayoutSize(85.71428571428571, 131, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_size'] = QgsLayoutSize(154.28571428571428,11, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_locals'] = QgsLayoutPoint(209, 74, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(51, 3, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Titre_rotate'] = 0 self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_locals'] = QgsLayoutPoint(189, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(151, 210, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Credit_rotate'] = 0 self.template_parameters['Echelle_size'] = QgsLayoutSize(51.42857142857143, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_locals'] = QgsLayoutPoint(9, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(229, 197, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Source_rotate'] = 0 self.template_parameters['Logo_size'] = QgsLayoutSize(45.714285714285715, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(125.71428571428571,14, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(60, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Sous_titre_rotate'] = 0 self.template_parameters['Titre_size'] = QgsLayoutSize(154.28571428571428, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(51.42857142857143,13, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_locals'] = QgsLayoutPoint(51, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(9, 184, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Echelle_2_rotate'] = 0 self.template_parameters['Credit_size'] = QgsLayoutSize(51.42857142857143, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_size'] = QgsLayoutSize(28.571428571428573,29, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_locals'] = QgsLayoutPoint(151, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(9, 151, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0 self.template_parameters['Source_size'] = QgsLayoutSize(51.42857142857143, 6, QgsUnitTypes.LayoutMillimeters)
if values_page == 'A3': self.template_parameters['Source_locals'] = QgsLayoutPoint(229, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_size'] = QgsLayoutSize(282,282, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Source_rotate'] = 0
self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_size'] = QgsLayoutSize(125.71428571428571, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0 self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(60, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_size'] = QgsLayoutSize(113,113, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(178, 296, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_size'] = QgsLayoutSize(51.42857142857143, 13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0 self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(9, 184, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_size'] = QgsLayoutSize(121,121, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Legande_locals'] = QgsLayoutPoint(8, 293, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_size'] = QgsLayoutSize(28.571428571428573, 29, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0 self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(9, 151, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_size'] = QgsLayoutSize(20,20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(267, 28, QgsUnitTypes.LayoutMillimeters) if values_page == 'A3':
self.template_parameters['Arrow_rotate'] = 0 self.template_parameters['Carte_size'] = QgsLayoutSize(282, 282, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_size'] = QgsLayoutSize(73,10, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(13, 278, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Echelle_rotate'] = 0 self.template_parameters['Carte_2_size'] = QgsLayoutSize(121, 97, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_size'] = QgsLayoutSize(64,16, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(294, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Logo_rotate'] = 0 self.template_parameters['Legande_size'] = QgsLayoutSize(121, 185, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_size'] = QgsLayoutSize(218,16, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_locals'] = QgsLayoutPoint(294, 105, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(72, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Titre_rotate'] = 0 self.template_parameters['Arrow_size'] = QgsLayoutSize(20, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_locals'] = QgsLayoutPoint(266, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(213, 296, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Credit_rotate'] = 0 self.template_parameters['Echelle_size'] = QgsLayoutSize(73, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_locals'] = QgsLayoutPoint(12, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(323, 278, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Source_rotate'] = 0 self.template_parameters['Logo_size'] = QgsLayoutSize(64, 16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(177,20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(85, 28, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Sous_titre_rotate'] = 0 self.template_parameters['Titre_size'] = QgsLayoutSize(218, 16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(73,18, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_locals'] = QgsLayoutPoint(73, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(13, 259, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Echelle_2_rotate'] = 0 self.template_parameters['Credit_size'] = QgsLayoutSize(73, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40,40, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_locals'] = QgsLayoutPoint(214, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(13, 213, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0 self.template_parameters['Source_size'] = QgsLayoutSize(73, 8, QgsUnitTypes.LayoutMillimeters)
if page_rotate == 'Landscape': self.template_parameters['Source_locals'] = QgsLayoutPoint(322, 278, QgsUnitTypes.LayoutMillimeters)
if values_page == 'A4': self.template_parameters['Source_rotate'] = 0
self.template_parameters['Carte_size'] = QgsLayoutSize(200.0,200, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_size'] = QgsLayoutSize(177, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 6, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(85, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0 self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Carte_2_size'] = QgsLayoutSize(85.71428571428571,69, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_size'] = QgsLayoutSize(73, 18, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(209, 3, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(12, 260, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0 self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Legande_size'] = QgsLayoutSize(85.71428571428571,131, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_size'] = QgsLayoutSize(40, 40, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_locals'] = QgsLayoutPoint(209, 74, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(12, 214, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0 self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286,14, QgsUnitTypes.LayoutMillimeters) if page_rotate == 'Landscape':
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(189, 20, QgsUnitTypes.LayoutMillimeters) if values_page == 'A4':
self.template_parameters['Arrow_rotate'] = 0 self.template_parameters['Carte_size'] = QgsLayoutSize(200.0, 200, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_size'] = QgsLayoutSize(51.42857142857143,7, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_locals'] = QgsLayoutPoint(6, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(9, 197, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Echelle_rotate'] = 0 self.template_parameters['Carte_2_size'] = QgsLayoutSize(85.71428571428571, 69, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_size'] = QgsLayoutSize(45.714285714285715,11, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(209, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 3, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Logo_rotate'] = 0 self.template_parameters['Legande_size'] = QgsLayoutSize(85.71428571428571, 131, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_size'] = QgsLayoutSize(154.28571428571428,11, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_locals'] = QgsLayoutPoint(209, 74, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(51, 3, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Titre_rotate'] = 0 self.template_parameters['Arrow_size'] = QgsLayoutSize(14.285714285714286, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_locals'] = QgsLayoutPoint(189, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(151, 197, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Credit_rotate'] = 0 self.template_parameters['Echelle_size'] = QgsLayoutSize(51.42857142857143, 7, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_size'] = QgsLayoutSize(51.42857142857143,6, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_locals'] = QgsLayoutPoint(9, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(229, 197, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Source_rotate'] = 0 self.template_parameters['Logo_size'] = QgsLayoutSize(45.714285714285715, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(125.71428571428571,14, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_locals'] = QgsLayoutPoint(3, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(60, 20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Sous_titre_rotate'] = 0 self.template_parameters['Titre_size'] = QgsLayoutSize(154.28571428571428, 11, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(51.42857142857143,13, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_locals'] = QgsLayoutPoint(51, 3, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(9, 184, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Echelle_2_rotate'] = 0 self.template_parameters['Credit_size'] = QgsLayoutSize(51.42857142857143, 6, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_size'] = QgsLayoutSize(28.571428571428573,29, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_locals'] = QgsLayoutPoint(151, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(9, 151, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0 self.template_parameters['Source_size'] = QgsLayoutSize(51.42857142857143, 6, QgsUnitTypes.LayoutMillimeters)
if values_page == 'A3': self.template_parameters['Source_locals'] = QgsLayoutPoint(229, 197, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_size'] = QgsLayoutSize(282,282, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Source_rotate'] = 0
self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_size'] = QgsLayoutSize(125.71428571428571, 14, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_rotate'] = 0 self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(60, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_size'] = QgsLayoutSize(121,97, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(294, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_size'] = QgsLayoutSize(51.42857142857143, 13, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Carte_2_rotate'] = 0 self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(9, 184, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_size'] = QgsLayoutSize(121,185, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Legande_locals'] = QgsLayoutPoint(294, 105, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_size'] = QgsLayoutSize(28.571428571428573, 29, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Legande_rotate'] = 0 self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(9, 151, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Arrow_size'] = QgsLayoutSize(20,20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_2_rotate'] = 0
self.template_parameters['Arrow_locals'] = QgsLayoutPoint(266, 28, QgsUnitTypes.LayoutMillimeters) if values_page == 'A3':
self.template_parameters['Arrow_rotate'] = 0 self.template_parameters['Carte_size'] = QgsLayoutSize(282, 282, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_size'] = QgsLayoutSize(73,10, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_locals'] = QgsLayoutPoint(8, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_locals'] = QgsLayoutPoint(12, 278, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_rotate'] = 0
self.template_parameters['Echelle_rotate'] = 0 self.template_parameters['Carte_2_size'] = QgsLayoutSize(121, 97, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_size'] = QgsLayoutSize(64,16, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_locals'] = QgsLayoutPoint(294, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Carte_2_rotate'] = 0
self.template_parameters['Logo_rotate'] = 0 self.template_parameters['Legande_size'] = QgsLayoutSize(121, 185, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_size'] = QgsLayoutSize(218,16, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_locals'] = QgsLayoutPoint(294, 105, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Titre_locals'] = QgsLayoutPoint(73, 4, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Legande_rotate'] = 0
self.template_parameters['Titre_rotate'] = 0 self.template_parameters['Arrow_size'] = QgsLayoutSize(20, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_locals'] = QgsLayoutPoint(266, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Credit_locals'] = QgsLayoutPoint(214, 278, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Arrow_rotate'] = 0
self.template_parameters['Credit_rotate'] = 0 self.template_parameters['Echelle_size'] = QgsLayoutSize(73, 10, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_size'] = QgsLayoutSize(73,8, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_locals'] = QgsLayoutPoint(12, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_locals'] = QgsLayoutPoint(322, 278, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Echelle_rotate'] = 0
self.template_parameters['Source_rotate'] = 0 self.template_parameters['Logo_size'] = QgsLayoutSize(64, 16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(177,20, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_locals'] = QgsLayoutPoint(4, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(85, 28, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Logo_rotate'] = 0
self.template_parameters['Sous_titre_rotate'] = 0 self.template_parameters['Titre_size'] = QgsLayoutSize(218, 16, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(73,18, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_locals'] = QgsLayoutPoint(73, 4, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(12, 260, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Titre_rotate'] = 0
self.template_parameters['Echelle_2_rotate'] = 0 self.template_parameters['Credit_size'] = QgsLayoutSize(73, 8, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40,40, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_locals'] = QgsLayoutPoint(214, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(12, 214, QgsUnitTypes.LayoutMillimeters) self.template_parameters['Credit_rotate'] = 0
self.template_parameters['Logo_2_rotate'] = 0 self.template_parameters['Source_size'] = QgsLayoutSize(73, 8, QgsUnitTypes.LayoutMillimeters)
return self.template_parameters self.template_parameters['Source_locals'] = QgsLayoutPoint(322, 278, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Source_rotate'] = 0
self.template_parameters['Sous_titre_size'] = QgsLayoutSize(177, 20, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_locals'] = QgsLayoutPoint(85, 28, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Sous_titre_rotate'] = 0
self.template_parameters['Echelle_2_size'] = QgsLayoutSize(73, 18, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_locals'] = QgsLayoutPoint(12, 260, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Echelle_2_rotate'] = 0
self.template_parameters['Logo_2_size'] = QgsLayoutSize(40, 40, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_locals'] = QgsLayoutPoint(12, 214, QgsUnitTypes.LayoutMillimeters)
self.template_parameters['Logo_2_rotate'] = 0
return self.template_parameters

View File

@ -5,8 +5,9 @@
[general] [general]
name=CenRa_PageRender name=CenRa_PageRender
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
supportsQt6=True
description=CenRa_PageRender description=CenRa_PageRender
version=1.3 version=0.2.3
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@ -21,7 +22,7 @@ tracker=https://gitea.cenra-outils.org/api/v1/repos/CEN-RA/Plugin_QGIS/issues
hasProcessingProvider=no hasProcessingProvider=no
# Uncomment the following line and add your changelog: # Uncomment the following line and add your changelog:
changelog=<h2>CenRa_PageRender:</h2></br><p><h3>08/11/2024 - Version 1.3: </h3> - Correctif de bug. </br><p><h3>21/10/2024 - Version 1.1: </h3> - Les match en if. </br> - Bouton de scroll et adaptation portrait.</p></br><p><h3>09/10/2024 - Version 1.0: </h3> - Création.</p> changelog=<h2>CenRa_PAGERENDER:</h2></br><p><h3>15/12/2025 - Version 0.2.3: </h3> - nouveau systeme de parametrage.</p></br><p><h3>12/12/2025 - Version 0.2.2: </h3> - bug sur le background.</p></br><p><h3>30/07/2025 - Version 0.2.1: </h3> - Correctife de bug.</p></br><p><h3>19/05/2025 - Version 0.2.0: </h3> - Compatible PyQt5 et PyQt6</p></br><p><h3>03/04/2025 - Version 0.1.6: </h3> - Mise a jour de securite.</p></br><p><h3>07/01/2025 - Version 0.1.5: </h3> - ByPass du certif ssl ci erreur.</br></p><p><h3>14/11/2024 - Version 0.1.4: </h3> - Implementation de la mollet. </br> - Implementation du dragging pour déplacer et modification de la taille </br></p></br><p><h3>08/11/2024 - Version 0.1.3: </h3> - Correctif de bug. </br><p><h3>21/10/2024 - Version 0.1.1: </h3> - Les match en if. </br> - Bouton de scroll et adaptation portrait.</p></br><p><h3>09/10/2024 - Version 0.1.0: </h3> - Création.</p>
# Tags are comma separated with spaces allowed # Tags are comma separated with spaces allowed
tags=python tags=python

View File

@ -1,34 +0,0 @@
import sys
import socket
import os
IPAddr=socket.gethostbyname(socket.gethostname())
#print(IPAddr)
if IPAddr[0:11] == "100.100.100": #4269
host = "100.100.100.81"
port = "5432"
dbname = "sig4269"
sigdb="sig4269"
refdb="ref_geo4269"
password = "McVities"
if IPAddr[0:9] == "192.168.0": #01
host = "192.168.0.201"
port = "5432"
dbname = "sig01"
sigdb="sig01"
refdb="ref_geo01"
password = "McVities"
if IPAddr[0:9] == "192.168.1": #0726
host = "192.168.1.201"
port = "5432"
dbname = "sig0726"
sigdb="sig0726"
refdb="ref_geo0726"
password = "McVities"
if sys.platform == 'linux':
os_user = os.environ['USER']
else:
os_user = os.environ['USERNAME']
if os_user == 'STAGE':
os_user='stage'
if os_user == 'Administrateur':
os_user='stage'

View File

@ -3,9 +3,9 @@
import configparser import configparser
import shutil import shutil
import tempfile import tempfile
import base64 # import base64
import psycopg2 # import psycopg2
import psycopg2.extras # import psycopg2.extras
from os.path import abspath, join, pardir, dirname from os.path import abspath, join, pardir, dirname
from qgis.PyQt.QtWidgets import QApplication from qgis.PyQt.QtWidgets import QApplication
from qgis.PyQt import uic from qgis.PyQt import uic
@ -107,81 +107,68 @@ def load_ui(*args):
return ui_class return ui_class
def login_base(take=None):
from CenRa_METABASE.tools.PythonSQL import host,port,dbname,password,os_user
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') def send_issues(url, titre, body, labels):
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp)
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take:
return cur,con
else:
return cur
def send_issues(url,titre,body,labels):
import requests import requests
import urllib.request
import json import json
import os # import os
import qgis
usr = os.environ['USERNAME'] # usr = os.environ['USERNAME']
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112' token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
url=url+'?token='+token url = url + '?token=' + token
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
headers = {'Authorization': 'token ' + token, 'accept': 'application/json', 'Content-Type': 'application/json'}
payload = {'title': titre, 'body': body, 'labels': labels} payload = {'title': titre, 'body': body, 'labels': labels}
try: try:
urllib.request.urlopen('https://google.com') urllib.request.urlopen('https://google.com')
binar = True binar = True
except: except urllib.requests.URLError:
binar = False binar = False
r = '' r = ''
if binar: if binar:
r = requests.post(url, data=json.dumps(payload), headers=headers) r = requests.post(url, data=json.dumps(payload), headers=headers)
return r return r
def maj_verif(NAME): def maj_verif(NAME):
import qgis import qgis
import urllib.request import urllib.request
iface = qgis.utils.iface iface = qgis.utils.iface
from qgis.core import Qgis from qgis.core import Qgis
url = qgis.utils.pluginMetadata(NAME,'repository') # url = qgis.utils.pluginMetadata(NAME, 'repository')
#URL = url+'/raw/branch/main/plugins.xml' # URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME, 'version')
len_version = len(version) len_version = len(version)
try: try:
urllib.request.urlopen('https://google.com') urllib.request.urlopen('https://google.com')
binar = True binar = True
except: except urllib.requests.URLError:
binar = False binar = False
if binar: if binar:
version_web = str(urllib.request.urlopen(URL).read()) try:
plugin_num = version_web.find(NAME) version_web = str(urllib.request.urlopen(URL).read())
valeur_version_web = version_web.find('<version>',plugin_num)+9 plugin_num = version_web.find(NAME)
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version] valeur_version_web = version_web.find('<version>', plugin_num) + 9
if version_plugin != version: version_plugin = version_web[valeur_version_web:valeur_version_web + len_version]
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30) if version_plugin != version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
except urllib.requests.URLError:
print("error gitea version ssl")
else: else:
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30) iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
def tr(text, context="@default"): def tr(text, context="@default"):
return QApplication.translate(context, text) return QApplication.translate(context, text)
def devlog(NAME): def devlog(NAME):
import qgis import qgis
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>' devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
devmaj = devmaj+qgis.utils.pluginMetadata(NAME,'changelog') devmaj = devmaj + qgis.utils.pluginMetadata(NAME, 'changelog')
return devmaj return devmaj

View File

@ -118,12 +118,6 @@
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QFrame#frame{background-color: rgb(255, 255, 255, 170);}</string> <string notr="true">QFrame#frame{background-color: rgb(255, 255, 255, 170);}</string>
</property> </property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QLabel" name="Carte"> <widget class="QLabel" name="Carte">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -133,27 +127,15 @@
<height>700</height> <height>700</height>
</rect> </rect>
</property> </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(10, 10, 10, 50)</string> <string notr="true">background-color: rgba(10, 10, 10, 50)</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>5</number>
</property>
<property name="midLineWidth">
<number>2</number>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin"> <property name="margin">
<number>5</number> <number>5</number>
</property> </property>
@ -167,11 +149,11 @@
<height>240</height> <height>240</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="autoFillBackground">
<string notr="true">background-color: rgb(10, 10, 10, 50)</string> <bool>false</bool>
</property> </property>
<property name="frameShadow"> <property name="styleSheet">
<enum>QFrame::Plain</enum> <string notr="true">background-color: rgba(10, 10, 10, 50)</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -186,8 +168,11 @@
<height>460</height> <height>460</height>
</rect> </rect>
</property> </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(10, 10, 10, 50)</string> <string notr="true">background-color: rgba(10, 10, 10, 50)</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -202,8 +187,11 @@
<height>50</height> <height>50</height>
</rect> </rect>
</property> </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(10, 10, 10, 50)</string> <string notr="true">background-color: rgba(10, 10, 10, 50)</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -218,8 +206,11 @@
<height>25</height> <height>25</height>
</rect> </rect>
</property> </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(10, 10, 10, 50)</string> <string notr="true">background-color: rgba(10, 10, 10, 50)</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -234,8 +225,11 @@
<height>40</height> <height>40</height>
</rect> </rect>
</property> </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(10, 10, 10, 50)</string> <string notr="true">background-color: rgba(10, 10, 10, 50)</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -257,19 +251,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(10, 10, 10, 50)</string> <string notr="true">background-color: rgba(10, 10, 10, 50)</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>-1</number>
</property>
<property name="midLineWidth">
<number>0</number>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -277,9 +259,6 @@
<property name="scaledContents"> <property name="scaledContents">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
<property name="wordWrap"> <property name="wordWrap">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -299,8 +278,11 @@
<height>20</height> <height>20</height>
</rect> </rect>
</property> </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(10, 10, 10, 50)</string> <string notr="true">background-color: rgba(10, 10, 10, 50)</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -315,8 +297,11 @@
<height>20</height> <height>20</height>
</rect> </rect>
</property> </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(10, 10, 10, 50)</string> <string notr="true">background-color: rgba(10, 10, 10, 50)</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -338,19 +323,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(10, 10, 10, 50)</string> <string notr="true">background-color: rgba(10, 10, 10, 50)</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>-1</number>
</property>
<property name="midLineWidth">
<number>0</number>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -358,9 +331,6 @@
<property name="scaledContents"> <property name="scaledContents">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
<property name="wordWrap"> <property name="wordWrap">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -380,8 +350,11 @@
<height>45</height> <height>45</height>
</rect> </rect>
</property> </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(10, 10, 10, 50)</string> <string notr="true">background-color: rgba(10, 10, 10, 50)</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -396,8 +369,11 @@
<height>100</height> <height>100</height>
</rect> </rect>
</property> </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(10, 10, 10, 50)</string> <string notr="true">background-color: rgba(10, 10, 10, 50)</string>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -416,33 +392,30 @@
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QFrame#frame_2{background-color: rgb(255, 255, 255, 170);}</string> <string notr="true">QFrame#frame_2{background-color: rgb(255, 255, 255, 170);}</string>
</property> </property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QTableWidget" name="tableWidget"> <widget class="QTableWidget" name="tableWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>10</y> <y>10</y>
<width>161</width> <width>161</width>
<height>641</height> <height>381</height>
</rect> </rect>
</property> </property>
<property name="midLineWidth"> <property name="midLineWidth">
<number>1</number> <number>1</number>
</property> </property>
<property name="horizontalScrollBarPolicy"> <property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum> <enum>Qt::ScrollBarAsNeeded</enum>
</property> </property>
<property name="sizeAdjustPolicy"> <property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum> <enum>QAbstractScrollArea::AdjustIgnored</enum>
</property> </property>
<property name="editTriggers"> <property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set> <set>QAbstractItemView::NoEditTriggers</set>
</property> </property>
<property name="tabKeyNavigation">
<bool>false</bool>
</property>
<property name="dragEnabled"> <property name="dragEnabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -459,10 +432,10 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="selectionMode"> <property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum> <enum>QAbstractItemView::NoSelection</enum>
</property> </property>
<property name="selectionBehavior"> <property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum> <enum>QAbstractItemView::SelectItems</enum>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -471,7 +444,7 @@
</size> </size>
</property> </property>
<property name="textElideMode"> <property name="textElideMode">
<enum>Qt::ElideMiddle</enum> <enum>Qt::ElideLeft</enum>
</property> </property>
<property name="showGrid"> <property name="showGrid">
<bool>true</bool> <bool>true</bool>
@ -532,7 +505,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>650</y> <y>660</y>
<width>161</width> <width>161</width>
<height>21</height> <height>21</height>
</rect> </rect>
@ -541,6 +514,117 @@
<string>Load</string> <string>Load</string>
</property> </property>
</widget> </widget>
<widget class="QTableWidget" name="tableWidget_2">
<property name="geometry">
<rect>
<x>10</x>
<y>400</y>
<width>161</width>
<height>241</height>
</rect>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<property name="midLineWidth">
<number>1</number>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="tabKeyNavigation">
<bool>false</bool>
</property>
<property name="dragEnabled">
<bool>false</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::NoDragDrop</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::IgnoreAction</enum>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectItems</enum>
</property>
<property name="iconSize">
<size>
<width>5</width>
<height>5</height>
</size>
</property>
<property name="textElideMode">
<enum>Qt::ElideLeft</enum>
</property>
<property name="showGrid">
<bool>true</bool>
</property>
<property name="cornerButtonEnabled">
<bool>true</bool>
</property>
<property name="rowCount">
<number>3</number>
</property>
<property name="columnCount">
<number>2</number>
</property>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>50</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>78</number>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderMinimumSectionSize">
<number>20</number>
</attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>30</number>
</attribute>
<row/>
<row/>
<row/>
<column/>
<column/>
<item row="0" column="0">
<property name="text">
<string>frame</string>
</property>
</item>
<item row="1" column="0">
<property name="text">
<string>background</string>
</property>
</item>
<item row="2" column="0">
<property name="text">
<string>path</string>
</property>
</item>
</widget>
</widget> </widget>
<widget class="QRadioButton" name="radioButton"> <widget class="QRadioButton" name="radioButton">
<property name="geometry"> <property name="geometry">
@ -592,12 +676,12 @@
<rect> <rect>
<x>240</x> <x>240</x>
<y>10</y> <y>10</y>
<width>61</width> <width>88</width>
<height>22</height> <height>22</height>
</rect> </rect>
</property> </property>
<property name="buttonSymbols"> <property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum> <enum>QAbstractSpinBox::UpDownArrows</enum>
</property> </property>
<property name="suffix"> <property name="suffix">
<string/> <string/>
@ -614,12 +698,12 @@
<rect> <rect>
<x>310</x> <x>310</x>
<y>10</y> <y>10</y>
<width>61</width> <width>88</width>
<height>22</height> <height>22</height>
</rect> </rect>
</property> </property>
<property name="buttonSymbols"> <property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum> <enum>QAbstractSpinBox::UpDownArrows</enum>
</property> </property>
<property name="suffix"> <property name="suffix">
<string/> <string/>
@ -668,9 +752,6 @@
<property name="value"> <property name="value">
<number>40</number> <number>40</number>
</property> </property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="invertedAppearance"> <property name="invertedAppearance">
<bool>true</bool> <bool>true</bool>
</property> </property>

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Metabase</string> <string>Journal des modifications</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset>
@ -29,9 +29,6 @@
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -41,7 +38,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>453</width> <width>453</width>
<height>547</height> <height>570</height>
</rect> </rect>
</property> </property>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
@ -56,7 +53,7 @@
<property name="title"> <property name="title">
<string>DevLog</string> <string>DevLog</string>
</property> </property>
<widget class="QWebView" name="viewer" native="true"> <widget class="QTextBrowser" name="viewer">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
@ -65,11 +62,6 @@
<height>511</height> <height>511</height>
</rect> </rect>
</property> </property>
<property name="url" stdset="0">
<url>
<string>about:blank</string>
</url>
</property>
</widget> </widget>
</widget> </widget>
</widget> </widget>
@ -78,19 +70,12 @@
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Ok</set> <set>QDialogButtonBox::NoButton</set>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header location="global">QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -4,50 +4,59 @@ __email__ = "info@3liz.org"
from qgis.core import QgsApplication from qgis.core import QgsApplication
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator, QUrl from qgis.PyQt.QtCore import QUrl
from qgis.PyQt.QtGui import QDesktopServices, QIcon from qgis.PyQt.QtGui import QDesktopServices, QIcon
from qgis.PyQt.QtWidgets import QAction, QMessageBox from qgis.PyQt.QtWidgets import QAction
from qgis.utils import iface from qgis.utils import iface
import qgis import qgis
#include <QSettings> # include <QSettings>
import socket
import os import os
from qgis.PyQt.QtCore import QSettings
from .about_form import AboutDialog
from .tools.resources import ( from .tools.resources import (
plugin_path, # plugin_path,
pyperclip,
resources_path, resources_path,
maj_verif, maj_verif,
) )
pyperclip()
from .postgis_editor import Postgis_Editor from .postgis_editor import Postgis_Editor
from .postgis_creator import Postgis_Creator from .postgis_creator import Postgis_Creator
from .about_form import PostgisAboutDialog from .postgis_rename import Postgis_Rename
IPAddr = socket.gethostbyname(socket.gethostname())
from PyQt5.QtCore import *
class PgPostgis: class PgPostgis:
def __init__(self): def __init__(self):
""" Constructor. """ """ Constructor. """
self.action_editor = None self.action_editor = None
self.action_creator = None self.action_creator = None
self.action_rename = None
# self.issues = None # self.issues = None
self.provider = None self.provider = None
self.locator_filter = None self.locator_filter = None
self.dock_action = None self.dock_action = None
self.help_action = None self.help_action = None
plugin_dir = os.path.dirname(__file__) plugin_dir = os.path.dirname(__file__)
end_find = plugin_dir.rfind('\\')+1 end_find = plugin_dir.rfind('\\') + 1
global NAME global NAME
NAME = plugin_dir[end_find:] NAME = plugin_dir[end_find:]
maj_verif(NAME) maj_verif(NAME)
# Display About window on first use # Display About window on first use
version = qgis.utils.pluginMetadata('CenRa_POSTGIS','version') version = qgis.utils.pluginMetadata('CenRa_POSTGIS', 'version')
s = QSettings() s = QSettings()
versionUse = s.value("postgis/version", 1, type=str) versionUse = s.value("postgis/version", 1, type=str)
if str(versionUse) != str(version) : if str(versionUse) != str(version):
s.setValue("postgis/version", str(version)) s.setValue("postgis/version", str(version))
print(versionUse,version) print(versionUse, version)
self.open_about_dialog() self.open_about_dialog()
def initGui(self): def initGui(self):
@ -58,6 +67,7 @@ class PgPostgis:
icon = QIcon(resources_path('icons', 'page_new.png')) icon = QIcon(resources_path('icons', 'page_new.png'))
icon2 = QIcon(resources_path('icons', 'page_ajout.png')) icon2 = QIcon(resources_path('icons', 'page_ajout.png'))
icon3 = QIcon(resources_path('icons', 'page_rename.png'))
# Open the online help # Open the online help
self.help_action = QAction(icon, "CenRa_Postgis", iface.mainWindow()) self.help_action = QAction(icon, "CenRa_Postgis", iface.mainWindow())
@ -66,22 +76,52 @@ class PgPostgis:
if not self.action_creator: if not self.action_creator:
self.action_creator = Postgis_Creator() self.action_creator = Postgis_Creator()
self.postgis_creator = QAction(icon, 'dossier_creator',None) self.postgis_creator = QAction(icon, 'dossier_creator', None)
self.toolBar.addAction(self.postgis_creator) self.toolBar.addAction(self.postgis_creator)
self.postgis_creator.triggered.connect(self.open_creator) self.postgis_creator.triggered.connect(self.open_creator)
self.postgis_creator.setEnabled(False)
if os.access('N:/', os.R_OK):
self.postgis_creator.setEnabled(True)
if not self.action_editor: if not self.action_editor:
self.action_editor = Postgis_Editor() self.action_editor = Postgis_Editor()
self.postgis_editor = QAction(icon2, 'dossier_editor',None) self.postgis_editor = QAction(icon2, 'dossier_editor', None)
self.toolBar.addAction(self.postgis_editor) self.toolBar.addAction(self.postgis_editor)
self.postgis_editor.triggered.connect(self.open_editor) self.postgis_editor.triggered.connect(self.open_editor)
self.postgis_editor.setEnabled(False)
if os.access('N:/', os.R_OK):
self.postgis_editor.setEnabled(True)
if not self.action_rename:
self.action_rename = Postgis_Rename()
self.postgis_rename = QAction(icon3, 'dossier_rename', None)
self.toolBar.addAction(self.postgis_rename)
self.postgis_rename.triggered.connect(self.open_rename)
if os.environ['USERNAME'] == 'tlaveille' or os.environ['USERNAME'] == 'lpoulin' or os.environ['USERNAME'] == 'rclement':
self.action_rename.setEnabled(True)
self.postgis_rename.setEnabled(True)
self.postgis_rename.setVisible(1)
else:
self.action_rename.setEnabled(False)
self.postgis_rename.setEnabled(False)
self.postgis_rename.setVisible(0)
self.postgis_rename.setEnabled(False)
if os.access('N:/', os.R_OK):
self.postgis_rename.setEnabled(True)
def open_about_dialog(self): def open_about_dialog(self):
""" """
About dialog About dialog
""" """
dialog = PostgisAboutDialog(iface) dialog = AboutDialog(iface)
dialog.exec_() dialog.exec()
def open_help(): def open_help():
""" Open the online help. """ """ Open the online help. """
QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/')) QDesktopServices.openUrl(QUrl('https://plateformesig.cenra-outils.org/'))
@ -94,12 +134,18 @@ class PgPostgis:
self.action_creator.show() self.action_creator.show()
self.action_creator.raise_() self.action_creator.raise_()
def open_rename(self):
self.action_rename.show()
self.action_rename.raise_()
def unload(self): def unload(self):
""" Unload the plugin. """ """ Unload the plugin. """
if self.action_editor: if self.action_editor:
iface.removePluginMenu('CenRa_Postgis',self.postgis_editor) iface.removePluginMenu('CenRa_Postgis', self.postgis_editor)
if self.action_creator: if self.action_creator:
iface.removePluginMenu('CenRa_Postgis',self.postgis_creator) iface.removePluginMenu('CenRa_Postgis', self.postgis_creator)
if self.action_rename:
iface.removePluginMenu('CenRa_Postgis', self.postgis_rename)
if self.provider: if self.provider:
QgsApplication.processingRegistry().removeProvider(self.provider) QgsApplication.processingRegistry().removeProvider(self.provider)

View File

@ -3,7 +3,7 @@ import os.path
from pathlib import Path from pathlib import Path
from qgis.PyQt import uic from qgis.PyQt import uic
from qgis.PyQt.QtGui import QPixmap # from qgis.PyQt.QtGui import QPixmap
from qgis.PyQt.QtWidgets import QDialog from qgis.PyQt.QtWidgets import QDialog
from .tools.resources import devlog from .tools.resources import devlog
@ -17,7 +17,7 @@ ABOUT_FORM_CLASS, _ = uic.loadUiType(
) )
class PostgisAboutDialog(QDialog, ABOUT_FORM_CLASS): class AboutDialog(QDialog, ABOUT_FORM_CLASS):
""" About - Let the user display the about dialog. """ """ About - Let the user display the about dialog. """
@ -26,7 +26,7 @@ class PostgisAboutDialog(QDialog, ABOUT_FORM_CLASS):
self.iface = iface self.iface = iface
self.setupUi(self) self.setupUi(self)
self.viewer.setHtml(devlog('CenRa_POSTGRES')) self.viewer.setHtml(devlog('CenRa_POSTGIS'))
self.rejected.connect(self.onReject) self.rejected.connect(self.onReject)
self.buttonBox.rejected.connect(self.onReject) self.buttonBox.rejected.connect(self.onReject)
@ -43,4 +43,4 @@ class PostgisAboutDialog(QDialog, ABOUT_FORM_CLASS):
Run some actions when Run some actions when
the user closes the dialog the user closes the dialog
""" """
self.close() self.close()

View File

@ -11,8 +11,9 @@
[general] [general]
name=CenRa_POSTGIS name=CenRa_POSTGIS
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
supportsQt6=True
description=Permet de crée un dossier dans la base PostGis description=Permet de crée un dossier dans la base PostGis
version=2.0 version=3.1
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@ -21,7 +22,7 @@ email=si_besoin@cen-rhonealpes.fr
# Optional items: # Optional items:
# Uncomment the following line and add your changelog entries: # Uncomment the following line and add your changelog entries:
changelog=<h2>CenRa_POSTGIS:</h2></br><p><h3>22/10/2024 - Version 2.0:</h3>- Refont du code.</p> changelog=<h2>CenRa_POSTGIS:</h2></br><p><h3>30/07/2025 - Version 3.1: </h3> - Correctife de bug.</p></br><p><h3>19/05/2025 - Version 3.0: </h3> - Compatible PyQt5 et PyQt6</p></br><p><h3>09/04/2025 - Version 2.9: </h3> - Correctif bug en TT.</p></br><p><h3>09/04/2025 - Version 2.8: </h3> - Optimisation pour le TT.</p></br><p><h3>03/04/2025 - Version 2.7: </h3> - Mise a jour de securite.</p></br><p><h3>12/02/2025 - Version 2.6: </h3> - InDev:renomé les schema et table.</p></br><p><h3>04/02/2025 - Version 2.5: </h3> - Correctif bug création de couche.</p></br><p><h3>23/01/2025 - Version 2.4: </h3> - Correctif sur les pkey.</p></br><p><h3>22/01/2025 - Version 2.3: </h3> - Correctif sur la creation de projet.</p></br><p><h3>21/01/2025 - Version 2.2: </h3> - Correctif sur la longeur des nom.</p></br><p><h3>07/01/2025 - Version 2.1: </h3> - ByPass du certif ssl ci erreur.</p></br><p><h3>22/10/2024 - Version 2.0:</h3>- Refont du code.</p>
# tags are comma separated with spaces allowed # tags are comma separated with spaces allowed
tags=cenra, postgis, database tags=cenra, postgis, database

View File

@ -2,431 +2,108 @@
from __future__ import absolute_import from __future__ import absolute_import
# Import the PyQt and QGIS libraries # Import the PyQt and QGIS libraries
from builtins import next # from builtins import next
from builtins import str # from builtins import str
from builtins import object # from builtins import object
import qgis # import qgis
from qgis.PyQt.QtCore import QSettings from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtWidgets import QAction, QMenu, QDialog from qgis.PyQt.QtWidgets import QDialog, QMessageBox
from qgis.PyQt.QtGui import QIcon # from qgis.PyQt.QtGui import QIcon
from PyQt5.QtCore import *
from PyQt5.QtGui import * # from qgis.PyQt.QtCore import *
from PyQt5 import QtGui # from qgis.PyQt.QtGui import *
from qgis.core import * from qgis.PyQt import QtGui
from qgis.core import QgsDataSourceUri
# from qgis.core import *
from qgis.core import QgsSettings, Qgis
try:
from .tools.PythonSQL import login_base
except ValueError:
print('Pas de fichier PythonSQL')
# from .tools.SQLRequet import *
from .tools.PythonSQL import *
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base, # send_issues,
send_issues, create_vierge,
create_contour,
create_travaux,
create_habita
) )
from .issues import CenRa_Issues # from .issues import CenRa_Issues
from qgis.utils import iface from qgis.utils import iface
import os.path # import os.path
import webbrowser, os # import webbrowser, os
import psycopg2 # import psycopg2
import psycopg2.extras # import psycopg2.extras
import base64 # import base64
EDITOR_CLASS = load_ui('CenRa_Postgis_base.ui') EDITOR_CLASS = load_ui('CenRa_Postgis_base.ui')
class Postgis_Creator(QDialog, EDITOR_CLASS):
class Postgis_Creator(QDialog, EDITOR_CLASS):
def __init__(self, parent=None): def __init__(self, parent=None):
_ = parent _ = parent
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.settings = QgsSettings() self.settings = QgsSettings()
self.s = QSettings() self.s = QSettings()
self.setWindowIcon(QtGui.QIcon(resources_path('icons','icon.png'))) self.setWindowIcon(QtGui.QIcon(resources_path('icons', 'icon.png')))
self.iface = iface self.iface = iface
# run method that performs all the real work # run method that performs all the real work
def raise_(self): def raise_(self):
self.activateWindow()
# show the dialog # show the dialog
self.show() self.show()
# Run the dialog event loop # Run the dialog event loop
result = self.exec_() result = self.exec()
# See if OK was pressed # See if OK was pressed
if result == 1: if result == 1:
# **********************************Debut_script****************************************
#**********************************Debut_script**************************************** # Creation du schema pour le nouveau site
### Creation du schema pour le nouveau site
if self.at.isChecked(): if self.at.isChecked():
schema = "_" + self.dept.currentText() + "_at_" + self.nom.text().lower() # Ajout de "_" pour eviter pb de numero en premier caractere # Ajout de "_" pour eviter pb de numero en premier caractere
else : schema = "_" + self.dept.currentText() + "_at_" + self.nom.text().lower()
schema = "_" + self.dept.currentText() + "_" + self.nom.text().lower() # Ajout de "_" pour eviter pb de numero en premier caractere else:
# Ajout de "_" pour eviter pb de numero en premier caractere
schema = "_" + self.dept.currentText() + "_" + self.nom.text().lower()
if self.nom.text() == "" or self.nom.text() == "NULL": if self.nom.text() == "" or self.nom.text() == "NULL":
QMessageBox.warning(None, "Oups :", "Veuillez renseigner un nom de dossier.") QMessageBox.warning(None, "Oups :", "Veuillez renseigner un nom de dossier.")
return return
ch = [u"à", u"À", u"â", u"Â", u"ä", u"Ä", u"å", u"Å", u"ç", u"Ç", u"é", u"É", u"è", u"È", u"ê", u"Ê", u"ë", u"Ë", u"î", u"Î", u"ï", u"Ï", u"ô", u"Ô", u"ö", u"Ö", u"ù", u"Ù", u"û", u"Û", u"ü", u"Ü", u"ÿ", u"Ÿ", u"'", u"-", u" "] ch = [u"à", u"À", u"â", u"Â", u"ä", u"Ä", u"å", u"Å", u"ç", u"Ç", u"é", u"É", u"è", u"È", u"ê", u"Ê", u"ë", u"Ë", u"î", u"Î", u"ï", u"Ï", u"ô", u"Ô", u"ö", u"Ö", u"ù", u"Ù", u"û", u"Û", u"ü", u"Ü", u"ÿ", u"Ÿ", u"'", u"-", u" "]
for car in ch : for car in ch:
if self.nom.text().find(car) != -1 : if self.nom.text().find(car) != - 1:
QMessageBox.warning(None, "Oups :", u"Le nom de dossier ne doit pas comporter de caractères spéciaux, ni d'espaces !\n\n\t" + self.nom.text().lower() ) QMessageBox.warning(None, "Oups :", u"Le nom de dossier ne doit pas comporter de caractères spéciaux, ni d'espaces !\n\n\t" + self.nom.text().lower())
return return
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base("account")
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) cur = account[7]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor) con = account[8]
first_conn.close()
SQL_schema = "CREATE SCHEMA " + schema + ";" SQL_schema = "CREATE SCHEMA " + schema + ";"
SQL_GRANT_SCHEMA="GRANT CREATE, USAGE ON SCHEMA "+schema+" TO grp_qgis; GRANT CREATE, USAGE ON SCHEMA "+schema+" TO grp_sig;" SQL_GRANT_SCHEMA = "GRANT CREATE, USAGE ON SCHEMA " + schema + " TO grp_qgis; GRANT CREATE, USAGE ON SCHEMA " + schema + " TO grp_sig;"
cur.execute(SQL_schema) if self.couche_contour.isChecked() or self.couche_habitat.isChecked() or self.couche_travaux_prevus.isChecked() or self.couche_vierge.isChecked():
cur.execute(SQL_GRANT_SCHEMA) cur.execute(SQL_schema)
cur.execute(SQL_GRANT_SCHEMA)
else:
iface.messageBar().pushMessage("POSTGRESQL :", "Pas de couche sélectionnée, création refusée.", level=Qgis.Warning, duration=30)
### Creation de la table contour create_contour(self, schema, cur, con, host, port, dbname, user, mdp)
if self.couche_contour.isChecked(): # Verifie si la checkbox est cochee create_habita(self, schema, cur, con, host, port, dbname, user, mdp)
if self.annee_1.text() == 'aaaa' or self.annee_1.text() == '': create_travaux(self, schema, cur, con, host, port, dbname, user, mdp)
tablename = schema + "_contour" create_vierge(self, schema, cur, con, host, port, dbname, user, mdp)
else :
tablename = schema + "_contour_" + self.annee_1.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_contour = "CREATE TABLE " + schema + "."+ tablename + champ_contour
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'contour_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_contour)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
### Creation de la table habitat
if self.couche_habitat.isChecked():
if self.annee_2.text() == 'aaaa' or self.annee_2.text() == '':
tablename = schema + "_habitat"
else :
tablename = schema + "_habitat_" + self.annee_2.text()
tablename_1=tablename+"_points"
tablename_qgis = tablename_1[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_VEGETHAB = "CREATE TABLE "+ schema + "."+ tablename_1 + champ_vegethab_point
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_1 + " ADD CONSTRAINT " + tablename_1 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename_1 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_1 + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_1 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_points_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_1+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_1+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename_1+"_gid_seq TO grp_qgis;"
cur.execute(SQL_VEGETHAB)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_coordonnees)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_1, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
tablename_2=tablename+"_lignes"
tablename_qgis = tablename_2[1:]
SQL_VEGETHAB = "CREATE TABLE "+ schema + "."+ tablename_2 + champ_vegethab_multilinestring
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_2 + " ADD CONSTRAINT " + tablename_2 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename_2 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_2 + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename_2 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_2 + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_2 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_lignes_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_2+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_2+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename_2+"_gid_seq TO grp_qgis;"
cur.execute(SQL_VEGETHAB)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_2, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
tablename_3=tablename+"_polygones"
tablename_qgis = tablename_3[1:]
SQL_VEGETHAB = "CREATE TABLE "+ schema + "."+ tablename_3 + champ_vegethab_multipolygon
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_3 + " ADD CONSTRAINT " + tablename_3 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename_3 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_3 + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename_3 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_3 + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_3 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_polygones_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_3+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_3+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename_3+"_gid_seq TO grp_qgis;"
cur.execute(SQL_VEGETHAB)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_3, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
'''
SQL_habitat = "CREATE TABLE " + schema + "."+ tablename + champ_habitat
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_concat_cd_cb = "CREATE TRIGGER concat_cd_cb" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.concat_cd_cb();"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'habitat_modele_v3'"""
cur.execute(SQL_habitat)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_trigger_concat_cd_cb)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
'''
### Creation de la table travaux prevus
if self.couche_travaux_prevus.isChecked():
#**********Poly
if self.annee_5.text() == 'aaaa' or self.annee_5.text() == '':
tablename = schema + "_travaux_prevus_poly"
else :
tablename = schema + "_travaux_prevus_poly_" + self.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_travaux_prevus = "CREATE TABLE " + schema + "."+ tablename + champ_travaux_prevus_multipolygon
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_poly_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_travaux_prevus)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
#**********ligne
if self.annee_5.text() == 'aaaa' or self.annee_5.text() == '':
tablename = schema + "_travaux_prevus_ligne"
else :
tablename = schema + "_travaux_prevus_ligne_" + self.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_travaux_prevus = "CREATE TABLE " + schema + "."+ tablename + champ_travaux_prevus_multilinestring
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_ligne_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_travaux_prevus)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
#**********point
if self.annee_5.text() == 'aaaa' or self.annee_5.text() == '':
tablename = schema + "_travaux_prevus_point"
else :
tablename = schema + "_travaux_prevus_point_" + self.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_travaux_prevus = "CREATE TABLE " + schema + "."+ tablename + champ_travaux_prevus_point
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_point_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_travaux_prevus)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_coordonnees)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
### Creation de la table vierge
if self.couche_vierge.isChecked():
if self.annee_4.text() == 'aaaa' or self.annee_4.text() == '':
tablename = schema + "_" + self.nom_couche_vierge.text().lower()
else :
tablename = schema + "_" + self.nom_couche_vierge.text().lower() + "_" + self.annee_4.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
if self.couche_vierge_point.isChecked() == 1 :
champ_vierge = champ_viergePoint
if self.couche_vierge_ligne.isChecked() == 1 :
champ_vierge = champ_viergeLigne
if self.couche_vierge_polygone.isChecked() == 1 :
champ_vierge = champ_viergePolygone
SQL_vierge = "CREATE TABLE " + schema + "."+ tablename + champ_vierge
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
cur.execute(SQL_vierge)
cur.execute(SQL_pkey)
if self.couche_vierge_point.isChecked() == 1 :
cur.execute(SQL_trigger_coordonnees)
if self.couche_vierge_ligne.isChecked() == 1 :
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
if self.couche_vierge_polygone.isChecked() == 1 :
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
else :
con.commit()
con.close() con.close()
pass pass

View File

@ -4,65 +4,71 @@ from __future__ import absolute_import
# Import the PyQt and QGIS libraries # Import the PyQt and QGIS libraries
from builtins import next from builtins import next
from builtins import str from builtins import str
from builtins import object # from builtins import object
import qgis # import qgis
from qgis.PyQt.QtCore import QSettings from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtWidgets import QAction, QMenu, QDialog from qgis.PyQt.QtWidgets import QDialog, QMessageBox
from qgis.PyQt.QtGui import QIcon # from qgis.PyQt.QtGui import QIcon
from PyQt5.QtCore import *
from PyQt5.QtGui import * from qgis.PyQt import QtGui
from PyQt5 import QtGui
from qgis.core import * # from qgis.core import *
from qgis.core import QgsDataSourceUri from qgis.core import QgsSettings
try:
from .tools.PythonSQL import login_base
except ValueError:
print('Pas de fichier PythonSQL')
# from .tools.SQLRequet import *
from .tools.PythonSQL import *
from .tools.resources import ( from .tools.resources import (
load_ui, load_ui,
resources_path, resources_path,
login_base, # send_issues,
send_issues, create_vierge,
create_contour,
create_travaux,
create_habita
) )
from .issues import CenRa_Issues # from .issues import CenRa_Issues
import os.path # import os.path
import webbrowser, os # import webbrowser
import psycopg2 # import psycopg2
import psycopg2.extras # import psycopg2.extras
import base64 # import base64
from qgis.utils import iface from qgis.utils import iface
EDITOR_CLASS = load_ui('CenRa_PostgisTable_base.ui') EDITOR_CLASS = load_ui('CenRa_PostgisTable_base.ui')
class Postgis_Editor(QDialog, EDITOR_CLASS):
class Postgis_Editor(QDialog, EDITOR_CLASS):
def __init__(self, parent=None): def __init__(self, parent=None):
_ = parent _ = parent
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.settings = QgsSettings() self.settings = QgsSettings()
self.s = QSettings() self.s = QSettings()
self.setWindowIcon(QtGui.QIcon(resources_path('icons','icon.png'))) self.setWindowIcon(QtGui.QIcon(resources_path('icons', 'icon.png')))
self.iface = iface self.iface = iface
### Outil Ajout de nouvelles couche a un dossier # Outil Ajout de nouvelles couche a un dossier
def raise_(self): def raise_(self):
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) self.activateWindow()
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) account = login_base("account")
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") user = account[0]
res_ident = first_cur.fetchone() mdp = account[1]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') host = account[2]
user = res_ident[1] port = account[3]
dbname = account[4]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) cur = account[7]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor) con = account[8]
first_conn.close() # Creation de la liste des schemas de la base de donnees
# Creation de la liste des schemas de la base de donnees
SQL = """WITH list_schema AS ( SQL = """WITH list_schema AS (
select schemaname,'sig' as group from pg_catalog.pg_tables select schemaname,'sig' as group from pg_catalog.pg_tables
where schemaname ~ E'^_(0|1|2|3|4|6|7|f)' where schemaname ~ E'^_(0|1|2|3|4|6|7|f)'
group by schemaname group by schemaname
order by schemaname) order by schemaname)
select string_agg(schemaname,',') select string_agg(schemaname,',')
from list_schema from list_schema
group by "group";""" group by "group";"""
@ -70,382 +76,42 @@ class Postgis_Editor(QDialog, EDITOR_CLASS):
cur.execute(SQL) cur.execute(SQL)
list_brut = str(next(cur)) list_brut = str(next(cur))
list = list_brut [2:-2] list = list_brut[2:-2]
listItems = list.split(",") listItems = list.split(",")
con.close() con.close()
self.schema.clear() self.schema.clear()
self.schema.addItems(listItems) self.schema.addItems(listItems)
self.schema.setCurrentIndex(-1) # Pour ne pas commencer la liste au premier schema # Pour ne pas commencer la liste au premier schema
self.schema.setCurrentIndex(-1)
# show the dialog # show the dialog
self.show() self.show()
# Run the dialog event loop # Run the dialog event loop
result = self.exec_() result = self.exec()
# See if OK was pressed # See if OK was pressed
if result == 1: if result == 1:
#******************************debut script********************************* # ******************************debut script*********************************
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password) account = login_base("account")
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor) user = account[0]
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')") mdp = account[1]
res_ident = first_cur.fetchone() host = account[2]
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8') port = account[3]
user = res_ident[1] dbname = account[4]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) cur = account[7]
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor) con = account[8]
first_conn.close()
if self.schema.currentIndex() == -1 : if self.schema.currentIndex() == - 1:
QMessageBox.warning(None, "Oups :", "Veuillez choisir un nom de dossier.") QMessageBox.warning(None, "Oups :", "Veuillez choisir un nom de dossier.")
return return
schema = self.schema.currentText() schema = self.schema.currentText()
### Creation de la table contour create_contour(self, schema, cur, con, host, port, dbname, user, mdp)
if self.couche_contour.isChecked(): # Verifie si la checkbox est cochee create_habita(self, schema, cur, con, host, port, dbname, user, mdp)
if self.annee_1.text() == 'aaaa' or self.annee_1.text() == '': create_travaux(self, schema, cur, con, host, port, dbname, user, mdp)
tablename = schema + "_contour" create_vierge(self, schema, cur, con, host, port, dbname, user, mdp)
else :
tablename = schema + "_contour_" + self.annee_1.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_contour = "CREATE TABLE " + schema + "."+ tablename + champ_contour
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'contour_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_contour)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
### Creation de la table habitat
if self.couche_habitat.isChecked():
if self.annee_2.text() == 'aaaa' or self.annee_2.text() == '':
tablename = schema + "_habitat"
else :
tablename = schema + "_habitat_" + self.annee_2.text()
tablename_1=tablename+"_points"
tablename_qgis = tablename_1[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_VEGETHAB = "CREATE TABLE "+ schema + "."+ tablename_1 + champ_vegethab_point
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_1 + " ADD CONSTRAINT " + tablename_1 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename_1 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_1 + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_1 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_points_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_1+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_1+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename_1+"_gid_seq TO grp_qgis;"
cur.execute(SQL_VEGETHAB)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_coordonnees)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_1, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
tablename_2=tablename+"_lignes"
tablename_qgis = tablename_2[1:]
SQL_VEGETHAB = "CREATE TABLE "+ schema + "."+ tablename_2 + champ_vegethab_multilinestring
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_2 + " ADD CONSTRAINT " + tablename_2 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename_2 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_2 + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename_2 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_2 + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_2 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_lignes_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_2+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_2+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename_2+"_gid_seq TO grp_qgis;"
cur.execute(SQL_VEGETHAB)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_2, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
tablename_3=tablename+"_polygones"
tablename_qgis = tablename_3[1:]
SQL_VEGETHAB = "CREATE TABLE "+ schema + "."+ tablename_3 + champ_vegethab_multipolygon
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_3 + " ADD CONSTRAINT " + tablename_3 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename_3 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_3 + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename_3 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_3 + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_3 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_polygones_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_3+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename_3+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename_3+"_gid_seq TO grp_qgis;"
cur.execute(SQL_VEGETHAB)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_3, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
'''
SQL_habitat = "CREATE TABLE " + schema + "."+ tablename + champ_habitat
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_concat_cd_cb = "CREATE TRIGGER concat_cd_cb" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.concat_cd_cb();"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'habitat_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_habitat)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_trigger_concat_cd_cb)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
'''
### Creation de la table travaux prevus
if self.couche_travaux_prevus.isChecked():
#**********Poly
if self.annee_5.text() == 'aaaa' or self.annee_5.text() == '':
tablename = schema + "_travaux_prevus_poly"
else :
tablename = schema + "_travaux_prevus_poly_" + self.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_travaux_prevus = "CREATE TABLE " + schema + "."+ tablename + champ_travaux_prevus_multipolygon
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_poly_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_travaux_prevus)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
#**********ligne
if self.annee_5.text() == 'aaaa' or self.annee_5.text() == '':
tablename = schema + "_travaux_prevus_ligne"
else :
tablename = schema + "_travaux_prevus_ligne_" + self.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_travaux_prevus = "CREATE TABLE " + schema + "."+ tablename + champ_travaux_prevus_multilinestring
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_ligne_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_travaux_prevus)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
#**********point
if self.annee_5.text() == 'aaaa' or self.annee_5.text() == '':
tablename = schema + "_travaux_prevus_point"
else :
tablename = schema + "_travaux_prevus_point_" + self.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_travaux_prevus = "CREATE TABLE " + schema + "."+ tablename + champ_travaux_prevus_point
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_point_modele_v3'"""
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_travaux_prevus)
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_coordonnees)
cur.execute(SQL_style) ## Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_GRANT_TABLE)
con.commit()
## Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
### Creation de la table vierge
if self.couche_vierge.isChecked():
if self.annee_4.text() == 'aaaa' or self.annee_4.text() == '':
tablename = schema + "_" + self.nom_couche_vierge.text().lower()
else :
tablename = schema + "_" + self.nom_couche_vierge.text().lower() + "_" + self.annee_4.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
if self.couche_vierge_point.isChecked() == 1 :
champ_vierge = champ_viergePoint
if self.couche_vierge_ligne.isChecked() == 1 :
champ_vierge = champ_viergeLigne
if self.couche_vierge_polygone.isChecked() == 1 :
champ_vierge = champ_viergePolygone
SQL_vierge = "CREATE TABLE " + schema + "."+ tablename + champ_vierge
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_GRANT_TABLE="GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON "+schema+"."+tablename+" TO grp_sig;GRANT ALL ON SEQUENCE "+schema+"."+tablename+"_gid_seq TO grp_qgis;"
cur.execute(SQL_vierge)
cur.execute(SQL_pkey)
cur.execute(SQL_GRANT_TABLE)
if self.couche_vierge_point.isChecked() == 1 :
cur.execute(SQL_trigger_coordonnees)
if self.couche_vierge_ligne.isChecked() == 1 :
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
if self.couche_vierge_polygone.isChecked() == 1 :
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
con.commit()
### Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host ,port ,dbname ,user ,mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
layer = self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
else :
con.commit()
con.close() con.close()
pass pass

View File

@ -0,0 +1,236 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
# Import the PyQt and QGIS libraries
# from builtins import next
from builtins import str
# from builtins import object
# import qgis
from qgis.PyQt.QtCore import QSettings
from qgis.PyQt.QtWidgets import QDialog, QMessageBox, QDialogButtonBox
# from qgis.PyQt.QtGui import QIcon
# from qgis.PyQt.QtCore import *
# from qgis.PyQt.QtGui import *
from qgis.PyQt import QtGui
# from qgis.core import *
from qgis.core import QgsSettings, QgsDataSourceUri, QgsProject
try:
from .tools.PythonSQL import login_base
except ValueError:
print('Pas de fichier PythonSQL')
# from .tools.SQLRequet import *
from .tools.resources import (
load_ui,
resources_path,
# send_issues,
)
# from .issues import CenRa_Issues
# import os.path
# import webbrowser
# import psycopg2
# import psycopg2.extras
# import base64
from qgis.utils import iface
EDITOR_CLASS = load_ui('CenRa_PostgisRename_base.ui')
ch = [u"à", u"À", u"â", u"Â", u"ä", u"Ä", u"å", u"Å", u"ç", u"Ç", u"é", u"É", u"è", u"È", u"ê", u"Ê", u"ë", u"Ë", u"î", u"Î", u"ï", u"Ï", u"ô", u"Ô", u"ö", u"Ö", u"ù", u"Ù", u"û", u"Û", u"ü", u"Ü", u"ÿ", u"Ÿ", u"'", u"-", u" "]
try:
account = login_base("account")
user = account[0]
mdp = account[1]
host = account[2]
port = account[3]
dbname = account[4]
cur = account[7]
con = account[8]
except ValueError:
print('')
class Postgis_Rename(QDialog, EDITOR_CLASS):
def __init__(self, parent=None):
_ = parent
super().__init__()
self.setupUi(self)
self.settings = QgsSettings()
self.s = QSettings()
self.setWindowIcon(QtGui.QIcon(resources_path('icons', 'icon.png')))
self.iface = iface
self.schema.currentIndexChanged.connect(self.Test)
self.buttonBox.accepted.connect(self.msgBox)
# Outil Ajout de nouvelles couche a un dossier
def raise_(self):
self.activateWindow()
self.groupBox_3.hide()
self.buttonBox.button(QDialogButtonBox.StandardButton(0x00000400)).setEnabled(False)
GET_ALL_SCHEMA = """SELECT DISTINCT table_schema FROM information_schema.tables WHERE table_schema LIKE '_form_%' OR table_schema LIKE '_01_%' OR table_schema LIKE '_07_%' OR table_schema LIKE '_26_%' OR table_schema LIKE '_42_%' OR table_schema LIKE '_69_%' ORDER BY table_schema;"""
cur.execute(GET_ALL_SCHEMA)
AllSchema = cur.fetchall()
last_value_schema = self.schema.currentText()
last_value_departement = self.departement.currentText()
self.schema.clear()
self.departement.clear()
self.schema.addItems([''])
for Schema in AllSchema:
self.schema.addItems(Schema)
self.departement.addItems(['', '01', '07', '26', '42', '69', 'form'])
if last_value_schema != '':
self.schema.setCurrentIndex(self.schema.findText(last_value_schema))
if last_value_departement != '':
self.departement.setCurrentIndex(self.departement.findText(last_value_departement))
def Test(self):
oldSchema = self.schema.currentText()
if oldSchema != '':
allIsGood = 0
GET_COUNT_LEFT = "SELECT count(*) FROM information_schema.tables WHERE table_schema LIKE left(table_name," + str(len(oldSchema)) + ") AND table_schema LIKE '" + oldSchema + "';"
GET_COUNT_TOT = "SELECT count(*) FROM information_schema.tables WHERE table_schema LIKE '" + oldSchema + "';"
cur.execute(GET_COUNT_TOT)
CountTot = cur.fetchall()[0]
cur.execute(GET_COUNT_LEFT)
CountLeft = cur.fetchall()[0]
if CountLeft[0] == CountTot[0]:
allIsGood = allIsGood + 1
self.couche.setChecked(1)
else:
self.couche.setChecked(0)
GET_GRANTEE_PRIVILEGE = "SELECT DISTINCT count(*) FROM information_schema.role_table_grants WHERE table_schema LIKE '" + oldSchema + "' AND grantee LIKE 'grp_qgis' AND privilege_type LIKE 'UPDATE';"
cur.execute(GET_GRANTEE_PRIVILEGE)
CountPrivilege = cur.fetchall()[0]
if CountTot[0] == CountPrivilege[0]:
allIsGood = allIsGood + 1
self.compte.setChecked(1)
else:
self.compte.setChecked(0)
if allIsGood == 2:
self.groupBox_3.show()
self.loadValue()
self.buttonBox.button(QDialogButtonBox.StandardButton(0x00000400)).setEnabled(True)
else:
self.groupBox_3.hide()
self.buttonBox.button(QDialogButtonBox.StandardButton(0x00000400)).setEnabled(False)
else:
self.old_name.setText('')
self.compte.setChecked(0)
self.couche.setChecked(0)
self.groupBox_3.hide()
def loadValue(self):
oldSchema = self.schema.currentText()
if oldSchema[:6] == '_form_':
oldSchema = self.schema.currentText()[6:]
prefixSchema = self.schema.currentText()[1:5]
else:
oldSchema = self.schema.currentText()[4:]
prefixSchema = self.schema.currentText()[1:3]
if oldSchema[:3] == 'at_':
oldSchema = oldSchema[3:]
self.animation.setChecked(1)
else:
self.animation.setChecked(0)
self.old_name.setText(oldSchema)
self.departement.setCurrentIndex(self.departement.findText(prefixSchema))
def updateName(self):
if self.departement.currentText() != '':
oldTableName = self.old_name.text()
newTableName = ((self.new_name.text()).lower()).replace(' ', '_')
newPrefixSchema = '_' + self.departement.currentText() + '_'
if self.schema.currentText()[:6] == '_form_':
oldPrefixSchema = self.schema.currentText()[:6]
if (self.schema.currentText()[6:9]) == "at_":
oldPrefixSchema = oldPrefixSchema + 'at_'
else:
oldPrefixSchema = self.schema.currentText()[:4]
if (self.schema.currentText()[4:7]) == 'at_':
oldPrefixSchema = oldPrefixSchema + 'at_'
if self.animation.isChecked():
newPrefixSchema = newPrefixSchema + 'at_'
oldSchemaName = oldPrefixSchema + oldTableName
newSchemaName = newPrefixSchema + newTableName
if oldSchemaName != newSchemaName:
global AllSQLrun
allSQLrun = ''
SQL_UPDATE = """UPDATE public.layer_styles SET f_table_schema = '""" + newSchemaName + """',f_table_name = replace(replace(f_table_name,'""" + oldTableName + """','""" + newTableName + """'),'""" + oldPrefixSchema + """','""" + newPrefixSchema + """') WHERE f_table_schema LIKE '""" + oldSchemaName + """';"""
allSQLrun = allSQLrun + SQL_UPDATE
cur.execute(SQL_UPDATE)
SQL_GET_TABLE_RENAME = """SELECT table_name,replace(replace(table_name,'""" + oldTableName + """','""" + newTableName + """'),'""" + oldPrefixSchema + """','""" + newPrefixSchema + """') from information_schema.tables WHERE table_schema LIKE '""" + oldSchemaName + """';"""
cur.execute(SQL_GET_TABLE_RENAME)
allTableRename = cur.fetchall()
allTableList = []
for TableRename in allTableRename:
oldTable = TableRename[0]
newTable = TableRename[1]
allTableList.append([oldTable, newSchemaName, newTable])
SQL_RENAME_TABLE = """ALTER TABLE """ + oldSchemaName + '.' + oldTable + """ RENAME TO """ + newTable + """;"""
allSQLrun = allSQLrun + SQL_RENAME_TABLE
cur.execute(SQL_RENAME_TABLE)
SQL_RENAME_SCHEMA = 'ALTER SCHEMA ' + oldSchemaName + ' RENAME TO ' + newSchemaName
allSQLrun = allSQLrun + SQL_RENAME_SCHEMA
cur.execute(SQL_RENAME_SCHEMA)
con.commit()
for LayerOpen in allTableList:
self.UnloadLoadLayers(LayerOpen[0], LayerOpen[1], LayerOpen[2])
def UnloadLoadLayers(self, OldName, NewSchema, NewTable):
allLayers = (QgsProject.instance().mapLayers().values())
listLayers = []
listLayersName = []
for layer in allLayers:
listLayers.append(layer)
listLayersName.append(layer.name())
if OldName in listLayersName:
layer = (listLayers[listLayersName.index(OldName)])
provider = layer.dataProvider()
dbname = (QgsDataSourceUri(provider.dataSourceUri()).database())
user = QgsDataSourceUri(provider.dataSourceUri()).username()
mdp = QgsDataSourceUri(provider.dataSourceUri()).password()
host = QgsDataSourceUri(provider.dataSourceUri()).host()
port = QgsDataSourceUri(provider.dataSourceUri()).port()
# Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host, port, dbname, user, mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(NewSchema, NewTable, 'geom')
QgsProject.instance().removeMapLayer(layer.id())
layer = self.iface.addVectorLayer(uri.uri(), NewTable, "postgres")
def msgBox(self):
self.QMBquestion = QMessageBox()
self.QMBquestion.setWindowTitle(u"Attention !")
self.QMBquestion.setIcon(QMessageBox.Icon.Warning)
self.QMBquestion.setText("Attention, le renommage de dossier PostGIS peut engendrer des pertes de liaisons avec des projets QGIS !")
self.QMBquestion.setStandardButtons(QMessageBox.StandardButton(0x00004000) | QMessageBox.StandardButton(0x00010000))
if self.new_name.text() != '':
error_caracteres = 0
for caracteres in ch:
if self.new_name.text().find(caracteres) != - 1:
error_caracteres = 1
if error_caracteres == 0:
self.QMBquestion = self.QMBquestion.exec()
else:
QMessageBox.warning(None, "Oups :", u"Le nom de dossier ne doit pas comporter de caractères spéciaux, ni d'espaces !\n\n\t" + self.new_name.text().lower())
else:
QMessageBox.warning(None, "Oups :", "Votre projet doit avoire un nom !")
if self.QMBquestion == QMessageBox.StandardButton(0x00004000):
self.updateName()

View File

@ -1,21 +0,0 @@
from qgis.core import QgsApplication
def gitea():
file_url = QgsApplication.qgisSettingsDirPath()+'QGIS/QGIS3.ini'
recherche_1 = 'plugin_repositories\\github\\url=https://github.com/CEN-Rhone-Alpes/Plugin_QGIS/releases/latest/download/plugins.xml'
replace_1 = 'plugin_repositories\\gitea\\url=https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
recherche_2 = 'github'
replace_2 = 'gitea'
# Read in the file
with open(file_url, 'r') as file:
filedata = file.read()
# Replace the target string
filedata = filedata.replace(recherche_1, replace_1)
filedata = filedata.replace(recherche_2, replace_2)
# Write the file out again
with open(file_url, 'w') as file:
file.write(filedata)

View File

@ -1,174 +1,141 @@
import sys
import socket geom = "geom"
import os champ_travaux_prevus_multipolygon = """(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, surface_m2 double precision, surface_ha double precision, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))"""
IPAddr=socket.gethostbyname(socket.gethostname()) champ_travaux_prevus_multilinestring = """(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, longueur_m double precision, longueur_km double precision, date_creation date, date_maj date, geom geometry(MultiLineString,2154))"""
if IPAddr[0:11] == "100.100.100": #4269 champ_travaux_prevus_point = """(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, x_wgs84 double precision, y_wgs84 double precision, date_creation date, date_maj date, geom geometry(Point,2154))"""
host = "100.100.100.11"
port = "5432" champ_viergePolygone = """(gid serial NOT NULL, commentaire text, surface_m2 double precision, surface_ha double precision, geom geometry(MultiPolygon,2154))"""
dbname = "sig4269" champ_viergeLigne = """(gid serial NOT NULL, commentaire text, longueur_m double precision, longueur_km double precision, geom geometry(MultiLineString,2154))"""
sigdb="sig4269" champ_viergePoint = """(gid serial NOT NULL, commentaire text, x_wgs84 double precision, y_wgs84 double precision, geom geometry(Point,2154))"""
refdb="ref_geo4269"
password = "McVities" champ_habitat = """(gid serial NOT NULL, cd_cb_01 text, lb_cb97_fr_01 text, occupation_01 integer, cd_cb_02 text, lb_cb97_fr_02 text, occupation_02 integer, cd_cb_03 text, lb_cb97_fr_03 text, occupation_03 integer, milieu_code text, milieu_libelle text, surface_m2 double precision, surface_ha double precision, commentaire text, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))"""
if IPAddr[0:9] == "192.168.0": #01
host = "192.168.0.201" champ_contour = """(gid serial NOT NULL, date_creation date, date_maj date, utilisateur character varying, dept character(2), nom character varying, surface_m2 double precision, surface_ha double precision, type_site character varying, type_milieu character varying, date_premier_pg integer, date_debut_pg integer, date_fin_pg integer, referent character varying, gestion_deleguee character varying, terrain_militaire character(3), ens character(3), zh character(3), adapt_pmr character(3), inform character(3), guide character(3), ouverture_public character(3), obs character(3), anim character(3), n2000_anim character(3), contrat_n2000_conseil character(3), n2000_op character(3), contrat_n2000_benef character(3), contrat_agri character(3), bc_habitat integer, bc_amphibien integer, bc_coleoptere integer, bc_crustace integer, bc_mammifere integer, bc_chiroptere integer, bc_mollusque integer, bc_odonate integer, bc_oiseau integer, bc_orthoptere integer, bc_poisson integer, bc_reptile integer, bc_rhopalocere integer, bc_heterocere integer, bc_autre_invertebre integer, bc_flore integer, bc_bryophyte integer, bc_champignon integer, suiv_analyse_sol character(3), suiv_piezo character(3), suiv_climat character(3), suiv_topo character(3), suiv_habitat character(3), suiv_amphibien character(3), suiv_coleoptere character(3), suiv_crustace character(3), suiv_mammifere character(3), suiv_chiroptere character(3), suiv_mollusque character(3), suiv_odonate character(3), suiv_oiseau character(3), suiv_orthoptere character(3), suiv_poisson character(3), suiv_reptile character(3), suiv_rhopalocere character(3), suiv_heterocere character(3), suiv_autre_invertebre character(3), suiv_flore character(3), suiv_bryophyte character(3), suiv_champignon character(3), suiv_analyse_eau character(3), suiv_phenologie character(3), suiv_frequentation character(3), suiv_paysager character(3), suiv_autre character(3), commentaire text, geom geometry(MultiPolygon,2154))
port = "5432" """
dbname = "sig01"
sigdb="sig01" champ_vegethab_point = """(
refdb="ref_geo01" gid serial NOT NULL ,
password = "McVities" cd_eu_01 character varying(254) COLLATE pg_catalog."default",
if IPAddr[0:9] == "192.168.1": #0726 lb_eu_01 character varying(254) COLLATE pg_catalog."default",
host = "192.168.1.201" occupati_1 bigint,
port = "5432" cd_eu_02 character varying(254) COLLATE pg_catalog."default",
dbname = "sig0726" lb_eu_02 character varying(254) COLLATE pg_catalog."default",
sigdb="sig0726" occupati_2 bigint,
refdb="ref_geo0726" cd_eu_03 character varying(254) COLLATE pg_catalog."default",
password = "McVities" lb_eu_03 character varying(254) COLLATE pg_catalog."default",
if sys.platform == 'linux': occupati_3 bigint,
os_user = os.environ['USER'] milieu_cod character varying(254) COLLATE pg_catalog."default",
else: milieu_lib character varying(254) COLLATE pg_catalog."default",
os_user = os.environ['USERNAME'] x_wgs84 double precision,
if os_user == 'STAGE': y_wgs84 double precision,
os_user='stage' commentair character varying(254) COLLATE pg_catalog."default",
if os_user == 'Administrateur': date_creat date,
os_user='stage' date_maj date,
num_phyto character varying(254) COLLATE pg_catalog."default",
geom = "geom" type_unite character varying(254) COLLATE pg_catalog."default",
champ_travaux_prevus_multipolygon="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, surface_m2 double precision, surface_ha double precision, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))""" dynamique character varying(254) COLLATE pg_catalog."default",
champ_travaux_prevus_multilinestring="""(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, longueur_m double precision, longueur_km double precision, date_creation date, date_maj date, geom geometry(MultiLineString,2154))""" gestio_obs character varying(254) COLLATE pg_catalog."default",
champ_travaux_prevus_point = """(gid serial NOT NULL, groupe_gestion text, gestion_lib text, id_gestion text, datedebut date, datefin date, commentaire text, x_wgs84 double precision, y_wgs84 double precision, date_creation date, date_maj date, geom geometry(Point,2154))""" degrad_obs character varying(254) COLLATE pg_catalog."default",
eta_conser character varying(254) COLLATE pg_catalog."default",
champ_viergePolygone = """(gid serial NOT NULL, commentaire text, surface_m2 double precision, surface_ha double precision, geom geometry(MultiPolygon,2154))""" clas_phyto character varying(254) COLLATE pg_catalog."default",
champ_viergeLigne = """(gid serial NOT NULL, commentaire text, longueur_m double precision, longueur_km double precision, geom geometry(MultiLineString,2154))""" alli_phyto character varying(254) COLLATE pg_catalog."default",
champ_viergePoint = """(gid serial NOT NULL, commentaire text, x_wgs84 double precision, y_wgs84 double precision, geom geometry(Point,2154))""" syntaxon character varying(254) COLLATE pg_catalog."default",
n2000 character varying(254) COLLATE pg_catalog."default",
champ_habitat = """(gid serial NOT NULL, cd_cb_01 text, lb_cb97_fr_01 text, occupation_01 integer, cd_cb_02 text, lb_cb97_fr_02 text, occupation_02 integer, cd_cb_03 text, lb_cb97_fr_03 text, occupation_03 integer, milieu_code text, milieu_libelle text, surface_m2 double precision, surface_ha double precision, commentaire text, date_creation date, date_maj date, geom geometry(MultiPolygon,2154))""" lrr_aura character varying(254) COLLATE pg_catalog."default",
lrr_cbna character varying(254) COLLATE pg_catalog."default",
champ_contour="""(gid serial NOT NULL, date_creation date, date_maj date, utilisateur character varying, dept character(2), nom character varying, surface_m2 double precision, surface_ha double precision, type_site character varying, type_milieu character varying, date_premier_pg integer, date_debut_pg integer, date_fin_pg integer, referent character varying, gestion_deleguee character varying, terrain_militaire character(3), ens character(3), zh character(3), adapt_pmr character(3), inform character(3), guide character(3), ouverture_public character(3), obs character(3), anim character(3), n2000_anim character(3), contrat_n2000_conseil character(3), n2000_op character(3), contrat_n2000_benef character(3), contrat_agri character(3), bc_habitat integer, bc_amphibien integer, bc_coleoptere integer, bc_crustace integer, bc_mammifere integer, bc_chiroptere integer, bc_mollusque integer, bc_odonate integer, bc_oiseau integer, bc_orthoptere integer, bc_poisson integer, bc_reptile integer, bc_rhopalocere integer, bc_heterocere integer, bc_autre_invertebre integer, bc_flore integer, bc_bryophyte integer, bc_champignon integer, suiv_analyse_sol character(3), suiv_piezo character(3), suiv_climat character(3), suiv_topo character(3), suiv_habitat character(3), suiv_amphibien character(3), suiv_coleoptere character(3), suiv_crustace character(3), suiv_mammifere character(3), suiv_chiroptere character(3), suiv_mollusque character(3), suiv_odonate character(3), suiv_oiseau character(3), suiv_orthoptere character(3), suiv_poisson character(3), suiv_reptile character(3), suiv_rhopalocere character(3), suiv_heterocere character(3), suiv_autre_invertebre character(3), suiv_flore character(3), suiv_bryophyte character(3), suiv_champignon character(3), suiv_analyse_eau character(3), suiv_phenologie character(3), suiv_frequentation character(3), suiv_paysager character(3), suiv_autre character(3), commentaire text, geom geometry(MultiPolygon,2154)) lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
""" vege_enjeu character varying(254) COLLATE pg_catalog."default",
num_photo character varying(254) COLLATE pg_catalog."default",
champ_vegethab_point = """( nature_obs character varying(254) COLLATE pg_catalog."default",
gid serial NOT NULL , date_sais date,
cd_eu_01 character varying(254) COLLATE pg_catalog."default", s_al_phyto character varying(254) COLLATE pg_catalog."default",
lb_eu_01 character varying(254) COLLATE pg_catalog."default", alli_name character varying(254) COLLATE pg_catalog."default",
occupati_1 bigint, salli_name character varying(254) COLLATE pg_catalog."default",
cd_eu_02 character varying(254) COLLATE pg_catalog."default", class_name character varying(254) COLLATE pg_catalog."default",
lb_eu_02 character varying(254) COLLATE pg_catalog."default", geom geometry(Point,2154)
occupati_2 bigint, )
cd_eu_03 character varying(254) COLLATE pg_catalog."default", """
lb_eu_03 character varying(254) COLLATE pg_catalog."default", champ_vegethab_multilinestring = """(
occupati_3 bigint, gid serial NOT NULL ,
milieu_cod character varying(254) COLLATE pg_catalog."default", cd_eu_01 character varying(254) COLLATE pg_catalog."default",
milieu_lib character varying(254) COLLATE pg_catalog."default", lb_eu_01 character varying(254) COLLATE pg_catalog."default",
x_wgs84 double precision, occupati_1 bigint,
y_wgs84 double precision, cd_eu_02 character varying(254) COLLATE pg_catalog."default",
commentair character varying(254) COLLATE pg_catalog."default", lb_eu_02 character varying(254) COLLATE pg_catalog."default",
date_creat date, occupati_2 bigint,
date_maj date, cd_eu_03 character varying(254) COLLATE pg_catalog."default",
num_phyto character varying(254) COLLATE pg_catalog."default", lb_eu_03 character varying(254) COLLATE pg_catalog."default",
type_unite character varying(254) COLLATE pg_catalog."default", occupati_3 bigint,
dynamique character varying(254) COLLATE pg_catalog."default", milieu_cod character varying(254) COLLATE pg_catalog."default",
gestio_obs character varying(254) COLLATE pg_catalog."default", milieu_lib character varying(254) COLLATE pg_catalog."default",
degrad_obs character varying(254) COLLATE pg_catalog."default", longueur_m double precision,
eta_conser character varying(254) COLLATE pg_catalog."default", longueur_km double precision,
clas_phyto character varying(254) COLLATE pg_catalog."default", commentair character varying(254) COLLATE pg_catalog."default",
alli_phyto character varying(254) COLLATE pg_catalog."default", date_creat date,
syntaxon character varying(254) COLLATE pg_catalog."default", date_maj date,
n2000 character varying(254) COLLATE pg_catalog."default", num_phyto character varying(254) COLLATE pg_catalog."default",
lrr_aura character varying(254) COLLATE pg_catalog."default", type_unite character varying(254) COLLATE pg_catalog."default",
lrr_cbna character varying(254) COLLATE pg_catalog."default", dynamique character varying(254) COLLATE pg_catalog."default",
lrr_cbnmc character varying(254) COLLATE pg_catalog."default", gestio_obs character varying(254) COLLATE pg_catalog."default",
vege_enjeu character varying(254) COLLATE pg_catalog."default", degrad_obs character varying(254) COLLATE pg_catalog."default",
num_photo character varying(254) COLLATE pg_catalog."default", eta_conser character varying(254) COLLATE pg_catalog."default",
nature_obs character varying(254) COLLATE pg_catalog."default", clas_phyto character varying(254) COLLATE pg_catalog."default",
date_sais date, alli_phyto character varying(254) COLLATE pg_catalog."default",
s_al_phyto character varying(254) COLLATE pg_catalog."default", syntaxon character varying(254) COLLATE pg_catalog."default",
alli_name character varying(254) COLLATE pg_catalog."default", n2000 character varying(254) COLLATE pg_catalog."default",
salli_name character varying(254) COLLATE pg_catalog."default", lrr_aura character varying(254) COLLATE pg_catalog."default",
class_name character varying(254) COLLATE pg_catalog."default", lrr_cbna character varying(254) COLLATE pg_catalog."default",
geom geometry(Point,2154) lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
) vege_enjeu character varying(254) COLLATE pg_catalog."default",
""" num_photo character varying(254) COLLATE pg_catalog."default",
champ_vegethab_multilinestring = """( nature_obs character varying(254) COLLATE pg_catalog."default",
gid serial NOT NULL , date_sais date,
cd_eu_01 character varying(254) COLLATE pg_catalog."default", s_al_phyto character varying(254) COLLATE pg_catalog."default",
lb_eu_01 character varying(254) COLLATE pg_catalog."default", alli_name character varying(254) COLLATE pg_catalog."default",
occupati_1 bigint, salli_name character varying(254) COLLATE pg_catalog."default",
cd_eu_02 character varying(254) COLLATE pg_catalog."default", class_name character varying(254) COLLATE pg_catalog."default",
lb_eu_02 character varying(254) COLLATE pg_catalog."default", geom geometry(MultiLineString,2154)
occupati_2 bigint, )
cd_eu_03 character varying(254) COLLATE pg_catalog."default", """
lb_eu_03 character varying(254) COLLATE pg_catalog."default", champ_vegethab_multipolygon = """(
occupati_3 bigint, gid serial NOT NULL ,
milieu_cod character varying(254) COLLATE pg_catalog."default", cd_eu_01 character varying(254) COLLATE pg_catalog."default",
milieu_lib character varying(254) COLLATE pg_catalog."default", lb_eu_01 character varying(254) COLLATE pg_catalog."default",
longueur_m double precision, occupati_1 bigint,
longueur_km double precision, cd_eu_02 character varying(254) COLLATE pg_catalog."default",
commentair character varying(254) COLLATE pg_catalog."default", lb_eu_02 character varying(254) COLLATE pg_catalog."default",
date_creat date, occupati_2 bigint,
date_maj date, cd_eu_03 character varying(254) COLLATE pg_catalog."default",
num_phyto character varying(254) COLLATE pg_catalog."default", lb_eu_03 character varying(254) COLLATE pg_catalog."default",
type_unite character varying(254) COLLATE pg_catalog."default", occupati_3 bigint,
dynamique character varying(254) COLLATE pg_catalog."default", milieu_cod character varying(254) COLLATE pg_catalog."default",
gestio_obs character varying(254) COLLATE pg_catalog."default", milieu_lib character varying(254) COLLATE pg_catalog."default",
degrad_obs character varying(254) COLLATE pg_catalog."default", surface_m2 numeric,
eta_conser character varying(254) COLLATE pg_catalog."default", surface_ha numeric,
clas_phyto character varying(254) COLLATE pg_catalog."default", commentair character varying(254) COLLATE pg_catalog."default",
alli_phyto character varying(254) COLLATE pg_catalog."default", date_creat date,
syntaxon character varying(254) COLLATE pg_catalog."default", date_maj date,
n2000 character varying(254) COLLATE pg_catalog."default", num_phyto character varying(254) COLLATE pg_catalog."default",
lrr_aura character varying(254) COLLATE pg_catalog."default", type_unite character varying(254) COLLATE pg_catalog."default",
lrr_cbna character varying(254) COLLATE pg_catalog."default", dynamique character varying(254) COLLATE pg_catalog."default",
lrr_cbnmc character varying(254) COLLATE pg_catalog."default", gestio_obs character varying(254) COLLATE pg_catalog."default",
vege_enjeu character varying(254) COLLATE pg_catalog."default", degrad_obs character varying(254) COLLATE pg_catalog."default",
num_photo character varying(254) COLLATE pg_catalog."default", eta_conser character varying(254) COLLATE pg_catalog."default",
nature_obs character varying(254) COLLATE pg_catalog."default", clas_phyto character varying(254) COLLATE pg_catalog."default",
date_sais date, alli_phyto character varying(254) COLLATE pg_catalog."default",
s_al_phyto character varying(254) COLLATE pg_catalog."default", syntaxon character varying(254) COLLATE pg_catalog."default",
alli_name character varying(254) COLLATE pg_catalog."default", n2000 character varying(254) COLLATE pg_catalog."default",
salli_name character varying(254) COLLATE pg_catalog."default", lrr_aura character varying(254) COLLATE pg_catalog."default",
class_name character varying(254) COLLATE pg_catalog."default", lrr_cbna character varying(254) COLLATE pg_catalog."default",
geom geometry(MultiLineString,2154) lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
) vege_enjeu character varying(254) COLLATE pg_catalog."default",
""" num_photo character varying(254) COLLATE pg_catalog."default",
champ_vegethab_multipolygon = """( nature_obs character varying(254) COLLATE pg_catalog."default",
gid serial NOT NULL , date_sais date,
cd_eu_01 character varying(254) COLLATE pg_catalog."default", s_al_phyto character varying(254) COLLATE pg_catalog."default",
lb_eu_01 character varying(254) COLLATE pg_catalog."default", alli_name character varying(254) COLLATE pg_catalog."default",
occupati_1 bigint, salli_name character varying(254) COLLATE pg_catalog."default",
cd_eu_02 character varying(254) COLLATE pg_catalog."default", class_name character varying(254) COLLATE pg_catalog."default",
lb_eu_02 character varying(254) COLLATE pg_catalog."default", geom geometry(MultiPolygon,2154)
occupati_2 bigint, )
cd_eu_03 character varying(254) COLLATE pg_catalog."default", """
lb_eu_03 character varying(254) COLLATE pg_catalog."default",
occupati_3 bigint,
milieu_cod character varying(254) COLLATE pg_catalog."default",
milieu_lib character varying(254) COLLATE pg_catalog."default",
surface_m2 numeric,
surface_ha numeric,
commentair character varying(254) COLLATE pg_catalog."default",
date_creat date,
date_maj date,
num_phyto character varying(254) COLLATE pg_catalog."default",
type_unite character varying(254) COLLATE pg_catalog."default",
dynamique character varying(254) COLLATE pg_catalog."default",
gestio_obs character varying(254) COLLATE pg_catalog."default",
degrad_obs character varying(254) COLLATE pg_catalog."default",
eta_conser character varying(254) COLLATE pg_catalog."default",
clas_phyto character varying(254) COLLATE pg_catalog."default",
alli_phyto character varying(254) COLLATE pg_catalog."default",
syntaxon character varying(254) COLLATE pg_catalog."default",
n2000 character varying(254) COLLATE pg_catalog."default",
lrr_aura character varying(254) COLLATE pg_catalog."default",
lrr_cbna character varying(254) COLLATE pg_catalog."default",
lrr_cbnmc character varying(254) COLLATE pg_catalog."default",
vege_enjeu character varying(254) COLLATE pg_catalog."default",
num_photo character varying(254) COLLATE pg_catalog."default",
nature_obs character varying(254) COLLATE pg_catalog."default",
date_sais date,
s_al_phyto character varying(254) COLLATE pg_catalog."default",
alli_name character varying(254) COLLATE pg_catalog."default",
salli_name character varying(254) COLLATE pg_catalog."default",
class_name character varying(254) COLLATE pg_catalog."default",
geom geometry(MultiPolygon,2154)
)
"""

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -3,11 +3,13 @@
import configparser import configparser
import shutil import shutil
import tempfile import tempfile
import base64 # import base64
import psycopg2 # import psycopg2
import psycopg2.extras # import psycopg2.extras
import os
from os.path import abspath, join, pardir, dirname from os.path import abspath, join, pardir, dirname
from qgis.core import QgsDataSourceUri
from .SQLRequet import geom, champ_contour, champ_travaux_prevus_multilinestring, champ_travaux_prevus_point, champ_travaux_prevus_multipolygon, champ_vegethab_multipolygon, champ_vegethab_multilinestring, champ_vegethab_point, champ_viergeLigne, champ_viergePoint, champ_viergePolygone
from qgis.PyQt import uic from qgis.PyQt import uic
__copyright__ = "Copyright 2019, 3Liz" __copyright__ = "Copyright 2019, 3Liz"
@ -107,77 +109,439 @@ def load_ui(*args):
return ui_class return ui_class
def login_base(take=None):
from CenRa_Metabase.resources.PythonSQL import host,port,dbname,password,os_user
first_conn = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=first_cnx password=" + password)
first_cur = first_conn.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_cur.execute("SELECT mdp_w, login_w FROM pg_catalog.pg_user t1, admin_sig.vm_users_sig t2 WHERE t2.oid = t1.usesysid AND (login_w = '" + os_user + "' OR login_w = '" + os_user + "')")
res_ident = first_cur.fetchone()
mdp = base64.b64decode(str(res_ident[0])).decode('utf-8')
user = res_ident[1]
con = psycopg2.connect("host=" + host + " port=" + port + " dbname="+dbname+" user=" + user + " password=" + mdp) def pyperclip():
dst = dirname(dirname(__file__)) + "\\tools\\"
if os.access('N:/', os.R_OK):
src = 'N:/SI_Systeme d information/Z_QGIS/PLUGIN/PythonSQL.py'
try:
shutil.copy(src, dst)
except FileNotFoundError:
print('404')
except UnboundLocalError:
print('404')
cur = con.cursor(cursor_factory = psycopg2.extras.DictCursor)
first_conn.close()
if take: def send_issues(url, titre, body, labels):
return cur,con
else:
return cur
def send_issues(url,titre,body,labels):
import requests import requests
import urllib.request
import json import json
import os # import os
import qgis # import qgis
usr = os.environ['USERNAME'] # usr = os.environ['USERNAME']
token = '9d0a4e0bea561710e0728f161f7edf4e5201e112' token = '9d0a4e0bea561710e0728f161f7edf4e5201e112'
url=url+'?token='+token url = url + '?token=' + token
headers = {'Authorization': 'token ' + token,'accept': 'application/json','Content-Type': 'application/json'}
headers = {'Authorization': 'token ' + token, 'accept': 'application/json', 'Content-Type': 'application/json'}
payload = {'title': titre, 'body': body, 'labels': labels} payload = {'title': titre, 'body': body, 'labels': labels}
try: try:
urllib.request.urlopen('https://google.com') urllib.request.urlopen('https://google.com')
binar = True binar = True
except: except ValueError:
binar = False binar = False
r = '' r = ''
if binar: if binar:
r = requests.post(url, data=json.dumps(payload), headers=headers) r = requests.post(url, data=json.dumps(payload), headers=headers)
return r return r
def maj_verif(NAME): def maj_verif(NAME):
import qgis import qgis
import urllib.request import urllib.request
iface = qgis.utils.iface iface = qgis.utils.iface
from qgis.core import Qgis from qgis.core import Qgis
url = qgis.utils.pluginMetadata(NAME,'repository') # url = qgis.utils.pluginMetadata(NAME, 'repository')
#URL = url+'/raw/branch/main/plugins.xml' # URL = url+'/raw/branch/main/plugins.xml'
URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/releases/plugins.xml' URL = 'https://gitea.cenra-outils.org/CEN-RA/Plugin_QGIS/releases/download/latest/plugins.xml'
# print(URL) # print(URL)
version = qgis.utils.pluginMetadata(NAME,'version') version = qgis.utils.pluginMetadata(NAME, 'version')
len_version = len(version) len_version = len(version)
try: try:
urllib.request.urlopen('https://google.com') urllib.request.urlopen('https://google.com')
binar = True binar = True
except: except urllib.error.URLError:
binar = False binar = False
if binar: if binar:
version_web = str(urllib.request.urlopen(URL).read()) try:
plugin_num = version_web.find(NAME) version_web = str(urllib.request.urlopen(URL).read())
valeur_version_web = version_web.find('<version>',plugin_num)+9 plugin_num = version_web.find(NAME)
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version] valeur_version_web = version_web.find('<version>', plugin_num) + 9
if version_plugin != version: version_plugin = version_web[valeur_version_web:valeur_version_web + len_version]
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30) if version_plugin != version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
except urllib.error.URLError:
print("error gitea version ssl")
else: else:
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30) iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
def devlog(NAME): def devlog(NAME):
import qgis import qgis
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>' devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
devmaj = devmaj+qgis.utils.pluginMetadata(NAME,'changelog') devmaj = devmaj + qgis.utils.pluginMetadata(NAME, 'changelog')
return devmaj return devmaj
def create_contour(self, schema, cur, con, host, port, dbname, user, mdp):
# Creation de la table contour
# Verifie si la checkbox est cochee
if self.couche_contour.isChecked():
if self.annee_1.text() == 'aaaa' or self.annee_1.text() == '':
tablename = schema + "_contour"
else:
tablename = schema + "_contour_" + self.annee_1.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
RETURNE = "SELECT pg_get_serial_sequence('" + schema + "." + tablename + "','gid')"
SQL_contour = "CREATE TABLE " + schema + "." + tablename + champ_contour
cur.execute(SQL_contour)
cur.execute(RETURNE)
sequence_name = cur.fetchone()[0]
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename[len(schema):] + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'contour_modele_v3'"""
SQL_GRANT_TABLE = "GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename + " TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename + " TO grp_sig;GRANT ALL ON SEQUENCE " + sequence_name + " TO grp_qgis;"
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
# Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
# Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host, port, dbname, user, mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
def create_travaux(self, schema, cur, con, host, port, dbname, user, mdp):
# Creation de la table travaux prevus
if self.couche_travaux_prevus.isChecked():
# **********Poly
if self.annee_5.text() == 'aaaa' or self.annee_5.text() == '':
tablename = schema + "_travaux_prevus_poly"
else:
tablename = schema + "_travaux_prevus_poly_" + self.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
RETURNE = "SELECT pg_get_serial_sequence('" + schema + "." + tablename + "','gid')"
SQL_travaux_prevus = "CREATE TABLE " + schema + "." + tablename + champ_travaux_prevus_multipolygon
cur.execute(SQL_travaux_prevus)
cur.execute(RETURNE)
sequence_name = cur.fetchone()[0]
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename[len(schema):] + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_poly_modele_v3'"""
SQL_GRANT_TABLE = "GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename + " TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename + " TO grp_sig;GRANT ALL ON SEQUENCE " + sequence_name + " TO grp_qgis;"
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
# Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
# Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host, port, dbname, user, mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
# **********ligne
if self.annee_5.text() == 'aaaa' or self.annee_5.text() == '':
tablename = schema + "_travaux_prevus_ligne"
else:
tablename = schema + "_travaux_prevus_ligne_" + self.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
RETURNE = "SELECT pg_get_serial_sequence('" + schema + "." + tablename + "','gid')"
SQL_travaux_prevus = "CREATE TABLE " + schema + "." + tablename + champ_travaux_prevus_multilinestring
cur.execute(SQL_travaux_prevus)
cur.execute(RETURNE)
sequence_name = cur.fetchone()[0]
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename[len(schema):] + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_ligne_modele_v3'"""
SQL_GRANT_TABLE = "GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename + " TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename + " TO grp_sig;GRANT ALL ON SEQUENCE " + sequence_name + " TO grp_qgis;"
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
# Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
# Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host, port, dbname, user, mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
# **********point
if self.annee_5.text() == 'aaaa' or self.annee_5.text() == '':
tablename = schema + "_travaux_prevus_point"
else:
tablename = schema + "_travaux_prevus_point_" + self.annee_5.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
RETURNE = "SELECT pg_get_serial_sequence('" + schema + "." + tablename + "','gid')"
SQL_travaux_prevus = "CREATE TABLE " + schema + "." + tablename + champ_travaux_prevus_point
cur.execute(SQL_travaux_prevus)
cur.execute(RETURNE)
sequence_name = cur.fetchone()[0]
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename[len(schema):] + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_date_creation = "CREATE TRIGGER date_creation" + tablename + " BEFORE INSERT ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_creation();"
SQL_trigger_date_maj = "CREATE TRIGGER date_maj" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.date_maj();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'travaux_prevus_point_modele_v3'"""
SQL_GRANT_TABLE = "GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename + " TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename + " TO grp_sig;GRANT ALL ON SEQUENCE " + sequence_name + " TO grp_qgis;"
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_date_creation)
cur.execute(SQL_trigger_date_maj)
cur.execute(SQL_trigger_coordonnees)
# Enregistrement du style (comme style par defaut) dans la table layer_styles
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
# Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host, port, dbname, user, mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
def create_habita(self, schema, cur, con, host, port, dbname, user, mdp):
# Creation de la table habitat
if self.couche_habitat.isChecked():
if self.annee_2.text() == 'aaaa' or self.annee_2.text() == '':
tablename = schema + "_habitat"
else:
tablename = schema + "_habitat_" + self.annee_2.text()
tablename_1 = tablename + "_points"
RETURNE = "SELECT pg_get_serial_sequence('" + schema + "." + tablename_1 + "','gid')"
tablename_qgis = tablename_1[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
SQL_VEGETHAB = "CREATE TABLE " + schema + "." + tablename_1 + champ_vegethab_point
print(RETURNE)
print('')
print(SQL_VEGETHAB)
cur.execute(SQL_VEGETHAB)
cur.execute(RETURNE)
sequence_name = cur.fetchone()[0]
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_1 + " ADD CONSTRAINT " + tablename_1 + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename_1 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_1 + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_1 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_points_modele_v3'"""
SQL_GRANT_TABLE = "GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename_1 + " TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename_1 + " TO grp_sig;GRANT ALL ON SEQUENCE " + sequence_name + " TO grp_qgis;"
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_coordonnees)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
# Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host, port, dbname, user, mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_1, geom)
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
tablename_2 = tablename + "_lignes"
RETURNE = "SELECT pg_get_serial_sequence('" + schema + "." + tablename_2 + "','gid')"
tablename_qgis = tablename_2[1:]
SQL_VEGETHAB = "CREATE TABLE " + schema + "." + tablename_2 + champ_vegethab_multilinestring
cur.execute(SQL_VEGETHAB)
cur.execute(RETURNE)
sequence_name = cur.fetchone()[0]
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_2 + " ADD CONSTRAINT " + tablename_2[len(schema):] + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename_2 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_2 + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename_2 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_2 + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_2 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_lignes_modele_v3'"""
SQL_GRANT_TABLE = "GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename_2 + " TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename_2 + " TO grp_sig;GRANT ALL ON SEQUENCE " + sequence_name + " TO grp_qgis;"
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
# Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host, port, dbname, user, mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_2, geom)
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
tablename_3 = tablename + "_polygones"
RETURNE = "SELECT pg_get_serial_sequence('" + schema + "." + tablename_3 + "','gid')"
tablename_qgis = tablename_3[1:]
SQL_VEGETHAB = "CREATE TABLE " + schema + "." + tablename_3 + champ_vegethab_multipolygon
cur.execute(SQL_VEGETHAB)
cur.execute(RETURNE)
sequence_name = cur.fetchone()[0]
SQL_pkey = "ALTER TABLE " + schema + "." + tablename_3 + " ADD CONSTRAINT " + tablename_3[len(schema):] + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename_3 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_3 + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename_3 + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename_3 + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_style = """INSERT INTO layer_styles (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, update_time)
SELECT f_table_catalog, '""" + schema + "', '" + tablename_3 + """', f_geometry_column, stylename, styleqml, stylesld, useasdefault, "owner", ui, now()
FROM layer_styles
WHERE description = 'vegethab_polygones_modele_v3'"""
SQL_GRANT_TABLE = "GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename_3 + " TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename_3 + " TO grp_sig;GRANT ALL ON SEQUENCE " + sequence_name + " TO grp_qgis;"
cur.execute(SQL_pkey)
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
cur.execute(SQL_style)
cur.execute(SQL_GRANT_TABLE)
con.commit()
# Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host, port, dbname, user, mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename_3, geom)
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")
def create_vierge(self, schema, cur, con, host, port, dbname, user, mdp):
# Creation de la table vierge
if self.couche_vierge.isChecked():
if self.annee_4.text() == 'aaaa' or self.annee_4.text() == '':
tablename = schema + "_" + self.nom_couche_vierge.text().lower()
else:
tablename = schema + "_" + self.nom_couche_vierge.text().lower() + "_" + self.annee_4.text()
tablename_qgis = tablename[1:] # Permet d'enlever le "_", ajouter a la premiere etape, dans qgis
if self.couche_vierge_point.isChecked() == 1:
champ_vierge = champ_viergePoint
if self.couche_vierge_ligne.isChecked() == 1:
champ_vierge = champ_viergeLigne
if self.couche_vierge_polygone.isChecked() == 1:
champ_vierge = champ_viergePolygone
RETURNE = "SELECT pg_get_serial_sequence('" + schema + "." + tablename + "','gid')"
SQL_vierge = "CREATE TABLE " + schema + "." + tablename + champ_vierge
cur.execute(SQL_vierge)
cur.execute(RETURNE)
sequence_name = cur.fetchone()[0]
SQL_pkey = "ALTER TABLE " + schema + "." + tablename + " ADD CONSTRAINT " + tablename[len(schema):] + "_pkey" + " PRIMARY KEY (gid)"
SQL_trigger_area_m2 = "CREATE TRIGGER area_m2" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_m2();"
SQL_trigger_area_ha = "CREATE TRIGGER area_ha" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.area_ha();"
SQL_trigger_length_m = "CREATE TRIGGER length_m" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_m();"
SQL_trigger_length_km = "CREATE TRIGGER length_km" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.length_km();"
SQL_trigger_coordonnees = "CREATE TRIGGER coordonnees" + tablename + " BEFORE INSERT OR UPDATE ON " + schema + "." + tablename + " FOR EACH ROW EXECUTE PROCEDURE ref.coordonnees();"
SQL_GRANT_TABLE = "GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename + " TO grp_qgis;GRANT DELETE, INSERT, REFERENCES, SELECT, TRIGGER, TRUNCATE, UPDATE ON " + schema + "." + tablename + " TO grp_sig;GRANT ALL ON SEQUENCE " + sequence_name + " TO grp_qgis;"
cur.execute(SQL_pkey)
cur.execute(SQL_GRANT_TABLE)
if self.couche_vierge_point.isChecked() == 1:
cur.execute(SQL_trigger_coordonnees)
if self.couche_vierge_ligne.isChecked() == 1:
cur.execute(SQL_trigger_length_m)
cur.execute(SQL_trigger_length_km)
if self.couche_vierge_polygone.isChecked() == 1:
cur.execute(SQL_trigger_area_m2)
cur.execute(SQL_trigger_area_ha)
con.commit()
# Affichage de la table
uri = QgsDataSourceUri()
# set host name, port, database name, username and password
uri.setConnection(host, port, dbname, user, mdp)
# set database schema, table name, geometry column and optionaly subset (WHERE clause)
uri.setDataSource(schema, tablename, geom)
self.iface.addVectorLayer(uri.uri(), tablename_qgis, "postgres")

View File

@ -0,0 +1,288 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>table_postgis</class>
<widget class="QDialog" name="table_postgis">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>533</width>
<height>364</height>
</rect>
</property>
<property name="windowTitle">
<string>Ajout d'une table</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>3</number>
</property>
<item>
<widget class="QLabel" name="schema_label">
<property name="maximumSize">
<size>
<width>90</width>
<height>1977</height>
</size>
</property>
<property name="text">
<string>Code analytique :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="schema"/>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>Tester mon éligibilite :</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="compte">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Compte</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="couche">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Couche</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>Les changement :</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Nouvau nom :</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Partie a renommée :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="old_name">
<property name="enabled">
<bool>false</bool>
</property>
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="new_name"/>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="maximumSize">
<size>
<width>130</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Département/Animation :</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="animation">
<property name="text">
<string>Animation territoriale</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="departement"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="4" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="Titre">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Renommée de table</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>table_postgis</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>table_postgis</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Metabase</string> <string>Journal des modifications</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset>
@ -29,9 +29,6 @@
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -41,7 +38,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>453</width> <width>453</width>
<height>547</height> <height>570</height>
</rect> </rect>
</property> </property>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
@ -56,7 +53,7 @@
<property name="title"> <property name="title">
<string>DevLog</string> <string>DevLog</string>
</property> </property>
<widget class="QWebView" name="viewer" native="true"> <widget class="QTextBrowser" name="viewer">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
@ -65,11 +62,6 @@
<height>511</height> <height>511</height>
</rect> </rect>
</property> </property>
<property name="url" stdset="0">
<url>
<string>about:blank</string>
</url>
</property>
</widget> </widget>
</widget> </widget>
</widget> </widget>
@ -78,19 +70,12 @@
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Ok</set> <set>QDialogButtonBox::NoButton</set>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header location="global">QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
/*************************************************************************** /***************************************************************************
SICEN SICEN
A QGIS plugin A QGIS plugin
Filtre sur données SICEN Filtre sur données SICEN
------------------- -------------------
begin : 2014-10-17 begin : 2014-10-17
copyright : (C) 2014 by Guillaume COSTES copyright : (C) 2014 by Guillaume COSTES
email : guillaume.costes@espaces-naturels.fr email : guillaume.costes@espaces-naturels.fr
@ -18,10 +18,11 @@
* (at your option) any later version. * * (at your option) any later version. *
* * * *
***************************************************************************/ ***************************************************************************/
This script initializes the plugin, making it known to QGIS. This script initializes the plugin, making it known to QGIS.
""" """
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

View File

@ -1,96 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>CenRa_Metabase_editorwidget_base</class> <class>CenRa_Metabase_editorwidget_base</class>
<widget class="QDialog" name="CenRa_Metabase_editorwidget_base"> <widget class="QDialog" name="CenRa_Metabase_editorwidget_base">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>471</width> <width>471</width>
<height>594</height> <height>594</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Metabase</string> <string>Journal des modifications</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset> <iconset>
<normaloff>../../CenRa_Metabase/tools/ui/icon.svg</normaloff>../../CenRa_Metabase/tools/ui/icon.svg</iconset> <normaloff>../../CenRa_Metabase/tools/ui/icon.svg</normaloff>../../CenRa_Metabase/tools/ui/icon.svg</iconset>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QScrollArea" name="scrollArea"> <widget class="QScrollArea" name="scrollArea">
<property name="mouseTracking"> <property name="mouseTracking">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="focusPolicy"> <property name="focusPolicy">
<enum>Qt::NoFocus</enum> <enum>Qt::NoFocus</enum>
</property> </property>
<property name="frameShape"> <property name="frameShape">
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="frameShadow"> <property name="widgetResizable">
<enum>QFrame::Plain</enum> <bool>true</bool>
</property> </property>
<property name="widgetResizable"> <widget class="QWidget" name="scrollAreaWidgetContents">
<bool>true</bool> <property name="geometry">
</property> <rect>
<widget class="QWidget" name="scrollAreaWidgetContents"> <x>0</x>
<property name="geometry"> <y>0</y>
<rect> <width>453</width>
<x>0</x> <height>570</height>
<y>0</y> </rect>
<width>453</width> </property>
<height>547</height> <widget class="QGroupBox" name="groupBox">
</rect> <property name="geometry">
</property> <rect>
<widget class="QGroupBox" name="groupBox"> <x>0</x>
<property name="geometry"> <y>0</y>
<rect> <width>451</width>
<x>0</x> <height>541</height>
<y>0</y> </rect>
<width>451</width> </property>
<height>541</height> <property name="title">
</rect> <string>DevLog</string>
</property> </property>
<property name="title"> <widget class="QTextBrowser" name="viewer">
<string>DevLog</string> <property name="geometry">
</property> <rect>
<widget class="QWebView" name="viewer" native="true"> <x>10</x>
<property name="geometry"> <y>20</y>
<rect> <width>431</width>
<x>10</x> <height>511</height>
<y>20</y> </rect>
<width>431</width> </property>
<height>511</height> </widget>
</rect> </widget>
</property> </widget>
<property name="url" stdset="0"> </widget>
<url> </item>
<string>about:blank</string> <item>
</url> <widget class="QDialogButtonBox" name="buttonBox">
</property> <property name="standardButtons">
</widget> <set>QDialogButtonBox::NoButton</set>
</widget> </property>
</widget> </widget>
</widget> </item>
</item> </layout>
<item> </widget>
<widget class="QDialogButtonBox" name="buttonBox"> <resources/>
<property name="standardButtons"> <connections/>
<set>QDialogButtonBox::Ok</set> </ui>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header location="global">QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -12,12 +12,12 @@ ABOUT_FORM_CLASS, _ = uic.loadUiType(
os.path.join( os.path.join(
str(Path(__file__).resolve().parent.parent), str(Path(__file__).resolve().parent.parent),
'forms', 'forms',
'sicen_about_form.ui' 'CenRa_about_form.ui'
) )
) )
class SicenAboutDialog(QDialog, ABOUT_FORM_CLASS): class AboutDialog(QDialog, ABOUT_FORM_CLASS):
""" About - Let the user display the about dialog. """ """ About - Let the user display the about dialog. """

View File

@ -11,8 +11,9 @@
[general] [general]
name=CenRa SICEN name=CenRa SICEN
qgisMinimumVersion=3.0 qgisMinimumVersion=3.0
supportsQt6=True
description=Filtre des données saisies dans SICEN et export d'une liste d'espèces. description=Filtre des données saisies dans SICEN et export d'une liste d'espèces.
version=1.7 version=2.1
author=Conservatoire d'Espaces Naturels de Rhône-Alpes author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr email=si_besoin@cen-rhonealpes.fr
@ -21,7 +22,7 @@ email=si_besoin@cen-rhonealpes.fr
# Optional items: # Optional items:
# Uncomment the following line and add your changelog entries: # Uncomment the following line and add your changelog entries:
changelog=<h2>CenRa_SICEN:</h2></br><p><h3>13/09/2024 - Version 1.7:</h3> - Il est maintenant possible de sélectionné plusieurs entité pour le filtre par Emprise.</br>- Ajoute d'un changelog.</br>- Ajoute une vérification de mise à jour.</p> changelog=<h2>CenRa_SICEN:</h2></br><p><h3>30/07/2025 - Version 2.1: </h3> - Correctife de bug.</p></br><p><h3>19/05/2025 - Version 2.0: </h3> - Compatible PyQt5 et PyQt6</p></br><p><h3>09/04/2025 - Version 1.11: </h3> - Correctif bug en TT.</p></br><p><h3>09/04/2025 - Version 1.10: </h3> - Optimisation pour le TT.</p></br><p><h3>03/04/2025 - Version 1.9: </h3> - Mise a jour de securite.</p></br><p><h3>07/01/2025 - Version 1.8: </h3> - ByPass du certif ssl ci erreur.</br></p><p><h3>13/09/2024 - Version 1.7:</h3> - Il est maintenant possible de sélectionné plusieurs entité pour le filtre par Emprise.</br>- Ajoute d'un changelog.</br>- Ajoute une vérification de mise à jour.</p>
# tags are comma separated with spaces allowed # tags are comma separated with spaces allowed
tags=cenra, postgis, sicen tags=cenra, postgis, sicen

Some files were not shown because too many files have changed in this diff Show More