Repository navigation
fix: avoid division by zero for flat faces on PostgreSQL 18 - #212
Merged
Merged
Conversation
surface_dimensions divides the face normal by h = sqrt(nx^2 + ny^2) to build its in-plane axes, and filters out near-horizontal faces with WHERE ABS(nz) <= 0.985. PostgreSQL 16 and 17 apply that filter first. PostgreSQL 18 computes the axes of a flat face (h = 0) anyway and raises division by zero, which fails script 03 for every batch that holds a flat roof or ground surface, so no building is extracted. h is now NULLIF(..., 0). Flat faces still get NULL in both extents and every other face is unchanged: a flat face gives (,) and a 2 x 3 m wall (2,3) on PostgreSQL 16.4, 17.0 and 18.6 alike.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…s-pg18 # Conflicts: # CHANGELOG.md
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On PostgreSQL 18, feature extraction fails for every batch with
division by zeroin script 03, so no building is extracted. PostgreSQL 16 and 17 are not affected;environment/http/docker-compose.ymlruns PostGIS 16.Cause
surface_dimensionsdivides the face normal byh = sqrt(nx^2 + ny^2)and drops near-horizontal faces withWHERE ABS(nz) <= 0.985. PostgreSQL 16 and 17 apply the filter first. PostgreSQL 18 computes the axes of a flat face (h = 0) anyway and raises the error. Every batch holds a flat roof or ground surface.Change
hisNULLIF(sqrt(nx * nx + ny * ny), 0). Flat faces still getNULLin both extents; every other face is unchanged.CHANGELOG.md: Fixes entry. A database created earlier gets the fixed function on its next-reset-city2tabula, since functions are installed by the setup step.Tests
surface_dimensionson a flat 1 x 1 m face and a vertical 2 x 3 m wall:(,)(2,3)(,)(2,3)(,)(2,3)(,)(2,3)ERROR: division by zero(,)(2,3)On PostgreSQL 18.6,
-extract-featureson 27,420 Bavarian and NRW buildings failed in all 28 batches before and extracts all of them after.go test -tags integration ./internal/process/passes. The integration container is PostgreSQL 17, so no automated test fails before this change.