diff --git a/CHANGELOG.md b/CHANGELOG.md index 195cffb..f21fffc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,11 @@ Fixes: against every cell: for Deggendorf and Koeln in one database that took 29 minutes before linking began. Each building's cell is now computed from its coordinates; the batches are unchanged. +- Feature extraction works on PostgreSQL 18. There every batch holding + a flat roof or ground surface failed with division by zero in + surface_dimensions, so no building was extracted. PostgreSQL 16 and + 17 were not affected. A database created by an earlier release gets + the fixed function on its next -reset-city2tabula. ## v0.11.4 (2026-10-20) diff --git a/sql/functions/01_surface_area_corrected_geom.sql b/sql/functions/01_surface_area_corrected_geom.sql index e6c0f6d..6ee3732 100644 --- a/sql/functions/01_surface_area_corrected_geom.sql +++ b/sql/functions/01_surface_area_corrected_geom.sql @@ -78,7 +78,9 @@ CREATE FUNCTION {city2tabula_schema}.surface_dimensions( WITH axes AS ( SELECT -ny / h AS ux, nx / h AS uy, -nz * nx / h AS vx, -nz * ny / h AS vy, h AS vz - FROM (SELECT sqrt(nx * nx + ny * ny) AS h) s + -- NULLIF because PostgreSQL 18 computes the axes of a flat face (h = 0) + -- before the WHERE below discards it, and raises division by zero. + FROM (SELECT NULLIF(sqrt(nx * nx + ny * ny), 0) AS h) s WHERE ABS(nz) <= 0.985 ), projected AS (