premier commit/push

This commit is contained in:
2024-10-14 13:56:22 +02:00
parent c9954f295d
commit 06e259c338
42 changed files with 274 additions and 4535 deletions
+34 -1
View File
@@ -1 +1,34 @@
# CenRa_SICEN
Plugin Builder Results
Your plugin SICEN was created in:
C:\Users\gcostes\.qgis2\python\plugins\SICEN
Your QGIS plugin directory is located at:
C:/Users/gcostes/.qgis2/python/plugins
What's Next:
* Copy the entire directory containing your new plugin to the QGIS plugin
directory
* Compile the ui file using pyuic4
* Compile the resources file using pyrcc4
* Test the plugin by enabling it in the QGIS plugin manager
* Customize it by editing the implementation file:
sicen.py
* Create your own custom icon, replacing the default icon.png
* Modify your user interface by opening sicen.ui
in Qt Designer (don't forget to compile it with pyuic4 after changing it)
* You can use the Makefile to compile your Ui and resource files when
you make changes. This requires GNU make (gmake)
For more information, see the PyQGIS Developer Cookbook at:
http://www.qgis.org/pyqgis-cookbook/index.html
(C) 2011-2014 GeoApt LLC - geoapt.com
+2 -2
View File
@@ -12,7 +12,7 @@
name=CenRa SICEN
qgisMinimumVersion=3.0
description=Filtre des données saisies dans SICEN et export d'une liste d'espèces.
version=1.4
version=1.7
author=Conservatoire d'Espaces Naturels de Rhône-Alpes
email=si_besoin@cen-rhonealpes.fr
@@ -21,7 +21,7 @@ email=si_besoin@cen-rhonealpes.fr
# Optional items:
# Uncomment the following line and add your changelog entries:
changelog=Traduction en Qgis v3.x
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>
# tags are comma separated with spaces allowed
tags=cenra, postgis, sicen
+23 -4
View File
@@ -52,6 +52,8 @@ import qgis
import datetime
import csv
from .forms.about_form import SicenAboutDialog
import psycopg2
import psycopg2.extras
import base64
@@ -59,6 +61,7 @@ import base64
import os
#import sys
class SICEN(object):
def __init__(self, iface):
@@ -81,6 +84,14 @@ class SICEN(object):
self.dlg = SICENDialog()
maj_verif('CenRa_SICEN')
version = qgis.utils.pluginMetadata('CenRa_SICEN','version')
# Display About window on first use
s = QSettings()
versionUse = s.value("sicen/version", 1, type=str)
if str(versionUse) != str(version) :
s.setValue("sicen/version", str(version))
self.open_about_dialog()
def initGui(self):
self.toolBar = self.iface.addToolBar("SICEN")
self.toolBar.setObjectName("SICEN")
@@ -123,6 +134,10 @@ class SICEN(object):
self.sicen_ouverture.triggered.connect(self.ouverture)
self.sicen_export.triggered.connect(self.export)
def open_about_dialog(self):
dialog = SicenAboutDialog(self.iface)
dialog.exec_()
def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu(u"&SICEN", self.action)
@@ -561,13 +576,16 @@ class SICEN(object):
else :
selection = layer.selectedFeatures()
if layer.selectedFeatureCount() == 1 :
if layer.selectedFeatureCount() >= 1 :
GEOM = ''
for feature in selection:
geom = feature.geometry()
poly = geom.asWkt()
poly = "ST_GeomFromText('"+geom.asWkt()+"',2154),"
GEOM = GEOM + poly
poly = GEOM[0:-1]
#print(poly)
buffer = self.dlg.buffer.text()
reqwhere_geom = " ST_intersects(geometrie,ST_Buffer(ST_geomFromText('" + poly + "',2154), " + buffer + " ))"
reqwhere_geom = " ST_intersects(geometrie,ST_Buffer(ST_Collect(array[" + poly + "]), " + buffer + " ))"
# Requete finale
reqwhere_final = '(' + reqwhere_obs + ')' + 'AND' + reqwhere_insee + 'AND' + reqwhere_ordre + 'AND' + reqwhere_sp + 'AND' + '(' + reqwhere_pat + ')' + 'AND' + reqwhere_regne + 'AND' + reqwhere_date + 'AND' + reqwhere_geom
@@ -596,6 +614,7 @@ class SICEN(object):
### Centroide
if reqwhere_final.find('()') != -1 :
reqwhere_final = ''
print(reqwhere_final)
uri.setDataSource("_agregation_ra", "observations_centroide", "geometrie", reqwhere_final, "gid")
layer = self.iface.addVectorLayer(uri.uri(), table_name + '_centroides', "postgres")
+33 -13
View File
@@ -89,7 +89,7 @@ def resources_path(*args):
:return: Absolute path to the resources folder.
:rtype: str
"""
path = abspath(abspath(join(plugin_path(), "CenRa_Metabase\\resources")))
path = abspath(abspath(join(plugin_path(), "CenRa_Metabase\\tools")))
for item in args:
path = abspath(join(path, item))
return path
@@ -108,7 +108,7 @@ def load_ui(*args):
return ui_class
def login_base(take=None):
from CenRa_Metabase.resources.PythonSQL import host,port,dbname,password,os_user
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 + "')")
@@ -139,26 +139,46 @@ def send_issues(url,titre,body,labels):
payload = {'title': titre, 'body': body, 'labels': labels}
r = requests.post(url, data=json.dumps(payload), headers=headers)
print(r.text)
try:
urllib.request.urlopen('https://google.com')
binar = True
except:
binar = False
r = ''
if binar:
r = requests.post(url, data=json.dumps(payload), headers=headers)
return r
def maj_verif(NAME):
import qgis
import urllib
import urllib.request
iface = qgis.utils.iface
from qgis.core import Qgis
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'
# print(URL)
version = qgis.utils.pluginMetadata(NAME,'version')
len_version = len(version)
version_web = str(urllib.request.urlopen(URL).read())
plugin_num = version_web.find(NAME)
valeur_version_web = version_web.find('<version>',plugin_num)+9
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
try:
urllib.request.urlopen('https://google.com')
binar = True
except:
binar = False
if binar:
version_web = str(urllib.request.urlopen(URL).read())
plugin_num = version_web.find(NAME)
valeur_version_web = version_web.find('<version>',plugin_num)+9
version_plugin = version_web[valeur_version_web:valeur_version_web+len_version]
if version_plugin != version:
iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
else:
iface.messageBar().pushMessage("WiFi :", "Pas de connection à internet.", level=Qgis.Warning, duration=30)
return version_plugin
if version_plugin == version:
qgis.utils.iface.messageBar().pushMessage("MAJ :", "Des mise à jour de plugin sont disponibles.", level=Qgis.Info, duration=30)
def devlog(NAME):
import qgis
devmaj = '<head><style>* {margin:0; padding:0; }</style></head>'
devmaj = devmaj+qgis.utils.pluginMetadata(NAME,'changelog')
return devmaj