add lisp packages
This commit is contained in:
27
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/LICENSE
generated
vendored
Normal file
27
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
Copyright 2010-2016 Mike Bostock
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the author nor the names of contributors may be used to
|
||||
endorse or promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
163
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/README.md
generated
vendored
Normal file
163
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/README.md
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
# d3-quadtree
|
||||
|
||||
A [quadtree](https://en.wikipedia.org/wiki/Quadtree) recursively partitions two-dimensional space into squares, dividing each square into four equally-sized squares. Each distinct point exists in a unique leaf [node](#nodes); coincident points are represented by a linked list. Quadtrees can accelerate various spatial operations, such as the [Barnes–Hut approximation](https://en.wikipedia.org/wiki/Barnes–Hut_simulation) for computing many-body forces, collision detection, and searching for nearby points.
|
||||
|
||||
<a href="http://bl.ocks.org/mbostock/9078690"><img src="http://bl.ocks.org/mbostock/raw/9078690/thumbnail.png" width="202"></a>
|
||||
<a href="http://bl.ocks.org/mbostock/4343214"><img src="http://bl.ocks.org/mbostock/raw/4343214/thumbnail.png" width="202"></a>
|
||||
|
||||
## Installing
|
||||
|
||||
If you use NPM, `npm install d3-quadtree`. Otherwise, download the [latest release](https://github.com/d3/d3-quadtree/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-quadtree.v1.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
|
||||
|
||||
```html
|
||||
<script src="https://d3js.org/d3-quadtree.v1.min.js"></script>
|
||||
<script>
|
||||
|
||||
var quadtree = d3.quadtree();
|
||||
|
||||
</script>
|
||||
```
|
||||
|
||||
## API Reference
|
||||
|
||||
<a name="quadtree" href="#quadtree">#</a> d3.<b>quadtree</b>([<i>data</i>[, <i>x</i>, <i>y</i>]])
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/quadtree.js "Source")
|
||||
|
||||
Creates a new, empty quadtree with an empty [extent](#quadtree_extent) and the default [*x*-](#quadtree_x) and [*y*-](#quadtree_y)accessors. If *data* is specified, [adds](#quadtree_addAll) the specified array of data to the quadtree. This is equivalent to:
|
||||
|
||||
```js
|
||||
var tree = d3.quadtree()
|
||||
.addAll(data);
|
||||
```
|
||||
|
||||
If *x* and *y* are also specified, sets the [*x*-](#quadtree_x) and [*y*-](#quadtree_y) accessors to the specified functions before adding the specified array of data to the quadtree, equivalent to:
|
||||
|
||||
```js
|
||||
var tree = d3.quadtree()
|
||||
.x(x)
|
||||
.y(y)
|
||||
.addAll(data);
|
||||
```
|
||||
|
||||
<a name="quadtree_x" href="#quadtree_x">#</a> <i>quadtree</i>.<b>x</b>([<i>x</i>]) [<>](https://github.com/d3/d3-quadtree/blob/master/src/x.js "Source")
|
||||
|
||||
If *x* is specified, sets the current *x*-coordinate accessor and returns the quadtree. If *x* is not specified, returns the current *x*-accessor, which defaults to:
|
||||
|
||||
```js
|
||||
function x(d) {
|
||||
return d[0];
|
||||
}
|
||||
```
|
||||
|
||||
The *x*-acccessor is used to derive the *x*-coordinate of data when [adding](#quadtree_add) to and [removing](#quadtree_remove) from the tree. It is also used when [finding](#quadtree_find) to re-access the coordinates of data previously added to the tree; therefore, the *x*- and *y*-accessors must be consistent, returning the same value given the same input.
|
||||
|
||||
<a name="quadtree_y" href="#quadtree_y">#</a> <i>quadtree</i>.<b>y</b>([<i>y</i>])
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/y.js "Source")
|
||||
|
||||
If *y* is specified, sets the current *y*-coordinate accessor and returns the quadtree. If *y* is not specified, returns the current *y*-accessor, which defaults to:
|
||||
|
||||
```js
|
||||
function y(d) {
|
||||
return d[1];
|
||||
}
|
||||
```
|
||||
|
||||
The *y*-acccessor is used to derive the *y*-coordinate of data when [adding](#quadtree_add) to and [removing](#quadtree_remove) from the tree. It is also used when [finding](#quadtree_find) to re-access the coordinates of data previously added to the tree; therefore, the *x*- and *y*-accessors must be consistent, returning the same value given the same input.
|
||||
|
||||
<a name="quadtree_extent" href="#quadtree_extent">#</a> <i>quadtree</i>.<b>extent</b>([*extent*])
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/extent.js "Source")
|
||||
|
||||
If *extent* is specified, expands the quadtree to [cover](#quadtree_cover) the specified points [[*x0*, *y0*], [*x1*, *y1*]] and returns the quadtree. If *extent* is not specified, returns the quadtree’s current extent [[*x0*, *y0*], [*x1*, *y1*]], where *x0* and *y0* are the inclusive lower bounds and *x1* and *y1* are the inclusive upper bounds, or undefined if the quadtree has no extent. The extent may also be expanded by calling [*quadtree*.cover](#quadtree_cover) or [*quadtree*.add](#quadtree_add).
|
||||
|
||||
<a name="quadtree_cover" href="#quadtree_cover">#</a> <i>quadtree</i>.<b>cover</b>(<i>x</i>, <i>y</i>)
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/cover.js "Source")
|
||||
|
||||
Expands the quadtree to cover the specified point ⟨*x*,*y*⟩, and returns the quadtree. If the quadtree’s extent already covers the specified point, this method does nothing. If the quadtree has an extent, the extent is repeatedly doubled to cover the specified point, wrapping the [root](#quadtree_root) [node](#nodes) as necessary; if the quadtree is empty, the extent is initialized to the extent [[⌊*x*⌋, ⌊*y*⌋], [⌈*x*⌉, ⌈*y*⌉]]. (Rounding is necessary such that if the extent is later doubled, the boundaries of existing quadrants do not change due to floating point error.)
|
||||
|
||||
<a name="quadtree_add" href="#quadtree_add">#</a> <i>quadtree</i>.<b>add</b>(<i>datum</i>)
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/add.js "Source")
|
||||
|
||||
Adds the specified *datum* to the quadtree, deriving its coordinates ⟨*x*,*y*⟩ using the current [*x*-](#quadtree_x) and [*y*-](#quadtree_y)accessors, and returns the quadtree. If the new point is outside the current [extent](#quadtree_extent) of the quadtree, the quadtree is automatically expanded to [cover](#quadtree_cover) the new point.
|
||||
|
||||
<a name="quadtree_addAll" href="#quadtree_addAll">#</a> <i>quadtree</i>.<b>addAll</b>(<i>data</i>)
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/add.js "Source")
|
||||
|
||||
Adds the specified array of *data* to the quadtree, deriving each element’s coordinates ⟨*x*,*y*⟩ using the current [*x*-](#quadtree_x) and [*y*-](#quadtree_y)accessors, and return this quadtree. This is approximately equivalent to calling [*quadtree*.add](#quadtree_add) repeatedly:
|
||||
|
||||
```js
|
||||
for (var i = 0, n = data.length; i < n; ++i) {
|
||||
quadtree.add(data[i]);
|
||||
}
|
||||
```
|
||||
|
||||
However, this method results in a more compact quadtree because the extent of the *data* is computed first before adding the data.
|
||||
|
||||
<a name="quadtree_remove" href="#quadtree_remove">#</a> <i>quadtree</i>.<b>remove</b>(<i>datum</i>)
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/remove.js "Source")
|
||||
|
||||
Removes the specified *datum* from the quadtree, deriving its coordinates ⟨*x*,*y*⟩ using the current [*x*-](#quadtree_x) and [*y*-](#quadtree_y)accessors, and returns the quadtree. If the specified *datum* does not exist in this quadtree, this method does nothing.
|
||||
|
||||
<a name="quadtree_removeAll" href="#quadtree_removeAll">#</a> <i>quadtree</i>.<b>removeAll</b>(<i>data</i>)
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/remove.js "Source")
|
||||
|
||||
Removes the specified *data* from the quadtree, deriving their coordinates ⟨*x*,*y*⟩ using the current [*x*-](#quadtree_x) and [*y*-](#quadtree_y)accessors, and returns the quadtree. If a specified datum does not exist in this quadtree, it is ignored.
|
||||
|
||||
<a name="quadtree_copy" href="#quadtree_copy">#</a> <i>quadtree</i>.<b>copy</b>()
|
||||
|
||||
Returns a copy of the quadtree. All [nodes](#nodes) in the returned quadtree are identical copies of the corresponding node in the quadtree; however, any data in the quadtree is shared by reference and not copied.
|
||||
|
||||
<a name="quadtree_root" href="#quadtree_root">#</a> <i>quadtree</i>.<b>root</b>()
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/root.js "Source")
|
||||
|
||||
Returns the root [node](#nodes) of the quadtree.
|
||||
|
||||
<a name="quadtree_data" href="#quadtree_data">#</a> <i>quadtree</i>.<b>data</b>()
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/data.js "Source")
|
||||
|
||||
Returns an array of all data in the quadtree.
|
||||
|
||||
<a name="quadtree_size" href="#quadtree_size">#</a> <i>quadtree</i>.<b>size</b>()
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/size.js "Source")
|
||||
|
||||
Returns the total number of data in the quadtree.
|
||||
|
||||
<a name="quadtree_find" href="#quadtree_find">#</a> <i>quadtree</i>.<b>find</b>(<i>x</i>, <i>y</i>[, <i>radius</i>])
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/find.js "Source")
|
||||
|
||||
Returns the datum closest to the position ⟨*x*,*y*⟩ with the given search *radius*. If *radius* is not specified, it defaults to infinity. If there is no datum within the search area, returns undefined.
|
||||
|
||||
<a name="quadtree_visit" href="#quadtree_visit">#</a> <i>quadtree</i>.<b>visit</b>(<i>callback</i>)
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/visit.js "Source")
|
||||
|
||||
Visits each [node](#nodes) in the quadtree in pre-order traversal, invoking the specified *callback* with arguments *node*, *x0*, *y0*, *x1*, *y1* for each node, where *node* is the node being visited, ⟨*x0*, *y0*⟩ are the lower bounds of the node, and ⟨*x1*, *y1*⟩ are the upper bounds, and returns the quadtree. (Assuming that positive *x* is right and positive *y* is down, as is typically the case in Canvas and SVG, ⟨*x0*, *y0*⟩ is the top-left corner and ⟨*x1*, *y1*⟩ is the lower-right corner; however, the coordinate system is arbitrary, so more formally *x0* <= *x1* and *y0* <= *y1*.)
|
||||
|
||||
If the *callback* returns true for a given node, then the children of that node are not visited; otherwise, all child nodes are visited. This can be used to quickly visit only parts of the tree, for example when using the [Barnes–Hut approximation](https://en.wikipedia.org/wiki/Barnes–Hut_simulation). Note, however, that child quadrants are always visited in sibling order: top-left, top-right, bottom-left, bottom-right. In cases such as [search](#quadtree_find), visiting siblings in a specific order may be faster.
|
||||
|
||||
<a name="quadtree_visitAfter" href="#quadtree_visitAfter">#</a> <i>quadtree</i>.<b>visitAfter</b>(<i>callback</i>)
|
||||
[<>](https://github.com/d3/d3-quadtree/blob/master/src/visitAfter.js "Source")
|
||||
|
||||
Visits each [node](#nodes) in the quadtree in post-order traversal, invoking the specified *callback* with arguments *node*, *x0*, *y0*, *x1*, *y1* for each node, where *node* is the node being visited, ⟨*x0*, *y0*⟩ are the lower bounds of the node, and ⟨*x1*, *y1*⟩ are the upper bounds, and returns the quadtree. (Assuming that positive *x* is right and positive *y* is down, as is typically the case in Canvas and SVG, ⟨*x0*, *y0*⟩ is the top-left corner and ⟨*x1*, *y1*⟩ is the lower-right corner; however, the coordinate system is arbitrary, so more formally *x0* <= *x1* and *y0* <= *y1*.) Returns *root*.
|
||||
|
||||
### Nodes
|
||||
|
||||
Internal nodes of the quadtree are represented as four-element arrays in left-to-right, top-to-bottom order:
|
||||
|
||||
* `0` - the top-left quadrant, if any.
|
||||
* `1` - the top-right quadrant, if any.
|
||||
* `2` - the bottom-left quadrant, if any.
|
||||
* `3` - the bottom-right quadrant, if any.
|
||||
|
||||
A child quadrant may be undefined if it is empty.
|
||||
|
||||
Leaf nodes are represented as objects with the following properties:
|
||||
|
||||
* `data` - the data associated with this point, as passed to [*quadtree*.add](#quadtree_add).
|
||||
* `next` - the next datum in this leaf, if any.
|
||||
|
||||
The `length` property may be used to distinguish leaf nodes from internal nodes: it is undefined for leaf nodes, and 4 for internal nodes. For example, to iterate over all data in a leaf node:
|
||||
|
||||
```js
|
||||
if (!node.length) do console.log(node.data); while (node = node.next);
|
||||
```
|
||||
|
||||
The point’s *x*- and *y*-coordinates **must not be modified** while the point is in the quadtree. To update a point’s position, [remove](#quadtree_remove) the point and then re-[add](#quadtree_add) it to the quadtree at the new position. Alternatively, you may discard the existing quadtree entirely and create a new one from scratch; this may be more efficient if many of the points have moved.
|
||||
419
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/dist/d3-quadtree.js
generated
vendored
Normal file
419
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/dist/d3-quadtree.js
generated
vendored
Normal file
@@ -0,0 +1,419 @@
|
||||
// https://d3js.org/d3-quadtree/ v1.0.7 Copyright 2019 Mike Bostock
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = global || self, factory(global.d3 = global.d3 || {}));
|
||||
}(this, function (exports) { 'use strict';
|
||||
|
||||
function tree_add(d) {
|
||||
var x = +this._x.call(null, d),
|
||||
y = +this._y.call(null, d);
|
||||
return add(this.cover(x, y), x, y, d);
|
||||
}
|
||||
|
||||
function add(tree, x, y, d) {
|
||||
if (isNaN(x) || isNaN(y)) return tree; // ignore invalid points
|
||||
|
||||
var parent,
|
||||
node = tree._root,
|
||||
leaf = {data: d},
|
||||
x0 = tree._x0,
|
||||
y0 = tree._y0,
|
||||
x1 = tree._x1,
|
||||
y1 = tree._y1,
|
||||
xm,
|
||||
ym,
|
||||
xp,
|
||||
yp,
|
||||
right,
|
||||
bottom,
|
||||
i,
|
||||
j;
|
||||
|
||||
// If the tree is empty, initialize the root as a leaf.
|
||||
if (!node) return tree._root = leaf, tree;
|
||||
|
||||
// Find the existing leaf for the new point, or add it.
|
||||
while (node.length) {
|
||||
if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm;
|
||||
if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym;
|
||||
if (parent = node, !(node = node[i = bottom << 1 | right])) return parent[i] = leaf, tree;
|
||||
}
|
||||
|
||||
// Is the new point is exactly coincident with the existing point?
|
||||
xp = +tree._x.call(null, node.data);
|
||||
yp = +tree._y.call(null, node.data);
|
||||
if (x === xp && y === yp) return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree;
|
||||
|
||||
// Otherwise, split the leaf node until the old and new point are separated.
|
||||
do {
|
||||
parent = parent ? parent[i] = new Array(4) : tree._root = new Array(4);
|
||||
if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm;
|
||||
if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym;
|
||||
} while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | (xp >= xm)));
|
||||
return parent[j] = node, parent[i] = leaf, tree;
|
||||
}
|
||||
|
||||
function addAll(data) {
|
||||
var d, i, n = data.length,
|
||||
x,
|
||||
y,
|
||||
xz = new Array(n),
|
||||
yz = new Array(n),
|
||||
x0 = Infinity,
|
||||
y0 = Infinity,
|
||||
x1 = -Infinity,
|
||||
y1 = -Infinity;
|
||||
|
||||
// Compute the points and their extent.
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (isNaN(x = +this._x.call(null, d = data[i])) || isNaN(y = +this._y.call(null, d))) continue;
|
||||
xz[i] = x;
|
||||
yz[i] = y;
|
||||
if (x < x0) x0 = x;
|
||||
if (x > x1) x1 = x;
|
||||
if (y < y0) y0 = y;
|
||||
if (y > y1) y1 = y;
|
||||
}
|
||||
|
||||
// If there were no (valid) points, abort.
|
||||
if (x0 > x1 || y0 > y1) return this;
|
||||
|
||||
// Expand the tree to cover the new points.
|
||||
this.cover(x0, y0).cover(x1, y1);
|
||||
|
||||
// Add the new points.
|
||||
for (i = 0; i < n; ++i) {
|
||||
add(this, xz[i], yz[i], data[i]);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function tree_cover(x, y) {
|
||||
if (isNaN(x = +x) || isNaN(y = +y)) return this; // ignore invalid points
|
||||
|
||||
var x0 = this._x0,
|
||||
y0 = this._y0,
|
||||
x1 = this._x1,
|
||||
y1 = this._y1;
|
||||
|
||||
// If the quadtree has no extent, initialize them.
|
||||
// Integer extent are necessary so that if we later double the extent,
|
||||
// the existing quadrant boundaries don’t change due to floating point error!
|
||||
if (isNaN(x0)) {
|
||||
x1 = (x0 = Math.floor(x)) + 1;
|
||||
y1 = (y0 = Math.floor(y)) + 1;
|
||||
}
|
||||
|
||||
// Otherwise, double repeatedly to cover.
|
||||
else {
|
||||
var z = x1 - x0,
|
||||
node = this._root,
|
||||
parent,
|
||||
i;
|
||||
|
||||
while (x0 > x || x >= x1 || y0 > y || y >= y1) {
|
||||
i = (y < y0) << 1 | (x < x0);
|
||||
parent = new Array(4), parent[i] = node, node = parent, z *= 2;
|
||||
switch (i) {
|
||||
case 0: x1 = x0 + z, y1 = y0 + z; break;
|
||||
case 1: x0 = x1 - z, y1 = y0 + z; break;
|
||||
case 2: x1 = x0 + z, y0 = y1 - z; break;
|
||||
case 3: x0 = x1 - z, y0 = y1 - z; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._root && this._root.length) this._root = node;
|
||||
}
|
||||
|
||||
this._x0 = x0;
|
||||
this._y0 = y0;
|
||||
this._x1 = x1;
|
||||
this._y1 = y1;
|
||||
return this;
|
||||
}
|
||||
|
||||
function tree_data() {
|
||||
var data = [];
|
||||
this.visit(function(node) {
|
||||
if (!node.length) do data.push(node.data); while (node = node.next)
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
function tree_extent(_) {
|
||||
return arguments.length
|
||||
? this.cover(+_[0][0], +_[0][1]).cover(+_[1][0], +_[1][1])
|
||||
: isNaN(this._x0) ? undefined : [[this._x0, this._y0], [this._x1, this._y1]];
|
||||
}
|
||||
|
||||
function Quad(node, x0, y0, x1, y1) {
|
||||
this.node = node;
|
||||
this.x0 = x0;
|
||||
this.y0 = y0;
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
}
|
||||
|
||||
function tree_find(x, y, radius) {
|
||||
var data,
|
||||
x0 = this._x0,
|
||||
y0 = this._y0,
|
||||
x1,
|
||||
y1,
|
||||
x2,
|
||||
y2,
|
||||
x3 = this._x1,
|
||||
y3 = this._y1,
|
||||
quads = [],
|
||||
node = this._root,
|
||||
q,
|
||||
i;
|
||||
|
||||
if (node) quads.push(new Quad(node, x0, y0, x3, y3));
|
||||
if (radius == null) radius = Infinity;
|
||||
else {
|
||||
x0 = x - radius, y0 = y - radius;
|
||||
x3 = x + radius, y3 = y + radius;
|
||||
radius *= radius;
|
||||
}
|
||||
|
||||
while (q = quads.pop()) {
|
||||
|
||||
// Stop searching if this quadrant can’t contain a closer node.
|
||||
if (!(node = q.node)
|
||||
|| (x1 = q.x0) > x3
|
||||
|| (y1 = q.y0) > y3
|
||||
|| (x2 = q.x1) < x0
|
||||
|| (y2 = q.y1) < y0) continue;
|
||||
|
||||
// Bisect the current quadrant.
|
||||
if (node.length) {
|
||||
var xm = (x1 + x2) / 2,
|
||||
ym = (y1 + y2) / 2;
|
||||
|
||||
quads.push(
|
||||
new Quad(node[3], xm, ym, x2, y2),
|
||||
new Quad(node[2], x1, ym, xm, y2),
|
||||
new Quad(node[1], xm, y1, x2, ym),
|
||||
new Quad(node[0], x1, y1, xm, ym)
|
||||
);
|
||||
|
||||
// Visit the closest quadrant first.
|
||||
if (i = (y >= ym) << 1 | (x >= xm)) {
|
||||
q = quads[quads.length - 1];
|
||||
quads[quads.length - 1] = quads[quads.length - 1 - i];
|
||||
quads[quads.length - 1 - i] = q;
|
||||
}
|
||||
}
|
||||
|
||||
// Visit this point. (Visiting coincident points isn’t necessary!)
|
||||
else {
|
||||
var dx = x - +this._x.call(null, node.data),
|
||||
dy = y - +this._y.call(null, node.data),
|
||||
d2 = dx * dx + dy * dy;
|
||||
if (d2 < radius) {
|
||||
var d = Math.sqrt(radius = d2);
|
||||
x0 = x - d, y0 = y - d;
|
||||
x3 = x + d, y3 = y + d;
|
||||
data = node.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function tree_remove(d) {
|
||||
if (isNaN(x = +this._x.call(null, d)) || isNaN(y = +this._y.call(null, d))) return this; // ignore invalid points
|
||||
|
||||
var parent,
|
||||
node = this._root,
|
||||
retainer,
|
||||
previous,
|
||||
next,
|
||||
x0 = this._x0,
|
||||
y0 = this._y0,
|
||||
x1 = this._x1,
|
||||
y1 = this._y1,
|
||||
x,
|
||||
y,
|
||||
xm,
|
||||
ym,
|
||||
right,
|
||||
bottom,
|
||||
i,
|
||||
j;
|
||||
|
||||
// If the tree is empty, initialize the root as a leaf.
|
||||
if (!node) return this;
|
||||
|
||||
// Find the leaf node for the point.
|
||||
// While descending, also retain the deepest parent with a non-removed sibling.
|
||||
if (node.length) while (true) {
|
||||
if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm;
|
||||
if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym;
|
||||
if (!(parent = node, node = node[i = bottom << 1 | right])) return this;
|
||||
if (!node.length) break;
|
||||
if (parent[(i + 1) & 3] || parent[(i + 2) & 3] || parent[(i + 3) & 3]) retainer = parent, j = i;
|
||||
}
|
||||
|
||||
// Find the point to remove.
|
||||
while (node.data !== d) if (!(previous = node, node = node.next)) return this;
|
||||
if (next = node.next) delete node.next;
|
||||
|
||||
// If there are multiple coincident points, remove just the point.
|
||||
if (previous) return (next ? previous.next = next : delete previous.next), this;
|
||||
|
||||
// If this is the root point, remove it.
|
||||
if (!parent) return this._root = next, this;
|
||||
|
||||
// Remove this leaf.
|
||||
next ? parent[i] = next : delete parent[i];
|
||||
|
||||
// If the parent now contains exactly one leaf, collapse superfluous parents.
|
||||
if ((node = parent[0] || parent[1] || parent[2] || parent[3])
|
||||
&& node === (parent[3] || parent[2] || parent[1] || parent[0])
|
||||
&& !node.length) {
|
||||
if (retainer) retainer[j] = node;
|
||||
else this._root = node;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function removeAll(data) {
|
||||
for (var i = 0, n = data.length; i < n; ++i) this.remove(data[i]);
|
||||
return this;
|
||||
}
|
||||
|
||||
function tree_root() {
|
||||
return this._root;
|
||||
}
|
||||
|
||||
function tree_size() {
|
||||
var size = 0;
|
||||
this.visit(function(node) {
|
||||
if (!node.length) do ++size; while (node = node.next)
|
||||
});
|
||||
return size;
|
||||
}
|
||||
|
||||
function tree_visit(callback) {
|
||||
var quads = [], q, node = this._root, child, x0, y0, x1, y1;
|
||||
if (node) quads.push(new Quad(node, this._x0, this._y0, this._x1, this._y1));
|
||||
while (q = quads.pop()) {
|
||||
if (!callback(node = q.node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.length) {
|
||||
var xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
|
||||
if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1));
|
||||
if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1));
|
||||
if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym));
|
||||
if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
function tree_visitAfter(callback) {
|
||||
var quads = [], next = [], q;
|
||||
if (this._root) quads.push(new Quad(this._root, this._x0, this._y0, this._x1, this._y1));
|
||||
while (q = quads.pop()) {
|
||||
var node = q.node;
|
||||
if (node.length) {
|
||||
var child, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1, xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
|
||||
if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym));
|
||||
if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym));
|
||||
if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1));
|
||||
if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1));
|
||||
}
|
||||
next.push(q);
|
||||
}
|
||||
while (q = next.pop()) {
|
||||
callback(q.node, q.x0, q.y0, q.x1, q.y1);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
function defaultX(d) {
|
||||
return d[0];
|
||||
}
|
||||
|
||||
function tree_x(_) {
|
||||
return arguments.length ? (this._x = _, this) : this._x;
|
||||
}
|
||||
|
||||
function defaultY(d) {
|
||||
return d[1];
|
||||
}
|
||||
|
||||
function tree_y(_) {
|
||||
return arguments.length ? (this._y = _, this) : this._y;
|
||||
}
|
||||
|
||||
function quadtree(nodes, x, y) {
|
||||
var tree = new Quadtree(x == null ? defaultX : x, y == null ? defaultY : y, NaN, NaN, NaN, NaN);
|
||||
return nodes == null ? tree : tree.addAll(nodes);
|
||||
}
|
||||
|
||||
function Quadtree(x, y, x0, y0, x1, y1) {
|
||||
this._x = x;
|
||||
this._y = y;
|
||||
this._x0 = x0;
|
||||
this._y0 = y0;
|
||||
this._x1 = x1;
|
||||
this._y1 = y1;
|
||||
this._root = undefined;
|
||||
}
|
||||
|
||||
function leaf_copy(leaf) {
|
||||
var copy = {data: leaf.data}, next = copy;
|
||||
while (leaf = leaf.next) next = next.next = {data: leaf.data};
|
||||
return copy;
|
||||
}
|
||||
|
||||
var treeProto = quadtree.prototype = Quadtree.prototype;
|
||||
|
||||
treeProto.copy = function() {
|
||||
var copy = new Quadtree(this._x, this._y, this._x0, this._y0, this._x1, this._y1),
|
||||
node = this._root,
|
||||
nodes,
|
||||
child;
|
||||
|
||||
if (!node) return copy;
|
||||
|
||||
if (!node.length) return copy._root = leaf_copy(node), copy;
|
||||
|
||||
nodes = [{source: node, target: copy._root = new Array(4)}];
|
||||
while (node = nodes.pop()) {
|
||||
for (var i = 0; i < 4; ++i) {
|
||||
if (child = node.source[i]) {
|
||||
if (child.length) nodes.push({source: child, target: node.target[i] = new Array(4)});
|
||||
else node.target[i] = leaf_copy(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return copy;
|
||||
};
|
||||
|
||||
treeProto.add = tree_add;
|
||||
treeProto.addAll = addAll;
|
||||
treeProto.cover = tree_cover;
|
||||
treeProto.data = tree_data;
|
||||
treeProto.extent = tree_extent;
|
||||
treeProto.find = tree_find;
|
||||
treeProto.remove = tree_remove;
|
||||
treeProto.removeAll = removeAll;
|
||||
treeProto.root = tree_root;
|
||||
treeProto.size = tree_size;
|
||||
treeProto.visit = tree_visit;
|
||||
treeProto.visitAfter = tree_visitAfter;
|
||||
treeProto.x = tree_x;
|
||||
treeProto.y = tree_y;
|
||||
|
||||
exports.quadtree = quadtree;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
}));
|
||||
2
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/dist/d3-quadtree.min.js
generated
vendored
Normal file
2
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/dist/d3-quadtree.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
42
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/package.json
generated
vendored
Normal file
42
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "d3-quadtree",
|
||||
"version": "1.0.7",
|
||||
"description": "Two-dimensional recursive spatial subdivision.",
|
||||
"keywords": [
|
||||
"d3",
|
||||
"d3-module",
|
||||
"quadtree"
|
||||
],
|
||||
"homepage": "https://d3js.org/d3-quadtree/",
|
||||
"license": "BSD-3-Clause",
|
||||
"author": {
|
||||
"name": "Mike Bostock",
|
||||
"url": "http://bost.ocks.org/mike"
|
||||
},
|
||||
"main": "dist/d3-quadtree.js",
|
||||
"unpkg": "dist/d3-quadtree.min.js",
|
||||
"jsdelivr": "dist/d3-quadtree.min.js",
|
||||
"module": "src/index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/d3/d3-quadtree.git"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*.js",
|
||||
"src/**/*.js"
|
||||
],
|
||||
"scripts": {
|
||||
"pretest": "rollup -c",
|
||||
"test": "tape 'test/**/*-test.js' && eslint src test",
|
||||
"prepublishOnly": "rm -rf dist && yarn test",
|
||||
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd - && zip -j dist/${npm_package_name}.zip -- LICENSE README.md dist/${npm_package_name}.js dist/${npm_package_name}.min.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"devDependencies": {
|
||||
"d3-array": "1 - 2",
|
||||
"eslint": "6",
|
||||
"rollup": "1",
|
||||
"rollup-plugin-terser": "5",
|
||||
"tape": "4"
|
||||
}
|
||||
}
|
||||
84
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/add.js
generated
vendored
Normal file
84
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/add.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
export default function(d) {
|
||||
var x = +this._x.call(null, d),
|
||||
y = +this._y.call(null, d);
|
||||
return add(this.cover(x, y), x, y, d);
|
||||
}
|
||||
|
||||
function add(tree, x, y, d) {
|
||||
if (isNaN(x) || isNaN(y)) return tree; // ignore invalid points
|
||||
|
||||
var parent,
|
||||
node = tree._root,
|
||||
leaf = {data: d},
|
||||
x0 = tree._x0,
|
||||
y0 = tree._y0,
|
||||
x1 = tree._x1,
|
||||
y1 = tree._y1,
|
||||
xm,
|
||||
ym,
|
||||
xp,
|
||||
yp,
|
||||
right,
|
||||
bottom,
|
||||
i,
|
||||
j;
|
||||
|
||||
// If the tree is empty, initialize the root as a leaf.
|
||||
if (!node) return tree._root = leaf, tree;
|
||||
|
||||
// Find the existing leaf for the new point, or add it.
|
||||
while (node.length) {
|
||||
if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm;
|
||||
if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym;
|
||||
if (parent = node, !(node = node[i = bottom << 1 | right])) return parent[i] = leaf, tree;
|
||||
}
|
||||
|
||||
// Is the new point is exactly coincident with the existing point?
|
||||
xp = +tree._x.call(null, node.data);
|
||||
yp = +tree._y.call(null, node.data);
|
||||
if (x === xp && y === yp) return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree;
|
||||
|
||||
// Otherwise, split the leaf node until the old and new point are separated.
|
||||
do {
|
||||
parent = parent ? parent[i] = new Array(4) : tree._root = new Array(4);
|
||||
if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm;
|
||||
if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym;
|
||||
} while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | (xp >= xm)));
|
||||
return parent[j] = node, parent[i] = leaf, tree;
|
||||
}
|
||||
|
||||
export function addAll(data) {
|
||||
var d, i, n = data.length,
|
||||
x,
|
||||
y,
|
||||
xz = new Array(n),
|
||||
yz = new Array(n),
|
||||
x0 = Infinity,
|
||||
y0 = Infinity,
|
||||
x1 = -Infinity,
|
||||
y1 = -Infinity;
|
||||
|
||||
// Compute the points and their extent.
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (isNaN(x = +this._x.call(null, d = data[i])) || isNaN(y = +this._y.call(null, d))) continue;
|
||||
xz[i] = x;
|
||||
yz[i] = y;
|
||||
if (x < x0) x0 = x;
|
||||
if (x > x1) x1 = x;
|
||||
if (y < y0) y0 = y;
|
||||
if (y > y1) y1 = y;
|
||||
}
|
||||
|
||||
// If there were no (valid) points, abort.
|
||||
if (x0 > x1 || y0 > y1) return this;
|
||||
|
||||
// Expand the tree to cover the new points.
|
||||
this.cover(x0, y0).cover(x1, y1);
|
||||
|
||||
// Add the new points.
|
||||
for (i = 0; i < n; ++i) {
|
||||
add(this, xz[i], yz[i], data[i]);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
43
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/cover.js
generated
vendored
Normal file
43
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/cover.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
export default function(x, y) {
|
||||
if (isNaN(x = +x) || isNaN(y = +y)) return this; // ignore invalid points
|
||||
|
||||
var x0 = this._x0,
|
||||
y0 = this._y0,
|
||||
x1 = this._x1,
|
||||
y1 = this._y1;
|
||||
|
||||
// If the quadtree has no extent, initialize them.
|
||||
// Integer extent are necessary so that if we later double the extent,
|
||||
// the existing quadrant boundaries don’t change due to floating point error!
|
||||
if (isNaN(x0)) {
|
||||
x1 = (x0 = Math.floor(x)) + 1;
|
||||
y1 = (y0 = Math.floor(y)) + 1;
|
||||
}
|
||||
|
||||
// Otherwise, double repeatedly to cover.
|
||||
else {
|
||||
var z = x1 - x0,
|
||||
node = this._root,
|
||||
parent,
|
||||
i;
|
||||
|
||||
while (x0 > x || x >= x1 || y0 > y || y >= y1) {
|
||||
i = (y < y0) << 1 | (x < x0);
|
||||
parent = new Array(4), parent[i] = node, node = parent, z *= 2;
|
||||
switch (i) {
|
||||
case 0: x1 = x0 + z, y1 = y0 + z; break;
|
||||
case 1: x0 = x1 - z, y1 = y0 + z; break;
|
||||
case 2: x1 = x0 + z, y0 = y1 - z; break;
|
||||
case 3: x0 = x1 - z, y0 = y1 - z; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._root && this._root.length) this._root = node;
|
||||
}
|
||||
|
||||
this._x0 = x0;
|
||||
this._y0 = y0;
|
||||
this._x1 = x1;
|
||||
this._y1 = y1;
|
||||
return this;
|
||||
}
|
||||
7
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/data.js
generated
vendored
Normal file
7
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/data.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default function() {
|
||||
var data = [];
|
||||
this.visit(function(node) {
|
||||
if (!node.length) do data.push(node.data); while (node = node.next)
|
||||
});
|
||||
return data;
|
||||
}
|
||||
5
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/extent.js
generated
vendored
Normal file
5
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/extent.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export default function(_) {
|
||||
return arguments.length
|
||||
? this.cover(+_[0][0], +_[0][1]).cover(+_[1][0], +_[1][1])
|
||||
: isNaN(this._x0) ? undefined : [[this._x0, this._y0], [this._x1, this._y1]];
|
||||
}
|
||||
70
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/find.js
generated
vendored
Normal file
70
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/find.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
import Quad from "./quad.js";
|
||||
|
||||
export default function(x, y, radius) {
|
||||
var data,
|
||||
x0 = this._x0,
|
||||
y0 = this._y0,
|
||||
x1,
|
||||
y1,
|
||||
x2,
|
||||
y2,
|
||||
x3 = this._x1,
|
||||
y3 = this._y1,
|
||||
quads = [],
|
||||
node = this._root,
|
||||
q,
|
||||
i;
|
||||
|
||||
if (node) quads.push(new Quad(node, x0, y0, x3, y3));
|
||||
if (radius == null) radius = Infinity;
|
||||
else {
|
||||
x0 = x - radius, y0 = y - radius;
|
||||
x3 = x + radius, y3 = y + radius;
|
||||
radius *= radius;
|
||||
}
|
||||
|
||||
while (q = quads.pop()) {
|
||||
|
||||
// Stop searching if this quadrant can’t contain a closer node.
|
||||
if (!(node = q.node)
|
||||
|| (x1 = q.x0) > x3
|
||||
|| (y1 = q.y0) > y3
|
||||
|| (x2 = q.x1) < x0
|
||||
|| (y2 = q.y1) < y0) continue;
|
||||
|
||||
// Bisect the current quadrant.
|
||||
if (node.length) {
|
||||
var xm = (x1 + x2) / 2,
|
||||
ym = (y1 + y2) / 2;
|
||||
|
||||
quads.push(
|
||||
new Quad(node[3], xm, ym, x2, y2),
|
||||
new Quad(node[2], x1, ym, xm, y2),
|
||||
new Quad(node[1], xm, y1, x2, ym),
|
||||
new Quad(node[0], x1, y1, xm, ym)
|
||||
);
|
||||
|
||||
// Visit the closest quadrant first.
|
||||
if (i = (y >= ym) << 1 | (x >= xm)) {
|
||||
q = quads[quads.length - 1];
|
||||
quads[quads.length - 1] = quads[quads.length - 1 - i];
|
||||
quads[quads.length - 1 - i] = q;
|
||||
}
|
||||
}
|
||||
|
||||
// Visit this point. (Visiting coincident points isn’t necessary!)
|
||||
else {
|
||||
var dx = x - +this._x.call(null, node.data),
|
||||
dy = y - +this._y.call(null, node.data),
|
||||
d2 = dx * dx + dy * dy;
|
||||
if (d2 < radius) {
|
||||
var d = Math.sqrt(radius = d2);
|
||||
x0 = x - d, y0 = y - d;
|
||||
x3 = x + d, y3 = y + d;
|
||||
data = node.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
1
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/index.js
generated
vendored
Normal file
1
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {default as quadtree} from "./quadtree.js";
|
||||
7
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/quad.js
generated
vendored
Normal file
7
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/quad.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default function(node, x0, y0, x1, y1) {
|
||||
this.node = node;
|
||||
this.x0 = x0;
|
||||
this.y0 = y0;
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
}
|
||||
73
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/quadtree.js
generated
vendored
Normal file
73
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/quadtree.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
import tree_add, {addAll as tree_addAll} from "./add.js";
|
||||
import tree_cover from "./cover.js";
|
||||
import tree_data from "./data.js";
|
||||
import tree_extent from "./extent.js";
|
||||
import tree_find from "./find.js";
|
||||
import tree_remove, {removeAll as tree_removeAll} from "./remove.js";
|
||||
import tree_root from "./root.js";
|
||||
import tree_size from "./size.js";
|
||||
import tree_visit from "./visit.js";
|
||||
import tree_visitAfter from "./visitAfter.js";
|
||||
import tree_x, {defaultX} from "./x.js";
|
||||
import tree_y, {defaultY} from "./y.js";
|
||||
|
||||
export default function quadtree(nodes, x, y) {
|
||||
var tree = new Quadtree(x == null ? defaultX : x, y == null ? defaultY : y, NaN, NaN, NaN, NaN);
|
||||
return nodes == null ? tree : tree.addAll(nodes);
|
||||
}
|
||||
|
||||
function Quadtree(x, y, x0, y0, x1, y1) {
|
||||
this._x = x;
|
||||
this._y = y;
|
||||
this._x0 = x0;
|
||||
this._y0 = y0;
|
||||
this._x1 = x1;
|
||||
this._y1 = y1;
|
||||
this._root = undefined;
|
||||
}
|
||||
|
||||
function leaf_copy(leaf) {
|
||||
var copy = {data: leaf.data}, next = copy;
|
||||
while (leaf = leaf.next) next = next.next = {data: leaf.data};
|
||||
return copy;
|
||||
}
|
||||
|
||||
var treeProto = quadtree.prototype = Quadtree.prototype;
|
||||
|
||||
treeProto.copy = function() {
|
||||
var copy = new Quadtree(this._x, this._y, this._x0, this._y0, this._x1, this._y1),
|
||||
node = this._root,
|
||||
nodes,
|
||||
child;
|
||||
|
||||
if (!node) return copy;
|
||||
|
||||
if (!node.length) return copy._root = leaf_copy(node), copy;
|
||||
|
||||
nodes = [{source: node, target: copy._root = new Array(4)}];
|
||||
while (node = nodes.pop()) {
|
||||
for (var i = 0; i < 4; ++i) {
|
||||
if (child = node.source[i]) {
|
||||
if (child.length) nodes.push({source: child, target: node.target[i] = new Array(4)});
|
||||
else node.target[i] = leaf_copy(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return copy;
|
||||
};
|
||||
|
||||
treeProto.add = tree_add;
|
||||
treeProto.addAll = tree_addAll;
|
||||
treeProto.cover = tree_cover;
|
||||
treeProto.data = tree_data;
|
||||
treeProto.extent = tree_extent;
|
||||
treeProto.find = tree_find;
|
||||
treeProto.remove = tree_remove;
|
||||
treeProto.removeAll = tree_removeAll;
|
||||
treeProto.root = tree_root;
|
||||
treeProto.size = tree_size;
|
||||
treeProto.visit = tree_visit;
|
||||
treeProto.visitAfter = tree_visitAfter;
|
||||
treeProto.x = tree_x;
|
||||
treeProto.y = tree_y;
|
||||
62
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/remove.js
generated
vendored
Normal file
62
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/remove.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
export default function(d) {
|
||||
if (isNaN(x = +this._x.call(null, d)) || isNaN(y = +this._y.call(null, d))) return this; // ignore invalid points
|
||||
|
||||
var parent,
|
||||
node = this._root,
|
||||
retainer,
|
||||
previous,
|
||||
next,
|
||||
x0 = this._x0,
|
||||
y0 = this._y0,
|
||||
x1 = this._x1,
|
||||
y1 = this._y1,
|
||||
x,
|
||||
y,
|
||||
xm,
|
||||
ym,
|
||||
right,
|
||||
bottom,
|
||||
i,
|
||||
j;
|
||||
|
||||
// If the tree is empty, initialize the root as a leaf.
|
||||
if (!node) return this;
|
||||
|
||||
// Find the leaf node for the point.
|
||||
// While descending, also retain the deepest parent with a non-removed sibling.
|
||||
if (node.length) while (true) {
|
||||
if (right = x >= (xm = (x0 + x1) / 2)) x0 = xm; else x1 = xm;
|
||||
if (bottom = y >= (ym = (y0 + y1) / 2)) y0 = ym; else y1 = ym;
|
||||
if (!(parent = node, node = node[i = bottom << 1 | right])) return this;
|
||||
if (!node.length) break;
|
||||
if (parent[(i + 1) & 3] || parent[(i + 2) & 3] || parent[(i + 3) & 3]) retainer = parent, j = i;
|
||||
}
|
||||
|
||||
// Find the point to remove.
|
||||
while (node.data !== d) if (!(previous = node, node = node.next)) return this;
|
||||
if (next = node.next) delete node.next;
|
||||
|
||||
// If there are multiple coincident points, remove just the point.
|
||||
if (previous) return (next ? previous.next = next : delete previous.next), this;
|
||||
|
||||
// If this is the root point, remove it.
|
||||
if (!parent) return this._root = next, this;
|
||||
|
||||
// Remove this leaf.
|
||||
next ? parent[i] = next : delete parent[i];
|
||||
|
||||
// If the parent now contains exactly one leaf, collapse superfluous parents.
|
||||
if ((node = parent[0] || parent[1] || parent[2] || parent[3])
|
||||
&& node === (parent[3] || parent[2] || parent[1] || parent[0])
|
||||
&& !node.length) {
|
||||
if (retainer) retainer[j] = node;
|
||||
else this._root = node;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
export function removeAll(data) {
|
||||
for (var i = 0, n = data.length; i < n; ++i) this.remove(data[i]);
|
||||
return this;
|
||||
}
|
||||
3
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/root.js
generated
vendored
Normal file
3
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/root.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function() {
|
||||
return this._root;
|
||||
}
|
||||
7
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/size.js
generated
vendored
Normal file
7
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/size.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default function() {
|
||||
var size = 0;
|
||||
this.visit(function(node) {
|
||||
if (!node.length) do ++size; while (node = node.next)
|
||||
});
|
||||
return size;
|
||||
}
|
||||
16
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/visit.js
generated
vendored
Normal file
16
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/visit.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import Quad from "./quad.js";
|
||||
|
||||
export default function(callback) {
|
||||
var quads = [], q, node = this._root, child, x0, y0, x1, y1;
|
||||
if (node) quads.push(new Quad(node, this._x0, this._y0, this._x1, this._y1));
|
||||
while (q = quads.pop()) {
|
||||
if (!callback(node = q.node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.length) {
|
||||
var xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
|
||||
if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1));
|
||||
if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1));
|
||||
if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym));
|
||||
if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
21
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/visitAfter.js
generated
vendored
Normal file
21
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/visitAfter.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import Quad from "./quad.js";
|
||||
|
||||
export default function(callback) {
|
||||
var quads = [], next = [], q;
|
||||
if (this._root) quads.push(new Quad(this._root, this._x0, this._y0, this._x1, this._y1));
|
||||
while (q = quads.pop()) {
|
||||
var node = q.node;
|
||||
if (node.length) {
|
||||
var child, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1, xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
|
||||
if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym));
|
||||
if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym));
|
||||
if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1));
|
||||
if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1));
|
||||
}
|
||||
next.push(q);
|
||||
}
|
||||
while (q = next.pop()) {
|
||||
callback(q.node, q.x0, q.y0, q.x1, q.y1);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
7
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/x.js
generated
vendored
Normal file
7
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/x.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export function defaultX(d) {
|
||||
return d[0];
|
||||
}
|
||||
|
||||
export default function(_) {
|
||||
return arguments.length ? (this._x = _, this) : this._x;
|
||||
}
|
||||
7
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/y.js
generated
vendored
Normal file
7
lisp/emacs-application-framework/app/mermaid/node_modules/d3-quadtree/src/y.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export function defaultY(d) {
|
||||
return d[1];
|
||||
}
|
||||
|
||||
export default function(_) {
|
||||
return arguments.length ? (this._y = _, this) : this._y;
|
||||
}
|
||||
Reference in New Issue
Block a user