line-simplify-rdp
Advanced tools
Comparing version 0.2.0 to 0.3.0
16
index.js
@@ -19,18 +19,18 @@ 'use strict'; | ||
var minDist = Number.POSITIVE_INFINITY, | ||
minDistIdx = -1; | ||
var maxDist = Number.NEGATIVE_INFINITY, | ||
maxDistIdx = -1; | ||
for (var i=idx1+1; i < idx2; i++) { | ||
var pointBetween = points[i]; | ||
var dist = distanceToLineSegment2(x1, y1, dx, dy, lineLengthSquared, pointBetween.x, pointBetween.y); | ||
if (dist < minDist) { | ||
minDist = dist; | ||
minDistIdx = i; | ||
if (dist > maxDist) { | ||
maxDist = dist; | ||
maxDistIdx = i; | ||
} | ||
} | ||
if (minDist <= threshold) | ||
if (maxDist <= threshold) | ||
return; | ||
simplifyInternal(points, idx1, minDistIdx, threshold, keepers); | ||
simplifyInternal(points, minDistIdx, idx2, threshold, keepers); | ||
simplifyInternal(points, idx1, maxDistIdx, threshold, keepers); | ||
simplifyInternal(points, maxDistIdx, idx2, threshold, keepers); | ||
@@ -37,0 +37,0 @@ |
{ | ||
"name": "line-simplify-rdp", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Simplify lines using the Ramer–Douglas–Peucker algorithm", | ||
@@ -8,6 +8,6 @@ "repository": "https://github.com/scottglz/line-simplify-rdp", | ||
"scripts": { | ||
"test": "tape test/*.js", | ||
"test": "tape test.js", | ||
"lint": "jshint index.js", | ||
"validate": "npm ls", | ||
"preflight": "npm run lint && npm run validate && npm run test" | ||
"prepublish": "npm run lint && npm run validate && npm run test" | ||
}, | ||
@@ -14,0 +14,0 @@ "keywords": [ |
@@ -15,3 +15,3 @@ 'use strict'; | ||
var simplified = simplify(stairstep, 1); | ||
t.deepEquals(simplified, [stairstep[0],stairstep[i]], (i+1) + " points") | ||
t.deepEquals(simplified, [stairstep[0],stairstep[i]], (i+1) + " points"); | ||
} | ||
@@ -25,3 +25,3 @@ | ||
} | ||
t.deepEquals(simplify(stairstep, 1 ), [stairstep[0],stairstep[999]], "1000 points") | ||
t.deepEquals(simplify(stairstep, 1 ), [stairstep[0],stairstep[999]], "1000 points"); | ||
}); | ||
@@ -28,0 +28,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3139