Keep the Z and M of empty geometries in UnmarshalTWKB #723
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 281 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.338
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #723"
general
weight: 0.35
youdie006
UnmarshalTWKBreads the extended dimensions byte for empty geometries, and the Point and LineString parsers keep it, but an empty Polygon, MultiPoint, MultiLineString, MultiPolygon or GeometryCollection came back as XY. A collection holding one of them was then narrowed to XY, which dropped the Z and M of its other members.PostGIS writes that byte for empty Z/M geometries. Decoding
ST_AsTWKB(..., 0, 3, 0)output from PostGIS 3.5.2:The empty branches now use
ForceCoordinatesType(p.ctype), as the WKB parser does, and so does a count of zero (the only empty form of a polygon inside a MultiPolygon). A non-empty collection keeps its children's types. XY empties are unchanged.The new
TWKBTestCasesrows fail without the change and pass with it (all but the zero-count MultiPolygon row useskipEncode, sinceMarshalTWKBwrites no extended byte for empty geometries, see #724); removing any one of the checks fails its rows.make unit(golang:1.19) andmake lint(golangci-lint v1.61.0) pass. I didn't run the geos, pgscan or cmp jobs.This only changes the parser. The writer still drops the dimensions of empty geometries, as the comment in
writeIsEmptyHeadersays it does, so a Z collection with an empty member does not round trip throughMarshalTWKB; that is separate from #721.Author Motivation
I found this by reading the TWKB parser with an AI assistant, not as a user of simplefeatures: the Point and LineString branches kept the dimensions of an empty geometry and the others didn't. I then checked the bytes against PostGIS's
ST_AsTWKB.Written with AI assistance (Claude); I have reviewed the change.