@thi.ng/geom-accel
Advanced tools
Comparing version 3.5.69 to 3.6.0
@@ -7,3 +7,3 @@ import { EPS } from "@thi.ng/math/api"; | ||
import { subN } from "@thi.ng/vectors/subn"; | ||
import { into } from "./utils.js"; | ||
import { __ensureRes, __into } from "./utils.js"; | ||
class ASpatialGrid { | ||
@@ -14,2 +14,3 @@ constructor(_min, _size, _res) { | ||
this._res = _res; | ||
__ensureRes(_res); | ||
floor(null, this._res); | ||
@@ -75,3 +76,3 @@ this._res1 = subN([], this._res, 1); | ||
into(pairs, eps = EPS) { | ||
return into(this, pairs, eps); | ||
return __into(this, pairs, eps); | ||
} | ||
@@ -78,0 +79,0 @@ remove(k) { |
# Change Log | ||
- **Last updated**: 2024-04-11T12:32:44Z | ||
- **Last updated**: 2024-04-20T14:42:45Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -12,2 +12,14 @@ | ||
## [3.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-accel@3.6.0) (2024-04-20) | ||
#### 🚀 Features | ||
- fix [#463](https://github.com/thi-ng/umbrella/issues/463), add grid resolution check ([8688ad5](https://github.com/thi-ng/umbrella/commit/8688ad5)) | ||
- update ASpatialGrid ctor to check for min res | ||
- add/rename internal helpers | ||
#### ♻️ Refactoring | ||
- update type usage ([aab2250](https://github.com/thi-ng/umbrella/commit/aab2250)) | ||
### [3.5.28](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-accel@3.5.28) (2023-11-09) | ||
@@ -14,0 +26,0 @@ |
@@ -1,5 +0,5 @@ | ||
import type { Fn, ICopy, IEmpty, Pair } from "@thi.ng/api"; | ||
import type { Fn, ICopy, IEmpty, Maybe, Pair } from "@thi.ng/api"; | ||
import type { IRegionQuery, ISpatialMap } from "@thi.ng/geom-api"; | ||
import type { DistanceFn, ReadonlyVec } from "@thi.ng/vectors"; | ||
type MaybeKdNode<K extends ReadonlyVec, V> = KdNode<K, V> | undefined; | ||
type MaybeKdNode<K extends ReadonlyVec, V> = Maybe<KdNode<K, V>>; | ||
export declare class KdNode<K extends ReadonlyVec, V> { | ||
@@ -6,0 +6,0 @@ d: number; |
@@ -6,3 +6,3 @@ import { ensureArray } from "@thi.ng/arrays/ensure-array"; | ||
import { distSq } from "@thi.ng/vectors/distsq"; | ||
import { addResults, CMP, into } from "./utils.js"; | ||
import { CMP, __addResults, __into } from "./utils.js"; | ||
class KdNode { | ||
@@ -109,3 +109,3 @@ d; | ||
into(pairs, eps = EPS) { | ||
return into(this, pairs, eps); | ||
return __into(this, pairs, eps); | ||
} | ||
@@ -172,3 +172,3 @@ remove(key) { | ||
nearest(q, nodes, this.dim, maxNum, this.root, this.distanceFn); | ||
return addResults(f, nodes.values, acc); | ||
return __addResults(f, nodes.values, acc); | ||
} | ||
@@ -175,0 +175,0 @@ return acc; |
@@ -1,5 +0,6 @@ | ||
import type { Fn, ICopy, IEmpty, Pair } from "@thi.ng/api"; | ||
import type { Fn, ICopy, IEmpty, Maybe, Pair } from "@thi.ng/api"; | ||
import type { IRegionQuery, ISpatialMap } from "@thi.ng/geom-api"; | ||
import { Heap } from "@thi.ng/heaps/heap"; | ||
import type { DistanceFn, ReadonlyVec } from "@thi.ng/vectors"; | ||
type MaybeNdQtNode<K extends ReadonlyVec, V> = Maybe<NdQtNode<K, V>>; | ||
export declare class NdQtNode<K extends ReadonlyVec, V> { | ||
@@ -13,3 +14,3 @@ pos: ReadonlyVec; | ||
v?: V; | ||
constructor(parent: NdQtNode<K, V> | undefined, pos: ReadonlyVec, ext: ReadonlyVec); | ||
constructor(parent: MaybeNdQtNode<K, V>, pos: ReadonlyVec, ext: ReadonlyVec); | ||
clear(): void; | ||
@@ -22,3 +23,3 @@ set(p: K, val: V, eps: number, distFn: DistanceFn): boolean; | ||
containsPoint(p: K): boolean; | ||
nodeForPoint(p: K): NdQtNode<K, V> | undefined; | ||
nodeForPoint(p: K): MaybeNdQtNode<K, V>; | ||
protected doQuery(p: K, r: number, max: number, acc: Heap<[number, NdQtNode<K, V>?]>, distFn: DistanceFn): Heap<[number, NdQtNode<K, V>?]>; | ||
@@ -69,4 +70,5 @@ protected ensureChild(id: number): NdQtNode<K, V>; | ||
containsPoint(p: K): boolean; | ||
nodeForPoint(p: K): NdQtNode<K, V> | undefined; | ||
nodeForPoint(p: K): MaybeNdQtNode<K, V>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=nd-quadtree-map.d.ts.map |
@@ -18,3 +18,3 @@ import { equivArrayLike } from "@thi.ng/equiv"; | ||
import { vop } from "@thi.ng/vectors/vop"; | ||
import { addResults, CMP, into } from "./utils.js"; | ||
import { CMP, __addResults, __into } from "./utils.js"; | ||
class NdQtNode { | ||
@@ -65,3 +65,3 @@ pos; | ||
query(fn, p, r, max, acc, distFn) { | ||
return addResults( | ||
return __addResults( | ||
fn, | ||
@@ -217,3 +217,3 @@ this.doQuery( | ||
into(pairs, eps = EPS) { | ||
return into(this, pairs, eps); | ||
return __into(this, pairs, eps); | ||
} | ||
@@ -220,0 +220,0 @@ remove(p) { |
{ | ||
"name": "@thi.ng/geom-accel", | ||
"version": "3.5.69", | ||
"version": "3.6.0", | ||
"description": "n-D spatial indexing data structures with a shared ES6 Map/Set-like API", | ||
@@ -40,14 +40,14 @@ "type": "module", | ||
"dependencies": { | ||
"@thi.ng/api": "^8.10.1", | ||
"@thi.ng/arrays": "^2.9.3", | ||
"@thi.ng/checks": "^3.6.1", | ||
"@thi.ng/distance": "^2.4.69", | ||
"@thi.ng/equiv": "^2.1.55", | ||
"@thi.ng/errors": "^2.5.4", | ||
"@thi.ng/geom-api": "^4.0.6", | ||
"@thi.ng/geom-isec": "^3.0.6", | ||
"@thi.ng/heaps": "^2.1.71", | ||
"@thi.ng/math": "^5.10.10", | ||
"@thi.ng/transducers": "^9.0.1", | ||
"@thi.ng/vectors": "^7.10.27" | ||
"@thi.ng/api": "^8.11.0", | ||
"@thi.ng/arrays": "^2.9.4", | ||
"@thi.ng/checks": "^3.6.2", | ||
"@thi.ng/distance": "^2.4.70", | ||
"@thi.ng/equiv": "^2.1.56", | ||
"@thi.ng/errors": "^2.5.5", | ||
"@thi.ng/geom-api": "^4.0.7", | ||
"@thi.ng/geom-isec": "^3.0.7", | ||
"@thi.ng/heaps": "^2.1.72", | ||
"@thi.ng/math": "^5.10.11", | ||
"@thi.ng/transducers": "^9.0.2", | ||
"@thi.ng/vectors": "^7.10.28" | ||
}, | ||
@@ -123,3 +123,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "18a0c063a7b33d790e5bc2486c106f45f663ac28\n" | ||
"gitHead": "8339d05ecc857e529c7325a9839c0063b89e728d\n" | ||
} |
@@ -64,6 +64,6 @@ <!-- This file is generated - DO NOT EDIT! --> | ||
```html | ||
<script type="module" src="https://cdn.skypack.dev/@thi.ng/geom-accel"></script> | ||
<script type="module" src="https://esm.run/@thi.ng/geom-accel"></script> | ||
``` | ||
[Skypack documentation](https://docs.skypack.dev/) | ||
[JSDelivr documentation](https://www.jsdelivr.com/) | ||
@@ -70,0 +70,0 @@ For Node.js REPL: |
@@ -8,3 +8,3 @@ import { isNumber } from "@thi.ng/checks/is-number"; | ||
import { ASpatialGrid } from "./aspatial-grid.js"; | ||
import { addResults, CMP } from "./utils.js"; | ||
import { __addResults, CMP } from "./utils.js"; | ||
const TMP = []; | ||
@@ -44,3 +44,3 @@ class SpatialGrid2 extends ASpatialGrid { | ||
} | ||
return addResults(fn, sel, acc); | ||
return __addResults(fn, sel, acc); | ||
} | ||
@@ -47,0 +47,0 @@ findIndex(k) { |
@@ -8,3 +8,3 @@ import { isNumber } from "@thi.ng/checks/is-number"; | ||
import { ASpatialGrid } from "./aspatial-grid.js"; | ||
import { addResults, CMP } from "./utils.js"; | ||
import { __addResults, CMP } from "./utils.js"; | ||
const TMP = []; | ||
@@ -50,3 +50,3 @@ class SpatialGrid3 extends ASpatialGrid { | ||
} | ||
return addResults(fn, sel, acc); | ||
return __addResults(fn, sel, acc); | ||
} | ||
@@ -53,0 +53,0 @@ findIndex(k) { |
import type { Fn, Fn3, Nullable, Pair } from "@thi.ng/api"; | ||
import type { ReadonlyVec } from "@thi.ng/vectors"; | ||
/** @internal */ | ||
export declare const CMP: (a: [number, any?], b: [number, any?]) => number; | ||
/** @internal */ | ||
export declare const addResults: <A, B>(fn: Fn<A, B>, sel: [number, Nullable<A>?][], acc: B[]) => B[]; | ||
export declare const __addResults: <A, B>(fn: Fn<A, B>, sel: [number, Nullable<A>?][], acc: B[]) => B[]; | ||
/** | ||
@@ -15,5 +16,7 @@ * Shared `into()` impl for spatial map types. | ||
*/ | ||
export declare const into: <K, V>(map: { | ||
export declare const __into: <K, V>(map: { | ||
set: Fn3<K, V, number, boolean>; | ||
}, pairs: Iterable<Pair<K, V>>, eps: number) => boolean; | ||
/** @internal */ | ||
export declare const __ensureRes: (res: ReadonlyVec, min?: number) => void; | ||
//# sourceMappingURL=utils.d.ts.map |
14
utils.js
@@ -0,3 +1,4 @@ | ||
import { assert } from "@thi.ng/errors/assert"; | ||
const CMP = (a, b) => b[0] - a[0]; | ||
const addResults = (fn, sel, acc) => { | ||
const __addResults = (fn, sel, acc) => { | ||
for (let n = sel.sort(CMP).length; n-- > 0; ) { | ||
@@ -9,3 +10,3 @@ const s = sel[n][1]; | ||
}; | ||
const into = (map, pairs, eps) => { | ||
const __into = (map, pairs, eps) => { | ||
let ok = true; | ||
@@ -17,6 +18,11 @@ for (let p of pairs) { | ||
}; | ||
const __ensureRes = (res, min = 1) => { | ||
for (let i = res.length; i-- > 0; ) | ||
assert(res[i] >= min, `invalid grid res: ${res}, require min=${min}`); | ||
}; | ||
export { | ||
CMP, | ||
addResults, | ||
into | ||
__addResults, | ||
__ensureRes, | ||
__into | ||
}; |
83383
1669
Updated@thi.ng/api@^8.11.0
Updated@thi.ng/arrays@^2.9.4
Updated@thi.ng/checks@^3.6.2
Updated@thi.ng/distance@^2.4.70
Updated@thi.ng/equiv@^2.1.56
Updated@thi.ng/errors@^2.5.5
Updated@thi.ng/geom-api@^4.0.7
Updated@thi.ng/geom-isec@^3.0.7
Updated@thi.ng/heaps@^2.1.72
Updated@thi.ng/math@^5.10.11
Updated@thi.ng/transducers@^9.0.2
Updated@thi.ng/vectors@^7.10.28