Skip to content

Commit

Permalink
Ajout st_simplifypreservetopology pour l'affichage des zones géograph…
Browse files Browse the repository at this point in the history
…iques + correction erreur prise en compte du selectedYearRange niveau backend
  • Loading branch information
eguilley committed Aug 26, 2019
1 parent a6a10ce commit c6ca9c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
28 changes: 11 additions & 17 deletions backend/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ def get_area_stat(type_code):
[
func.count(Synthese.id_synthese),
LAreas.area_name,
func.st_asgeojson(func.st_transform(LAreas.geom, 4326)),
func.st_asgeojson(
func.st_transform(
func.st_simplifypreservetopology(LAreas.geom, 50), 4326
)
),
func.count(distinct(Taxref.cd_ref)),
]
)
Expand All @@ -76,14 +80,9 @@ def get_area_stat(type_code):
.group_by(LAreas.area_name, LAreas.geom)
)
if "selectedYearRange" in params:
q = q.where(
func.date_part("year", Synthese.date_min)
<= params["selectedYearRange"][5:9]
)
q = q.where(
func.date_part("year", Synthese.date_max)
>= params["selectedYearRange"][0:4]
)
yearRange = params["selectedYearRange"].split(",")
q = q.where(func.date_part("year", Synthese.date_min) <= yearRange[1])
q = q.where(func.date_part("year", Synthese.date_max) >= yearRange[0])
if ("selectedRegne" in params) and (params["selectedRegne"] != ""):
q = q.where(Taxref.regne == params["selectedRegne"])
if ("selectedPhylum" in params) and (params["selectedPhylum"] != ""):
Expand Down Expand Up @@ -172,14 +171,9 @@ def get_synthese_per_tax_level_stat(taxLevel):
.order_by(VSynthese.group2_inpn)
)
if "selectedYearRange" in params:
q = q.filter(
func.date_part("year", VSynthese.date_min)
<= params["selectedYearRange"][5:9]
)
q = q.filter(
func.date_part("year", VSynthese.date_max)
>= params["selectedYearRange"][0:4]
)
yearRange = params["selectedYearRange"].split(",")
q = q.filter(func.date_part("year", VSynthese.date_min) <= yearRange[1])
q = q.filter(func.date_part("year", VSynthese.date_max) >= yearRange[0])
return q.all()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export class DashboardMapsComponent
this.spinner = false;
this.spinnerInit = false;
});
console.log(this.mapForm.value.selectedYearRange);
// Initialisation de la variable currentMap (au chargement de la page, la carte affiche automatiquement le nombre d'observations)
this.currentMap = 1; // Permet d'afficher les informations de légende associées au nombre d'observations
// Liste déroulante des areas_types
Expand All @@ -229,6 +230,7 @@ export class DashboardMapsComponent
});
this.areaTypeControl.patchValue("COM");
this.areaTypeControl.valueChanges.subscribe(value => {
console.log(this.mapForm.value);
this.currentTypeCode = value;
this.dataService
.getDataAreas(this.currentTypeCode, this.mapForm.value)
Expand Down Expand Up @@ -308,7 +310,7 @@ export class DashboardMapsComponent
this.disabledTaxButton = false;
// console.log(event);
// console.log(this.filter);
// console.log(this.mapForm.value);
console.log(this.mapForm.value);
// Copie des éléments du formulaire pour pouvoir y ajouter cd_ref s'il s'agit d'un filtre par taxon
this.filtersDict = Object.assign({}, this.mapForm.value);
// S'il s'agit d'une recherche de taxon...
Expand Down

0 comments on commit c6ca9c6

Please sign in to comment.