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
3.1.0

3

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

@@ -48,2 +48,3 @@ "main": "index.js",

"clamp": "^1.0.1",
"dtype": "^2.0.0",
"flatten-vertex-data": "^1.0.0",

@@ -50,0 +51,0 @@ "is-obj": "^1.0.1",

@@ -17,2 +17,3 @@ /**

const isObj = require('is-obj')
const dtype = require('dtype')

@@ -28,2 +29,3 @@

maxDepth: 'depth maxDepth maxdepth level maxLevel maxlevel levels',
dtype: 'type dtype format out dst output destination'
// sort: 'sortBy sortby sort',

@@ -44,3 +46,12 @@ // pick: 'pick levelPoint',

let n = srcPoints.length >>> 1
let ids = new Uint32Array(n)
let ids
if (!options.dtype) options.dtype = 'array'
if (typeof options.dtype === 'string') {
ids = new (dtype(options.dtype))(n)
}
else if (options.dtype) {
ids = options.dtype
if (Array.isArray(ids)) ids.length = n
}
for (let i = 0; i < n; ++i) {

@@ -71,3 +82,9 @@ ids[i] = i

for (let level = 0; level < levels.length; level++) {
ids.set(levels[level], offset)
let levelItems = levels[level]
if (ids.set) ids.set(levelItems, offset)
else {
for (let i = 0, l = levelItems.length; i < l; i++) {
ids[i + offset] = levelItems[i]
}
}
let nextOffset = offset + levels[level].length

@@ -74,0 +91,0 @@ offsets[level] = [offset, nextOffset]

@@ -46,2 +46,3 @@ # 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-yellow.svg)](http://github.com/badges/stability-badges)

`depth` | `256` | Max number of levels. Points below the indicated level are grouped into single level.
`output` | `'array'` | Output data array or data format. For available formats see [dtype](https://npmjs.org/package/dtype).
<!-- `node` | `1` | Min size of node, ie. tree traversal is stopped once the node contains less than the indicated number of points. -->

@@ -48,0 +49,0 @@ <!-- `sort` | `'z'` | Sort values within levels by `x`-, `y`-coordinate, `z`-curve or `r` - point radius. `z` is the fastest for init, `x` or `y` are faster for `lod` and `r` is the most data-relevant. -->

@@ -12,8 +12,19 @@ 'use strict'

t.deepEqual(index.slice(), [0, 1,3,2, 4,5, 6])
t.deepEqual(index.subarray(), [0, 1,3,2, 4,5, 6])
t.end()
})
t('quad: output container', t => {
let points = [.15,.8, .2,.15, .6,.6, .6,.45, .8,.1, .9,.6, .91,.61]
let arr = []
let index = cluster(points, {bounds: [0,0,1,1], output: arr})
t.deepEqual(arr.slice(), [0, 1,3,2, 4,5, 6])
t.equal(index, arr)
t.end()
})
t('quad: max depth', t => {

@@ -20,0 +31,0 @@ let points = []