Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Réimplémentation de la sensibilité #441

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open

Conversation

TheoLechemia
Copy link
Member

@TheoLechemia TheoLechemia commented Sep 22, 2022

Cette PR reprend le travail de Maxime sur la sensibilité.
La partie backend et frontend a été conservée (quelques peu modifiée), elle permet à l'API d'afficher différents niveaux de géométries dégradées sur une fiche espèce et sur les dernières obs, et au frontend de controler ces différentes couches à l'aide d'un sélecteur de couche.
Côté SQL, la PR a été complètement reprise pour se baser sur celle-ci : #358
Le calcul de la géométrie dégradée est fait de la manière suivante :

id_nomenclature_sensitivity Geom associée
0 Précise
1 Maille 1km
2 Maille 5km
3 Maille 10km
4 Pas de diffusion

On exclue volontairement les communes et les départements pour des raisons de performances.
Pour calculer les géométrie dégradées on s'appuie sur la table de la synthese de GeoNature gn_synthese.cor_area_synthese qui comprend déjà toutes les intersections avec les mailles dont nous avons besoin. l'objectif et ne refaire aucune intersection pour gagner en performance.
Une vue materialisée intermédiaire est créée en amont du calcul de la vm_observations pour améliorer les performances : atlas.vm_cor_area_synthese
Cette VM est construite à partir de gn_synthese.cor_area_synthese à laquelle on rajoute un booléen pour connaître la bonne géométrie dégradée en fonction de la sensibilité de l'observation courante.

id_synthese type_code is_blured_geom
1 M1 t
1 M5 f
1 M10 f

Calcul de VM observations :

Cette table contient uniquement des géométrie de type point (the_geom_point).
Quatre cas :

  • l'observation initiale est un point non sensible -> on prend la géom telle quelle
  • l'observation initiale est un point sensible -> on prend le centroid de la maille de dégradation
  • l'observation est un polygone non sensible -> on prend le centroid de la geom initiale
  • l'observation est un polygone sensible -> on prend le centroid des mailles de dégradation (necessite de faire un st_unions() sur les mailles)

Calcul de VM observations maille :

  • l'observation initiale est un point non sensible -> on prend la maille de taille correspondant au paramètre paramètre taillemaille
  • l'observation initiale est un point sensible -> on prend la maille de dégradation
  • l'observation est un polygone non sensible -> on prend le ou les les mailles de taille correspondant au paramètre taillemaille
  • l'observation est un polygone sensible -> on prend le ou les mailles de dégradation

Cette VM perd donc l'unicité sur le champ id_observation, une même observation pouvant être dans N mailles.

LIMITES :

  • Pour les atlas non basés sur GeoNature, et qui n'ont par conséquence pas la table gn_synthese.cor_area_synthese, l'installation est plus compliquée. Il faut se refaire les vues vm_observations et vm_observations_mailles

AVANTAGES :

  • Meilleurs perf
  • On a plus besoin d'importer les mailles car celle-ci sont déjà compris dans la vm_observations_mailles, et qu'on ne fait plus d'intersection

TODO :

  • Revoir les scripts d'installation de la BDD
  • L'intersection avec le territoire n'est plus faite. Necessaire ? Ou custo de la vm_observations ?

Lié à #117

Maxime Vergez and others added 28 commits July 26, 2021 14:04
Add layerGroups to the map for the user to be able to filter
along the different cells (Department, cities, 10km, 1km)
Added id_type to all queries to be able to filter along this
property
Correct zoom function to work on all "fiches" by adding a
zoomMaille function
Added snogylop to ficheCommune.html and invert: true in style of
map
Changed layerGroup by featureGroup to have bringToBack and
bringToFront functions
Add bringToFront and bringToBack to respectively the 1km² cell and
the department because it was impossible to click on a city cell
Changed the sql files to be able to reproduce the changes done on
the database.
Tested if it was possible to add hover and click effect to
hightlight a specific cell.
Added ZIndex values for the filter to be more robust
Beforehand the lastObservationsCommuneMaille selected from
the vm_observations which was not coherent. Now it selects from
vm_observations_mailles.
Add columns to select and removed the last_obs intermediate
Enabled to get the id of the cell and its type.
Cells border color is now grey
Made styleMailleClickedOrHover more versatile
styleMailleClickedOrHover now takes the --main-color css var to
fill the cells with the main color of the atlas
Removed setZIndex because it was useless
Added a new var (main-color-rgb) which is the same as main-color
variable but with a rgb description enabling to set different
opacity depending on the state (hover or click) of the row in
the tabEspece
Now the layers stack properly when the user activate or deactivate
them from the Control (top hand right corner).
Add a selected variable enabling the clicked cell to stay filled
even if the mouse exits the cell (mouseout event called)
Before was used to find a way to set background opacity other
than by using rgb formulation
Sql query was from vm_observations whereas we are in
a Maille function so it should be from vm_observations_maille
Corrected a copy paste mistake on id_type
Added dateobs in lastObservationsCommune
The older function took oservations based on Insee whereas it
should take info from the observations requested before. This new
function is based on the observations dictionnary that is
computed from the vm_observations (maille or not) and take the
taxons info
Used this function in atlasRoutes.py
mapHome.js: Clarified code
mapGenerator.js: Move control layer bloc for  more clarity as well
  Added id_type in property for geojson of commune
  Corrected a bug by added addTo(map) in displayMailleLayerLastObs
mapHome.js: simplified code
To be compatible with the new get_taxons_from_obs function, the
date object must be returned and not an str conversion
The function crashed when there were no taxons in a particular
city. Changed also the request for it to be more versatile in
terms of cd_ref (bugged when there was one taxon)
atlas.sql:
   add centroid to vm_observations to be compatible with point
   mode
   Changed st_contains by st_intersect as mentionned in an issue
observations_mailles.sql:
   Changed tables where to take infos
   Make this vm independant from vm_observations
   Removed index since it take to much space
atlas_synthese.sql:
   Changed index since it was not working with observations that
   do not have type_code
   Returns Point when there is no sensibility instead of a mesh
   cell
Need to update leaflet for bringToFront/BringToBack to work
Remove dependency to snogilop (had to test for compatibility)
To be able to alter the background transparency of the species
list on the main page, we need to have a rgb color. Indeed rgba()
css function does not work on hexadecimal colors. It adds complexity
but this seems to be the only way
In FicheEspece: the displayed cities were not right. There was no
instersection between the observation and the cities. Now for
instance, for a department level observation all the cities in the
department will appear...
In popup showing species, removes duplicates so that only different
species are displayed
Changed the plain id number to a Select with a Like to enter
directly the mesh cell type
It might be a parameter in the settings.ini in the future
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant