Skip to content

[GH-1272] Return the containing pixel from ST_Pixelize for sub-pixel geometries - #3484

Merged
jiayuasu merged 3 commits into
apache:masterfrom
Mayukh-D:GH-1272-pixelize-small-geometries
Oct 31, 2026
Merged

jiayuasu merged 3 commits into
apache:masterfrom
Mayukh-D:GH-1272-pixelize-small-geometries

Conversation

@Mayukh-D

@Mayukh-D Mayukh-D commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

ST_Pixelize traces lines and polygon rings with Bresenham's algorithm, which draws a segment's start pixel but not its end. When every vertex of a geometry falls in the same pixel, every segment draws nothing and the expression fails on assert(pixels.size() > 0).

Now:

  • a line or polygon that traces to no pixels returns the one pixel that contains it
  • collections (including the Multi* types) are pixelized member by member, so a GeometryCollection no longer fails with a MatchError
  • empty geometries return no pixels instead of failing

Geometries that span several pixels are traced exactly as before. VizTestBase now calls super.beforeAll(), so the viz suites register Sedona's SQL functions themselves instead of relying on another suite running first.

One visible change: a Multi* geometry with a member small enough to fit inside one pixel used to get no pixels for that member, and now gets that member's pixel. Geometries outside the boundary are not skipped; they keep their computed pixel, the same way ST_Pixelize already handles points.

How was this patch tested?

New cases in PixelizeTest for tiny lines and polygons, collections and empty geometries. Ran the viz tests on Spark 3.5 / Scala 2.12 and Spark 4.1 / Scala 2.13, and compared the old and new code on 3,000 random shapes: everything that pixelized before gives the same pixels, apart from the Multi* case above.

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation.

Assisted by Claude Code
Generated-by: Claude Code (Claude Opus 5.5)

…pixel geometries

ST_Pixelize traced lines and polygon rings with Bresenham's algorithm, which
draws a segment's start pixel but not its end pixel. When every vertex of a
geometry fell in the same pixel, every segment drew nothing, and the
expression failed on `assert(pixels.size() > 0)`.

A line or polygon that traces to no pixels now returns the single pixel
that contains it. Collections, including the Multi* types, are pixelized
member by member, so a GeometryCollection no longer fails with a
MatchError and each member keeps its own pixel. Empty geometries return no
pixels instead of failing.

Geometries spanning several pixels are traced exactly as before.

VizTestBase now calls super.beforeAll(), so the viz suites register
Sedona's SQL functions themselves instead of relying on an earlier suite
having done it.

Generated-by: Claude Code (Claude Opus 5.5)
…y geometries

Generated-by: Claude Code (Claude Opus 5.5)
@Mayukh-D
Mayukh-D requested a review from jiayuasu as a code owner October 19, 2026 13:14
@Mayukh-D

Copy link
Copy Markdown
Contributor Author

Hi @jiayuasu, when you get a chance, could you approve the CI workflows for this one? They're still waiting on maintainer approval. Happy to address any review comments once it's run. Thanks!

@Mayukh-D

Copy link
Copy Markdown
Contributor Author

Hi @jiayuasu, whenever you have time, this one is ready for review. CI is green, and it follows your comment on #1272 that ST_Pixelize should always return at least one pixel. While fixing it I found a related rasterization bug, which is in #3485 (also green). Happy to make any changes to either, or to close them if they're not something you want right now. Thanks for merging #3503!

@jiayuasu
jiayuasu merged commit eb2e9bf into apache:master Oct 31, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ST_Pixelize small polygon error

4 participants