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

Masque l'onglet zonage d'urbanisme quand l'emprise du diagnostic n'en contient pas #581

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion project/models/project_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,32 @@ def has_no_ocsge_coverage(self) -> bool:

@property
def has_zonage_urbanisme(self) -> bool:
return ArtifAreaZoneUrba.objects.filter(zone_urba__mpoly__intersects=self.combined_emprise).exists()
"""
Cette fonction vérifie si l'emprise du diagnostic intersecte
des zonages d'urbanisme. Pour effectuer cette vérification,
on commence par sélectionner les zonages avec ST_Intersects,
puis on vérifie que le point central de chaque zone est
bien dans l'emprise du diagnostic. Cette vérification est
nécessaire car la méthode ST_Intersects peut retourner des
zones qui intersectent très légèrement l'emprise du projet
sur un bord.
"""
zone_urbas_intersecting = ArtifAreaZoneUrba.objects.filter(
zone_urba__mpoly__intersects=self.combined_emprise,
).values_list("zone_urba")

return (
ZoneUrba.objects.filter(
checksum__in=zone_urbas_intersecting,
)
.annotate(
point_on_surface=PointOnSurface("mpoly"),
)
.filter(
point_on_surface__intersects=self.combined_emprise,
)
.exists()
)

def get_ocsge_millesimes(self):
"""Return all OCS GE millésimes available within project cities and between
Expand Down