Skip to content

Share one bounding box accumulator across TWKB sub-writers #722

Open

Description

@peterstace

This issue assumes that #720 will be merged. It is about widenBBox, which that PR adds and which isn't on master yet. If #720 is closed without merging, this issue can be closed too. Nothing here is externally detectable.

writeGeometryCollection writes each child with its own twkbWriter (from copytwkbWriter), and each writer tracks its own bounding box in bboxValid, bboxMin and bboxMax. #720 adds widenBBox, which merges a child writer's box into the parent's after the child is written. That leaves two places that maintain the box: writePointArray for each coordinate, and widenBBox for each child.

Two ways to bring that back to one place:

  1. Have copytwkbWriter give the sub-writer the parent's bounding box state, for example as a pointer to a small struct holding the three fields. writePointArray then extends the collection's box directly and widenBBox can be deleted. Sub-writers don't write a bounding box, and they use the parent's precision, so the values are already on the same integer scale.
  2. Keep a box per writer and move the min/max update into one helper, such as extendBBox(d, lo, hi), which writePointArray calls with lo == hi and widenBBox calls with the child's range.

Option 1 removes more code and handles nested collections without a merging step.

Activity

  1. added
    cleanup
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cleanup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions