diff --git a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/interfaces/IDBDepartmentAreaRepository.kt b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/interfaces/IDBDepartmentAreaRepository.kt index 0c6b062a0..4a2ed6f43 100644 --- a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/interfaces/IDBDepartmentAreaRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/interfaces/IDBDepartmentAreaRepository.kt @@ -8,7 +8,7 @@ import org.springframework.data.repository.CrudRepository interface IDBDepartmentAreaRepository : CrudRepository { @Query( value = - """ + """ SELECT * FROM departments_areas WHERE insee_dep = :inseeCode @@ -20,11 +20,7 @@ interface IDBDepartmentAreaRepository : CrudRepository @Query( """ WITH geom AS ( - SELECT CASE - WHEN GeometryType(ST_SetSRID(:geometry, 4326)) IN ('ST_MultiPolygon', 'ST_Polygon') - THEN ST_Buffer(ST_SetSRID(:geometry, 4326), 0) - ELSE ST_SetSRID(:geometry, 4326) - END AS geom + SELECT ST_SetSRID(ST_Union(:geometry), 4326) AS geom ), departments_intersection_areas AS ( diff --git a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/interfaces/IDBFacadeAreasRepository.kt b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/interfaces/IDBFacadeAreasRepository.kt index 959069208..1d439b1ea 100644 --- a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/interfaces/IDBFacadeAreasRepository.kt +++ b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/interfaces/IDBFacadeAreasRepository.kt @@ -9,9 +9,9 @@ interface IDBFacadeAreasRepository : CrudRepository { @Query( """ WITH geom AS ( - SELECT st_setsrid(:geometry, 4326) AS geom + SELECT st_setsrid(ST_Union(:geometry), 4326) AS geom ), - + facades_intersection_areas AS ( SELECT facade, @@ -30,7 +30,7 @@ interface IDBFacadeAreasRepository : CrudRepository { ON ST_Intersects(geom.geom, facade_areas_subdivided.geometry) GROUP BY facade ) - + SELECT facade FROM facades_intersection_areas ORDER BY intersection_area DESC