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

Feat: Add sensibility management #324

Closed
wants to merge 24 commits into from

Conversation

mvergez
Copy link
Contributor

@mvergez mvergez commented Jul 26, 2021

This PR enables the atlas to take into account SINP rules for sensitivity.
Several changes had to be made to be able to display different types of geometries. The sql requests and backend function for the ficheCommune had also to be changed to aggregate observations from mesh cells or polygons that intersect the municipality territory.

The goal is to :

  • get the deteriorated geometry (1km², 10km² mesh cell, the departement or the municipality) from GeoNature synthese table with a diffusion level. So that it is not deteriorated twice (in the following materialized views)
  • provide it to the vm_observations and the vm_observations_mailles materialized views
  • regroup the different types of geometries into leaflet's feature layers to be able to filter them

The AFFICHAGE_MAILLE=True and False are supported but the point aggregation does not work yet.

Closes #117

Maxime Vergez added 21 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
-- since s.the_geom_point can be either a point or a geometry
-- corresponding to m.the_geom, we need to use a case
-- Intersects the geom point with a 1km mesh cell if no sensibility
WHEN s.diffusion_level = 5 THEN st_intersects(s.the_geom_point, m.the_geom) AND m.id_type = 29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id_type = 29 est-ce que ce sera pas plus robuste d'utiliser un code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci beaucoup pour ton retour
Effectivement, ce serait beaucoup mieux !

J'ai testé cette ligne qui fonctionne bien :

WHEN s.diffusion_level = 5 THEN st_intersects(s.the_geom_point, m.the_geom) AND m.id_type = (
	            select id_type 
                    from ref_geo.l_areas la 
                    where la.area_code like '1km%'
	            limit 1
            )

On pourrait alors changer facilement 1km par 5 ou 10. On peut également le mettre en paramètre.

Si cela te convient, je fais cette modification.

Maxime Vergez added 3 commits July 29, 2021 16:58
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
@camillemonchicourt
Copy link
Member

Remplacé par #441

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.

3 participants