Skip to content

Commit

Permalink
upgrade rbush & other deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Sep 26, 2016
1 parent 8416af3 commit 18aa0ef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function concaveman(points, concavity, lengthThreshold) {
}

// index the segments with an R-tree (for intersection checks)
var segTree = rbush(16, ['.minX', '.minY', '.maxX', '.maxY']);
var segTree = rbush(16);
for (i = 0; i < queue.length; i++) segTree.insert(updateBBox(queue[i]));

var sqConcavity = concavity * concavity;
Expand Down Expand Up @@ -90,7 +90,7 @@ function findCandidate(tree, a, b, c, d, maxDist, segTree) {
for (var i = 0; i < node.children.length; i++) {
var child = node.children[i];

var dist = node.leaf ? sqSegDist(child, b, c) : sqSegBoxDist(b, c, child.bbox);
var dist = node.leaf ? sqSegDist(child, b, c) : sqSegBoxDist(b, c, child);
if (dist > maxDist) continue; // skip the node if it's farther than we ever need

queue.push({
Expand Down Expand Up @@ -126,22 +126,22 @@ function compareDist(a, b) {
// square distance from a segment bounding box to the given one
function sqSegBoxDist(a, b, bbox) {
if (inside(a, bbox) || inside(b, bbox)) return 0;
var d1 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox[0], bbox[1], bbox[2], bbox[1]);
var d1 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox.minX, bbox.minY, bbox.maxX, bbox.minY);
if (d1 === 0) return 0;
var d2 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox[0], bbox[1], bbox[0], bbox[3]);
var d2 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox.minX, bbox.minY, bbox.minX, bbox.maxY);
if (d2 === 0) return 0;
var d3 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox[2], bbox[1], bbox[2], bbox[3]);
var d3 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox.maxX, bbox.minY, bbox.maxX, bbox.maxY);
if (d3 === 0) return 0;
var d4 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox[0], bbox[3], bbox[2], bbox[3]);
var d4 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox.minX, bbox.maxY, bbox.maxX, bbox.maxY);
if (d4 === 0) return 0;
return Math.min(d1, d2, d3, d4);
}

function inside(a, bbox) {
return a[0] >= bbox[0] &&
a[0] <= bbox[2] &&
a[1] >= bbox[1] &&
a[1] <= bbox[3];
return a[0] >= bbox.minX &&
a[0] <= bbox.maxX &&
a[1] >= bbox.minY &&
a[1] <= bbox.maxY;
}

// check if the edge (a,b) doesn't intersect any other edges
Expand All @@ -151,7 +151,7 @@ function noIntersections(a, b, segTree) {
var maxX = Math.max(a[0], b[0]);
var maxY = Math.max(a[1], b[1]);

var edges = segTree.search([minX, minY, maxX, maxY]);
var edges = segTree.search({minX: minX, minY: minY, maxX: maxX, maxY: maxY});
for (var i = 0; i < edges.length; i++) {
if (intersects(edges[i].p, edges[i].next.p, a, b)) return false;
}
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"main": "index.js",
"dependencies": {
"monotone-convex-hull-2d": "^1.0.1",
"point-in-polygon": "^1.0.0",
"rbush": "^1.4.2",
"point-in-polygon": "^1.0.1",
"rbush": "^2.0.1",
"robust-orientation": "^1.1.3",
"tinyqueue": "^1.0.1"
"tinyqueue": "^1.1.0"
},
"devDependencies": {
"eslint": "^2.1.0",
"eslint-config-mourner": "^2.0.0",
"tap": "^5.4.3"
"eslint": "^3.6.0",
"eslint-config-mourner": "^2.0.1",
"tap": "^7.1.2"
},
"scripts": {
"pretest": "eslint index.js test/*.js",
Expand Down

0 comments on commit 18aa0ef

Please sign in to comment.