line-simplify-rdp
Advanced tools
Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "line-simplify-rdp", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Simplify lines using the Ramer–Douglas–Peucker algorithm", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/scottglz/line-simplify-rdp", |
15
test.js
@@ -37,2 +37,17 @@ 'use strict'; | ||
t.deepEquals(simplify(points, 1), points); | ||
}); | ||
function expandPts(pts) { | ||
var ret = []; | ||
for (var i=0; i < pts.length; i += 2) { | ||
ret.push({x: pts[i], y: pts[i+1]}); | ||
} | ||
return ret; | ||
} | ||
test("redundant square", function(t) { | ||
t.plan(1); | ||
var points = expandPts([0,0, 0,1, 0,2, 0,3, 1,3, 2,3, 3,3, 3,2, 3,1, 3,0, 2,0, 1,0, 0,0]); | ||
t.deepEquals(simplify(points, 0), expandPts([0,0, 0,3, 3,3, 3,0, 0,0])); | ||
}); |
3523
85