@thi.ng/geom-accel
Advanced tools
Comparing version 1.1.6 to 1.1.7
@@ -6,2 +6,13 @@ # Change Log | ||
## [1.1.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-accel@1.1.6...@thi.ng/geom-accel@1.1.7) (2019-03-10) | ||
### Bug Fixes | ||
* **geom-accel:** fix/update existing point search in add()/select*() ([8186f12](https://github.com/thi-ng/umbrella/commit/8186f12)) | ||
## [1.1.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/geom-accel@1.1.5...@thi.ng/geom-accel@1.1.6) (2019-03-03) | ||
@@ -8,0 +19,0 @@ |
@@ -67,16 +67,17 @@ import { ensureArray } from "@thi.ng/arrays"; | ||
const search = (node, parent) => node | ||
? distSq(p, node.k) > eps | ||
? search(p[node.d] < node.k[node.d] ? node.l : node.r, node) | ||
: false | ||
? search(p[node.d] < node.k[node.d] ? node.l : node.r, node) | ||
: parent; | ||
const parent = search(this.root, null); | ||
if (parent === false) | ||
return false; | ||
if (parent == null) { | ||
this.root = new KdNode(null, 0, p, v); | ||
} | ||
else { | ||
let parent; | ||
if (this.root) { | ||
parent = nearest1(p, [eps * eps, null], [], this.dim, this.root)[1]; | ||
if (parent) { | ||
return false; | ||
} | ||
parent = search(this.root, null); | ||
const dim = parent.d; | ||
parent[p[dim] < parent.k[dim] ? "l" : "r"] = new KdNode(parent, (dim + 1) % this.dim, p, v); | ||
} | ||
else { | ||
this.root = new KdNode(null, 0, p, v); | ||
} | ||
this._length++; | ||
@@ -120,3 +121,3 @@ return true; | ||
if (maxNum === 1) { | ||
const sel = nearest1(q, [maxDist != null ? maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
const sel = nearest1(q, [maxDist != null ? maxDist * maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
sel && res.push([sel.k, sel.v]); | ||
@@ -138,3 +139,3 @@ } | ||
if (maxNum === 1) { | ||
const sel = nearest1(q, [maxDist != null ? maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
const sel = nearest1(q, [maxDist != null ? maxDist * maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
sel && res.push(sel.k); | ||
@@ -156,3 +157,3 @@ } | ||
if (maxNum === 1) { | ||
const sel = nearest1(q, [maxDist != null ? maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
const sel = nearest1(q, [maxDist != null ? maxDist * maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
sel && res.push(sel.v); | ||
@@ -159,0 +160,0 @@ } |
@@ -65,16 +65,17 @@ 'use strict'; | ||
const search = (node, parent) => node | ||
? vectors.distSq(p, node.k) > eps | ||
? search(p[node.d] < node.k[node.d] ? node.l : node.r, node) | ||
: false | ||
? search(p[node.d] < node.k[node.d] ? node.l : node.r, node) | ||
: parent; | ||
const parent = search(this.root, null); | ||
if (parent === false) | ||
return false; | ||
if (parent == null) { | ||
this.root = new KdNode(null, 0, p, v); | ||
} | ||
else { | ||
let parent; | ||
if (this.root) { | ||
parent = nearest1(p, [eps * eps, null], [], this.dim, this.root)[1]; | ||
if (parent) { | ||
return false; | ||
} | ||
parent = search(this.root, null); | ||
const dim = parent.d; | ||
parent[p[dim] < parent.k[dim] ? "l" : "r"] = new KdNode(parent, (dim + 1) % this.dim, p, v); | ||
} | ||
else { | ||
this.root = new KdNode(null, 0, p, v); | ||
} | ||
this._length++; | ||
@@ -118,3 +119,3 @@ return true; | ||
if (maxNum === 1) { | ||
const sel = nearest1(q, [maxDist != null ? maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
const sel = nearest1(q, [maxDist != null ? maxDist * maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
sel && res.push([sel.k, sel.v]); | ||
@@ -136,3 +137,3 @@ } | ||
if (maxNum === 1) { | ||
const sel = nearest1(q, [maxDist != null ? maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
const sel = nearest1(q, [maxDist != null ? maxDist * maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
sel && res.push(sel.k); | ||
@@ -154,3 +155,3 @@ } | ||
if (maxNum === 1) { | ||
const sel = nearest1(q, [maxDist != null ? maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
const sel = nearest1(q, [maxDist != null ? maxDist * maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
sel && res.push(sel.v); | ||
@@ -157,0 +158,0 @@ } |
@@ -62,16 +62,17 @@ (function (global, factory) { | ||
const search = (node, parent) => node | ||
? vectors.distSq(p, node.k) > eps | ||
? search(p[node.d] < node.k[node.d] ? node.l : node.r, node) | ||
: false | ||
? search(p[node.d] < node.k[node.d] ? node.l : node.r, node) | ||
: parent; | ||
const parent = search(this.root, null); | ||
if (parent === false) | ||
return false; | ||
if (parent == null) { | ||
this.root = new KdNode(null, 0, p, v); | ||
} | ||
else { | ||
let parent; | ||
if (this.root) { | ||
parent = nearest1(p, [eps * eps, null], [], this.dim, this.root)[1]; | ||
if (parent) { | ||
return false; | ||
} | ||
parent = search(this.root, null); | ||
const dim = parent.d; | ||
parent[p[dim] < parent.k[dim] ? "l" : "r"] = new KdNode(parent, (dim + 1) % this.dim, p, v); | ||
} | ||
else { | ||
this.root = new KdNode(null, 0, p, v); | ||
} | ||
this._length++; | ||
@@ -115,3 +116,3 @@ return true; | ||
if (maxNum === 1) { | ||
const sel = nearest1(q, [maxDist != null ? maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
const sel = nearest1(q, [maxDist != null ? maxDist * maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
sel && res.push([sel.k, sel.v]); | ||
@@ -133,3 +134,3 @@ } | ||
if (maxNum === 1) { | ||
const sel = nearest1(q, [maxDist != null ? maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
const sel = nearest1(q, [maxDist != null ? maxDist * maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
sel && res.push(sel.k); | ||
@@ -151,3 +152,3 @@ } | ||
if (maxNum === 1) { | ||
const sel = nearest1(q, [maxDist != null ? maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
const sel = nearest1(q, [maxDist != null ? maxDist * maxDist : Infinity, null], [], this.dim, this.root)[1]; | ||
sel && res.push(sel.v); | ||
@@ -154,0 +155,0 @@ } |
{ | ||
"name": "@thi.ng/geom-accel", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "nD spatial indexing data structures", | ||
@@ -35,9 +35,9 @@ "module": "./index.js", | ||
"dependencies": { | ||
"@thi.ng/api": "^5.0.3", | ||
"@thi.ng/arrays": "^0.1.1", | ||
"@thi.ng/geom-api": "^0.1.5", | ||
"@thi.ng/heaps": "^1.0.4", | ||
"@thi.ng/api": "^5.1.0", | ||
"@thi.ng/arrays": "^0.1.2", | ||
"@thi.ng/geom-api": "^0.1.6", | ||
"@thi.ng/heaps": "^1.0.5", | ||
"@thi.ng/math": "^1.1.1", | ||
"@thi.ng/transducers": "^5.1.2", | ||
"@thi.ng/vectors": "^2.4.0" | ||
"@thi.ng/transducers": "^5.2.0", | ||
"@thi.ng/vectors": "^2.4.1" | ||
}, | ||
@@ -61,3 +61,3 @@ "keywords": [ | ||
"sideEffects": false, | ||
"gitHead": "ce74afc55215fee990748c9e7d555a839adcec69" | ||
"gitHead": "794f0b6f07f6eef99f6f244d6c52c1d5de34675f" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
76525
1030
Updated@thi.ng/api@^5.1.0
Updated@thi.ng/arrays@^0.1.2
Updated@thi.ng/geom-api@^0.1.6
Updated@thi.ng/heaps@^1.0.5
Updated@thi.ng/transducers@^5.2.0
Updated@thi.ng/vectors@^2.4.1