Skip to content

Conversation

smallsaucepan
Copy link
Member

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

  • 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.

@smallsaucepan smallsaucepan requested a review from mfedderly June 11, 2025 11:14
// 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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

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";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I love kdbush, it's saved my bacon a few times now.

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.

Segmentation fault when using clustersDbscan
2 participants