You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

point-cluster

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

point-cluster - npm Package Compare versions

Comparing version

to
2.2.0

2

package.json
{
"name": "point-cluster",
"version": "2.1.1",
"version": "2.2.0",
"description": "Fast nd point clustering.",

@@ -5,0 +5,0 @@ "main": "quad.js",

@@ -21,22 +21,25 @@ /**

let points = this.points
this.points
// point indexes for levels [0: [a,b,c,d], 1: [a,b,c,d,e,f,...], ...]
let levels = this.levels = []
this.levels = []
// starting indexes of subranges in sub levels, levels.length * 4
let sublevels = this.sublevels = []
this.sublevels = []
// unique group ids, sorted in z-curve fashion within levels
let groups = this.groups = []
this.groups = []
let bounds = this.bounds
this.diam = Math.max(bounds[2] - bounds[0], bounds[3] - bounds[1])
this.update(this.ids)
}
let nodeSize = this.nodeSize
let maxDepth = this.maxDepth
QuadCluster.prototype = Object.create(PointCluster.prototype)
QuadCluster.prototype.update = function (ids) {
let { points, levels, sublevels, groups, bounds, nodeSize, maxDepth } = this
sort(0, 0, 1, this.ids, 0, 1)
// FIXME: it is possible to create one typed array heap and reuse that to avoid memory blow

@@ -55,3 +58,3 @@ function sort (x, y, diam, ids, level, group) {

for (let i = 0; i < ids.length; i++) {
levelItems.push(ids[0])
levelItems.push(ids[i])
levelGroups.push(group)

@@ -79,3 +82,3 @@ sublevel.push(null, null, null, null)

for (let i = 1; i < ids.length; i++) {
for (let i = 1, l = ids.length; i < l; i++) {
let idx = ids[i],

@@ -98,8 +101,7 @@ x = points[idx * 2],

}
return this
}
QuadCluster.prototype = Object.create(PointCluster.prototype)
// get all points within box range

@@ -177,2 +179,3 @@ QuadCluster.prototype.range = function () {

// get range offsets within levels to render lods appropriate for zoom level

@@ -182,4 +185,6 @@ // TODO: it is possible to store minSize of a point and increase pxSize by that number

let offsets = []
let diam = this.diam
let { bounds } = this
this.diam = Math.max(bounds[2] - bounds[0], bounds[3] - bounds[1])
for (let level = 0; level < this.levels.length; level++) {

@@ -186,0 +191,0 @@ let levelGroups = this.groups[level]

@@ -23,6 +23,6 @@ # point-cluster [![Build Status](https://travis-ci.org/dfcreative/point-cluster.svg?branch=master)](https://travis-ci.org/dfcreative/point-cluster) [![experimental](https://img.shields.io/badge/stability-experimental-red.svg)](http://github.com/badges/stability-badges)

let tree = cluster(points)
let ids = cluster(points)
// get point ids within the indicated range
let ids = tree.range(10, 10, 20, 20)
let selected = ids.range(10, 10, 20, 20)
```

@@ -32,5 +32,5 @@

### `points = cluster(coords, options?)`
### `tree = cluster(points, options?)`
Create index tree for the set of 2d `coords` based on `options`.
Create index tree for the set of 2d `points` based on `options`.

@@ -49,11 +49,11 @@ `points` is an array of `[x,y, x,y, ...]` or `[[x,y], [x,y], ...]` coordinates.

### `points.levels`
### `tree.ids`, `tree.levels`
Point ids distributed by zoom levels of details. Handy to form a buffer in WebGL and use `points.lod` method to get subranges of buffer to render.
Point ids distributed by zoom levels of details. Handy to form a buffer in WebGL and use `tree.lod` method to get subranges of buffer to render.
### `points.range(minX, minY, maxX, maxY)`
### `tree.range(minX, minY, maxX, maxY)`
Get point ids from the indicated range.
### `points.lod(pxSize, minX, minY, maxX, maxY)`
### `tree.lod(pxSize, minX, minY, maxX, maxY)`

@@ -60,0 +60,0 @@ Get offsets for the points visible at a specific zoom level and range. Returns list of arrays corresponding to `points.levels` ranges, eg. `[[120, 200], [1120, 1540], ...]`. Useful for obtaining subranges to render.

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.