Skip to content

Commit

Permalink
[Tech] use ST_Union to calculate facade and departement
Browse files Browse the repository at this point in the history
  • Loading branch information
claire2212 committed Dec 13, 2024
1 parent ccd9688 commit 2fd64ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.springframework.data.repository.CrudRepository
interface IDBDepartmentAreaRepository : CrudRepository<DepartmentAreaModel, Int> {
@Query(
value =
"""
"""
SELECT *
FROM departments_areas
WHERE insee_dep = :inseeCode
Expand All @@ -20,11 +20,7 @@ interface IDBDepartmentAreaRepository : CrudRepository<DepartmentAreaModel, Int>
@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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ interface IDBFacadeAreasRepository : CrudRepository<FacadeAreasModel, Int> {
@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,
Expand All @@ -30,7 +30,7 @@ interface IDBFacadeAreasRepository : CrudRepository<FacadeAreasModel, Int> {
ON ST_Intersects(geom.geom, facade_areas_subdivided.geometry)
GROUP BY facade
)
SELECT facade
FROM facades_intersection_areas
ORDER BY intersection_area DESC
Expand Down

0 comments on commit 2fd64ec

Please sign in to comment.