Significantly improved performance of clustersDbscan#2885
Merged
smallsaucepan merged 5 commits intoTurfjs:masterfrom Jan 11, 2026
Merged
Significantly improved performance of clustersDbscan#2885smallsaucepan merged 5 commits intoTurfjs:masterfrom
smallsaucepan merged 5 commits intoTurfjs:masterfrom
Conversation
…er is better suited to static sets of points such as those processed in this module.
mfedderly
approved these changes
Jun 19, 2025
| // Input validation being handled by Typescript | ||
| // TODO oops! No it isn't. Typescript doesn't do runtime checking. We should | ||
| // re-enable these checks, though will have to wait for a major version bump | ||
| // as more restrictive checks could break currently working code. |
Collaborator
There was a problem hiding this comment.
Yeah there's a philosophical argument on whether these should be static checks or runtime checks. We've gone back and forth on it over the years.
| } | ||
| return ( | ||
| geokdbush | ||
| // @ts-expect-error - until https://github.com/mourner/geokdbush/issues/20 is resolved |
Collaborator
There was a problem hiding this comment.
Can you add the error number that we're expecting just so its a little more safe?
| tsup: | ||
| specifier: ^8.4.0 | ||
| version: 8.4.0(postcss@8.5.3)(tsx@4.19.4)(typescript@5.8.3) | ||
| version: 8.4.0(postcss@8.5.3)(tsx@4.19.4)(typescript@5.8.3)(yaml@2.7.1) |
Collaborator
There was a problem hiding this comment.
Whatever caused this resolution to change added a second copy of tsup even though it's the same version. We should probably run pnpm dedupe again. Probably easiest in a follow up PR unless the diff is very small in this same PR.
| import { degreesToRadians, lengthToDegrees, Units } from "@turf/helpers"; | ||
| import { rbush as RBush } from "./lib/rbush-export.js"; | ||
| import { Units } from "@turf/helpers"; | ||
| import KDBush from "kdbush"; |
Collaborator
There was a problem hiding this comment.
I love kdbush, it's saved my bacon a few times now.
Added expected TS error code as suggested.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
clustersDbscan seemed to exhibit a sharp decrease in performance when processing large numbers of points. Thanks to some input from the author of the existing rbush library @mourner, it was suggested another library they author might be a better fit. geokdbush caters more to static input data which is all Turf needs in the case of clustersDbscan.
The performance improvement was .. impressive.
All regression tests pass and changes within clustersDbscan have been limited to one functional area. License looks to be compatible with Turf's.
Resolves #2817
contributorsfield ofpackage.json- you've earned it! 👏