kdgrass

WebJar for kdgrass

License

License

ISC
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

kdgrass
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

kdgrass
WebJar for kdgrass
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/dfcreative/kdgrass

Download kdgrass

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/kdgrass/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>kdgrass</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/kdgrass/
implementation 'org.webjars.npm:kdgrass:1.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/kdgrass/
implementation ("org.webjars.npm:kdgrass:1.0.1")
'org.webjars.npm:kdgrass:jar:1.0.1'
<dependency org="org.webjars.npm" name="kdgrass" rev="1.0.1">
  <artifact name="kdgrass" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='kdgrass', version='1.0.1')
)
libraryDependencies += "org.webjars.npm" % "kdgrass" % "1.0.1"
[org.webjars.npm/kdgrass "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

kdgrass unstable Build Status

KDBush with flat API, which turns out to be even faster.

npm install kdgrass

const kdgrass = require('kdgrass')

let grass = kdgrass(points);
let ids1 = grass.range(10, 10, 20, 20);  // bbox search - minX, minY, maxX, maxY
let ids2 = grass.within(10, 10, 5);      // radius search - x, y, radius

API

let grass = kdgrass(points, nodeSize?)

Creates an index from the given points.

  • points: Input array of points in [x, y, x, y, ...] form.
  • nodeSize: Size of the KD-tree node, 64 by default. Higher means faster indexing but slower search, and vise versa.
let index = kdgrass(points, 64);

grass.range(minX, minY, maxX, maxY)

Finds all items within the given bounding box and returns an array of indices that refer to the items in the original points input array.

let results = index.range(10, 10, 20, 20).map((id) => points[id]);

grass.within(x, y, radius)

Finds all items within a given radius from the query point and returns an array of indices.

let results = index.within(10, 10, 5).map((id) => points[id]);

See also

  • kdbush − initial implementation with verbose API.
  • rbush — r-tree implementation with insertion/removal API.

Versions

Version
1.0.1