From 7fa556f1486775d14518aecc372928756ea2acf9 Mon Sep 17 00:00:00 2001 From: gildeluermoz Date: Fri, 7 Jan 2022 11:03:00 +0100 Subject: [PATCH] Replace commune Entry by custom geo Entry --- .gitignore | 8 +- README.rst | 2 +- atlas/atlasAPI.py | 24 ++--- atlas/atlasRoutes.py | 44 ++++---- atlas/configuration/config.py.example | 2 +- atlas/configuration/config.py.sample | 6 ++ atlas/configuration/config_schema.py | 1 + atlas/configuration/settings.ini.sample | 20 ++-- atlas/messages.pot | 6 +- atlas/modeles/entities/tCommunes.py | 17 ---- .../entities/{vmCommunes.py => vmGeoEntry.py} | 9 +- atlas/modeles/entities/vmObservations.py | 2 +- .../repositories/tCommunesRepository.py | 10 +- .../repositories/vmCommunesRepository.py | 77 -------------- .../repositories/vmGeoEntryRepository.py | 77 ++++++++++++++ .../vmObservationsMaillesRepository.py | 20 ++-- .../repositories/vmObservationsRepository.py | 22 ++-- .../repositories/vmTaxonsRepository.py | 12 +-- atlas/static/css/index.css | 2 +- atlas/static/custom/maps-custom.js.sample | 4 +- .../templates/presentation.html.example | 2 +- atlas/static/main.js | 16 +-- atlas/static/mapAreas.js | 12 +-- atlas/static/mapGenerator.js | 28 ++--- atlas/templates/areaSheet/_main.html | 12 +-- atlas/templates/core/listTaxons.html | 2 +- atlas/templates/core/navbar.html | 8 +- atlas/templates/core/tabTaxons.html | 2 +- atlas/templates/home/globalStats.html | 12 +-- atlas/templates/speciesSheet/map.html | 4 +- .../speciesSheet/otherInformations.html | 16 +-- atlas/translations/en/LC_MESSAGES/messages.mo | Bin 5787 -> 5764 bytes atlas/translations/en/LC_MESSAGES/messages.po | 12 +-- atlas/translations/fr/LC_MESSAGES/messages.mo | Bin 6175 -> 6168 bytes atlas/translations/fr/LC_MESSAGES/messages.po | 12 +-- atlas/translations/it/LC_MESSAGES/messages.mo | Bin 6036 -> 6027 bytes atlas/translations/it/LC_MESSAGES/messages.po | 8 +- data/atlas/12.atlas.t_mailles_territoire.sql | 12 +-- data/atlas/14.grant.sql | 2 +- ....sql => 2.atlas.vm_cor_taxon_attribut.sql} | 1 + ...ations.sql => 3.atlas.vm_observations.sql} | 6 +- ...as.vm_taxons.sql => 4.atlas.vm_taxons.sql} | 4 +- ...altitudes.sql => 5.atlas.vm_altitudes.sql} | 0 ..._taxon.sql => 6.atlas.vm_search_taxon.sql} | 0 data/atlas/7.atlas.vm_communes.sql | 12 --- ....atlas.vm_mois.sql => 7.atlas.vm_mois.sql} | 0 ...as.vm_medias.sql => 9.atlas.vm_medias.sql} | 0 data/atlas/without_geonature.sql | 6 +- data/atlas_with_extended_areas.sql | 4 +- data/gn2/atlas_ref_geo.sql | 96 +++++++++--------- data/gn2/atlas_synthese.sql | 4 +- ...mmunes.dbf.sample => geo_entry.dbf.sample} | Bin ...mmunes.prj.sample => geo_entry.prj.sample} | 0 ...mmunes.shp.sample => geo_entry.shp.sample} | Bin ...mmunes.shx.sample => geo_entry.shx.sample} | Bin data/update/update_vm_observations.sql | 4 +- docs/installation.rst | 4 +- docs/vues_materialisees_maj.rst | 6 +- geonature_atlas.egg-info/SOURCES.txt | 8 +- geonature_atlas.egg-info/requires.txt | 9 +- install_app.sh | 3 +- install_db.sh | 60 +++++------ install_env.sh | 3 +- 63 files changed, 367 insertions(+), 388 deletions(-) delete mode 100644 atlas/modeles/entities/tCommunes.py rename atlas/modeles/entities/{vmCommunes.py => vmGeoEntry.py} (63%) delete mode 100644 atlas/modeles/repositories/vmCommunesRepository.py create mode 100644 atlas/modeles/repositories/vmGeoEntryRepository.py rename data/atlas/{9.atlas.vm_cor_taxon_attribut.sql => 2.atlas.vm_cor_taxon_attribut.sql} (87%) rename data/atlas/{2.atlas.vm_observations.sql => 3.atlas.vm_observations.sql} (84%) rename data/atlas/{3.atlas.vm_taxons.sql => 4.atlas.vm_taxons.sql} (90%) rename data/atlas/{4.atlas.vm_altitudes.sql => 5.atlas.vm_altitudes.sql} (100%) rename data/atlas/{5.atlas.vm_search_taxon.sql => 6.atlas.vm_search_taxon.sql} (100%) delete mode 100644 data/atlas/7.atlas.vm_communes.sql rename data/atlas/{6.atlas.vm_mois.sql => 7.atlas.vm_mois.sql} (100%) rename data/atlas/{8.atlas.vm_medias.sql => 9.atlas.vm_medias.sql} (100%) rename data/ref/{communes.dbf.sample => geo_entry.dbf.sample} (100%) rename data/ref/{communes.prj.sample => geo_entry.prj.sample} (100%) rename data/ref/{communes.shp.sample => geo_entry.shp.sample} (100%) rename data/ref/{communes.shx.sample => geo_entry.shx.sample} (100%) diff --git a/.gitignore b/.gitignore index 5c2bd0bd3..a89713635 100644 --- a/.gitignore +++ b/.gitignore @@ -40,10 +40,10 @@ atlas/static/custom/templates/credits.html atlas/static/custom/templates/mentions-legales.html data/ref/emprise_territoire.* -data/ref/communes.dbf -data/ref/communes.prj -data/ref/communes.shp -data/ref/communes.shx +data/ref/geo_entry.dbf +data/ref/geo_entry.prj +data/ref/geo_entry.shp +data/ref/geo_entry.shx data/ref/territoire.dbf data/ref/territoire.prj diff --git a/README.rst b/README.rst index 5df0eb04f..471b75f19 100644 --- a/README.rst +++ b/README.rst @@ -7,7 +7,7 @@ Atlas WEB dynamique Faune-Flore basé sur les données présentes dans la synth Utilisé pour Biodiv'Ecrins, l'atlas de faune et de la flore du Parc national des Ecrins (http://biodiversite.ecrins-parcnational.fr). -Il permet de générer dynamiquement des fiches espèces avec des données calculées automatiquement (cartes de répartition, répartition altitudinale et phénologique, communes, secteurs, observateurs...) ainsi que des données saisies pour chaque espèce (photos, description...). +Il permet de générer dynamiquement des fiches espèces avec des données calculées automatiquement (cartes de répartition, répartition altitudinale et phénologique, entrée géographique, secteurs, observateurs...) ainsi que des données saisies pour chaque espèce (photos, description...). L'outil a été développé de manière générique pour pouvoir être déployé sur d'autres BDD que GeoNature (SERENA, SICEN, INPN, fichier CSV, etc). diff --git a/atlas/atlasAPI.py b/atlas/atlasAPI.py index 8f0c478ef..00bcb3ee0 100644 --- a/atlas/atlasAPI.py +++ b/atlas/atlasAPI.py @@ -8,7 +8,7 @@ vmObservationsRepository, vmObservationsMaillesRepository, vmMedias, - vmCommunesRepository, + vmGeoEntryRepository ) api = Blueprint("api", __name__) @@ -24,12 +24,12 @@ def searchTaxonAPI(): return jsonify(results) -@api.route("/searchCommune", methods=["GET"]) -def searchCommuneAPI(): +@api.route("/searchGeoEntry", methods=["GET"]) +def searchGeoEntryAPI(): session = utils.loadSession() search = request.args.get("search", "") limit = request.args.get("limit", 50) - results = vmCommunesRepository.getCommunesSearch(session, search, limit) + results = vmGeoEntryRepository.getGeoEntrySearch(session, search, limit) session.close() return jsonify(results) @@ -104,21 +104,21 @@ def getObservationsGenericApi(cd_ref: int): if not current_app.config['AFFICHAGE_MAILLE']: - @api.route("/observations//", methods=["GET"]) - def getObservationsCommuneTaxonAPI(insee, cd_ref): + @api.route("/observations//", methods=["GET"]) + def getObservationsGeoEntryTaxonAPI(geo_entry_id, cd_ref): connection = utils.engine.connect() - observations = vmObservationsRepository.getObservationTaxonCommune( - connection, insee, cd_ref + observations = vmObservationsRepository.getObservationTaxonGeoEntry( + connection, geo_entry_id, cd_ref ) connection.close() return jsonify(observations) -@api.route("/observationsMaille//", methods=["GET"]) -def getObservationsCommuneTaxonMailleAPI(insee, cd_ref): +@api.route("/observationsMaille//", methods=["GET"]) +def getObservationsGeoEntryTaxonMailleAPI(geo_entry_id, cd_ref): connection = utils.engine.connect() - observations = vmObservationsMaillesRepository.getObservationsTaxonCommuneMaille( - connection, insee, cd_ref + observations = vmObservationsMaillesRepository.getObservationsTaxonGeoEntryMaille( + connection, geo_entry_id, cd_ref ) connection.close() return jsonify(observations) diff --git a/atlas/atlasRoutes.py b/atlas/atlasRoutes.py index 6cdc4d6f4..466003455 100644 --- a/atlas/atlasRoutes.py +++ b/atlas/atlasRoutes.py @@ -18,7 +18,7 @@ from atlas import utils from atlas.env import config -from atlas.modeles.entities import vmTaxons, vmCommunes +from atlas.modeles.entities import vmTaxons, vmGeoEntry from atlas.modeles.repositories import ( vmOrganismsRepository, vmTaxonsRepository, @@ -26,7 +26,7 @@ vmAltitudesRepository, vmMoisRepository, vmTaxrefRepository, - vmCommunesRepository, + vmGeoEntryRepository, vmObservationsMaillesRepository, vmMedias, vmCorTaxonAttribut, @@ -123,10 +123,10 @@ def ficheOrganism(id_organism): @main.route( - "/commune/" + current_app.config["REMOTE_MEDIAS_PATH"] + "", + "/geoentry/" + current_app.config["REMOTE_MEDIAS_PATH"] + "", methods=["GET", "POST"], ) -def communeMedias(image): +def geoentryMedias(image): return redirect( current_app.config["REMOTE_MEDIAS_URL"] + current_app.config["REMOTE_MEDIAS_PATH"] @@ -239,7 +239,7 @@ def ficheEspece(cd_ref): altitudes = vmAltitudesRepository.getAltitudesChilds(connection, cd_ref) months = vmMoisRepository.getMonthlyObservationsChilds(connection, cd_ref) synonyme = vmTaxrefRepository.getSynonymy(connection, cd_ref) - communes = vmCommunesRepository.getCommunesObservationsChilds(connection, cd_ref) + geoentries = vmGeoEntryRepository.getGeoEntryObservationsChilds(connection, cd_ref) taxonomyHierarchy = vmTaxrefRepository.getAllTaxonomy(db_session, cd_ref) firstPhoto = vmMedias.getFirstPhoto( connection, cd_ref, current_app.config["ATTR_MAIN_PHOTO"] @@ -286,7 +286,7 @@ def ficheEspece(cd_ref): altitudes=altitudes, months=months, synonyme=synonyme, - communes=communes, + geoentries=geoentries, taxonomyHierarchy=taxonomyHierarchy, firstPhoto=firstPhoto, photoCarousel=photoCarousel, @@ -298,39 +298,39 @@ def ficheEspece(cd_ref): ) -@main.route("/commune/", methods=["GET", "POST"]) -def ficheCommune(insee): +@main.route("/geoentry/", methods=["GET", "POST"]) +def ficheGeoEntry(geo_entry_id): session = utils.loadSession() connection = utils.engine.connect() - listTaxons = vmTaxonsRepository.getTaxonsCommunes(connection, insee) - commune = vmCommunesRepository.getCommuneFromInsee(connection, insee) + listTaxons = vmTaxonsRepository.getTaxonsGeoEntry(connection, geo_entry_id) + geoentry = vmGeoEntryRepository.getGeoEntryFromId(connection, geo_entry_id) if current_app.config["AFFICHAGE_MAILLE"]: - observations = vmObservationsMaillesRepository.lastObservationsCommuneMaille( - connection, current_app.config["NB_LAST_OBS"], str(insee) + observations = vmObservationsMaillesRepository.astObservationsGeoEntryMaille( + connection, current_app.config["NB_LAST_OBS"], str(geo_entry_id) ) else: - observations = vmObservationsRepository.lastObservationsCommune( - connection, current_app.config["NB_LAST_OBS"], insee + observations = vmObservationsRepository.lastObservationsGeoEntry( + connection, current_app.config["NB_LAST_OBS"], geo_entry_id ) surroundingAreas = [] - observers = vmObservationsRepository.getObserversCommunes(connection, insee) + observers = vmObservationsRepository.getObserversGeoEntry(connection, geo_entry_id) session.close() connection.close() return render_template( "templates/areaSheet/_main.html", - sheetType="commune", + sheetType="geoentry", surroundingAreas=surroundingAreas, listTaxons=listTaxons, - areaInfos=commune, + areaInfos=geoentry, observations=observations, observers=observers, DISPLAY_EYE_ON_LIST=True, - insee=insee, + geo_entry_id=geo_entry_id, ) @@ -431,11 +431,11 @@ def sitemap(): modified_time = ten_days_ago pages.append([url, modified_time]) - municipalities = ( - session.query(vmCommunes.VmCommunes).order_by(vmCommunes.VmCommunes.insee).all() + geoentries = ( + session.query(vmGeoEntry.VmGeoEntry).order_by(vmGeoEntry.VmGeoEntry.geo_entry_id).all() ) - for municipalitie in municipalities: - url = url_root + url_for("main.ficheCommune", insee=municipalitie.insee) + for geoentrie in geoentries: + url = url_root + url_for("main.ficheGeoEntry", geo_entry_id=geoentrie.geo_entry_id) modified_time = ten_days_ago pages.append([url, modified_time]) diff --git a/atlas/configuration/config.py.example b/atlas/configuration/config.py.example index 39b660fd3..43546c578 100644 --- a/atlas/configuration/config.py.example +++ b/atlas/configuration/config.py.example @@ -136,7 +136,7 @@ NB_DAY_LAST_OBS = '7' # Texte à afficher pour décrire la cartographie des 'dernières observations' TEXT_LAST_OBS = 'Les observations des agents ces 7 derniers jours |' -# Carte de la fiche commune : nombre des 'x' dernières observations affichées +# Carte de la fiche de l'entrée géographique : nombre des 'x' dernières observations affichées NB_LAST_OBS=100 ########################### diff --git a/atlas/configuration/config.py.sample b/atlas/configuration/config.py.sample index f0765c0c9..26c14e62e 100644 --- a/atlas/configuration/config.py.sample +++ b/atlas/configuration/config.py.sample @@ -21,6 +21,12 @@ STRUCTURE = "Nom de la structure" # Nom de l'application NOM_APPLICATION = "Nom de l application" +# Code de l'entrée geographique principale dans 'ref_geo.bib_area_type' +MAIN_GEO_ENTRY_CODE = "COM" + +# Intitulé de l'entrée géographique principale +MAIN_GEO_ENTRY_NAME = "commune" + # URL de l'application depuis la racine du domaine # ex "/atlas" pour une URL: http://mon-domaine/atlas OU "" si l'application est accessible à la racine du domaine URL_APPLICATION = "" diff --git a/atlas/configuration/config_schema.py b/atlas/configuration/config_schema.py index ccd05277e..885f1ad9b 100644 --- a/atlas/configuration/config_schema.py +++ b/atlas/configuration/config_schema.py @@ -136,6 +136,7 @@ class Meta: AFFICHAGE_RANG_STAT = fields.Boolean(load_default=True) AFFICHAGE_NOUVELLES_ESPECES = fields.Boolean(load_default=True) AFFICHAGE_RECHERCHE_AVANCEE = fields.Boolean(load_default=False) + MAIN_GEO_ENTRY_NAME = fields.String(load_default="geoentry") RANG_STAT = fields.List( fields.Dict, diff --git a/atlas/configuration/settings.ini.sample b/atlas/configuration/settings.ini.sample index 32b9747a6..8e0eea78f 100644 --- a/atlas/configuration/settings.ini.sample +++ b/atlas/configuration/settings.ini.sample @@ -76,22 +76,26 @@ atlas_source_pass=monpassachanger # Voir la colonne type_code de la table ref_geo.bib_areas_type # Indiquer le code des entités géographiques du ref_geo qui correspondent respectivement aux mailles et aux limites de votre territoire # Les données doivent préalablement être présentes dans le ref_geo +# type_code de l'entrée geographique principale (permet de consulter les observations pour chacune des entités géeographique : par ex : par commune) +type_geo_entry="'COM'" +# type code pour l'affichage des observations par maille type_maille="'M1'" +# type code correspondant à votre territoire type_territoire="'PEC'" ########### Si ref_geo = False ############# -#### COMMUNES #### +#### ENTREE GEOGRAPHIQUE #### -# Creer la table des communes à partir d'un shapefile ? -# Si false, modifiez la creation de 'atlas.vm_communes' dans data/atlas/atlas.vm_communes.sql -import_commune_shp=true +# Creer la table de l'entrée geographique à partir d'un shapefile ? +# Si false, modifiez la creation de 'atlas.vm_geo_entry' dans data/gn2/atlas_ref_geo.sql +import_geo_entry_shp=true -# Chemin et nom des colonnes du SHP des communes du territoire. Laisser tel quel (en modifiant uniquement MYUSERLINUX) +# Chemin et nom des colonnes du SHP de l'entrée géographique. Laisser tel quel (en modifiant uniquement MYUSERLINUX) # pour utiliser les communes du PnEcrins par défaut -communes_shp=/home/`whoami`/atlas/data/ref/communes.shp -colonne_insee=insee -colonne_nom_commune=nom_com +geo_entry_shp=/home/`whoami`/atlas/data/ref/geo_entry.shp +id_column=geo_entry_id +name_column=geo_entry_name #### TERRITOIRE #### diff --git a/atlas/messages.pot b/atlas/messages.pot index e8a6e205e..7dd70d7a6 100644 --- a/atlas/messages.pot +++ b/atlas/messages.pot @@ -207,7 +207,7 @@ msgid "search.species" msgstr "" #: templates/core/navbar.html:47 templates/home/globalStats.html:47 -msgid "search.city" +msgid "search.geo" msgstr "" #: templates/core/sideBar.html:3 @@ -279,13 +279,13 @@ msgstr "" #: templates/home/globalStats.html:39 templates/speciesSheet/map.html:20 #: templates/speciesSheet/otherInformations.html:10 #: templates/speciesSheet/otherInformations.html:14 -msgid "municipalities" +msgid "geoentries" msgstr "" #: templates/home/globalStats.html:39 templates/speciesSheet/map.html:20 #: templates/speciesSheet/otherInformations.html:10 #: templates/speciesSheet/otherInformations.html:14 -msgid "municipality" +msgid "geoentry" msgstr "" #: templates/home/globalStats.html:58 diff --git a/atlas/modeles/entities/tCommunes.py b/atlas/modeles/entities/tCommunes.py deleted file mode 100644 index 8e5286958..000000000 --- a/atlas/modeles/entities/tCommunes.py +++ /dev/null @@ -1,17 +0,0 @@ -# coding: utf-8 -from geoalchemy2 import Geometry -from sqlalchemy import Column, String -from sqlalchemy.ext.declarative import declarative_base - -Base = declarative_base() -metadata = Base.metadata - - -class LCommune(Base): - __tablename__ = 'l_communes' - __table_args__ = {u'schema': 'layers'} - - insee = Column(String(5), primary_key=True) - commune_maj = Column(String(50)) - commune_min = Column(String(50)) - the_geom = Column(Geometry) diff --git a/atlas/modeles/entities/vmCommunes.py b/atlas/modeles/entities/vmGeoEntry.py similarity index 63% rename from atlas/modeles/entities/vmCommunes.py rename to atlas/modeles/entities/vmGeoEntry.py index 43a32b0ee..189d34511 100644 --- a/atlas/modeles/entities/vmCommunes.py +++ b/atlas/modeles/entities/vmGeoEntry.py @@ -9,12 +9,11 @@ Base = declarative_base() -class VmCommunes(Base): +class VmGeoEntry(Base): __table__ = Table( - 'vm_communes', metadata, - Column('insee', String(5), primary_key=True, unique=True), - Column('commune_maj', String(50)), - # Column('commune_min', String(50)), + 'vm_geo_entry', metadata, + Column('geo_entry_id', String(255), primary_key=True, unique=True), + Column('geo_entry_name', String(50)), Column('the_geom', Geometry(u'MULTIPOLYGON', 2154), index=True), schema='atlas', autoload=True, autoload_with=engine ) diff --git a/atlas/modeles/entities/vmObservations.py b/atlas/modeles/entities/vmObservations.py index c15b1bcf8..9d53c9448 100644 --- a/atlas/modeles/entities/vmObservations.py +++ b/atlas/modeles/entities/vmObservations.py @@ -22,7 +22,7 @@ class VmObservations(Base): "vm_observations", metadata, Column("id_observation", Integer, primary_key=True, unique=True), - Column("insee", String(5), index=True), + Column("geo_entry_id", String(255), index=True), Column("dateobs", Date, index=True), Column("observateurs", String(255)), Column("altitude_retenue", Integer, index=True), diff --git a/atlas/modeles/repositories/tCommunesRepository.py b/atlas/modeles/repositories/tCommunesRepository.py index 65102aad5..cf3d869f6 100644 --- a/atlas/modeles/repositories/tCommunesRepository.py +++ b/atlas/modeles/repositories/tCommunesRepository.py @@ -4,15 +4,15 @@ from sqlalchemy.sql import text -def getCommunesObservationsChilds(connection, cd_ref): +def getGeoEntryObservationsChilds(connection, cd_ref): sql = """ - SELECT DISTINCT(com.insee) AS insee, com.commune_maj - FROM layers.l_communes com - JOIN atlas.vm_observations obs ON obs.insee = com.insee + SELECT DISTINCT(e.geo_entry_id) AS geo_entry_id, e.geo_entry_name + FROM layers.vm_geo_entry e + JOIN atlas.vm_observations obs ON obs.geo_entry_id = e.geo_entry_id WHERE obs.cd_ref IN ( SELECT * FROM atlas.find_all_taxons_childs(:thiscdref) ) OR obs.cd_ref = :thiscdref - GROUP BY com.commune_maj, com.insee + GROUP BY e.geo_entry_name, e.geo_entry_id """.encode('UTF-8') return connection.execute(text(sql), thiscdref=cd_ref) diff --git a/atlas/modeles/repositories/vmCommunesRepository.py b/atlas/modeles/repositories/vmCommunesRepository.py deleted file mode 100644 index cbb274572..000000000 --- a/atlas/modeles/repositories/vmCommunesRepository.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding:utf-8 -*- - -import ast - -from flask import current_app -from sqlalchemy import distinct -from sqlalchemy.sql import text -from sqlalchemy.sql.expression import func - -from atlas.modeles.entities.vmCommunes import VmCommunes - - -def getAllCommunes(session): - req = session.query(distinct(VmCommunes.commune_maj), VmCommunes.insee).all() - communeList = list() - for r in req: - temp = {"label": r[0], "value": r[1]} - communeList.append(temp) - return communeList - - -def getCommunesSearch(session, search, limit=50): - req = session.query( - distinct(VmCommunes.commune_maj), - VmCommunes.insee, - func.length(VmCommunes.commune_maj), - ).filter(VmCommunes.commune_maj.ilike("%" + search + "%")) - - - req = req.order_by(VmCommunes.commune_maj) - - req = req.limit(limit).all() - - communeList = list() - for r in req: - temp = {"label": r[0], "value": r[1]} - communeList.append(temp) - return communeList - - -def getCommuneFromInsee(connection, insee): - sql = """ - SELECT c.commune_maj, - c.insee, - c.commune_geojson - FROM atlas.vm_communes c - WHERE c.insee = :thisInsee - """ - req = connection.execute(text(sql), thisInsee=insee) - communeObj = dict() - for r in req: - communeObj = { - "areaName": r.commune_maj, - "areaCode": str(r.insee), - "areaGeoJson": ast.literal_eval(r.commune_geojson), - } - return communeObj - - -def getCommunesObservationsChilds(connection, cd_ref): - sql = """ - SELECT DISTINCT (com.insee) AS insee, com.commune_maj - FROM atlas.vm_communes com - JOIN atlas.vm_observations obs - ON obs.insee = com.insee - WHERE obs.cd_ref IN ( - SELECT * FROM atlas.find_all_taxons_childs(:thiscdref) - ) - OR obs.cd_ref = :thiscdref - ORDER BY com.commune_maj ASC - """ - req = connection.execute(text(sql), thiscdref=cd_ref) - listCommunes = list() - for r in req: - temp = {"insee": r.insee, "commune_maj": r.commune_maj} - listCommunes.append(temp) - return listCommunes diff --git a/atlas/modeles/repositories/vmGeoEntryRepository.py b/atlas/modeles/repositories/vmGeoEntryRepository.py new file mode 100644 index 000000000..e6711bcff --- /dev/null +++ b/atlas/modeles/repositories/vmGeoEntryRepository.py @@ -0,0 +1,77 @@ +# -*- coding:utf-8 -*- + +import ast + +from flask import current_app +from sqlalchemy import distinct +from sqlalchemy.sql import text +from sqlalchemy.sql.expression import func + +from atlas.modeles.entities.vmGeoEntry import VmGeoEntry + + +def getAllGeoEntry(session): + req = session.query(distinct(VmGeoEntry.geo_entry_name), VmGeoEntry.geo_entry_id).all() + geoentryList = list() + for r in req: + temp = {"label": r[0], "value": r[1]} + geoentryList.append(temp) + return geoentryList + + +def getGeoEntrySearch(session, search, limit=50): + req = session.query( + distinct(VmGeoEntry.geo_entry_name), + VmGeoEntry.geo_entry_id, + func.length(VmGeoEntry.geo_entry_name), + ).filter(VmGeoEntry.geo_entry_name.ilike("%" + search + "%")) + + + req = req.order_by(VmGeoEntry.geo_entry_name) + + req = req.limit(limit).all() + + geoentryList = list() + for r in req: + temp = {"label": r[0], "value": r[1]} + geoentryList.append(temp) + return geoentryList + + +def getGeoEntryFromId(connection, geo_entry_id): + sql = """ + SELECT e.geo_entry_name, + e.geo_entry_id, + e.geo_entry_geojson + FROM atlas.vm_geo_entry e + WHERE e.geo_entry_id = :thisId + """ + req = connection.execute(text(sql), thisId=geo_entry_id) + geoentryObj = dict() + for r in req: + geoentryObj = { + "areaName": r.geo_entry_name, + "areaCode": str(r.geo_entry_id), + "areaGeoJson": ast.literal_eval(r.geo_entry_geojson), + } + return geoentryObj + + +def getGeoEntryObservationsChilds(connection, cd_ref): + sql = """ + SELECT DISTINCT (e.geo_entry_id) AS geo_entry_id, e.geo_entry_name + FROM atlas.vm_geo_entry e + JOIN atlas.vm_observations obs + ON obs.geo_entry_id = e.geo_entry_id + WHERE obs.cd_ref IN ( + SELECT * FROM atlas.find_all_taxons_childs(:thiscdref) + ) + OR obs.cd_ref = :thiscdref + ORDER BY e.geo_entry_name ASC + """ + req = connection.execute(text(sql), thiscdref=cd_ref) + listGeoEntry = list() + for r in req: + temp = {"geo_entry_id": r.geo_entry_id, "geo_entry_name": r.geo_entry_name} + listGeoEntry.append(temp) + return listGeoEntry diff --git a/atlas/modeles/repositories/vmObservationsMaillesRepository.py b/atlas/modeles/repositories/vmObservationsMaillesRepository.py index a2ed2ab66..732a6cda0 100644 --- a/atlas/modeles/repositories/vmObservationsMaillesRepository.py +++ b/atlas/modeles/repositories/vmObservationsMaillesRepository.py @@ -87,18 +87,18 @@ def lastObservationsMailles(connection, mylimit, idPhoto): return obsList -def lastObservationsCommuneMaille(connection, mylimit, insee): +def lastObservationsGeoEntryMaille(connection, mylimit, geo_entry_id): sql = """ WITH last_obs AS ( SELECT obs.cd_ref, obs.dateobs, t.lb_nom, t.nom_vern, obs.the_geom_point AS l_geom FROM atlas.vm_observations obs - JOIN atlas.vm_communes c - ON ST_Intersects(obs.the_geom_point, c.the_geom) + JOIN atlas.vm_geo_entry e + ON ST_Intersects(obs.the_geom_point, e.the_geom) JOIN atlas.vm_taxons t ON obs.cd_ref = t.cd_ref - WHERE c.insee = :thisInsee + WHERE e.geo_entry_id = :thisGeoEntryId ORDER BY obs.dateobs DESC LIMIT :thislimit ) @@ -108,7 +108,7 @@ def lastObservationsCommuneMaille(connection, mylimit, insee): ON st_intersects(m.the_geom, l.l_geom) GROUP BY l.lb_nom, l.cd_ref, m.id_maille, l.nom_vern, m.geojson_maille """ - observations = connection.execute(text(sql), thisInsee=insee, thislimit=mylimit) + observations = connection.execute(text(sql), thisGeoEntryId=geo_entry_id, thislimit=mylimit) obsList = list() for o in observations: if o.nom_vern: @@ -126,20 +126,20 @@ def lastObservationsCommuneMaille(connection, mylimit, insee): # Use for API -def getObservationsTaxonCommuneMaille(connection, insee, cd_ref): +def getObservationsTaxonGeoEntryMaille(connection, geo_entry_id, cd_ref): sql = """ SELECT o.cd_ref, t.id_maille, t.geojson_maille, extract(YEAR FROM o.dateobs) AS annee FROM atlas.vm_observations o - JOIN atlas.vm_communes c - ON ST_INTERSECTS(o.the_geom_point, c.the_geom) + JOIN atlas.vm_geo_entry e + ON ST_INTERSECTS(o.the_geom_point, e.the_geom) JOIN atlas.t_mailles_territoire t ON ST_INTERSECTS(t.the_geom, o.the_geom_point) - WHERE o.cd_ref = :thiscdref AND c.insee = :thisInsee + WHERE o.cd_ref = :thiscdref AND e.geo_entry_id = :thisGeoEntryId ORDER BY id_maille """ - observations = connection.execute(text(sql), thisInsee=insee, thiscdref=cd_ref) + observations = connection.execute(text(sql), thisGeoEntryId=geo_entry_id, thiscdref=cd_ref) tabObs = list() for o in observations: temp = { diff --git a/atlas/modeles/repositories/vmObservationsRepository.py b/atlas/modeles/repositories/vmObservationsRepository.py index 1a3c41bb1..9397b46df 100644 --- a/atlas/modeles/repositories/vmObservationsRepository.py +++ b/atlas/modeles/repositories/vmObservationsRepository.py @@ -97,17 +97,17 @@ def lastObservations(connection, mylimit, idPhoto): return obsList -def lastObservationsCommune(connection, mylimit, insee): +def lastObservationsGeoEntry(connection, mylimit, geo_entry_id): sql = """SELECT o.*, COALESCE(split_part(tax.nom_vern, ',', 1) || ' | ', '') || tax.lb_nom AS taxon FROM atlas.vm_observations o - JOIN atlas.vm_communes c ON ST_Intersects(o.the_geom_point, c.the_geom) + JOIN atlas.vm_geo_entry e ON ST_Intersects(o.the_geom_point, e.the_geom) JOIN atlas.vm_taxons tax ON o.cd_ref = tax.cd_ref - WHERE c.insee = :thisInsee + WHERE e.geo_entry_id = :thisGeoEntryId ORDER BY o.dateobs DESC LIMIT 100""" - observations = connection.execute(text(sql), thisInsee=insee) + observations = connection.execute(text(sql), thisGeoEntryId=geo_entry_id) obsList = list() for o in observations: temp = dict(o) @@ -118,7 +118,7 @@ def lastObservationsCommune(connection, mylimit, insee): return obsList -def getObservationTaxonCommune(connection, insee, cd_ref): +def getObservationTaxonGeoEntry(connection, geo_entry_id, cd_ref): sql = """ SELECT o.*, COALESCE(split_part(tax.nom_vern, ',', 1) || ' | ', '') @@ -126,7 +126,7 @@ def getObservationTaxonCommune(connection, insee, cd_ref): o.observateurs FROM ( SELECT * FROM atlas.vm_observations o - WHERE o.insee = :thisInsee AND o.cd_ref = :thiscdref + WHERE o.geo_entry_id = :thisGeoEntryId AND o.cd_ref = :thiscdref ) o JOIN ( SELECT nom_vern, lb_nom, cd_ref @@ -135,7 +135,7 @@ def getObservationTaxonCommune(connection, insee, cd_ref): ) tax ON tax.cd_ref = tax.cd_ref """ - observations = connection.execute(text(sql), thiscdref=cd_ref, thisInsee=insee) + observations = connection.execute(text(sql), thiscdref=cd_ref, thisGeoEntryId=geo_entry_id) obsList = list() for o in observations: temp = dict(o) @@ -195,13 +195,13 @@ def getGroupeObservers(connection, groupe): return observersParser(req) -def getObserversCommunes(connection, insee): +def getObserversGeoEntry(connection, geo_entry_id): sql = """ SELECT DISTINCT observateurs FROM atlas.vm_observations - WHERE insee = :thisInsee + WHERE geo_entry_id = :thisGeoEntryId """ - req = connection.execute(text(sql), thisInsee=insee) + req = connection.execute(text(sql), thisGeoEntryId=geo_entry_id) return observersParser(req) @@ -214,7 +214,7 @@ def statIndex(connection): result["nbTotalObs"] = r.count sql = "SELECT COUNT(*) AS count\ - FROM atlas.vm_communes" + FROM atlas.vm_geo_entry" req = connection.execute(text(sql)) for r in req: result["town"] = r.count diff --git a/atlas/modeles/repositories/vmTaxonsRepository.py b/atlas/modeles/repositories/vmTaxonsRepository.py index a173521a6..f9dd7aca9 100644 --- a/atlas/modeles/repositories/vmTaxonsRepository.py +++ b/atlas/modeles/repositories/vmTaxonsRepository.py @@ -7,7 +7,7 @@ # With distinct the result in a array not an object, 0: lb_nom, 1: nom_vern -def getTaxonsCommunes(connection, insee): +def getTaxonsGeoEntry(connection, geo_entry_id): sql = """ SELECT DISTINCT o.cd_ref, max(date_part('year'::text, o.dateobs)) as last_obs, @@ -17,13 +17,13 @@ def getTaxonsCommunes(connection, insee): FROM atlas.vm_observations o JOIN atlas.vm_taxons t ON t.cd_ref=o.cd_ref LEFT JOIN atlas.vm_medias m ON m.cd_ref=o.cd_ref AND m.id_type={} - WHERE o.insee = :thisInsee + WHERE o.geo_entry_id = :thisGeoEntryId GROUP BY o.cd_ref, t.nom_vern, t.nom_complet_html, t.group2_inpn, t.patrimonial, t.protection_stricte, m.url, m.chemin, m.id_media ORDER BY nb_obs DESC """.format(current_app.config['ATTR_MAIN_PHOTO']) - req = connection.execute(text(sql), thisInsee=insee) - taxonCommunesList = list() + req = connection.execute(text(sql), thisGeoEntryId=geo_entry_id) + taxonGeoEntryList = list() nbObsTotal = 0 for r in req: temp = { @@ -38,9 +38,9 @@ def getTaxonsCommunes(connection, insee): 'path': utils.findPath(r), 'id_media': r.id_media } - taxonCommunesList.append(temp) + taxonGeoEntryList.append(temp) nbObsTotal = nbObsTotal + r.nb_obs - return {'taxons': taxonCommunesList, 'nbObsTotal': nbObsTotal} + return {'taxons': taxonGeoEntryList, 'nbObsTotal': nbObsTotal} def getTaxonsChildsList(connection, cd_ref): diff --git a/atlas/static/css/index.css b/atlas/static/css/index.css index ca0b9e225..24a0e20e5 100644 --- a/atlas/static/css/index.css +++ b/atlas/static/css/index.css @@ -145,7 +145,7 @@ h3.title-spaced { } #searchTaxonsStat, -#searchCommunesStat { +#searchGeoEntryStat { background-position: right center; background-repeat: no-repeat; background-size: 25px 25px; diff --git a/atlas/static/custom/maps-custom.js.sample b/atlas/static/custom/maps-custom.js.sample index 64e89d5e2..515b014ca 100644 --- a/atlas/static/custom/maps-custom.js.sample +++ b/atlas/static/custom/maps-custom.js.sample @@ -1,6 +1,6 @@ // Fonction style d'affichage des points dans la fiche espèce // Voir documentation leaflet pour customiser davantage l'affichage des points: http://leafletjs.com/reference-1.3.0.html#circlemarker-option -var pointDisplayOptionsFicheEspece = (pointDisplayOptionsFicheCommuneHome = function( +var pointDisplayOptionsFicheEspece = (pointDisplayOptionsFicheGeoEntryHome = function( feature ) { return { @@ -9,7 +9,7 @@ var pointDisplayOptionsFicheEspece = (pointDisplayOptionsFicheCommuneHome = func }); // Légende des points dans la fiche espèce -var divLegendeFicheEspece = (divLegendeFicheCommuneHome = +var divLegendeFicheEspece = (divLegendeFicheGeoEntryHome = '\

\ Dégradées\ diff --git a/atlas/static/custom/templates/presentation.html.example b/atlas/static/custom/templates/presentation.html.example index ab68220d5..b61132fb8 100644 --- a/atlas/static/custom/templates/presentation.html.example +++ b/atlas/static/custom/templates/presentation.html.example @@ -148,7 +148,7 @@ Generic placeholder image

Fiches communes

Découvrez les espèces observées sur chaque commune du parc national et affichez leurs observations sur la carte de la commune.

-

Exemple »

+

Exemple »

Generic placeholder image diff --git a/atlas/static/main.js b/atlas/static/main.js index 92fb2f89f..2748db379 100644 --- a/atlas/static/main.js +++ b/atlas/static/main.js @@ -29,8 +29,8 @@ autocompleteSearch = function(inputID, urlDestination, nbProposal) { var searchUrl; if (urlDestination == "espece") { searchUrl = "/api/searchTaxon"; - } else if (urlDestination == "commune") { - searchUrl = "/api/searchCommune"; + } else if (urlDestination == "geoentry") { + searchUrl = "/api/searchGeoEntry"; } else { searchUrl = "/api/searchArea/"+urlDestination; @@ -62,8 +62,8 @@ autocompleteSearch = function(inputID, urlDestination, nbProposal) { var url = ui.item.value; if (urlDestination == "espece") { location.href = configuration.URL_APPLICATION + language + "/espece/" + url; - } else if (urlDestination == "commune") { - location.href = configuration.URL_APPLICATION + language + "/commune/" + url; + } else if (urlDestination == "geoentry") { + location.href = configuration.URL_APPLICATION + language + "/geoentry/" + url; } else { location.href = configuration.URL_APPLICATION + language + "/area/" + urlDestination +"/"+ url; } @@ -88,11 +88,11 @@ $("#searchTaxonsStat").focus(function() { autocompleteSearch("#searchTaxonsStat", "espece", 10); }); -$("#searchCommunes").focus(function() { - autocompleteSearch("#searchCommunes", "commune", 20); +$("#searchGeoEntry").focus(function() { + autocompleteSearch("#searchGeoEntry", "geoentry", 20); }); -$("#searchCommunesStat").focus(function() { - autocompleteSearch("#searchCommunesStat", "commune", 10); +$("#searchGeoEntryStat").focus(function() { + autocompleteSearch("#searchGeoEntryStat", "geoentry", 10); }); diff --git a/atlas/static/mapAreas.js b/atlas/static/mapAreas.js index 66e00b73f..f922b36b5 100644 --- a/atlas/static/mapAreas.js +++ b/atlas/static/mapAreas.js @@ -65,7 +65,7 @@ htmlLegend = configuration.AFFICHAGE_MAILLE generateLegende(htmlLegend); function displayObsPreciseBaseUrl() { - if (sheetType === 'commune') { + if (sheetType === 'geoentry') { return configuration.URL_APPLICATION + "/api/observations/" + areaInfos.areaCode } else { return configuration.URL_APPLICATION + "/api/observations/area/" + areaInfos.id_area @@ -96,13 +96,13 @@ function displayObsPreciseBaseUrl(areaCode, cd_ref) { if (configuration.AFFICHAGE_MAILLE) { displayMailleLayerLastObs(observations); } else { - displayMarkerLayerPointCommune(observations); + displayMarkerLayerPointGeoEntry(observations); } }); } function displayObsGridBaseUrl() { - if (sheetType === 'commune') { + if (sheetType === 'geoentry') { return configuration.URL_APPLICATION + "/api/observationsMaille/" } else { return configuration.URL_APPLICATION + "/api/observationsMaille/area/" @@ -110,12 +110,12 @@ function displayObsGridBaseUrl() { } // display observation on click -function displayObsTaxon(insee, cd_ref) { +function displayObsTaxon(geo_entry_id, cd_ref) { $.ajax({ url: configuration.URL_APPLICATION + "/api/observations/" + - insee + + geo_entry_id + "/" + cd_ref, dataType: "json", @@ -132,7 +132,7 @@ function displayObsTaxon(insee, cd_ref) { if (configuration.AFFICHAGE_MAILLE) { displayMailleLayerLastObs(observations); } else { - displayMarkerLayerPointCommune(observations); + displayMarkerLayerPointGeoEntry(observations); } }); } diff --git a/atlas/static/mapGenerator.js b/atlas/static/mapGenerator.js index ec3dda797..146f82dd0 100644 --- a/atlas/static/mapGenerator.js +++ b/atlas/static/mapGenerator.js @@ -408,7 +408,7 @@ function displayMarkerLayerFicheEspece( } } -// ***************Fonction lastObservations: mapHome et mapCommune***************** +// ***************Fonction lastObservations: mapHome et mapGeoEntry***************** /* *** Point ****/ @@ -433,7 +433,7 @@ function onEachFeaturePointLastObs(feature, layer) { ); } -function onEachFeaturePointCommune(feature, layer) { +function onEachFeaturePointGeoEntry(feature, layer) { popupContent = "Espèce: " + feature.properties.taxon + @@ -473,8 +473,8 @@ function generateGeojsonPointLastObs(observationsPoint) { function displayMarkerLayerPointLastObs(observationsPoint) { myGeoJson = generateGeojsonPointLastObs(observationsPoint); - if (typeof pointDisplayOptionsFicheCommuneHome == "undefined") { - pointDisplayOptionsFicheCommuneHome = function (feature) { + if (typeof pointDisplayOptionsFicheGeoEntryHome == "undefined") { + pointDisplayOptionsFicheGeoEntryHome = function (feature) { return {}; }; } @@ -484,45 +484,45 @@ function displayMarkerLayerPointLastObs(observationsPoint) { pointToLayer: function (feature, latlng) { return L.circleMarker( latlng, - pointDisplayOptionsFicheCommuneHome(feature) + pointDisplayOptionsFicheGeoEntryHome(feature) ); }, }); map.addLayer(currentLayer); - if (typeof divLegendeFicheCommuneHome !== "undefined") { + if (typeof divLegendeFicheGeoEntryHome !== "undefined") { legend.onAdd = function (map) { var div = L.DomUtil.create("div", "info legend"); - div.innerHTML = divLegendeFicheCommuneHome; + div.innerHTML = divLegendeFicheGeoEntryHome; return div; }; legend.addTo(map); } } -function displayMarkerLayerPointCommune(observationsPoint) { +function displayMarkerLayerPointGeoEntry(observationsPoint) { myGeoJson = generateGeojsonPointLastObs(observationsPoint); - if (typeof pointDisplayOptionsFicheCommuneHome == "undefined") { - pointDisplayOptionsFicheCommuneHome = function (feature) { + if (typeof pointDisplayOptionsFicheGeoEntryHome == "undefined") { + pointDisplayOptionsFicheGeoEntryHome = function (feature) { return {}; }; } currentLayer = L.geoJson(myGeoJson, { - onEachFeature: onEachFeaturePointCommune, + onEachFeature: onEachFeaturePointGeoEntry, pointToLayer: function (feature, latlng) { return L.circleMarker( latlng, - pointDisplayOptionsFicheCommuneHome(feature) + pointDisplayOptionsFicheGeoEntryHome(feature) ); }, }); map.addLayer(currentLayer); - if (typeof divLegendeFicheCommuneHome !== "undefined") { + if (typeof divLegendeFicheGeoEntryHome !== "undefined") { legend.onAdd = function (map) { var div = L.DomUtil.create("div", "info legend"); - div.innerHTML = divLegendeFicheCommuneHome; + div.innerHTML = divLegendeFicheGeoEntryHome; return div; }; legend.addTo(map); diff --git a/atlas/templates/areaSheet/_main.html b/atlas/templates/areaSheet/_main.html index 128f9b5e2..29e0550b6 100644 --- a/atlas/templates/areaSheet/_main.html +++ b/atlas/templates/areaSheet/_main.html @@ -2,7 +2,7 @@ {% block title %} {# Personnalisez ici le titre de la page (celui qui est affiché dans l'onglet du navigateur) #} - {% if sheetType =='commune' %} + {% if sheetType =='geoentry' %} {{ _('municipality.of') }} {{ areaInfos.areaName }} {% else %} {{ areaInfos.typeName }} - {{ areaInfos.areaName }} @@ -33,9 +33,9 @@ var observations = {{observations|tojson}}; var areaInfos = {{ areaInfos | tojson }}; var sheetType = {{ sheetType|tojson }}; - var communeArea = false; - if (sheetType === 'commune') { - var communeArea = true; + var geoentryArea = false; + if (sheetType === 'geoentry') { + var geoentryArea = true; } ; var url_limit_territory = "{{url_for('static', filename='custom/territoire.json') }}"; @@ -55,7 +55,7 @@ {% if configuration.EXTENDED_AREAS %} {% include 'templates/areaSheet/surrounding_areas.html' %} {% endif %} - {% if sheetType =='commune' %} + {% if sheetType =='geoentry' %}

{{ _('municipality.of') }} {{ areaInfos.areaName }}

{% else %}

{{ areaInfos.typeName }} - {{ areaInfos.areaName }}

@@ -66,7 +66,7 @@

{{ areaInfos.typeName }} - {{ areaInfos.areaName }}

- {% if sheetType =='commune' %} + {% if sheetType =='geoentry' %}
{{ configuration.NB_LAST_OBS }} {{ _('last.obs.municipality') }} {{ areaInfos.areaName }}
{% else %} diff --git a/atlas/templates/core/listTaxons.html b/atlas/templates/core/listTaxons.html index b222607f1..893baed66 100644 --- a/atlas/templates/core/listTaxons.html +++ b/atlas/templates/core/listTaxons.html @@ -18,7 +18,7 @@
    {% for taxon in listTaxons.taxons %} -
  • {{ taxon.group2_inpn }} diff --git a/atlas/templates/core/navbar.html b/atlas/templates/core/navbar.html index 52f81b9c6..d6fd8cd7d 100644 --- a/atlas/templates/core/navbar.html +++ b/atlas/templates/core/navbar.html @@ -38,15 +38,15 @@ {% if configuration.MULTILINGUAL %} diff --git a/atlas/templates/core/tabTaxons.html b/atlas/templates/core/tabTaxons.html index 2d60b9f63..ed02da034 100644 --- a/atlas/templates/core/tabTaxons.html +++ b/atlas/templates/core/tabTaxons.html @@ -23,7 +23,7 @@ {% for taxon in listTaxons.taxons %} - + {% if taxon.path == None %}

    {{ stat.town | pretty }}

    - {{ _('municipalities') if stat.town > 1 else _('municipality') }}

    -
diff --git a/atlas/templates/speciesSheet/map.html b/atlas/templates/speciesSheet/map.html index 70b7a0182..4f0b15711 100644 --- a/atlas/templates/speciesSheet/map.html +++ b/atlas/templates/speciesSheet/map.html @@ -16,8 +16,8 @@

  • - {{ communes|length|pretty }}
    - {{ _('municipalities')|lower if communes|length > 1 else _('municipality')|lower }} + {{ geoentries|length|pretty }}
    + {{ _('geoentries')|lower if geoentries|length > 1 else _('geoentry')|lower }}

  • diff --git a/atlas/templates/speciesSheet/otherInformations.html b/atlas/templates/speciesSheet/otherInformations.html index 00ad09e1b..41d99e792 100644 --- a/atlas/templates/speciesSheet/otherInformations.html +++ b/atlas/templates/speciesSheet/otherInformations.html @@ -6,12 +6,12 @@
  • - {% else %} - {% endif %} @@ -80,13 +80,13 @@
    {% endif %} {% if articles | length != 0 %} -
    +
    {% else %} -
    +
    {% endif %}

    - {% for com in communes %} - {{ com.commune_maj }} + {% for e in geoentries %} + {{ e.geo_entry_name }} {% if not loop.last %} - {% endif %} diff --git a/atlas/translations/en/LC_MESSAGES/messages.mo b/atlas/translations/en/LC_MESSAGES/messages.mo index e015369d16da42fea5a6907a9c02e0202978498f..858e2b8088f080034ce938eda13b1aadf85ddbdf 100644 GIT binary patch delta 1381 zcmXZbOGs2v9LMqhn6H`2Ms0i)rIr~bZbAv7HrWF=1x-XnB7+V-7#*3CD1vE9iZa7& zArckYyG_E)APXs^5`v&;OqLKmYSTGuNuRtA>yGk^wV2 zn{CErm$_x&0H))0%)=op#t~eKA21ic;$r-XT=v(E)BR>4#zEBl3RK=|%)%`g#O;1d z&L;>HSVo`$mt!2YU^lMB8@L2VQ479xcv5O(d6XsP~;nEtWjZ z!)hLSa2y}u8tkB4b>fP12o?9-cnWpK-%*ABLv=8h?CMlGsxy_S1#7rz-cHoKL%4$V zEyjZ?JCE8yFY3$&Q9r_A7au_t^a@My6RMy&)Y%sBQr}l1wb*7B}Y)W72*>L~7^7JPyFw@jc4nnWGNH(ZA^ zE}ld3q*_$SLpg3h6|x7l<9gJGQPjLRmS74i@D{2g6R0zPkJ`Yba~k#i4^%7N3D6`@x;|L*+>djy3zfh*4B&JqN@N^)?7JKP<;Hz^W77kk}!zjFY!@l#Y{Z&8JOaQ)9XkNyN|V~7|(lVW2pD71eYDC_i-dAOC)J5 zq>;i5rm+mWNLMG(>wJhBf9d*Ts5_rTC7MfAonQ&-q$*J-Q-wTM!;j`|M$K!&685)F z8p`Yvs)FmNJG+DWD4)6U*QkVsFpMLpgr-n;TgpqVuR?ONwWy=sf-0~P74L-e^t9an zSvPRenL-7)g-Yzc8-IlCWof*@(PmIrQBOI#V!s7cm5UiQB631qSpULCFCbdonR1k z#gSs}UyW)8v_UO0*Y=?TA44T_(wW2^^e>|l9!I`c%O?m$SqN3}3e>-2H7ZUWGS&8= z)*V5s%{*wyq_^d+%DQ^f_bCu-?y%O*wpcXQ-q;d598d4^cYE1UwZ`(^4nF9?!Df3&bjAZ?^NEbd~m{-$TG7F znPxn8m7g^@gc&%B1$Y;W@eyX@JIu#%ZK(ak?<;K~&rb=3uq+P*!5~ z#X1&r(neHe-N<8o{HXE)^y8pgA9jwT5>KKEdxAR1jQjgXT+e&~mG}>;a{)FhZgGNv zT2hK?RXJ|PYFvkPZawDaJ*X33#;rJr3N(d0HqDO;n8g8~*(bN&LU0utM;){mbnb)M(?VyYd)!;ykKz0jgDJvQeEYL~`18H?Khzbi`SYir*aO z`|B3>vOp}mg-Y}g6?g{q3ErRr&S4iWp<3BM6m`r)mh3#L;33?GW2iVUa1*}9N?b&% zPfc{BlE?j3X$7tE)~+*Nd+TY7tqyyy_h-%}y`bkyXC?VP>zF^UCEnTD)5RV)NLJ-n cq$fKI18JdHY9b!Px# delta 1364 zcmXZbO-R&17{~Ev&DPy5b2Z(z7j+Xcjb4`OR9IO@JM>CXYKU2^tY%rL2yP@1mK42# z6&NO1fkm(fgYaMm5h_dGLc$KcLX@34RM7Wl1Aq22Gt4~m%rmpS(RAn||U z5e9VfdQ_%u$YuUH=^}q5l=Nv4=^jWDpg%C_zId zDn*qpiut$|7h{zhZ+87o)QPX-O1z5-G=h9K#*Y$6VUNdb#*N1bu0-2V2R)BEXyO)) zVj6=uiQ~8yZXHM=v zkA_MZb`~Iqv|?1iji@Wyj0(I172zN%u|pg)g2zz(3#g5+p%Qz5t8vuzzo9~S36{zJ z7N(&Sm!L{ij=JLmsEuoo_hZLVZ{rje;8oXuf?79$O5g+P-!kj^e_h{CR!Ss4eLM!yo{PSfFx~?QEz1w%kUGbazV0Jr9!C6 z5cjWFe9jHrM{V>B6?g(wi78aTX>7t-RB4ZrCGXYRks-T?O1KY;@F6PBIIh4q7{%{s z`^O%|$C7)!8`5s{`lf=h`W92D28G6j&5u zg+v=y8ULbkQP5BsEn4*0gyJSFD++R97}fWu7ykS|_g=5(o^$ShuGU|ypE~AC1kG$X z(~QS1@k+z%n2I+s4{u`;KENz|gSj}1>+lEi*ovE{2Fyatb5Q%MQE?kE1NUMMwgfD( z8X(LUx#7mivU^qZqAM-`M9 zW>Cf80w!?^E3uz+mH8OzAMRldK0_W`W&vsceR8H6yS7KmV-*9l$R2&b%wE&`5>yoYpBlMKwaq+R$~(Vxaj3mkMh^ zb?yj;INt^tsKU#rmXD)0dd?ZtM>dQ4nisGf|GIe@o3-AAI`E*g9Thj~?8EKM6R4}1 z#Dpq+#9#-$Ld}9`ncNg5XMj+(^J&`IaI)JsQv$N8)ni@#o2{w z`5xSf?P_ydaol%k+)k delta 1363 zcmXZbPe{{Y9LMqRmd1vN$tR;|)9DhEZ7CLK~D z>JUZ+LPWSjSOnP)78QbY2rRrr)+G!{h%$PA@_`?}*Yi9)`~G>J->xBw(hvQ7ph(3}FN6_pMlnI|G)n z6%6*XunLdhYCMA~U;xYU0czh%RDel0pGFn(6?yE3TmS9W{Xw%5*2Ac{F;wCf=dNI8 z>4zOGsPhD>(jMfoK3?i%2z_|Vtq(gNq7pwr6*i7)DTk(n*F;ajP;6 zbVM=K(KTTuZp9+(bn9t1??rWd9XH@@RG{a`V>w$yNsD?5F z3~Cq*Vh+c!8ZS_;D!+^R!BgCbZ;;34d8q&|*>pwKxE8me0(YSH9mX|y0@qt3_0x2-($H8LE&PUMhIAvlA^^tu+ea&+i#R7h$dCb|0Dqx>8j!Kkvp2s@oS5Q|o ziWzk}&R`Qxq2`Oo-B=;zYGVWHC|giRzZdKAH0osTp{{TQ`Fv~?snK4bPV7CZfzPOT z-%;@vi#dPYU5GX~O{+%*XhogCZdBlQ)W>xI_h1j|V|sP^QjH9*ZMpC(Ko3GhBc+)=>N+wR((e7i(crtw`mFzm3Js9Zq3jh bKWRITvni4NSQPaJ(}|PO_|n{0a@q3_+z5> log/install_db.log else # FR: Import du shape des limites du territoire ($limit_shp) dans la BDD / atlas.t_layer_territoire # EN: Import of the shape of the territory limits ($limit_shp) in the BDD / atlas.t_layer_territory - ogr2ogr -f "ESRI Shapefile" -t_srs EPSG:4326 data/ref/emprise_territoire_4326.shp $limit_shp - sudo -u postgres -s shp2pgsql -W "LATIN1" -s 4326 -D -I ./data/ref/emprise_territoire_4326.shp atlas.t_layer_territoire | sudo -n -u postgres -s psql -d $db_name &>> log/install_db.log - rm data/ref/emprise_territoire_4326.* + ogr2ogr -f "ESRI Shapefile" -t_srs EPSG:4326 data/ref/territoire.shp $limit_shp + sudo -u postgres -s shp2pgsql -W "LATIN1" -s 4326 -D -I ./data/ref/territoire.shp atlas.t_layer_territoire | sudo -n -u postgres -s psql -d $db_name &>> log/install_db.log + # rm data/ref/territoire.* sudo -u postgres -s psql -d $db_name -c "ALTER TABLE atlas.t_layer_territoire OWNER TO "$owner_atlas";" # FR: Creation de l'index GIST sur la couche territoire atlas.t_layer_territoire # EN: Creation of the GIST index on the territory layer atlas.t_layer_territory sudo -u postgres -s psql -d $db_name -c "ALTER TABLE atlas.t_layer_territoire RENAME COLUMN geom TO the_geom; CREATE INDEX index_gist_t_layer_territoire ON atlas.t_layer_territoire USING gist(the_geom); " &>> log/install_db.log - # FR: Import du shape des communes ($communes_shp) dans la BDD (si parametre import_commune_shp = TRUE) / atlas.l_communes - # EN: Import of the shape of the communes ($communes_shp) in the DB (if parameter import_commune_shp = TRUE) / atlas.l_communes - if $import_commune_shp + # FR: Import du shape de l'entrée géograpique ($geo_entry) dans la BDD (si parametre import_geo_entry_shp = TRUE) / atlas.vm_geo_entry + # EN: Import of the shape of the geographical entry ($geo_entry) in the DB (if parameter import_geo_entry = TRUE) / atlas.vm_geo_entry + if $import_geo_entry_shp then - ogr2ogr -f "ESRI Shapefile" -t_srs EPSG:4326 ./data/ref/communes_4326.shp $communes_shp - sudo -u postgres -s shp2pgsql -W "LATIN1" -s 4326 -D -I ./data/ref/communes_4326.shp atlas.l_communes | sudo -n -u postgres -s psql -d $db_name &>> log/install_db.log - sudo -u postgres -s psql -d $db_name -c "ALTER TABLE atlas.l_communes RENAME COLUMN "$colonne_nom_commune" TO commune_maj;" &>> log/install_db.log - sudo -u postgres -s psql -d $db_name -c "ALTER TABLE atlas.l_communes RENAME COLUMN "$colonne_insee" TO insee;" &>> log/install_db.log - sudo -u postgres -s psql -d $db_name -c "ALTER TABLE atlas.l_communes RENAME COLUMN geom TO the_geom;" &>> log/install_db.log - sudo -u postgres -s psql -d $db_name -c "CREATE INDEX index_gist_t_layers_communes ON atlas.l_communes USING gist (the_geom);" &>> log/install_db.log - sudo -u postgres -s psql -d $db_name -c "ALTER TABLE atlas.l_communes OWNER TO "$owner_atlas";" - rm ./data/ref/communes_4326.* + ogr2ogr -f "ESRI Shapefile" -t_srs EPSG:4326 ./data/ref/geo_entry.shp $geo_entry + sudo -u postgres -s shp2pgsql -W "LATIN1" -s 4326 -D -I ./data/ref/geo_entry.shp atlas.vm_geo_entry | sudo -n -u postgres -s psql -d $db_name &>> log/install_db.log + sudo -u postgres -s psql -d $db_name -c "ALTER TABLE atlas.vm_geo_entry RENAME COLUMN "$name_column" TO geo_entry_id;" &>> log/install_db.log + sudo -u postgres -s psql -d $db_name -c "ALTER TABLE atlas.vm_geo_entry RENAME COLUMN "$id_column" TO geo_entry_id;" &>> log/install_db.log + sudo -u postgres -s psql -d $db_name -c "ALTER TABLE atlas.vm_geo_entry RENAME COLUMN geom TO the_geom;" &>> log/install_db.log + sudo -u postgres -s psql -d $db_name -c "CREATE INDEX index_gist_t_geo_entry ON atlas.vm_geo_entry USING gist (the_geom);" &>> log/install_db.log + sudo -u postgres -s psql -d $db_name -c "ALTER TABLE atlas.vm_geo_entry OWNER TO "$owner_atlas";" + # rm ./data/ref/geo_entry.* fi # FR: Mise en place des mailles @@ -347,52 +348,47 @@ if ! database_exists $db_name fi done - sudo sed -i "s/INSERT_ALTITUDE/${insert}/" /tmp/atlas/4.atlas.vm_altitudes.sql + sudo sed -i "s/INSERT_ALTITUDE/${insert}/" /tmp/atlas/5.atlas.vm_altitudes.sql echo "[$(date +'%H:%M:%S')] Creating atlas.vm_taxref..." time_temp=$SECONDS export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/1.atlas.vm_taxref.sql &>> log/install_db.log echo "[$(date +'%H:%M:%S')] Passed - Duration : $((($SECONDS-$time_temp)/60))m$((($SECONDS-$time_temp)%60))s" + echo "[$(date +'%H:%M:%S')] Creating atlas.vm_cor_taxon_attribut..." + time_temp=$SECONDS + sudo sed -i "s/WHERE id_attribut IN (100, 101, 102, 103);$/WHERE id_attribut IN ($attr_desc, $attr_commentaire, $attr_milieu, $attr_chorologie);/" /tmp/atlas/2.atlas.vm_cor_taxon_attribut.sql + export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/2.atlas.vm_cor_taxon_attribut.sql &>> log/install_db.log + echo "[$(date +'%H:%M:%S')] Passed - Duration : $((($SECONDS-$time_temp)/60))m$((($SECONDS-$time_temp)%60))s" + echo "[$(date +'%H:%M:%S')] Creating atlas.vm_observations..." time_temp=$SECONDS - export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/2.atlas.vm_observations.sql &>> log/install_db.log + export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/3.atlas.vm_observations.sql &>> log/install_db.log echo "[$(date +'%H:%M:%S')] Passed - Duration : $((($SECONDS-$time_temp)/60))m$((($SECONDS-$time_temp)%60))s" echo "[$(date +'%H:%M:%S')] Creating atlas.vm_taxons..." time_temp=$SECONDS - export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/3.atlas.vm_taxons.sql &>> log/install_db.log + export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/4.atlas.vm_taxons.sql &>> log/install_db.log echo "[$(date +'%H:%M:%S')] Passed - Duration : $((($SECONDS-$time_temp)/60))m$((($SECONDS-$time_temp)%60))s" echo "[$(date +'%H:%M:%S')] Creating atlas.vm_altitudes..." time_temp=$SECONDS - export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/4.atlas.vm_altitudes.sql &>> log/install_db.log + export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/5.atlas.vm_altitudes.sql &>> log/install_db.log echo "[$(date +'%H:%M:%S')] Passed - Duration : $((($SECONDS-$time_temp)/60))m$((($SECONDS-$time_temp)%60))s" echo "[$(date +'%H:%M:%S')] Creating atlas.vm_search_taxon..." time_temp=$SECONDS - export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/5.atlas.vm_search_taxon.sql &>> log/install_db.log + export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/6.atlas.vm_search_taxon.sql &>> log/install_db.log echo "[$(date +'%H:%M:%S')] Passed - Duration : $((($SECONDS-$time_temp)/60))m$((($SECONDS-$time_temp)%60))s" echo "[$(date +'%H:%M:%S')] Creating atlas.vm_mois..." time_temp=$SECONDS - export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/6.atlas.vm_mois.sql &>> log/install_db.log - echo "[$(date +'%H:%M:%S')] Passed - Duration : $((($SECONDS-$time_temp)/60))m$((($SECONDS-$time_temp)%60))s" - - echo "[$(date +'%H:%M:%S')] Creating atlas.vm_communes..." - time_temp=$SECONDS - export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/7.atlas.vm_communes.sql &>> log/install_db.log + export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/7.atlas.vm_mois.sql &>> log/install_db.log echo "[$(date +'%H:%M:%S')] Passed - Duration : $((($SECONDS-$time_temp)/60))m$((($SECONDS-$time_temp)%60))s" echo "[$(date +'%H:%M:%S')] Creating atlas.vm_medias" time_temp=$SECONDS - export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/8.atlas.vm_medias.sql &>> log/install_db.log - echo "[$(date +'%H:%M:%S')] Passed - Duration : $((($SECONDS-$time_temp)/60))m$((($SECONDS-$time_temp)%60))s" - - echo "[$(date +'%H:%M:%S')] Creating atlas.vm_cor_taxon_attribut..." - time_temp=$SECONDS - sudo sed -i "s/WHERE id_attribut IN (100, 101, 102, 103);$/WHERE id_attribut IN ($attr_desc, $attr_commentaire, $attr_milieu, $attr_chorologie);/" /tmp/atlas/9.atlas.vm_cor_taxon_attribut.sql - export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/9.atlas.vm_cor_taxon_attribut.sql &>> log/install_db.log + export PGPASSWORD=$owner_atlas_pass;psql -d $db_name -U $owner_atlas -h $db_host -f /tmp/atlas/9.atlas.vm_medias.sql &>> log/install_db.log echo "[$(date +'%H:%M:%S')] Passed - Duration : $((($SECONDS-$time_temp)/60))m$((($SECONDS-$time_temp)%60))s" echo "[$(date +'%H:%M:%S')] Creating atlas.vm_taxons_plus_observes..." diff --git a/install_env.sh b/install_env.sh index 1266e9e94..cebb551c7 100755 --- a/install_env.sh +++ b/install_env.sh @@ -58,7 +58,8 @@ sudo apt-get install python-pip sudo apt-get install -y python-gdal sudo apt-get install -y gdal-bin -sudo apt-get install -y python3-virtualenv virtualenv +# sudo apt-get install -y python3-virtualenv virtualenv +sudo apt-get install -y python3-venv # install nvm wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash