Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kdbush

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kdbush

A very fast static 2D index for points based on kd-tree.

  • 4.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.2M
decreased by-5.82%
Maintainers
1
Weekly downloads
 
Created

What is kdbush?

kdbush is a high-performance JavaScript library for creating and querying static spatial indexes using a k-d tree. It is particularly useful for handling large sets of 2D points and performing fast nearest neighbor searches.

What are kdbush's main functionalities?

Creating a spatial index

This feature allows you to create a spatial index from an array of 2D points. The index can then be used for efficient spatial queries.

const KDBush = require('kdbush');
const points = [
  [20, 30],
  [40, 50],
  [10, 15],
  [25, 35]
];
const index = new KDBush(points);

Performing a range search

This feature allows you to perform a range search on the spatial index. The `range` method returns all points within the specified bounding box.

const KDBush = require('kdbush');
const points = [
  [20, 30],
  [40, 50],
  [10, 15],
  [25, 35]
];
const index = new KDBush(points);
const results = index.range(10, 10, 30, 40);

Performing a nearest neighbor search

This feature allows you to perform a nearest neighbor search on the spatial index. The `within` method returns all points within a specified radius from a given point.

const KDBush = require('kdbush');
const points = [
  [20, 30],
  [40, 50],
  [10, 15],
  [25, 35]
];
const index = new KDBush(points);
const nearest = index.within(20, 30, 10);

Other packages similar to kdbush

Keywords

FAQs

Package last updated on 27 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc