← Back to Pull requests

cleanCoords: Add collection support and typescript fixes #3012

Open
unknown opened this pull request with 395 lines diff across 4 files
View on GitHub
unknown unknown commented on Feb 01, 2026 00:40 UTC
Author

Addresses #2998.

Summary

Adds some features to clean-coords:

  • Added support for FeatureCollection and GeometryCollection types through a recursive call.

  • Improves consistency of structural sharing for both mutate options, and documents it (see note below).

  • Improved typscript type signature (see note below).

  • Adds the ability to pass an epsilon through to the booleanPointOnLine calls.

  • Changed the MultiPoint methodology from POJO to Set for substantial speedup.

  • Made some other minor cleanups - removing redundant checks, cleaning up the benchmarks file, etc.
  • Additional Notes

    1. I had originally suggested also changing the behavior such that output polygons with < 4 points should not throw but instead return a valid 4 Position polygon. Changed my mind given that these, while technically valid geojson, are not OGC Simple Feature valid polygons and could lead to downstream choking.
    2. Wanted to (a) maximize structural sharing to improve performance wherever possible, and (b) ensure we are clear about what gets preserved vs. not. The basic premise is that:
    - The geojson objects down to the Geometry are always reused when mutate=true and always new when mutate=false
    - All properties, id, bbox, are always reused irrespective of mutate value
    - Mutate=false is (as you would expect) guaranteed not to change any coordinates from the original, but otherwise, will reuse or create new or mutate if mutate=true with no specific guarantees
    3. The type signature improvement aims to be maximally informative in that it passes the geometry's generic through, requiring that the function always either outputs the same type it receives or throws. If this is too constraining then can back it off, but figured more type inference was better, and it matches the behavior.
    4. Benchmarks are variable but more got faster than slower, with the main impacts coming from the structural sharing changes. e.g., the biggest slowdown was in the single point test where we replace the object rather than return it. The better sharing tends to boost performance when few changes are made to larger geometries - i.e., more realistic cases.

    Future Work

    I do wonder if you would be interested in a follow up PR that adds a collapse option? Reason being I am concerned by the workflow of input > truncate > clean throwing errors for valid input. The collapse option would remove the offending geometry at the ring level rather than throw an error. Thoughts?

    ---

    Please provide the following when creating a PR:

  • Meaningful title, including the name of the package being modified.

  • Summary of the changes.

  • Heads up if this is a breaking change.

  • Any issues this resolves.

  • Inclusion of your details in the contributors field of package.json - you've earned it! 👏

  • Confirmation you've read the steps for preparing a pull request.
  • Diff: 395 lines (+296 / -99) across 4 files Reviewer: smallsaucepan Review duration: 436048m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.50) × (1 − Review Confidence (0.41)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 395 lines diff across 4 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    40%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.358
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3012"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 40.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.2% (MEDIUM) · Higher = larger blast radius
    50.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 40.9% · Lower = rushed or shallow review
    40.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.6% · Safe to merge
    29.6%
    Repository