Skip to content

transform-scale, transform-translate, transform-rotate: Invalidate stale bboxes after coordinate transforms#3106

Merged
mfedderly merged 3 commits into
Turfjs:masterfrom
khalilurrrahmanridoykhan:agent/invalidate-transform-bboxes
Jul 24, 2026
Merged

transform-scale, transform-translate, transform-rotate: Invalidate stale bboxes after coordinate transforms#3106
mfedderly merged 3 commits into
Turfjs:masterfrom
khalilurrrahmanridoykhan:agent/invalidate-transform-bboxes

Conversation

@khalilurrrahmanridoykhan

Copy link
Copy Markdown
Contributor

What changed

  • recursively removes stale bbox values after transformTranslate and transformRotate
  • extends the same invalidation to nested objects handled by transformScale
  • covers Features, FeatureCollections, and GeometryCollections
  • preserves the existing clone-versus-mutate behavior
  • adds regression coverage for both default cloning and mutate: true

Why

Coordinate transforms mutate positions but previously retained cached bounding boxes at one or more levels of the GeoJSON hierarchy. A later bbox lookup could therefore return coordinates describing the pre-transform object. Invalidating those cached values lets callers explicitly recompute them when needed.

Validation

  • pnpm --filter @turf/transform-translate test — 29 passed
  • pnpm --filter @turf/transform-rotate test — 25 passed
  • pnpm --filter @turf/transform-scale test — 54 passed
  • ESLint on all six changed TypeScript files
  • Prettier check on all six changed TypeScript files
  • git diff --check

Closes #2835

@mfedderly

Copy link
Copy Markdown
Collaborator

(👍 for the recursive approach here)

Comment thread packages/turf-transform-rotate/index.ts Outdated
Comment thread packages/turf-transform-rotate/index.ts Outdated
@khalilurrrahmanridoykhan

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. I moved removeBbox to @turf/helpers, simplified the parameter to GeoJSON, documented its recursive mutation behavior, and added focused tests, type coverage, and generated documentation. All relevant local tests pass.

@khalilurrrahmanridoykhan
khalilurrrahmanridoykhan marked this pull request as ready for review July 23, 2026 18:41

@mfedderly mfedderly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@mfedderly mfedderly added this to the v7.4 milestone Jul 24, 2026
@mfedderly mfedderly changed the title Invalidate stale bboxes after coordinate transforms transform-scale, transform-translate, transform-rotate: Invalidate stale bboxes after coordinate transforms Jul 24, 2026
@mfedderly
mfedderly merged commit 5fd684d into Turfjs:master Jul 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transform Translate/Rotate method do not recompute bounding box property

2 participants