From 51d4c2e061b79684f52b8c335187ff196c1d53cd Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Sat, 27 Apr 2013 09:00:20 +0300 Subject: [PATCH 01/49] more ports, update website link --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6734d84..88176dc 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ Simplify.js is a high-performance JavaScript 2D/3D polyline simplification library by Vladimir Agafonkin, extracted from [Leaflet](http://leaflet.cloudmade.com/). -Docs and demo: http://mourner.github.com/simplify-js/ +Docs and demo: http://mourner.github.io/simplify-js/ #### Ports * Python port: https://github.com/omarestrella/simplify.py (by Omar Estrella) - * PHP port: https://github.com/AKeN/simplify-php (by Rotari Gheorghe) \ No newline at end of file + * PHP port: https://github.com/AKeN/simplify-php (by Rotari Gheorghe) + * Java: https://github.com/ekeneijeoma/simplify-java (by Ekene Ijeoma) + * Processing: https://github.com/ekeneijeoma/simplify-processing (by Ekene Ijeoma) From c5c99a198e7ab43da8fae676b39c5f368f7dbb47 Mon Sep 17 00:00:00 2001 From: fnicollet Date: Fri, 3 May 2013 15:37:43 +0300 Subject: [PATCH 02/49] Added AS3 port in the README listing --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 88176dc..a0f6080 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,4 @@ Docs and demo: http://mourner.github.io/simplify-js/ * PHP port: https://github.com/AKeN/simplify-php (by Rotari Gheorghe) * Java: https://github.com/ekeneijeoma/simplify-java (by Ekene Ijeoma) * Processing: https://github.com/ekeneijeoma/simplify-processing (by Ekene Ijeoma) + * AS3: https://github.com/fnicollet/simplify-as3 (by Fabien Nicollet) From 17b4717eb639560fadedc567cd82691abb710dd0 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Sat, 1 Jun 2013 12:13:24 +0300 Subject: [PATCH 03/49] improve comments, update copyright --- simplify.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/simplify.js b/simplify.js index 7e4845a..b5aaf36 100644 --- a/simplify.js +++ b/simplify.js @@ -1,7 +1,7 @@ /* - Copyright (c) 2012, Vladimir Agafonkin - Simplify.js is a high-performance polyline simplification library - mourner.github.com/simplify-js + Copyright (c) 2013, Vladimir Agafonkin + Simplify.js is a high-performance JS polyline simplification library + mourner.github.io/simplify-js */ (function (global, undefined) { @@ -9,7 +9,7 @@ "use strict"; - // to suit your point format, run search/replace for '.x' and '.y' + // to suit your point format, run search/replace for '.x' and '.y'; // to switch to 3D, uncomment the lines in the next 2 functions // (configurability would draw significant performance overhead) @@ -70,7 +70,9 @@ // the rest of the code doesn't care for the point format - function simplifyRadialDistance(points, sqTolerance) { // distance-based simplification + // basic distance-based simplification + + function simplifyRadialDistance(points, sqTolerance) { var i, len = points.length, @@ -163,6 +165,7 @@ ? exports : global; + // both algorithms combined for awesome performance root.simplify = function (points, tolerance, highestQuality) { From 9f52288464a4293e06a7eb43eea27d8f2f270cee Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Sat, 1 Jun 2013 12:14:38 +0300 Subject: [PATCH 04/49] simplify code a bit --- simplify.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/simplify.js b/simplify.js index b5aaf36..83ce85d 100644 --- a/simplify.js +++ b/simplify.js @@ -169,13 +169,9 @@ root.simplify = function (points, tolerance, highestQuality) { - var sqTolerance = (tolerance !== undefined) - ? tolerance * tolerance - : 1; + var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1; - if (!highestQuality) { - points = simplifyRadialDistance(points, sqTolerance); - } + points = highestQuality ? points : simplifyRadialDistance(points, sqTolerance); points = simplifyDouglasPeucker(points, sqTolerance); return points; From 6d0406ed352dc562e327dc14a20a1f5f45c8f5ea Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Sat, 1 Jun 2013 12:15:11 +0300 Subject: [PATCH 05/49] add AMD compat; export in Node.js as a function instead of object --- simplify.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/simplify.js b/simplify.js index 83ce85d..1048d9f 100644 --- a/simplify.js +++ b/simplify.js @@ -161,13 +161,9 @@ } - var root = (typeof exports !== undefined + '') - ? exports - : global; - // both algorithms combined for awesome performance - root.simplify = function (points, tolerance, highestQuality) { + function simplify(points, tolerance, highestQuality) { var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1; @@ -177,4 +173,19 @@ return points; }; -}(this)); \ No newline at end of file + + // export either as a Node.js module, AMD module or a global browser variable + + if (typeof exports === 'object') { + module.exports = simplify; + + } else if (typeof define === 'function' && define.amd) { + define(function () { + return simplify; + }); + + } else { + global.simplify = simplify; + } + +}(this)); From 5909899febce00e55a7e3c0d7b24ae2fa9a5fc0c Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Sat, 1 Jun 2013 12:21:43 +0300 Subject: [PATCH 06/49] remove minified file (no need, you can do it as a part of your app build process) --- simplify-min.js | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 simplify-min.js diff --git a/simplify-min.js b/simplify-min.js deleted file mode 100644 index 00b5348..0000000 --- a/simplify-min.js +++ /dev/null @@ -1,5 +0,0 @@ -/* - (c) 2012, Vladimir Agafonkin - mourner.github.com/simplify-js -*/ -(function(a,b){function c(a,b){var c=a.x-b.x,d=a.y-b.y;return c*c+d*d}function d(a,b,c){var d=b.x,e=b.y,f=c.x-d,g=c.y-e,h;if(f!==0||g!==0)h=((a.x-d)*f+(a.y-e)*g)/(f*f+g*g),h>1?(d=c.x,e=c.y):h>0&&(d+=f*h,e+=g*h);return f=a.x-d,g=a.y-e,f*f+g*g}function e(a,b){var d,e=a.length,f,g=a[0],h=[g];for(d=1;db&&(h.push(f),g=f);return g!==f&&h.push(f),h}function f(a,c){var e=a.length,f=typeof Uint8Array!=b+""?Uint8Array:Array,g=new f(e),h=0,i=e-1,j,k,l,m,n=[],o=[],p=[];g[h]=g[i]=1;while(i){k=0;for(j=h+1;jk&&(m=j,k=l);k>c&&(g[m]=1,n.push(h),o.push(m),n.push(m),o.push(i)),h=n.pop(),i=o.pop()}for(j=0;j Date: Sat, 1 Jun 2013 12:24:16 +0300 Subject: [PATCH 07/49] bump version, prettify package.json --- package.json | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d4fa3f7..b9410cd 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,17 @@ "name": "simplify-js", "description": "A high-performance JavaScript 2D/3D polyline simplification library", "homepage": "http://mourner.github.com/simplify-js/", - "keywords": ["math", "geometry", "polyline", "simplification"], "author": "Vladimir Agafonkin", - "repository" : {"type": "git", "url": "git://github.com/mourner/simplify-js.git"}, + "keywords": [ + "math", + "geometry", + "polyline", + "simplification" + ], + "repository": { + "type": "git", + "url": "git://github.com/mourner/simplify-js.git" + }, "main": "simplify.js", - "version": "1.0.0" + "version": "1.1.0" } From 78ad74eeaf1ad7aa27b8370e3004f881d4654b18 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Sat, 1 Jun 2013 12:40:36 +0300 Subject: [PATCH 08/49] improve readme --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a0f6080..61f33eb 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -Simplify.js is a high-performance JavaScript 2D/3D polyline simplification library by Vladimir Agafonkin, extracted from [Leaflet](http://leaflet.cloudmade.com/). +Simplify.js is a high-performance JavaScript 2D/3D polyline simplification library by Vladimir Agafonkin, extracted from [Leaflet](http://leafletjs.com). Docs and demo: http://mourner.github.io/simplify-js/ #### Ports - * Python port: https://github.com/omarestrella/simplify.py (by Omar Estrella) - * PHP port: https://github.com/AKeN/simplify-php (by Rotari Gheorghe) - * Java: https://github.com/ekeneijeoma/simplify-java (by Ekene Ijeoma) - * Processing: https://github.com/ekeneijeoma/simplify-processing (by Ekene Ijeoma) - * AS3: https://github.com/fnicollet/simplify-as3 (by Fabien Nicollet) + * Python: [omarestrella / simplify.py](https://github.com/omarestrella/simplify.py) (by Omar Estrella) + * PHP: [AKeN / simplify-php](https://github.com/AKeN/simplify-php) (by Rotari Gheorghe) + * Java: [ekeneijeoma / simplify-java](https://github.com/ekeneijeoma/simplify-java) (by Ekene Ijeoma) + * Processing: [ekeneijeoma / simplify-processing](https://github.com/ekeneijeoma/simplify-processing) (by Ekene Ijeoma) + * AS3: [fnicollet / simplify-as3](https://github.com/fnicollet/simplify-as3) (by Fabien Nicollet) From 136c84c5eb9d2625fedc38aeab4ba945b4314694 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Sat, 13 Jul 2013 10:18:53 +0300 Subject: [PATCH 09/49] add another Java port --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 61f33eb..28b3465 100644 --- a/README.md +++ b/README.md @@ -7,5 +7,6 @@ Docs and demo: http://mourner.github.io/simplify-js/ * Python: [omarestrella / simplify.py](https://github.com/omarestrella/simplify.py) (by Omar Estrella) * PHP: [AKeN / simplify-php](https://github.com/AKeN/simplify-php) (by Rotari Gheorghe) * Java: [ekeneijeoma / simplify-java](https://github.com/ekeneijeoma/simplify-java) (by Ekene Ijeoma) + * Java: [hgoebl / simplify-java](https://github.com/hgoebl/simplify-java) (by Heinrich Göbl) * Processing: [ekeneijeoma / simplify-processing](https://github.com/ekeneijeoma/simplify-processing) (by Ekene Ijeoma) * AS3: [fnicollet / simplify-as3](https://github.com/fnicollet/simplify-as3) (by Fabien Nicollet) From fb511994ee29974d3beee1a0efe5f8b64b289706 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Sat, 31 Aug 2013 20:50:54 +0300 Subject: [PATCH 10/49] add a link to Rust port by @calvinmetcalf --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 28b3465..8fbc236 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,4 @@ Docs and demo: http://mourner.github.io/simplify-js/ * Java: [hgoebl / simplify-java](https://github.com/hgoebl/simplify-java) (by Heinrich Göbl) * Processing: [ekeneijeoma / simplify-processing](https://github.com/ekeneijeoma/simplify-processing) (by Ekene Ijeoma) * AS3: [fnicollet / simplify-as3](https://github.com/fnicollet/simplify-as3) (by Fabien Nicollet) + * Rust: [calvinmetcalf / simplify-rs](https://github.com/calvinmetcalf/simplify-rs) (by Calvin Metcalf) From 7740dad1545bb556ff60ae385f7756b2d0a57678 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Wed, 16 Oct 2013 15:02:51 +0300 Subject: [PATCH 11/49] improve formatting and simplify code --- simplify.js | 248 +++++++++++++++++++++------------------------------- 1 file changed, 101 insertions(+), 147 deletions(-) diff --git a/simplify.js b/simplify.js index 1048d9f..3edf7a9 100644 --- a/simplify.js +++ b/simplify.js @@ -1,191 +1,145 @@ /* - Copyright (c) 2013, Vladimir Agafonkin - Simplify.js is a high-performance JS polyline simplification library + (c) 2013, Vladimir Agafonkin + Simplify.js, a high-performance JS polyline simplification library mourner.github.io/simplify-js */ -(function (global, undefined) { +(function () { "use strict"; - "use strict"; +// to suit your point format, run search/replace for '.x' and '.y'; +// for 3D version, see 3d branch (configurability would draw significant performance overhead) +// square distance between 2 points +function getSquareDistance(p1, p2) { - // to suit your point format, run search/replace for '.x' and '.y'; - // to switch to 3D, uncomment the lines in the next 2 functions - // (configurability would draw significant performance overhead) + var dx = p1.x - p2.x, + dy = p1.y - p2.y; + return dx * dx + dy * dy; +} - function getSquareDistance(p1, p2) { // square distance between 2 points +// square distance from a point to a segment +function getSquareSegmentDistance(p, p1, p2) { - var dx = p1.x - p2.x, - // dz = p1.z - p2.z, - dy = p1.y - p2.y; + var x = p1.x, + y = p1.y, + dx = p2.x - x, + dy = p2.y - y; - return dx * dx + - // dz * dz + - dy * dy; - } + if (dx !== 0 || dy !== 0) { - function getSquareSegmentDistance(p, p1, p2) { // square distance from a point to a segment + var t = ((p.x - x) * dx + (p.y - y) * dy) / (dx * dx + dy * dy); - var x = p1.x, - y = p1.y, - // z = p1.z, + if (t > 1) { + x = p2.x; + y = p2.y; - dx = p2.x - x, - dy = p2.y - y, - // dz = p2.z - z, + } else if (t > 0) { + x += dx * t; + y += dy * t; + } + } - t; + dx = p.x - x; + dy = p.y - y; - if (dx !== 0 || dy !== 0) { + return dx * dx + dy * dy; +} +// the rest of the code doesn't care for the point format - t = ((p.x - x) * dx + - // (p.z - z) * dz + - (p.y - y) * dy) / - (dx * dx + - // dz * dz + - dy * dy); +// basic distance-based simplification +function simplifyRadialDistance(points, sqTolerance) { - if (t > 1) { - x = p2.x; - y = p2.y; - // z = p2.z; + var prevPoint = points[0], + newPoints = [prevPoint], + point; - } else if (t > 0) { - x += dx * t; - y += dy * t; - // z += dz * t; - } - } + for (var i = 1, len = points.length; i < len; i++) { + point = points[i]; - dx = p.x - x; - dy = p.y - y; - // dz = p.z - z; + if (getSquareDistance(point, prevPoint) > sqTolerance) { + newPoints.push(point); + prevPoint = point; + } + } - return dx * dx + - // dz * dz + - dy * dy; - } + if (prevPoint !== point) { + newPoints.push(point); + } - // the rest of the code doesn't care for the point format + return newPoints; +} +// simplification using optimized Douglas-Peucker algorithm with recursion elimination +function simplifyDouglasPeucker(points, sqTolerance) { - // basic distance-based simplification + var len = points.length, + MarkerArray = typeof Uint8Array !== 'undefined' ? Uint8Array : Array, + markers = new MarkerArray(len), - function simplifyRadialDistance(points, sqTolerance) { + first = 0, + last = len - 1, - var i, - len = points.length, - point, - prevPoint = points[0], - newPoints = [prevPoint]; + stack = [], + newPoints = [], - for (i = 1; i < len; i++) { - point = points[i]; + i, maxSqDist, sqDist, index; - if (getSquareDistance(point, prevPoint) > sqTolerance) { - newPoints.push(point); - prevPoint = point; - } - } + markers[first] = markers[last] = 1; - if (prevPoint !== point) { - newPoints.push(point); - } + while (last) { - return newPoints; - } + maxSqDist = 0; + for (i = first + 1; i < last; i++) { + sqDist = getSquareSegmentDistance(points[i], points[first], points[last]); - // simplification using optimized Douglas-Peucker algorithm with recursion elimination + if (sqDist > maxSqDist) { + index = i; + maxSqDist = sqDist; + } + } - function simplifyDouglasPeucker(points, sqTolerance) { + if (maxSqDist > sqTolerance) { + markers[index] = 1; + stack.push(first, index, index, last); + } - var len = points.length, + last = stack.pop(); + first = stack.pop(); + } - MarkerArray = (typeof Uint8Array !== undefined + '') - ? Uint8Array - : Array, + for (i = 0; i < len; i++) { + if (markers[i]) { + newPoints.push(points[i]); + } + } - markers = new MarkerArray(len), + return newPoints; +} - first = 0, - last = len - 1, +// both algorithms combined for awesome performance +function simplify(points, tolerance, highestQuality) { - i, - maxSqDist, - sqDist, - index, + var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1; - firstStack = [], - lastStack = [], + points = highestQuality ? points : simplifyRadialDistance(points, sqTolerance); + points = simplifyDouglasPeucker(points, sqTolerance); - newPoints = []; + return points; +} - markers[first] = markers[last] = 1; +// export as a Node module, an AMD module or a global browser variable +if (typeof module !== 'undefined') { + module.exports = simplify; - while (last) { +} else if (typeof define === 'function' && define.amd) { + define(function() { + return simplify; + }); - maxSqDist = 0; +} else { + window.simplify = simplify; +} - for (i = first + 1; i < last; i++) { - sqDist = getSquareSegmentDistance(points[i], points[first], points[last]); - - if (sqDist > maxSqDist) { - index = i; - maxSqDist = sqDist; - } - } - - if (maxSqDist > sqTolerance) { - markers[index] = 1; - - firstStack.push(first); - lastStack.push(index); - - firstStack.push(index); - lastStack.push(last); - } - - first = firstStack.pop(); - last = lastStack.pop(); - } - - for (i = 0; i < len; i++) { - if (markers[i]) { - newPoints.push(points[i]); - } - } - - return newPoints; - } - - - // both algorithms combined for awesome performance - - function simplify(points, tolerance, highestQuality) { - - var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1; - - points = highestQuality ? points : simplifyRadialDistance(points, sqTolerance); - points = simplifyDouglasPeucker(points, sqTolerance); - - return points; - }; - - - // export either as a Node.js module, AMD module or a global browser variable - - if (typeof exports === 'object') { - module.exports = simplify; - - } else if (typeof define === 'function' && define.amd) { - define(function () { - return simplify; - }); - - } else { - global.simplify = simplify; - } - -}(this)); +})(); From 3accee476f53ec961a5b57218fe9312eea10b19e Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Wed, 16 Oct 2013 17:32:13 +0300 Subject: [PATCH 12/49] cleanup more --- simplify.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/simplify.js b/simplify.js index 3edf7a9..5737a60 100644 --- a/simplify.js +++ b/simplify.js @@ -10,7 +10,7 @@ // for 3D version, see 3d branch (configurability would draw significant performance overhead) // square distance between 2 points -function getSquareDistance(p1, p2) { +function sqDist(p1, p2) { var dx = p1.x - p2.x, dy = p1.y - p2.y; @@ -19,7 +19,7 @@ function getSquareDistance(p1, p2) { } // square distance from a point to a segment -function getSquareSegmentDistance(p, p1, p2) { +function sqSegDist(p, p1, p2) { var x = p1.x, y = p1.y, @@ -45,10 +45,10 @@ function getSquareSegmentDistance(p, p1, p2) { return dx * dx + dy * dy; } -// the rest of the code doesn't care for the point format +// rest of the code doesn't care about point format // basic distance-based simplification -function simplifyRadialDistance(points, sqTolerance) { +function simplifyRadialDist(points, sqTolerance) { var prevPoint = points[0], newPoints = [prevPoint], @@ -57,7 +57,7 @@ function simplifyRadialDistance(points, sqTolerance) { for (var i = 1, len = points.length; i < len; i++) { point = points[i]; - if (getSquareDistance(point, prevPoint) > sqTolerance) { + if (sqDist(point, prevPoint) > sqTolerance) { newPoints.push(point); prevPoint = point; } @@ -76,13 +76,10 @@ function simplifyDouglasPeucker(points, sqTolerance) { var len = points.length, MarkerArray = typeof Uint8Array !== 'undefined' ? Uint8Array : Array, markers = new MarkerArray(len), - first = 0, last = len - 1, - stack = [], newPoints = [], - i, maxSqDist, sqDist, index; markers[first] = markers[last] = 1; @@ -92,7 +89,7 @@ function simplifyDouglasPeucker(points, sqTolerance) { maxSqDist = 0; for (i = first + 1; i < last; i++) { - sqDist = getSquareSegmentDistance(points[i], points[first], points[last]); + sqDist = sqSegDist(points[i], points[first], points[last]); if (sqDist > maxSqDist) { index = i; @@ -123,20 +120,18 @@ function simplify(points, tolerance, highestQuality) { var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1; - points = highestQuality ? points : simplifyRadialDistance(points, sqTolerance); + points = highestQuality ? points : simplifyRadialDist(points, sqTolerance); points = simplifyDouglasPeucker(points, sqTolerance); return points; } -// export as a Node module, an AMD module or a global browser variable +// export as Node module / AMD module / browser variable if (typeof module !== 'undefined') { module.exports = simplify; } else if (typeof define === 'function' && define.amd) { - define(function() { - return simplify; - }); + define(function() { return simplify; }); } else { window.simplify = simplify; From f5935dd43768752488f7a38e9ff88adfefc93ce6 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Wed, 16 Oct 2013 17:34:24 +0300 Subject: [PATCH 13/49] add get prefix back --- simplify.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/simplify.js b/simplify.js index 5737a60..317eb17 100644 --- a/simplify.js +++ b/simplify.js @@ -10,7 +10,7 @@ // for 3D version, see 3d branch (configurability would draw significant performance overhead) // square distance between 2 points -function sqDist(p1, p2) { +function getSqDist(p1, p2) { var dx = p1.x - p2.x, dy = p1.y - p2.y; @@ -19,7 +19,7 @@ function sqDist(p1, p2) { } // square distance from a point to a segment -function sqSegDist(p, p1, p2) { +function getSqSegDist(p, p1, p2) { var x = p1.x, y = p1.y, @@ -57,7 +57,7 @@ function simplifyRadialDist(points, sqTolerance) { for (var i = 1, len = points.length; i < len; i++) { point = points[i]; - if (sqDist(point, prevPoint) > sqTolerance) { + if (getSqDist(point, prevPoint) > sqTolerance) { newPoints.push(point); prevPoint = point; } @@ -89,7 +89,7 @@ function simplifyDouglasPeucker(points, sqTolerance) { maxSqDist = 0; for (i = first + 1; i < last; i++) { - sqDist = sqSegDist(points[i], points[first], points[last]); + sqDist = getSqSegDist(points[i], points[first], points[last]); if (sqDist > maxSqDist) { index = i; From b07eacf1824b86dee3c5409e33f6df77a071804a Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Wed, 16 Oct 2013 18:29:39 +0300 Subject: [PATCH 14/49] damn you perfectionism --- simplify.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/simplify.js b/simplify.js index 317eb17..6164202 100644 --- a/simplify.js +++ b/simplify.js @@ -126,13 +126,13 @@ function simplify(points, tolerance, highestQuality) { return points; } -// export as Node module / AMD module / browser variable -if (typeof module !== 'undefined') { +// export as AMD module / Node module / browser variable +if (typeof define === 'function' && define.amd) { + define(function() { + return simplify; + }); +} else if (typeof module !== 'undefined') { module.exports = simplify; - -} else if (typeof define === 'function' && define.amd) { - define(function() { return simplify; }); - } else { window.simplify = simplify; } From e8259d6ac2aac732e3e890cdb4121a75ccde5b54 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 17 Oct 2013 16:12:19 +0300 Subject: [PATCH 15/49] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8fbc236..f0f54bf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -Simplify.js is a high-performance JavaScript 2D/3D polyline simplification library by Vladimir Agafonkin, extracted from [Leaflet](http://leafletjs.com). +Simplify.js is a high-performance JavaScript polyline simplification library by Vladimir Agafonkin, extracted from [Leaflet](http://leafletjs.com). -Docs and demo: http://mourner.github.io/simplify-js/ +Checkout the demo with docs: http://mourner.github.io/simplify-js/ #### Ports From b46e00196b5fa4dc3b1b49d415f962272a6375be Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 17 Oct 2013 16:16:18 +0300 Subject: [PATCH 16/49] add mocha and test script to package.json --- package.json | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index b9410cd..0df6d92 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,24 @@ { - "name": "simplify-js", - "description": "A high-performance JavaScript 2D/3D polyline simplification library", - "homepage": "http://mourner.github.com/simplify-js/", - "author": "Vladimir Agafonkin", - "keywords": [ - "math", - "geometry", - "polyline", - "simplification" - ], - "repository": { - "type": "git", - "url": "git://github.com/mourner/simplify-js.git" - }, - "main": "simplify.js", - "version": "1.1.0" + "name": "simplify-js", + "version": "1.1.0", + "description": "A high-performance JavaScript 2D/3D polyline simplification library", + "homepage": "http://mourner.github.com/simplify-js/", + "author": "Vladimir Agafonkin", + "keywords": [ + "math", + "geometry", + "polyline", + "simplification" + ], + "repository": { + "type": "git", + "url": "git://github.com/mourner/simplify-js.git" + }, + "main": "simplify.js", + "devDependencies": { + "mocha": "~1.13.0" + }, + "scripts": { + "test": "./node_modules/.bin/mocha" + } } From c9f39d06cbab4d806ec69d93f925daebd117a718 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 17 Oct 2013 16:34:12 +0300 Subject: [PATCH 17/49] add basic simplify test --- test.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test.js diff --git a/test.js b/test.js new file mode 100644 index 0000000..7cfb251 --- /dev/null +++ b/test.js @@ -0,0 +1,50 @@ +var points = [ + {"x":224.55,"y":250.15},{"x":226.91,"y":244.19},{"x":233.31,"y":241.45},{"x":234.98,"y":236.06}, + {"x":244.21,"y":232.76},{"x":262.59,"y":215.31},{"x":267.76,"y":213.81},{"x":273.57,"y":201.84}, + {"x":273.12,"y":192.16},{"x":277.62,"y":189.03},{"x":280.36,"y":181.41},{"x":286.51,"y":177.74}, + {"x":292.41,"y":159.37},{"x":296.91,"y":155.64},{"x":314.95,"y":151.37},{"x":319.75,"y":145.16}, + {"x":330.33,"y":137.57},{"x":341.48,"y":139.96},{"x":369.98,"y":137.89},{"x":387.39,"y":142.51}, + {"x":391.28,"y":139.39},{"x":409.52,"y":141.14},{"x":414.82,"y":139.75},{"x":427.72,"y":127.30}, + {"x":439.60,"y":119.74},{"x":474.93,"y":107.87},{"x":486.51,"y":106.75},{"x":489.20,"y":109.45}, + {"x":493.79,"y":108.63},{"x":504.74,"y":119.66},{"x":512.96,"y":122.35},{"x":518.63,"y":120.89}, + {"x":524.09,"y":126.88},{"x":529.57,"y":127.86},{"x":534.21,"y":140.93},{"x":539.27,"y":147.24}, + {"x":567.69,"y":148.91},{"x":575.25,"y":157.26},{"x":580.62,"y":158.15},{"x":601.53,"y":156.85}, + {"x":617.74,"y":159.86},{"x":622.00,"y":167.04},{"x":629.55,"y":194.60},{"x":638.90,"y":195.61}, + {"x":641.26,"y":200.81},{"x":651.77,"y":204.56},{"x":671.55,"y":222.55},{"x":683.68,"y":217.45}, + {"x":695.25,"y":219.15},{"x":700.64,"y":217.98},{"x":703.12,"y":214.36},{"x":712.26,"y":215.87}, + {"x":721.49,"y":212.81},{"x":727.81,"y":213.36},{"x":729.98,"y":208.73},{"x":735.32,"y":208.20}, + {"x":739.94,"y":204.77},{"x":769.98,"y":208.42},{"x":779.60,"y":216.87},{"x":784.20,"y":218.16}, + {"x":800.24,"y":214.62},{"x":810.53,"y":219.73},{"x":817.19,"y":226.82},{"x":820.77,"y":236.17}, + {"x":827.23,"y":236.16},{"x":829.89,"y":239.89},{"x":851.00,"y":248.94},{"x":859.88,"y":255.49}, + {"x":865.21,"y":268.53},{"x":857.95,"y":280.30},{"x":865.48,"y":291.45},{"x":866.81,"y":298.66}, + {"x":864.68,"y":302.71},{"x":867.79,"y":306.17},{"x":859.87,"y":311.37},{"x":860.08,"y":314.35}, + {"x":858.29,"y":314.94},{"x":858.10,"y":327.60},{"x":854.54,"y":335.40},{"x":860.92,"y":343.00}, + {"x":856.43,"y":350.15},{"x":851.42,"y":352.96},{"x":849.84,"y":359.59},{"x":854.56,"y":365.53}, + {"x":849.74,"y":370.38},{"x":844.09,"y":371.89},{"x":844.75,"y":380.44},{"x":841.52,"y":383.67}, + {"x":839.57,"y":390.40},{"x":845.59,"y":399.05},{"x":848.40,"y":407.55},{"x":843.71,"y":411.30}, + {"x":844.09,"y":419.88},{"x":839.51,"y":432.76},{"x":841.33,"y":441.04},{"x":847.62,"y":449.22}, + {"x":847.16,"y":458.44},{"x":851.38,"y":462.79},{"x":853.97,"y":471.15},{"x":866.36,"y":480.77} +]; + +var simplified = [ + {"x":224.55,"y":250.15},{"x":267.76,"y":213.81},{"x":296.91,"y":155.64},{"x":330.33,"y":137.57}, + {"x":409.52,"y":141.14},{"x":439.60,"y":119.74},{"x":486.51,"y":106.75},{"x":529.57,"y":127.86}, + {"x":539.27,"y":147.24},{"x":617.74,"y":159.86},{"x":629.55,"y":194.60},{"x":671.55,"y":222.55}, + {"x":727.81,"y":213.36},{"x":739.94,"y":204.77},{"x":769.98,"y":208.42},{"x":779.60,"y":216.87}, + {"x":800.24,"y":214.62},{"x":820.77,"y":236.17},{"x":859.88,"y":255.49},{"x":865.21,"y":268.53}, + {"x":857.95,"y":280.30},{"x":867.79,"y":306.17},{"x":859.87,"y":311.37},{"x":854.54,"y":335.40}, + {"x":860.92,"y":343.00},{"x":849.84,"y":359.59},{"x":854.56,"y":365.53},{"x":844.09,"y":371.89}, + {"x":839.57,"y":390.40},{"x":848.40,"y":407.55},{"x":839.51,"y":432.76},{"x":853.97,"y":471.15}, + {"x":866.36,"y":480.77} +]; + +var simplify = require('./simplify'), + assert = require('assert'); + +describe('simplify', function () { + it('should simplify points correctly with the given tolerance', function () { + var result = simplify(points, 5); + assert.deepEqual(result, simplified); + }); +}); + From 2c9a7f3fd7fb632b7fb46fc36397e7795764fb4b Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 17 Oct 2013 16:34:35 +0300 Subject: [PATCH 18/49] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0df6d92..d3439b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simplify-js", - "version": "1.1.0", + "version": "1.2.0", "description": "A high-performance JavaScript 2D/3D polyline simplification library", "homepage": "http://mourner.github.com/simplify-js/", "author": "Vladimir Agafonkin", From 44d2ebb5fcadb3fb7414c6388ac67366fa6eea32 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 11 Apr 2014 11:40:52 +0300 Subject: [PATCH 19/49] drop brackets for single-line blocks --- simplify.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/simplify.js b/simplify.js index 6164202..ba4b81d 100644 --- a/simplify.js +++ b/simplify.js @@ -63,9 +63,7 @@ function simplifyRadialDist(points, sqTolerance) { } } - if (prevPoint !== point) { - newPoints.push(point); - } + if (prevPoint !== point) newPoints.push(point); return newPoints; } @@ -107,9 +105,7 @@ function simplifyDouglasPeucker(points, sqTolerance) { } for (i = 0; i < len; i++) { - if (markers[i]) { - newPoints.push(points[i]); - } + if (markers[i]) newPoints.push(points[i]); } return newPoints; @@ -127,14 +123,8 @@ function simplify(points, tolerance, highestQuality) { } // export as AMD module / Node module / browser variable -if (typeof define === 'function' && define.amd) { - define(function() { - return simplify; - }); -} else if (typeof module !== 'undefined') { - module.exports = simplify; -} else { - window.simplify = simplify; -} +if (typeof define === 'function' && define.amd) define(function() { return simplify; }); +else if (typeof module !== 'undefined') module.exports = simplify; +else window.simplify = simplify; })(); From caa8d8b9e5d08eaa5b84aa6dfd07b953b92308df Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 11 Apr 2014 11:42:48 +0300 Subject: [PATCH 20/49] switch from mocha to tape for tests --- package.json | 5 +++-- test.js | 12 +++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index d3439b2..4ebeee0 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,10 @@ }, "main": "simplify.js", "devDependencies": { - "mocha": "~1.13.0" + "faucet": "0.0.1", + "tape": "^2.12.3" }, "scripts": { - "test": "./node_modules/.bin/mocha" + "test": "node test.js | faucet" } } diff --git a/test.js b/test.js index 7cfb251..aa6dd67 100644 --- a/test.js +++ b/test.js @@ -39,12 +39,10 @@ var simplified = [ ]; var simplify = require('./simplify'), - assert = require('assert'); + t = require('tape'); -describe('simplify', function () { - it('should simplify points correctly with the given tolerance', function () { - var result = simplify(points, 5); - assert.deepEqual(result, simplified); - }); +t('simplifies points correctly with the given tolerance', function (t) { + var result = simplify(points, 5); + t.same(result, simplified); + t.end(); }); - From 5e0433d78d2f6e79911307e6676c1050f93dda54 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 11 Apr 2014 11:46:19 +0300 Subject: [PATCH 21/49] add jshint --- package.json | 10 ++++++-- simplify.js | 2 +- test.js | 68 ++++++++++++++++++++++++++-------------------------- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 4ebeee0..aa562d4 100644 --- a/package.json +++ b/package.json @@ -17,9 +17,15 @@ "main": "simplify.js", "devDependencies": { "faucet": "0.0.1", - "tape": "^2.12.3" + "tape": "^2.12.3", + "jshint": "^2.5.0" }, "scripts": { - "test": "node test.js | faucet" + "test": "jshint simplify.js test.js && node test.js | faucet" + }, + "jshintConfig": { + "quotmark": "single", + "trailing": true, + "unused": true } } diff --git a/simplify.js b/simplify.js index ba4b81d..9ffdaca 100644 --- a/simplify.js +++ b/simplify.js @@ -4,7 +4,7 @@ mourner.github.io/simplify-js */ -(function () { "use strict"; +(function () { 'use strict'; // to suit your point format, run search/replace for '.x' and '.y'; // for 3D version, see 3d branch (configurability would draw significant performance overhead) diff --git a/test.js b/test.js index aa6dd67..c042e1f 100644 --- a/test.js +++ b/test.js @@ -1,41 +1,41 @@ var points = [ - {"x":224.55,"y":250.15},{"x":226.91,"y":244.19},{"x":233.31,"y":241.45},{"x":234.98,"y":236.06}, - {"x":244.21,"y":232.76},{"x":262.59,"y":215.31},{"x":267.76,"y":213.81},{"x":273.57,"y":201.84}, - {"x":273.12,"y":192.16},{"x":277.62,"y":189.03},{"x":280.36,"y":181.41},{"x":286.51,"y":177.74}, - {"x":292.41,"y":159.37},{"x":296.91,"y":155.64},{"x":314.95,"y":151.37},{"x":319.75,"y":145.16}, - {"x":330.33,"y":137.57},{"x":341.48,"y":139.96},{"x":369.98,"y":137.89},{"x":387.39,"y":142.51}, - {"x":391.28,"y":139.39},{"x":409.52,"y":141.14},{"x":414.82,"y":139.75},{"x":427.72,"y":127.30}, - {"x":439.60,"y":119.74},{"x":474.93,"y":107.87},{"x":486.51,"y":106.75},{"x":489.20,"y":109.45}, - {"x":493.79,"y":108.63},{"x":504.74,"y":119.66},{"x":512.96,"y":122.35},{"x":518.63,"y":120.89}, - {"x":524.09,"y":126.88},{"x":529.57,"y":127.86},{"x":534.21,"y":140.93},{"x":539.27,"y":147.24}, - {"x":567.69,"y":148.91},{"x":575.25,"y":157.26},{"x":580.62,"y":158.15},{"x":601.53,"y":156.85}, - {"x":617.74,"y":159.86},{"x":622.00,"y":167.04},{"x":629.55,"y":194.60},{"x":638.90,"y":195.61}, - {"x":641.26,"y":200.81},{"x":651.77,"y":204.56},{"x":671.55,"y":222.55},{"x":683.68,"y":217.45}, - {"x":695.25,"y":219.15},{"x":700.64,"y":217.98},{"x":703.12,"y":214.36},{"x":712.26,"y":215.87}, - {"x":721.49,"y":212.81},{"x":727.81,"y":213.36},{"x":729.98,"y":208.73},{"x":735.32,"y":208.20}, - {"x":739.94,"y":204.77},{"x":769.98,"y":208.42},{"x":779.60,"y":216.87},{"x":784.20,"y":218.16}, - {"x":800.24,"y":214.62},{"x":810.53,"y":219.73},{"x":817.19,"y":226.82},{"x":820.77,"y":236.17}, - {"x":827.23,"y":236.16},{"x":829.89,"y":239.89},{"x":851.00,"y":248.94},{"x":859.88,"y":255.49}, - {"x":865.21,"y":268.53},{"x":857.95,"y":280.30},{"x":865.48,"y":291.45},{"x":866.81,"y":298.66}, - {"x":864.68,"y":302.71},{"x":867.79,"y":306.17},{"x":859.87,"y":311.37},{"x":860.08,"y":314.35}, - {"x":858.29,"y":314.94},{"x":858.10,"y":327.60},{"x":854.54,"y":335.40},{"x":860.92,"y":343.00}, - {"x":856.43,"y":350.15},{"x":851.42,"y":352.96},{"x":849.84,"y":359.59},{"x":854.56,"y":365.53}, - {"x":849.74,"y":370.38},{"x":844.09,"y":371.89},{"x":844.75,"y":380.44},{"x":841.52,"y":383.67}, - {"x":839.57,"y":390.40},{"x":845.59,"y":399.05},{"x":848.40,"y":407.55},{"x":843.71,"y":411.30}, - {"x":844.09,"y":419.88},{"x":839.51,"y":432.76},{"x":841.33,"y":441.04},{"x":847.62,"y":449.22}, - {"x":847.16,"y":458.44},{"x":851.38,"y":462.79},{"x":853.97,"y":471.15},{"x":866.36,"y":480.77} + {x:224.55,y:250.15},{x:226.91,y:244.19},{x:233.31,y:241.45},{x:234.98,y:236.06}, + {x:244.21,y:232.76},{x:262.59,y:215.31},{x:267.76,y:213.81},{x:273.57,y:201.84}, + {x:273.12,y:192.16},{x:277.62,y:189.03},{x:280.36,y:181.41},{x:286.51,y:177.74}, + {x:292.41,y:159.37},{x:296.91,y:155.64},{x:314.95,y:151.37},{x:319.75,y:145.16}, + {x:330.33,y:137.57},{x:341.48,y:139.96},{x:369.98,y:137.89},{x:387.39,y:142.51}, + {x:391.28,y:139.39},{x:409.52,y:141.14},{x:414.82,y:139.75},{x:427.72,y:127.30}, + {x:439.60,y:119.74},{x:474.93,y:107.87},{x:486.51,y:106.75},{x:489.20,y:109.45}, + {x:493.79,y:108.63},{x:504.74,y:119.66},{x:512.96,y:122.35},{x:518.63,y:120.89}, + {x:524.09,y:126.88},{x:529.57,y:127.86},{x:534.21,y:140.93},{x:539.27,y:147.24}, + {x:567.69,y:148.91},{x:575.25,y:157.26},{x:580.62,y:158.15},{x:601.53,y:156.85}, + {x:617.74,y:159.86},{x:622.00,y:167.04},{x:629.55,y:194.60},{x:638.90,y:195.61}, + {x:641.26,y:200.81},{x:651.77,y:204.56},{x:671.55,y:222.55},{x:683.68,y:217.45}, + {x:695.25,y:219.15},{x:700.64,y:217.98},{x:703.12,y:214.36},{x:712.26,y:215.87}, + {x:721.49,y:212.81},{x:727.81,y:213.36},{x:729.98,y:208.73},{x:735.32,y:208.20}, + {x:739.94,y:204.77},{x:769.98,y:208.42},{x:779.60,y:216.87},{x:784.20,y:218.16}, + {x:800.24,y:214.62},{x:810.53,y:219.73},{x:817.19,y:226.82},{x:820.77,y:236.17}, + {x:827.23,y:236.16},{x:829.89,y:239.89},{x:851.00,y:248.94},{x:859.88,y:255.49}, + {x:865.21,y:268.53},{x:857.95,y:280.30},{x:865.48,y:291.45},{x:866.81,y:298.66}, + {x:864.68,y:302.71},{x:867.79,y:306.17},{x:859.87,y:311.37},{x:860.08,y:314.35}, + {x:858.29,y:314.94},{x:858.10,y:327.60},{x:854.54,y:335.40},{x:860.92,y:343.00}, + {x:856.43,y:350.15},{x:851.42,y:352.96},{x:849.84,y:359.59},{x:854.56,y:365.53}, + {x:849.74,y:370.38},{x:844.09,y:371.89},{x:844.75,y:380.44},{x:841.52,y:383.67}, + {x:839.57,y:390.40},{x:845.59,y:399.05},{x:848.40,y:407.55},{x:843.71,y:411.30}, + {x:844.09,y:419.88},{x:839.51,y:432.76},{x:841.33,y:441.04},{x:847.62,y:449.22}, + {x:847.16,y:458.44},{x:851.38,y:462.79},{x:853.97,y:471.15},{x:866.36,y:480.77} ]; var simplified = [ - {"x":224.55,"y":250.15},{"x":267.76,"y":213.81},{"x":296.91,"y":155.64},{"x":330.33,"y":137.57}, - {"x":409.52,"y":141.14},{"x":439.60,"y":119.74},{"x":486.51,"y":106.75},{"x":529.57,"y":127.86}, - {"x":539.27,"y":147.24},{"x":617.74,"y":159.86},{"x":629.55,"y":194.60},{"x":671.55,"y":222.55}, - {"x":727.81,"y":213.36},{"x":739.94,"y":204.77},{"x":769.98,"y":208.42},{"x":779.60,"y":216.87}, - {"x":800.24,"y":214.62},{"x":820.77,"y":236.17},{"x":859.88,"y":255.49},{"x":865.21,"y":268.53}, - {"x":857.95,"y":280.30},{"x":867.79,"y":306.17},{"x":859.87,"y":311.37},{"x":854.54,"y":335.40}, - {"x":860.92,"y":343.00},{"x":849.84,"y":359.59},{"x":854.56,"y":365.53},{"x":844.09,"y":371.89}, - {"x":839.57,"y":390.40},{"x":848.40,"y":407.55},{"x":839.51,"y":432.76},{"x":853.97,"y":471.15}, - {"x":866.36,"y":480.77} + {x:224.55,y:250.15},{x:267.76,y:213.81},{x:296.91,y:155.64},{x:330.33,y:137.57}, + {x:409.52,y:141.14},{x:439.60,y:119.74},{x:486.51,y:106.75},{x:529.57,y:127.86}, + {x:539.27,y:147.24},{x:617.74,y:159.86},{x:629.55,y:194.60},{x:671.55,y:222.55}, + {x:727.81,y:213.36},{x:739.94,y:204.77},{x:769.98,y:208.42},{x:779.60,y:216.87}, + {x:800.24,y:214.62},{x:820.77,y:236.17},{x:859.88,y:255.49},{x:865.21,y:268.53}, + {x:857.95,y:280.30},{x:867.79,y:306.17},{x:859.87,y:311.37},{x:854.54,y:335.40}, + {x:860.92,y:343.00},{x:849.84,y:359.59},{x:854.56,y:365.53},{x:844.09,y:371.89}, + {x:839.57,y:390.40},{x:848.40,y:407.55},{x:839.51,y:432.76},{x:853.97,y:471.15}, + {x:866.36,y:480.77} ]; var simplify = require('./simplify'), From b4e3f59121a1d789209c480fc9f4d429f8b1b99e Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 11 Apr 2014 13:04:02 +0300 Subject: [PATCH 22/49] add worker support, bump version --- package.json | 2 +- simplify.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index aa562d4..7479a24 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simplify-js", - "version": "1.2.0", + "version": "1.2.1", "description": "A high-performance JavaScript 2D/3D polyline simplification library", "homepage": "http://mourner.github.com/simplify-js/", "author": "Vladimir Agafonkin", diff --git a/simplify.js b/simplify.js index 9ffdaca..3233c1a 100644 --- a/simplify.js +++ b/simplify.js @@ -122,9 +122,10 @@ function simplify(points, tolerance, highestQuality) { return points; } -// export as AMD module / Node module / browser variable +// export as AMD module / Node module / browser or worker variable if (typeof define === 'function' && define.amd) define(function() { return simplify; }); else if (typeof module !== 'undefined') module.exports = simplify; +else if (typeof self !== 'undefined') self.simplify = simplify; else window.simplify = simplify; })(); From 74394d7a40790a6723c2c77c8b36916cc97f2b30 Mon Sep 17 00:00:00 2001 From: Yutaka HARA Date: Fri, 11 Apr 2014 19:10:17 +0900 Subject: [PATCH 23/49] fix simplify([]) returns [undefined] --- simplify.js | 4 ++++ test.js | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/simplify.js b/simplify.js index 9ffdaca..c80d08d 100644 --- a/simplify.js +++ b/simplify.js @@ -113,6 +113,10 @@ function simplifyDouglasPeucker(points, sqTolerance) { // both algorithms combined for awesome performance function simplify(points, tolerance, highestQuality) { + + if (points.length <= 1) { + return points; + } var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1; diff --git a/test.js b/test.js index c042e1f..c1c3a7d 100644 --- a/test.js +++ b/test.js @@ -46,3 +46,15 @@ t('simplifies points correctly with the given tolerance', function (t) { t.same(result, simplified); t.end(); }); + +t('just return the points if it has only one point', function(t){ + var result = simplify([{x:1, y:2}]); + t.same(result, [{x:1, y:2}]); + t.end(); +}); + +t('just return the points if it has no points', function(t){ + var result = simplify([]); + t.same(result, []); + t.end(); +}); From da10f513dec0db2f78df99da43bdfd46efb02f55 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 11 Apr 2014 13:38:05 +0300 Subject: [PATCH 24/49] minor cleanup --- simplify.js | 6 ++---- test.js | 14 +++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/simplify.js b/simplify.js index 8656898..fa86746 100644 --- a/simplify.js +++ b/simplify.js @@ -113,10 +113,8 @@ function simplifyDouglasPeucker(points, sqTolerance) { // both algorithms combined for awesome performance function simplify(points, tolerance, highestQuality) { - - if (points.length <= 1) { - return points; - } + + if (points.length <= 1) return points; var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1; diff --git a/test.js b/test.js index c1c3a7d..185a8a5 100644 --- a/test.js +++ b/test.js @@ -39,22 +39,22 @@ var simplified = [ ]; var simplify = require('./simplify'), - t = require('tape'); + t = require('tape'); t('simplifies points correctly with the given tolerance', function (t) { - var result = simplify(points, 5); - t.same(result, simplified); + var result = simplify(points, 5); + t.same(result, simplified); t.end(); }); t('just return the points if it has only one point', function(t){ - var result = simplify([{x:1, y:2}]); - t.same(result, [{x:1, y:2}]); + var result = simplify([{x:1, y:2}]); + t.same(result, [{x:1, y:2}]); t.end(); }); t('just return the points if it has no points', function(t){ - var result = simplify([]); - t.same(result, []); + var result = simplify([]); + t.same(result, []); t.end(); }); From 98a6d020f97c7a164068d0d13a2ce42f4dfe386e Mon Sep 17 00:00:00 2001 From: Andrey Chumak Date: Thu, 3 Jul 2014 14:50:41 +0200 Subject: [PATCH 25/49] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f0f54bf..6960f8c 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Checkout the demo with docs: http://mourner.github.io/simplify-js/ * Python: [omarestrella / simplify.py](https://github.com/omarestrella/simplify.py) (by Omar Estrella) * PHP: [AKeN / simplify-php](https://github.com/AKeN/simplify-php) (by Rotari Gheorghe) + * PHP: [andreychumak / simplify-php](https://github.com/andreychumak/simplify-php) (by Andrey Chumak) * Java: [ekeneijeoma / simplify-java](https://github.com/ekeneijeoma/simplify-java) (by Ekene Ijeoma) * Java: [hgoebl / simplify-java](https://github.com/hgoebl/simplify-java) (by Heinrich Göbl) * Processing: [ekeneijeoma / simplify-processing](https://github.com/ekeneijeoma/simplify-processing) (by Ekene Ijeoma) From f7accd2ecf0c76e1ca0986bec7b2763401301427 Mon Sep 17 00:00:00 2001 From: odlp Date: Thu, 24 Jul 2014 23:07:18 +0100 Subject: [PATCH 26/49] Added link to Ruby port --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6960f8c..e43edf6 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,4 @@ Checkout the demo with docs: http://mourner.github.io/simplify-js/ * Processing: [ekeneijeoma / simplify-processing](https://github.com/ekeneijeoma/simplify-processing) (by Ekene Ijeoma) * AS3: [fnicollet / simplify-as3](https://github.com/fnicollet/simplify-as3) (by Fabien Nicollet) * Rust: [calvinmetcalf / simplify-rs](https://github.com/calvinmetcalf/simplify-rs) (by Calvin Metcalf) + * Ruby: [odlp / simplify_rb](https://github.com/odlp/simplify_rb) (by Oliver Peate) From 6b5b3f7c0da8a63b16bb8b37e055e704fc07a292 Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 15 Oct 2014 14:32:11 +0400 Subject: [PATCH 27/49] Added Go port in the readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e43edf6..89a0992 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,4 @@ Checkout the demo with docs: http://mourner.github.io/simplify-js/ * AS3: [fnicollet / simplify-as3](https://github.com/fnicollet/simplify-as3) (by Fabien Nicollet) * Rust: [calvinmetcalf / simplify-rs](https://github.com/calvinmetcalf/simplify-rs) (by Calvin Metcalf) * Ruby: [odlp / simplify_rb](https://github.com/odlp/simplify_rb) (by Oliver Peate) + * Go: [yrsh / simplify_go](https://github.com/yrsh/simplify-go) (by Anton Korotkikh) From 89022fb083775ce9e98656d819da9b5e44879d49 Mon Sep 17 00:00:00 2001 From: imshz Date: Tue, 9 Dec 2014 00:37:16 +0100 Subject: [PATCH 28/49] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 89a0992..46405bc 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,4 @@ Checkout the demo with docs: http://mourner.github.io/simplify-js/ * Rust: [calvinmetcalf / simplify-rs](https://github.com/calvinmetcalf/simplify-rs) (by Calvin Metcalf) * Ruby: [odlp / simplify_rb](https://github.com/odlp/simplify_rb) (by Oliver Peate) * Go: [yrsh / simplify_go](https://github.com/yrsh/simplify-go) (by Anton Korotkikh) + * C# (Portable): [imshz / simplify-net](https://github.com/imshz/simplify-net) (by Shees Ul-Hassan) From 40d768424071e14e365a30a1a12d214d739faff0 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Mon, 23 Mar 2015 12:38:40 +0200 Subject: [PATCH 29/49] update year --- LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index d4e1335..4730ad7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2012, Vladimir Agafonkin +Copyright (c) 2015, Vladimir Agafonkin All rights reserved. Redistribution and use in source and binary forms, with or without modification, are @@ -19,4 +19,4 @@ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 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. \ No newline at end of file +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From 4f0af00947978b1da3bd12b83c98edba31e94d90 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Mon, 23 Mar 2015 12:41:22 +0200 Subject: [PATCH 30/49] update deps --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7479a24..7e88e0f 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "main": "simplify.js", "devDependencies": { "faucet": "0.0.1", - "tape": "^2.12.3", - "jshint": "^2.5.0" + "tape": "^3.5.0", + "jshint": "^2.6.3" }, "scripts": { "test": "jshint simplify.js test.js && node test.js | faucet" From e637a16b921f0616cea4c3634ecc005e1e588821 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Mon, 23 Mar 2015 12:50:05 +0200 Subject: [PATCH 31/49] move test to subdir --- package.json | 7 ++++--- test.js => test/test.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) rename test.js => test/test.js (98%) diff --git a/package.json b/package.json index 7e88e0f..9f4017b 100644 --- a/package.json +++ b/package.json @@ -16,12 +16,13 @@ }, "main": "simplify.js", "devDependencies": { + "benchmark": "^1.0.0", "faucet": "0.0.1", - "tape": "^3.5.0", - "jshint": "^2.6.3" + "jshint": "^2.6.3", + "tape": "^3.5.0" }, "scripts": { - "test": "jshint simplify.js test.js && node test.js | faucet" + "test": "jshint simplify.js test/test.js && node test/test.js | faucet" }, "jshintConfig": { "quotmark": "single", diff --git a/test.js b/test/test.js similarity index 98% rename from test.js rename to test/test.js index 185a8a5..2850850 100644 --- a/test.js +++ b/test/test.js @@ -38,7 +38,7 @@ var simplified = [ {x:866.36,y:480.77} ]; -var simplify = require('./simplify'), +var simplify = require('../simplify'), t = require('tape'); t('simplifies points correctly with the given tolerance', function (t) { From d6c2e5ef48a961188c70b2190fb1cf03306e979e Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 2 Apr 2015 13:18:46 +0300 Subject: [PATCH 32/49] 2-3x Douglas-Peucker perf improvement Avoids keeping a separate array for tracking picked points with a recursive implementation, plus some other minor tweaks. --- simplify.js | 56 +++++++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/simplify.js b/simplify.js index fa86746..407c988 100644 --- a/simplify.js +++ b/simplify.js @@ -68,47 +68,35 @@ function simplifyRadialDist(points, sqTolerance) { return newPoints; } -// simplification using optimized Douglas-Peucker algorithm with recursion elimination -function simplifyDouglasPeucker(points, sqTolerance) { - - var len = points.length, - MarkerArray = typeof Uint8Array !== 'undefined' ? Uint8Array : Array, - markers = new MarkerArray(len), - first = 0, - last = len - 1, - stack = [], - newPoints = [], - i, maxSqDist, sqDist, index; - - markers[first] = markers[last] = 1; - - while (last) { +function simplifyDPStep(points, first, last, sqTolerance, simplified) { + var maxSqDist = 0, + index; - maxSqDist = 0; - - for (i = first + 1; i < last; i++) { - sqDist = getSqSegDist(points[i], points[first], points[last]); - - if (sqDist > maxSqDist) { - index = i; - maxSqDist = sqDist; - } - } + for (var i = first + 1; i < last; i++) { + var sqDist = getSqSegDist(points[i], points[first], points[last]); - if (maxSqDist > sqTolerance) { - markers[index] = 1; - stack.push(first, index, index, last); + if (sqDist > maxSqDist) { + index = i; + maxSqDist = sqDist; } - - last = stack.pop(); - first = stack.pop(); } - for (i = 0; i < len; i++) { - if (markers[i]) newPoints.push(points[i]); + if (maxSqDist > sqTolerance) { + if (index - first > 1) simplifyDPStep(points, first, index, sqTolerance, simplified); + simplified.push(points[index]); + if (last - index > 1) simplifyDPStep(points, index, last, sqTolerance, simplified); } +} - return newPoints; +// simplification using Ramer-Douglas-Peucker algorithm +function simplifyDouglasPeucker(points, sqTolerance) { + var last = points.length - 1; + + var simplified = [points[0]]; + simplifyDPStep(points, 0, last, sqTolerance, simplified); + simplified.push(points[last]); + + return simplified; } // both algorithms combined for awesome performance From 71164654de13898ccc33c0f7252ca1e490feebef Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 2 Apr 2015 16:02:21 +0300 Subject: [PATCH 33/49] don't attempt simplifying 2-point lines --- simplify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplify.js b/simplify.js index 407c988..63a5ddb 100644 --- a/simplify.js +++ b/simplify.js @@ -102,7 +102,7 @@ function simplifyDouglasPeucker(points, sqTolerance) { // both algorithms combined for awesome performance function simplify(points, tolerance, highestQuality) { - if (points.length <= 1) return points; + if (points.length <= 2) return points; var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1; From 2bcd7ce5fb2e9767571b82718a9175a256a56da8 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 2 Apr 2015 16:14:59 +0300 Subject: [PATCH 34/49] 1.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9f4017b..c3b7eb7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simplify-js", - "version": "1.2.1", + "version": "1.2.2", "description": "A high-performance JavaScript 2D/3D polyline simplification library", "homepage": "http://mourner.github.com/simplify-js/", "author": "Vladimir Agafonkin", From 8c8b59a46514a11bb2d795993de808af1613611c Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 2 Apr 2015 17:41:14 +0300 Subject: [PATCH 35/49] add a simple benchmark --- bench/bench.js | 19 +++++++++++++++++++ test/fixtures/1k.json | 1 + 2 files changed, 20 insertions(+) create mode 100644 bench/bench.js create mode 100644 test/fixtures/1k.json diff --git a/bench/bench.js b/bench/bench.js new file mode 100644 index 0000000..b06ddad --- /dev/null +++ b/bench/bench.js @@ -0,0 +1,19 @@ + +var Benchmark = require('benchmark'); +var simplify = require('../simplify'); + +var points = require('../test/fixtures/1k.json'); + +console.log('Benchmarking simplify on ' + points.length + ' points...'); + +new Benchmark.Suite() +.add('simplify (HQ)', function() { + simplify(points, 1, true); +}) +.add('simplify', function() { + simplify(points, 1, false); +}) +.on('cycle', function(event) { + console.log(String(event.target)); +}) +.run(); diff --git a/test/fixtures/1k.json b/test/fixtures/1k.json new file mode 100644 index 0000000..1f3180f --- /dev/null +++ b/test/fixtures/1k.json @@ -0,0 +1 @@ +[{"x":224.55,"y":250.15},{"x":224.69,"y":250.61},{"x":225.15,"y":249.8},{"x":224.16,"y":249.25},{"x":224.26,"y":248.87},{"x":224.93,"y":247.89},{"x":225.18,"y":246.9},{"x":226.56,"y":245.62},{"x":226.9,"y":245.04},{"x":226.91,"y":244.19},{"x":227.47,"y":244.29},{"x":227.98,"y":244.1},{"x":229.79,"y":244.14},{"x":231.58,"y":243.65},{"x":232.32,"y":242.32},{"x":232.76,"y":242.1},{"x":233.31,"y":241.45},{"x":233.59,"y":240.66},{"x":233.38,"y":238.66},{"x":234.32,"y":237.77},{"x":234.98,"y":236.06},{"x":235.45,"y":235.85},{"x":237.05,"y":235.71},{"x":237.44,"y":235.95},{"x":238.8,"y":235.98},{"x":240.13,"y":234.6},{"x":243.53,"y":233.18},{"x":243.72,"y":232.87},{"x":244.21,"y":232.76},{"x":244.67,"y":232.26},{"x":244.79,"y":231.8},{"x":245.39,"y":231.58},{"x":245.71,"y":231.27},{"x":247.44,"y":229},{"x":248.09,"y":228.83},{"x":248.75,"y":228.18},{"x":248.91,"y":227.75},{"x":249.91,"y":226.75},{"x":250.68,"y":225.45},{"x":251.76,"y":224.93},{"x":253.59,"y":223.23},{"x":254.27,"y":222.87},{"x":254.68,"y":222.92},{"x":255.45,"y":222.66},{"x":255.65,"y":222.25},{"x":256.48,"y":221.57},{"x":256.9,"y":221.42},{"x":257.8,"y":220.52},{"x":258.29,"y":220.46},{"x":259.12,"y":219.84},{"x":259.65,"y":219.81},{"x":259.69,"y":219.55},{"x":259.94,"y":219.41},{"x":259.96,"y":219.1},{"x":260.68,"y":218.47},{"x":260.62,"y":218.23},{"x":260.98,"y":218.1},{"x":261.38,"y":217.5},{"x":262.15,"y":216.86},{"x":262.15,"y":216},{"x":262.59,"y":215.31},{"x":263,"y":215.52},{"x":263.31,"y":215.31},{"x":265.12,"y":215.33},{"x":265.37,"y":215.08},{"x":266.19,"y":214.86},{"x":267.11,"y":214.04},{"x":267.76,"y":213.81},{"x":267.97,"y":212.72},{"x":268.57,"y":212.22},{"x":269,"y":212.1},{"x":269.13,"y":211.31},{"x":270.22,"y":209.55},{"x":270.42,"y":208.65},{"x":271.35,"y":206.48},{"x":271.16,"y":204.85},{"x":271.25,"y":204.51},{"x":272.26,"y":203.54},{"x":272.52,"y":203.4},{"x":272.91,"y":203.47},{"x":273.16,"y":203.05},{"x":273.09,"y":202.64},{"x":273.57,"y":201.84},{"x":273.24,"y":200.81},{"x":273.26,"y":200.35},{"x":272.56,"y":198.59},{"x":272.47,"y":197.87},{"x":272.65,"y":196.88},{"x":272.18,"y":195.66},{"x":272.46,"y":194.59},{"x":272.82,"y":194.1},{"x":273.12,"y":192.16},{"x":274.21,"y":190.81},{"x":276.63,"y":189.43},{"x":277.2,"y":189.42},{"x":277.62,"y":189.03},{"x":278,"y":188.43},{"x":278.14,"y":187.72},{"x":278.89,"y":187.1},{"x":279.35,"y":184.47},{"x":279.94,"y":182.84},{"x":280.02,"y":182.02},{"x":280.36,"y":181.41},{"x":282.49,"y":180.2},{"x":283.6,"y":180.14},{"x":285.89,"y":177.93},{"x":286.51,"y":177.74},{"x":286.51,"y":174.97},{"x":286.88,"y":173.04},{"x":286.83,"y":172.31},{"x":288.11,"y":171.63},{"x":288.83,"y":170.76},{"x":289.02,"y":170.83},{"x":289.34,"y":170.35},{"x":289.37,"y":169.96},{"x":290.07,"y":169.32},{"x":290.07,"y":168.66},{"x":290.41,"y":168.18},{"x":290.56,"y":167.19},{"x":291.34,"y":165.93},{"x":291.34,"y":164.45},{"x":292.41,"y":159.37},{"x":293.32,"y":158.78},{"x":294.89,"y":157.33},{"x":295.21,"y":156.86},{"x":295.71,"y":156.55},{"x":296.26,"y":156.57},{"x":296.91,"y":155.64},{"x":298.25,"y":155.53},{"x":298.69,"y":155.19},{"x":299.08,"y":155.3},{"x":299.69,"y":155.09},{"x":300.4,"y":155.31},{"x":301.77,"y":155.4},{"x":302.39,"y":155.17},{"x":303.28,"y":155.17},{"x":304.16,"y":154.83},{"x":305,"y":154.86},{"x":305.76,"y":154.33},{"x":306.8,"y":154.06},{"x":307.25,"y":153.61},{"x":307.94,"y":153.43},{"x":308.74,"y":153.92},{"x":310.09,"y":153.8},{"x":310.87,"y":153.12},{"x":311.14,"y":152.68},{"x":311.1,"y":152.41},{"x":311.44,"y":152.21},{"x":312.63,"y":152.11},{"x":313.39,"y":151.64},{"x":314.04,"y":151.61},{"x":314.49,"y":151.27},{"x":314.95,"y":151.37},{"x":315.01,"y":150.76},{"x":315.63,"y":150.29},{"x":316.54,"y":149.92},{"x":316.67,"y":149.58},{"x":317.12,"y":149.2},{"x":317.26,"y":148.67},{"x":317.1,"y":148.35},{"x":317.33,"y":147.82},{"x":318.7,"y":146.87},{"x":318.92,"y":146.51},{"x":319.39,"y":146.2},{"x":319.75,"y":145.16},{"x":321,"y":144.76},{"x":321.37,"y":144.26},{"x":321.61,"y":143.55},{"x":324.39,"y":142.35},{"x":325,"y":141.75},{"x":325.3,"y":140.82},{"x":325.7,"y":140.45},{"x":325.73,"y":140.23},{"x":326.1,"y":140.08},{"x":326.27,"y":139.6},{"x":327.29,"y":139.43},{"x":328.26,"y":139.49},{"x":328.77,"y":139.29},{"x":329.75,"y":138.04},{"x":330.33,"y":137.57},{"x":331.77,"y":137.48},{"x":332.2,"y":137.78},{"x":333.94,"y":138.17},{"x":334.22,"y":138.36},{"x":337.6,"y":138.61},{"x":338.49,"y":139.04},{"x":338.91,"y":139.46},{"x":341.06,"y":139.74},{"x":341.48,"y":139.96},{"x":342.92,"y":139.36},{"x":345.95,"y":139.2},{"x":346.8,"y":138.88},{"x":347.37,"y":138.23},{"x":348.87,"y":138.35},{"x":349.47,"y":138.79},{"x":352.86,"y":138.52},{"x":353.58,"y":138.61},{"x":354,"y":138.48},{"x":355.41,"y":138.6},{"x":356.64,"y":138.3},{"x":358.69,"y":138.57},{"x":361.11,"y":138.35},{"x":362.24,"y":138.46},{"x":362.92,"y":138.76},{"x":363.58,"y":138.53},{"x":364.44,"y":138.48},{"x":365.39,"y":138.74},{"x":366.01,"y":138.47},{"x":367.8,"y":138.1},{"x":369.98,"y":137.89},{"x":370.82,"y":138.25},{"x":372.24,"y":138.21},{"x":373.71,"y":138.64},{"x":375.12,"y":138.53},{"x":376.08,"y":138.63},{"x":379.45,"y":139.95},{"x":380.38,"y":140.19},{"x":381.02,"y":140.07},{"x":381.86,"y":140.18},{"x":382.52,"y":140.4},{"x":383.38,"y":141.16},{"x":385.1,"y":142},{"x":387.39,"y":142.51},{"x":387.67,"y":142.49},{"x":387.78,"y":142.12},{"x":389.17,"y":141.03},{"x":389.39,"y":140.38},{"x":390.47,"y":140.07},{"x":390.92,"y":139.47},{"x":391.14,"y":139.58},{"x":391.28,"y":139.39},{"x":393.29,"y":139.65},{"x":395.17,"y":139.38},{"x":395.55,"y":139.48},{"x":395.98,"y":139.3},{"x":398.28,"y":139.63},{"x":398.75,"y":139.84},{"x":400.57,"y":139.55},{"x":402.4,"y":139.89},{"x":402.45,"y":140.15},{"x":403.03,"y":140.26},{"x":404.11,"y":140.85},{"x":404.97,"y":141.02},{"x":405.47,"y":141.48},{"x":405.79,"y":141.49},{"x":406.09,"y":141.23},{"x":406.53,"y":141.13},{"x":407.24,"y":141.17},{"x":407.51,"y":141},{"x":408.37,"y":141.17},{"x":409.52,"y":141.14},{"x":410.11,"y":140.33},{"x":410.76,"y":140.08},{"x":411.69,"y":140.42},{"x":414.13,"y":139.64},{"x":414.47,"y":139.84},{"x":414.82,"y":139.75},{"x":414.99,"y":139.32},{"x":417.7,"y":137.3},{"x":419.56,"y":135.5},{"x":421.29,"y":134.3},{"x":421.9,"y":133.5},{"x":422.7,"y":131.95},{"x":423.23,"y":131.48},{"x":423.38,"y":130.94},{"x":426.08,"y":129.26},{"x":427.15,"y":128.21},{"x":427.72,"y":127.3},{"x":429.37,"y":126.9},{"x":429.83,"y":126.52},{"x":430.08,"y":125.88},{"x":432.07,"y":125.45},{"x":433.14,"y":125.07},{"x":434.13,"y":124.46},{"x":434.88,"y":123.79},{"x":435.25,"y":123},{"x":436.4,"y":122.42},{"x":437.77,"y":122.05},{"x":439.1,"y":120.02},{"x":439.6,"y":119.74},{"x":440.85,"y":119.64},{"x":441.91,"y":119.03},{"x":442.73,"y":118.95},{"x":445.6,"y":117.92},{"x":446.05,"y":117.97},{"x":447.34,"y":117.65},{"x":447.77,"y":117.29},{"x":448.22,"y":117.18},{"x":448.99,"y":116.53},{"x":451.14,"y":115.9},{"x":452.8,"y":115.83},{"x":455.08,"y":115.26},{"x":456.19,"y":114.32},{"x":458.08,"y":114.11},{"x":458.64,"y":113.86},{"x":460,"y":112.48},{"x":465.64,"y":111.28},{"x":466.42,"y":110.95},{"x":467.42,"y":111},{"x":468.84,"y":110.79},{"x":469.75,"y":110.92},{"x":471.64,"y":110.14},{"x":474.93,"y":107.87},{"x":475.8,"y":107.73},{"x":477.38,"y":107.87},{"x":478.2,"y":108.1},{"x":481.19,"y":108.21},{"x":481.8,"y":107.84},{"x":483.39,"y":107.3},{"x":486.51,"y":106.75},{"x":486.37,"y":107.53},{"x":486.79,"y":107.98},{"x":487.66,"y":108.73},{"x":488.86,"y":109.07},{"x":489.2,"y":109.45},{"x":491.39,"y":109.36},{"x":492.01,"y":109.1},{"x":493.15,"y":109.03},{"x":493.57,"y":108.63},{"x":493.79,"y":108.63},{"x":494.48,"y":109.16},{"x":495.27,"y":110.44},{"x":495.78,"y":110.65},{"x":496.09,"y":111.22},{"x":497.28,"y":111.75},{"x":497.3,"y":112.24},{"x":497.55,"y":112.68},{"x":498.84,"y":113.96},{"x":501.08,"y":115.96},{"x":502.08,"y":116.42},{"x":502.63,"y":117.28},{"x":503.71,"y":118.01},{"x":504.16,"y":118.77},{"x":504.18,"y":119.09},{"x":504.74,"y":119.66},{"x":505.18,"y":119.8},{"x":507.32,"y":119.66},{"x":508.21,"y":119.83},{"x":508.79,"y":120.46},{"x":509.6,"y":120.56},{"x":510.02,"y":121.08},{"x":512.96,"y":122.35},{"x":513.27,"y":121.99},{"x":513.66,"y":122.18},{"x":514.28,"y":122.2},{"x":514.8,"y":121.6},{"x":515.49,"y":121.39},{"x":516.2,"y":121.4},{"x":517.51,"y":120.87},{"x":517.86,"y":121.04},{"x":518.63,"y":120.89},{"x":518.88,"y":121.42},{"x":519.95,"y":122.03},{"x":520.43,"y":122.49},{"x":520.56,"y":122.87},{"x":521.93,"y":123.43},{"x":523.01,"y":125.73},{"x":524.09,"y":126.88},{"x":524.55,"y":126.97},{"x":524.92,"y":127.38},{"x":525.36,"y":127.41},{"x":526.63,"y":127.94},{"x":527.99,"y":127.95},{"x":528.98,"y":127.61},{"x":529.57,"y":127.86},{"x":529.89,"y":128.14},{"x":530.53,"y":129.23},{"x":530.87,"y":129.47},{"x":530.69,"y":129.79},{"x":530.81,"y":132.77},{"x":532.48,"y":134.47},{"x":533.15,"y":136.66},{"x":533.9,"y":137.9},{"x":534.03,"y":138.86},{"x":533.91,"y":139.82},{"x":534.21,"y":140.93},{"x":534.77,"y":141.58},{"x":535.23,"y":142.66},{"x":536.2,"y":143.65},{"x":536.69,"y":144.76},{"x":537.01,"y":144.47},{"x":537.85,"y":144.57},{"x":538.5,"y":144.83},{"x":539.24,"y":145.53},{"x":539.45,"y":146.73},{"x":539.27,"y":147.24},{"x":541.59,"y":148.01},{"x":542.6,"y":148.02},{"x":543.15,"y":148.44},{"x":543.68,"y":148.54},{"x":546.12,"y":148.44},{"x":546.26,"y":148.13},{"x":547.74,"y":147.7},{"x":548.95,"y":147.72},{"x":549.68,"y":147.45},{"x":550.4,"y":147.56},{"x":550.66,"y":147.27},{"x":552,"y":147.31},{"x":552.94,"y":148.22},{"x":554.75,"y":148.14},{"x":555.02,"y":148.64},{"x":555.32,"y":148.74},{"x":556.16,"y":148.56},{"x":557.88,"y":148.83},{"x":559.07,"y":148.41},{"x":559.7,"y":148.48},{"x":559.99,"y":148.85},{"x":560.62,"y":148.99},{"x":560.92,"y":149.29},{"x":562.06,"y":149.76},{"x":565.3,"y":149.57},{"x":566.51,"y":148.91},{"x":567.69,"y":148.91},{"x":567.89,"y":148.98},{"x":567.77,"y":149.19},{"x":568.1,"y":149.46},{"x":568.52,"y":149.57},{"x":568.94,"y":149.45},{"x":569.23,"y":150.05},{"x":570.38,"y":151.12},{"x":571.1,"y":152.6},{"x":571.76,"y":153.09},{"x":575.25,"y":157.26},{"x":576.85,"y":157.4},{"x":580.62,"y":158.15},{"x":581.86,"y":158.14},{"x":583.83,"y":157.79},{"x":584.98,"y":158.17},{"x":586.67,"y":158.32},{"x":592.8,"y":158.21},{"x":593.19,"y":157.95},{"x":595.17,"y":157.66},{"x":596.17,"y":157.78},{"x":598.02,"y":157.63},{"x":598.61,"y":157.4},{"x":599.48,"y":157.39},{"x":601.06,"y":157.06},{"x":601.53,"y":156.85},{"x":601.68,"y":157.03},{"x":605.03,"y":157.05},{"x":606.47,"y":157.69},{"x":606.9,"y":157.71},{"x":608.23,"y":157.27},{"x":608.5,"y":157.46},{"x":608.81,"y":157.35},{"x":609.47,"y":158.05},{"x":609.86,"y":157.92},{"x":611.26,"y":158.55},{"x":612.3,"y":158.44},{"x":614.73,"y":158.8},{"x":617.74,"y":159.86},{"x":618.14,"y":160.29},{"x":617.91,"y":160.98},{"x":619.71,"y":164.86},{"x":621.52,"y":166.36},{"x":622,"y":167.04},{"x":622.11,"y":170.69},{"x":622.01,"y":171.26},{"x":623.66,"y":173.26},{"x":624.15,"y":176.75},{"x":624.68,"y":177.5},{"x":625.05,"y":179.03},{"x":625.69,"y":179.83},{"x":626.06,"y":181.1},{"x":625.92,"y":185.63},{"x":626.45,"y":185.96},{"x":626.72,"y":186.8},{"x":627.07,"y":186.84},{"x":627.62,"y":188.65},{"x":628.11,"y":189.21},{"x":628.09,"y":190.19},{"x":629.18,"y":192.37},{"x":629.55,"y":194.6},{"x":629.93,"y":194.86},{"x":630.78,"y":194.7},{"x":632.12,"y":194.86},{"x":633.06,"y":195.47},{"x":635.78,"y":196.31},{"x":638.39,"y":195.52},{"x":638.9,"y":195.61},{"x":640.48,"y":197.63},{"x":640.44,"y":199.01},{"x":641.26,"y":200.81},{"x":644.54,"y":202.78},{"x":645.02,"y":202.82},{"x":645.55,"y":202.57},{"x":647.72,"y":202.67},{"x":648.57,"y":203.55},{"x":648.85,"y":203.38},{"x":648.94,"y":203.12},{"x":649.85,"y":203.32},{"x":651,"y":204.22},{"x":651.77,"y":204.56},{"x":653.14,"y":206.28},{"x":655.45,"y":208.18},{"x":656.46,"y":208.26},{"x":657.19,"y":208.81},{"x":657.89,"y":209.06},{"x":658.59,"y":210.25},{"x":659.45,"y":210.83},{"x":661.57,"y":213.37},{"x":664.15,"y":215.09},{"x":664.54,"y":215},{"x":664.76,"y":215.19},{"x":664.73,"y":215.38},{"x":665.8,"y":215.98},{"x":666.58,"y":216.94},{"x":667.21,"y":217.45},{"x":669.67,"y":219.1},{"x":669.72,"y":219.89},{"x":670.07,"y":220.84},{"x":670.36,"y":221.01},{"x":671.19,"y":222.26},{"x":671.55,"y":222.55},{"x":671.9,"y":222.07},{"x":672.3,"y":222.11},{"x":672.9,"y":221.69},{"x":673.65,"y":221.62},{"x":674.39,"y":221.09},{"x":675.68,"y":220.97},{"x":677.51,"y":221.33},{"x":677.85,"y":220.89},{"x":678.6,"y":220.39},{"x":679.03,"y":219.79},{"x":681.31,"y":218.71},{"x":681.6,"y":217.98},{"x":681.8,"y":217.85},{"x":682.62,"y":218.16},{"x":683.68,"y":217.45},{"x":686.87,"y":217.67},{"x":687.49,"y":217.59},{"x":688.81,"y":218.15},{"x":690.62,"y":218.21},{"x":695.25,"y":219.15},{"x":696.58,"y":218.76},{"x":697.68,"y":218.83},{"x":699.34,"y":218.53},{"x":699.44,"y":218.09},{"x":700.64,"y":217.98},{"x":701.01,"y":217.32},{"x":700.98,"y":216.37},{"x":701.16,"y":215.87},{"x":702.86,"y":214.71},{"x":703.12,"y":214.36},{"x":707.1,"y":215.09},{"x":707.62,"y":214.92},{"x":709.34,"y":215.08},{"x":709.97,"y":215.36},{"x":710.42,"y":215.78},{"x":712.26,"y":215.87},{"x":713.11,"y":215.63},{"x":713.67,"y":215.25},{"x":714.04,"y":215.23},{"x":714.79,"y":214.47},{"x":715.81,"y":214.36},{"x":717.26,"y":213.55},{"x":717.92,"y":213.57},{"x":718.67,"y":213.28},{"x":721.25,"y":212.98},{"x":721.49,"y":212.81},{"x":721.76,"y":213.15},{"x":723.17,"y":213.29},{"x":723.44,"y":214},{"x":724.02,"y":214.27},{"x":726.71,"y":213.43},{"x":726.88,"y":213.52},{"x":727.13,"y":213.32},{"x":727.28,"y":213.43},{"x":727.81,"y":213.36},{"x":728.05,"y":213.1},{"x":728.07,"y":211.23},{"x":728.78,"y":210.03},{"x":729.98,"y":208.73},{"x":730.99,"y":208.38},{"x":732.01,"y":208.25},{"x":733.02,"y":207.73},{"x":733.8,"y":208.35},{"x":735.32,"y":208.2},{"x":735.9,"y":207.87},{"x":737.28,"y":206.1},{"x":737.56,"y":205.95},{"x":737.78,"y":206.1},{"x":737.69,"y":205.78},{"x":738.66,"y":205.44},{"x":738.96,"y":204.97},{"x":739.94,"y":204.77},{"x":742.94,"y":204.7},{"x":743.39,"y":204.86},{"x":744.12,"y":205.44},{"x":745.4,"y":205.53},{"x":746.71,"y":205.36},{"x":747.72,"y":204.96},{"x":747.93,"y":204.54},{"x":748.7,"y":204.81},{"x":749.82,"y":204.91},{"x":750.6,"y":205.38},{"x":751.17,"y":205.32},{"x":751.64,"y":205.58},{"x":751.78,"y":205.93},{"x":753.07,"y":206.02},{"x":754.04,"y":206.39},{"x":754.36,"y":206.67},{"x":755.78,"y":206.77},{"x":756.67,"y":206.5},{"x":756.99,"y":206.68},{"x":758.49,"y":206.49},{"x":759.99,"y":206.84},{"x":760.57,"y":206.82},{"x":761.03,"y":207.05},{"x":762.69,"y":207.01},{"x":763.05,"y":207.31},{"x":763.56,"y":207.32},{"x":764.71,"y":207.68},{"x":765.3,"y":207.74},{"x":765.97,"y":207.51},{"x":767.35,"y":208.01},{"x":767.71,"y":207.96},{"x":769.98,"y":208.42},{"x":771.92,"y":209.93},{"x":773.43,"y":210.6},{"x":773.77,"y":211.31},{"x":773.63,"y":211.74},{"x":773.94,"y":212.21},{"x":774.16,"y":212.25},{"x":774.26,"y":212.59},{"x":775.22,"y":212.7},{"x":776.36,"y":213.25},{"x":777.16,"y":214.24},{"x":777.95,"y":214.82},{"x":778.4,"y":214.87},{"x":778.64,"y":215.14},{"x":778.66,"y":215.48},{"x":779.21,"y":215.85},{"x":779.6,"y":216.87},{"x":780.98,"y":217.05},{"x":781.53,"y":217.41},{"x":782.83,"y":217.49},{"x":784.2,"y":218.16},{"x":785.44,"y":218.23},{"x":785.78,"y":218.02},{"x":787.96,"y":218.51},{"x":789.45,"y":218.36},{"x":789.93,"y":217.8},{"x":792.07,"y":217.27},{"x":793.31,"y":216.27},{"x":794.3,"y":215.97},{"x":796.24,"y":214.79},{"x":797.09,"y":214.55},{"x":797.67,"y":214.73},{"x":798.01,"y":214.61},{"x":798.25,"y":214.7},{"x":799.15,"y":214.29},{"x":800.24,"y":214.62},{"x":800.4,"y":215.1},{"x":801.04,"y":215.54},{"x":802.54,"y":215.57},{"x":803.32,"y":216.22},{"x":808.09,"y":218.4},{"x":808.83,"y":218.91},{"x":809.39,"y":218.95},{"x":810.53,"y":219.73},{"x":811.64,"y":221},{"x":811.65,"y":222.65},{"x":813.64,"y":224.71},{"x":815.18,"y":225.97},{"x":815.43,"y":225.97},{"x":816.14,"y":226.61},{"x":816.68,"y":226.79},{"x":817.06,"y":226.68},{"x":817.19,"y":226.82},{"x":817.85,"y":228.24},{"x":818.19,"y":228.64},{"x":818.6,"y":231.56},{"x":819.14,"y":232.38},{"x":819.1,"y":232.81},{"x":819.87,"y":233.97},{"x":820.77,"y":236.17},{"x":821.54,"y":236.39},{"x":823.92,"y":236.03},{"x":827.23,"y":236.16},{"x":827.53,"y":236.42},{"x":828.36,"y":238.42},{"x":829.89,"y":239.89},{"x":832.6,"y":241.26},{"x":834.54,"y":241.96},{"x":835.07,"y":241.88},{"x":835.18,"y":242.14},{"x":835.58,"y":242.13},{"x":836.17,"y":242.51},{"x":836.78,"y":242.66},{"x":837.53,"y":243.4},{"x":838.37,"y":243.88},{"x":838.43,"y":243.5},{"x":838.66,"y":243.57},{"x":839.04,"y":244.12},{"x":839.22,"y":244.92},{"x":841.21,"y":245.84},{"x":841.83,"y":246.04},{"x":842.04,"y":245.77},{"x":842.41,"y":245.75},{"x":843.26,"y":245.27},{"x":844.24,"y":245.57},{"x":845.03,"y":246.39},{"x":845.85,"y":246.6},{"x":847,"y":247.64},{"x":847.34,"y":247.73},{"x":847.41,"y":248.18},{"x":848.42,"y":248.13},{"x":849.7,"y":248.92},{"x":851,"y":248.94},{"x":851.44,"y":249.29},{"x":852.08,"y":250.28},{"x":852.61,"y":250.7},{"x":852.83,"y":251.42},{"x":854.06,"y":252.12},{"x":854.8,"y":252.81},{"x":856.59,"y":253.4},{"x":858.68,"y":254.64},{"x":859.5,"y":255.39},{"x":859.88,"y":255.49},{"x":860.33,"y":256.75},{"x":861.17,"y":257.75},{"x":861.43,"y":258.74},{"x":861.26,"y":259.2},{"x":861.57,"y":259.34},{"x":860.95,"y":260.82},{"x":862.67,"y":262.25},{"x":862.85,"y":262.88},{"x":863.1,"y":263.15},{"x":863.12,"y":263.53},{"x":864.01,"y":265},{"x":864.49,"y":267.98},{"x":864.76,"y":268.06},{"x":865.21,"y":268.53},{"x":865.02,"y":269.11},{"x":864.37,"y":268.85},{"x":864.15,"y":269.33},{"x":863.73,"y":269.69},{"x":863.78,"y":269.93},{"x":863.88,"y":269.85},{"x":864.53,"y":270.31},{"x":864.3,"y":270.94},{"x":864.43,"y":271.25},{"x":864.29,"y":271.5},{"x":863.59,"y":271.56},{"x":863.07,"y":272.03},{"x":863.14,"y":272.21},{"x":861.6,"y":273.31},{"x":861.47,"y":273.58},{"x":860.76,"y":273.83},{"x":860.64,"y":274.09},{"x":860.96,"y":274.52},{"x":860.93,"y":274.95},{"x":861.15,"y":275.41},{"x":861.42,"y":275.58},{"x":861.54,"y":276.09},{"x":861.18,"y":276.87},{"x":860.91,"y":276.89},{"x":861.03,"y":277.41},{"x":860.24,"y":277.5},{"x":859.28,"y":278.03},{"x":858.98,"y":278.5},{"x":858.91,"y":279.15},{"x":858.01,"y":279.83},{"x":857.95,"y":280.3},{"x":858.02,"y":280.95},{"x":858.56,"y":281.61},{"x":859.44,"y":281.91},{"x":859.85,"y":282.31},{"x":860.42,"y":282.4},{"x":860.41,"y":282.97},{"x":861.29,"y":283.62},{"x":861.73,"y":284.46},{"x":861.78,"y":285.25},{"x":861.6,"y":285.89},{"x":862.09,"y":286.16},{"x":862.38,"y":285.9},{"x":862.55,"y":285.95},{"x":862.9,"y":286.61},{"x":863.29,"y":288.07},{"x":863.36,"y":288.97},{"x":863.98,"y":289.4},{"x":863.94,"y":290.43},{"x":864.45,"y":290.42},{"x":864.57,"y":290.73},{"x":864.91,"y":290.59},{"x":865.21,"y":291.29},{"x":865.48,"y":291.45},{"x":865.32,"y":292.52},{"x":865.63,"y":293.4},{"x":866.1,"y":294.07},{"x":866.06,"y":294.62},{"x":866.32,"y":295.2},{"x":866.04,"y":296.21},{"x":865.82,"y":296.36},{"x":865.78,"y":297.21},{"x":866.12,"y":298.04},{"x":866.61,"y":298.23},{"x":866.81,"y":298.66},{"x":865.76,"y":299.92},{"x":865.06,"y":300.33},{"x":864.58,"y":301.43},{"x":864.79,"y":302},{"x":864.68,"y":302.71},{"x":865.32,"y":303.37},{"x":865.35,"y":303.62},{"x":865.46,"y":303.68},{"x":865.63,"y":303.49},{"x":866.81,"y":304.67},{"x":867.29,"y":304.96},{"x":867.33,"y":305.89},{"x":867.79,"y":306.17},{"x":866.43,"y":308.08},{"x":865.7,"y":308.15},{"x":864.81,"y":308.75},{"x":864.24,"y":308.72},{"x":863.18,"y":308.96},{"x":862.52,"y":309.54},{"x":861.87,"y":309.86},{"x":861.49,"y":310.42},{"x":861.54,"y":310.76},{"x":861.2,"y":311.37},{"x":860.66,"y":311.38},{"x":860.43,"y":311.04},{"x":859.87,"y":311.37},{"x":859.84,"y":311.72},{"x":859.7,"y":311.8},{"x":859.89,"y":312.99},{"x":859.71,"y":313.68},{"x":860.08,"y":314.35},{"x":859.84,"y":314.22},{"x":859.59,"y":314.42},{"x":859.41,"y":314.31},{"x":859.35,"y":314.56},{"x":859.05,"y":314.76},{"x":858.87,"y":314.68},{"x":858.29,"y":314.94},{"x":858.49,"y":315.35},{"x":858.19,"y":315.6},{"x":858.2,"y":316.09},{"x":857.97,"y":316.42},{"x":857.99,"y":317.18},{"x":857.71,"y":317.99},{"x":857.81,"y":318.45},{"x":857.63,"y":318.77},{"x":857.65,"y":319.12},{"x":857.32,"y":319.49},{"x":857.37,"y":320.92},{"x":857.23,"y":321.32},{"x":857.23,"y":322.66},{"x":857.44,"y":324.03},{"x":857.34,"y":326.69},{"x":858.08,"y":327.3},{"x":858.1,"y":327.6},{"x":857.59,"y":328.6},{"x":857.21,"y":328.98},{"x":856.81,"y":330.34},{"x":856.37,"y":330.51},{"x":855.98,"y":330.93},{"x":855.95,"y":331.89},{"x":855.36,"y":332.13},{"x":855.38,"y":332.51},{"x":855.06,"y":332.61},{"x":854.91,"y":333.44},{"x":855.21,"y":334.74},{"x":854.57,"y":335.21},{"x":854.54,"y":335.4},{"x":855.01,"y":336.06},{"x":855,"y":336.45},{"x":855.28,"y":336.79},{"x":855.8,"y":338.6},{"x":856.14,"y":338.6},{"x":856.23,"y":338.86},{"x":856.35,"y":338.63},{"x":856.71,"y":338.94},{"x":857.05,"y":338.89},{"x":857.23,"y":338.64},{"x":858.07,"y":338.79},{"x":858.2,"y":338.94},{"x":858.92,"y":338.57},{"x":859.11,"y":338.89},{"x":858.81,"y":339.55},{"x":858.92,"y":340.41},{"x":859.53,"y":340.69},{"x":859.84,"y":341.04},{"x":860.07,"y":341.37},{"x":860.06,"y":341.83},{"x":860.66,"y":342.03},{"x":860.92,"y":343},{"x":860.55,"y":343.73},{"x":859.97,"y":344.14},{"x":859.58,"y":344.7},{"x":858.97,"y":346.97},{"x":858.43,"y":347.23},{"x":857.95,"y":347.79},{"x":857.37,"y":348.06},{"x":857.06,"y":348.95},{"x":856.76,"y":349.12},{"x":856.84,"y":349.26},{"x":856.38,"y":349.83},{"x":856.43,"y":350.15},{"x":856.12,"y":350.24},{"x":856,"y":350.57},{"x":855.55,"y":350.42},{"x":855.29,"y":350.5},{"x":854.9,"y":351.05},{"x":854.52,"y":351.3},{"x":854.44,"y":351.92},{"x":854.11,"y":351.83},{"x":853.89,"y":352.24},{"x":853.66,"y":352.25},{"x":853.37,"y":352.65},{"x":852.5,"y":352.57},{"x":852.42,"y":353.03},{"x":852.19,"y":352.87},{"x":851.42,"y":352.96},{"x":851.41,"y":353.57},{"x":850.85,"y":354.08},{"x":850.76,"y":354.94},{"x":850.88,"y":355.32},{"x":850.21,"y":356.07},{"x":850.17,"y":356.49},{"x":850.62,"y":356.9},{"x":851.06,"y":357.75},{"x":850.59,"y":357.96},{"x":850.56,"y":358.47},{"x":849.95,"y":359.08},{"x":849.84,"y":359.59},{"x":850.11,"y":360.29},{"x":849.92,"y":360.43},{"x":850.33,"y":360.49},{"x":851.07,"y":361.18},{"x":852.05,"y":361.17},{"x":852.13,"y":361.59},{"x":852.71,"y":362.1},{"x":852.73,"y":362.8},{"x":853.19,"y":363},{"x":853.47,"y":363.67},{"x":853.87,"y":363.76},{"x":853.9,"y":364.28},{"x":854.42,"y":364.29},{"x":854.65,"y":365.14},{"x":854.56,"y":365.53},{"x":854.16,"y":366.23},{"x":854.24,"y":366.42},{"x":853.84,"y":366.47},{"x":852.39,"y":367.52},{"x":851.57,"y":368.38},{"x":850.93,"y":368.68},{"x":851.06,"y":369},{"x":850.93,"y":369.23},{"x":850.46,"y":369.51},{"x":849.74,"y":370.38},{"x":849.06,"y":370.71},{"x":848.5,"y":370.69},{"x":848.23,"y":370.49},{"x":847.4,"y":371.33},{"x":847.14,"y":371.16},{"x":846.94,"y":370.7},{"x":846.18,"y":371.02},{"x":845.71,"y":371.5},{"x":845.04,"y":371.11},{"x":844.09,"y":371.89},{"x":844.19,"y":372.58},{"x":844.02,"y":373.35},{"x":843.52,"y":373.95},{"x":843.27,"y":374.55},{"x":843.51,"y":376.21},{"x":843.82,"y":376.83},{"x":843.72,"y":377.01},{"x":843.96,"y":377.62},{"x":843.94,"y":378.01},{"x":844.01,"y":378.16},{"x":844.38,"y":378.03},{"x":844.52,"y":378.57},{"x":844.31,"y":378.85},{"x":844.75,"y":380.44},{"x":843.74,"y":382.15},{"x":843.46,"y":382.35},{"x":842.91,"y":382.37},{"x":841.52,"y":383.67},{"x":841.12,"y":385.66},{"x":840.87,"y":385.75},{"x":840.51,"y":386.39},{"x":840.63,"y":386.95},{"x":840.12,"y":388.01},{"x":839.9,"y":389.41},{"x":839.99,"y":389.78},{"x":839.57,"y":390.4},{"x":839.94,"y":390.99},{"x":839.86,"y":391.33},{"x":839.99,"y":391.65},{"x":839.87,"y":391.82},{"x":840.73,"y":392.78},{"x":841.69,"y":393.3},{"x":842.18,"y":394.49},{"x":842.93,"y":394.88},{"x":843.07,"y":395.1},{"x":843.39,"y":396.4},{"x":844.27,"y":397.32},{"x":844.69,"y":398.01},{"x":845.22,"y":398.44},{"x":845.22,"y":398.71},{"x":845.59,"y":399.05},{"x":845.73,"y":400.37},{"x":846.1,"y":401.41},{"x":847.39,"y":403.44},{"x":847.56,"y":405.01},{"x":847.98,"y":405.98},{"x":848.35,"y":406.33},{"x":848.4,"y":407.55},{"x":847.99,"y":407.71},{"x":847.46,"y":408.34},{"x":847.21,"y":409.09},{"x":847.21,"y":410.25},{"x":846.4,"y":410.25},{"x":845.98,"y":409.99},{"x":845.81,"y":409.69},{"x":844.62,"y":409.75},{"x":843.99,"y":410.77},{"x":843.92,"y":411.16},{"x":843.71,"y":411.3},{"x":843.95,"y":413.34},{"x":844.59,"y":413.95},{"x":844.31,"y":414.5},{"x":844.57,"y":415.53},{"x":844.47,"y":415.98},{"x":844.08,"y":416.54},{"x":844.46,"y":417.78},{"x":844.25,"y":418.04},{"x":844,"y":419.22},{"x":844.09,"y":419.88},{"x":843.69,"y":420.87},{"x":843.57,"y":421.64},{"x":843.09,"y":422.17},{"x":842.62,"y":423.24},{"x":842.18,"y":423.58},{"x":841.69,"y":424.45},{"x":841.31,"y":425.32},{"x":841.28,"y":426.07},{"x":840.43,"y":426.98},{"x":840.28,"y":427.27},{"x":840.35,"y":427.98},{"x":840.13,"y":428.36},{"x":839.85,"y":428.43},{"x":839.94,"y":429.62},{"x":839.66,"y":430.25},{"x":839.76,"y":430.97},{"x":839.51,"y":432.76},{"x":839.78,"y":433.31},{"x":840.19,"y":435.49},{"x":839.97,"y":436.57},{"x":840.18,"y":437.41},{"x":840.88,"y":438.25},{"x":841.33,"y":441.04},{"x":842.75,"y":442.31},{"x":843.89,"y":442.49},{"x":844.23,"y":442.69},{"x":844.56,"y":444.33},{"x":845.21,"y":445.61},{"x":845.11,"y":445.98},{"x":845.26,"y":446.13},{"x":845.25,"y":446.61},{"x":845.51,"y":446.83},{"x":845.92,"y":447.72},{"x":846.54,"y":448.23},{"x":846.22,"y":448.39},{"x":846.58,"y":449.03},{"x":846.85,"y":449.22},{"x":847.26,"y":449.12},{"x":847.62,"y":449.22},{"x":847.22,"y":451.51},{"x":847.37,"y":453.41},{"x":847.06,"y":454.37},{"x":847.52,"y":455.19},{"x":847.87,"y":456.51},{"x":847.8,"y":456.93},{"x":847.37,"y":457.36},{"x":847.16,"y":458.44},{"x":847.35,"y":458.58},{"x":847.82,"y":459.76},{"x":848.54,"y":460.28},{"x":848.79,"y":461.67},{"x":849.1,"y":461.82},{"x":850.01,"y":461.85},{"x":850.38,"y":462.26},{"x":850.7,"y":462.24},{"x":851.38,"y":462.79},{"x":851.35,"y":463.26},{"x":851.9,"y":464.12},{"x":851.99,"y":464.81},{"x":852.29,"y":465.31},{"x":852.39,"y":466.28},{"x":853.62,"y":468.27},{"x":853.52,"y":468.55},{"x":853.77,"y":469.76},{"x":853.68,"y":470.22},{"x":854,"y":470.91},{"x":853.97,"y":471.15},{"x":854.32,"y":471.15},{"x":854.55,"y":471.34},{"x":855.21,"y":473.19},{"x":856.05,"y":473.73},{"x":856.86,"y":474.89},{"x":857.4,"y":475.11},{"x":857.89,"y":475.79},{"x":859.65,"y":476.31},{"x":860.05,"y":476.74},{"x":860.69,"y":476.85},{"x":861.3,"y":477.2},{"x":861.65,"y":477.05},{"x":862.23,"y":477.64},{"x":862.5,"y":477.67},{"x":863.43,"y":478.32},{"x":863.96,"y":478.96},{"x":865.71,"y":480.02},{"x":865.75,"y":480.29},{"x":866.36,"y":480.77}] From f9b50b68ecaa8fd5ab7a525c66e363c7eaaa9e4e Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 2 Apr 2015 19:14:43 +0300 Subject: [PATCH 36/49] tiny optimization --- simplify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simplify.js b/simplify.js index 63a5ddb..f451078 100644 --- a/simplify.js +++ b/simplify.js @@ -69,7 +69,7 @@ function simplifyRadialDist(points, sqTolerance) { } function simplifyDPStep(points, first, last, sqTolerance, simplified) { - var maxSqDist = 0, + var maxSqDist = sqTolerance, index; for (var i = first + 1; i < last; i++) { From 4ffecf5559d06c2c16d44ba509e0734dba94b1d2 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 16 Jul 2015 19:28:53 +0300 Subject: [PATCH 37/49] add swift port notice, close #17 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 46405bc..b55ad4a 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,4 @@ Checkout the demo with docs: http://mourner.github.io/simplify-js/ * Ruby: [odlp / simplify_rb](https://github.com/odlp/simplify_rb) (by Oliver Peate) * Go: [yrsh / simplify_go](https://github.com/yrsh/simplify-go) (by Anton Korotkikh) * C# (Portable): [imshz / simplify-net](https://github.com/imshz/simplify-net) (by Shees Ul-Hassan) + * Swift: [malcommac / SwiftSimplify](https://github.com/malcommac/SwiftSimplify) (by Daniele Margutti) From 8267c91720c1dfa18a922c66e370df9aba0858f6 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 20 Jul 2015 10:10:50 +0200 Subject: [PATCH 38/49] Add .gitignore file see https://github.com/github/gitignore/blob/master/Node.gitignore --- .gitignore | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c26f93a --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +### Node template +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git +node_modules From 21037fd7b8f96f593aaa49451ccf00431600b8e9 Mon Sep 17 00:00:00 2001 From: Ed Date: Tue, 30 Aug 2016 18:17:39 +1200 Subject: [PATCH 39/49] add license to package.json (#22) --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index c3b7eb7..bf8d888 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "A high-performance JavaScript 2D/3D polyline simplification library", "homepage": "http://mourner.github.com/simplify-js/", "author": "Vladimir Agafonkin", + "license": "BSD-2-Clause", "keywords": [ "math", "geometry", From 6ae668ba4b832c40fb3cd97d4f24a4a06f953d60 Mon Sep 17 00:00:00 2001 From: Antoine Pultier Date: Tue, 3 Jan 2017 14:49:34 +0200 Subject: [PATCH 40/49] Added link to the Unreal Engine port. (#27) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b55ad4a..626a3b5 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,4 @@ Checkout the demo with docs: http://mourner.github.io/simplify-js/ * Go: [yrsh / simplify_go](https://github.com/yrsh/simplify-go) (by Anton Korotkikh) * C# (Portable): [imshz / simplify-net](https://github.com/imshz/simplify-net) (by Shees Ul-Hassan) * Swift: [malcommac / SwiftSimplify](https://github.com/malcommac/SwiftSimplify) (by Daniele Margutti) + * Unreal Engine: [SINTEF-9012 / SimplifyUnreal](https://github.com/SINTEF-9012/SimplifyUnreal) (by Antoine Pultier) From edcf86b11e5327032a8c8d54cb29db0a9aea7560 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 6 Oct 2017 10:39:03 -0400 Subject: [PATCH 41/49] Support export default (#31) Ref: https://github.com/mapbox/supercluster/pull/62 --- simplify.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/simplify.js b/simplify.js index f451078..e438581 100644 --- a/simplify.js +++ b/simplify.js @@ -114,8 +114,10 @@ function simplify(points, tolerance, highestQuality) { // export as AMD module / Node module / browser or worker variable if (typeof define === 'function' && define.amd) define(function() { return simplify; }); -else if (typeof module !== 'undefined') module.exports = simplify; -else if (typeof self !== 'undefined') self.simplify = simplify; +else if (typeof module !== 'undefined') { + module.exports = simplify; + module.exports.default = simplify; +} else if (typeof self !== 'undefined') self.simplify = simplify; else window.simplify = simplify; })(); From ffcd3f816f76342a976e1479ab0abcf271519dca Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 21 Dec 2017 15:31:40 +0200 Subject: [PATCH 42/49] upgrade deps and year --- LICENSE | 2 +- package.json | 9 ++++++--- simplify.js | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/LICENSE b/LICENSE index 4730ad7..bda6bcc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015, Vladimir Agafonkin +Copyright (c) 2017, Vladimir Agafonkin All rights reserved. Redistribution and use in source and binary forms, with or without modification, are diff --git a/package.json b/package.json index bf8d888..630f289 100644 --- a/package.json +++ b/package.json @@ -16,11 +16,14 @@ "url": "git://github.com/mourner/simplify-js.git" }, "main": "simplify.js", + "files": [ + "simplify.js" + ], "devDependencies": { - "benchmark": "^1.0.0", + "benchmark": "^2.1.4", "faucet": "0.0.1", - "jshint": "^2.6.3", - "tape": "^3.5.0" + "jshint": "^2.9.5", + "tape": "^4.8.0" }, "scripts": { "test": "jshint simplify.js test/test.js && node test/test.js | faucet" diff --git a/simplify.js b/simplify.js index e438581..339c84f 100644 --- a/simplify.js +++ b/simplify.js @@ -1,5 +1,5 @@ /* - (c) 2013, Vladimir Agafonkin + (c) 2017, Vladimir Agafonkin Simplify.js, a high-performance JS polyline simplification library mourner.github.io/simplify-js */ From d5aae2be69835719d33eca21c229a286559c1664 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 21 Dec 2017 15:31:50 +0200 Subject: [PATCH 43/49] 1.2.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 630f289..106935d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simplify-js", - "version": "1.2.2", + "version": "1.2.3", "description": "A high-performance JavaScript 2D/3D polyline simplification library", "homepage": "http://mourner.github.com/simplify-js/", "author": "Vladimir Agafonkin", From 9c67ff90c058df55267d401efa220d7479134674 Mon Sep 17 00:00:00 2001 From: Daniel Hritzkiv Date: Tue, 18 Jun 2019 08:16:53 -0400 Subject: [PATCH 44/49] Add TypeScript defintion (#33) * Create index.d.ts * Update package.json Add types reference to package.json --- index.d.ts | 9 +++++++++ package.json | 2 ++ 2 files changed, 11 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..b2bf7af --- /dev/null +++ b/index.d.ts @@ -0,0 +1,9 @@ +interface Point { + x: number; + y: number; +} + +declare function simplify (points: Point[], tolerance?: number, highQuality?: boolean): Point[]; +declare namespace simplify {} + +export = simplify; diff --git a/package.json b/package.json index 106935d..f7d3e2d 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,10 @@ }, "main": "simplify.js", "files": [ + "index.d.ts", "simplify.js" ], + "types": "index.d.ts", "devDependencies": { "benchmark": "^2.1.4", "faucet": "0.0.1", From 3fd597fc8fd7b15c7d0efeff9ac3193b708397da Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Mon, 3 Feb 2020 20:08:44 +0200 Subject: [PATCH 45/49] update deps --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f7d3e2d..a128059 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,8 @@ "devDependencies": { "benchmark": "^2.1.4", "faucet": "0.0.1", - "jshint": "^2.9.5", - "tape": "^4.8.0" + "jshint": "^2.11.0", + "tape": "^4.13.0" }, "scripts": { "test": "jshint simplify.js test/test.js && node test/test.js | faucet" From 4f566b7368d4f4be8a9db40608bba557a2b5f643 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Mon, 3 Feb 2020 20:08:56 +0200 Subject: [PATCH 46/49] 1.2.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a128059..87b92d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simplify-js", - "version": "1.2.3", + "version": "1.2.4", "description": "A high-performance JavaScript 2D/3D polyline simplification library", "homepage": "http://mourner.github.com/simplify-js/", "author": "Vladimir Agafonkin", From 6930f87d19f87a5b262becaf1fd3080102b0cb51 Mon Sep 17 00:00:00 2001 From: Are Date: Thu, 3 Dec 2020 18:52:47 +0100 Subject: [PATCH 47/49] Improve TypeScript definitions (#41) --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index b2bf7af..b0cf060 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,7 +3,7 @@ interface Point { y: number; } -declare function simplify (points: Point[], tolerance?: number, highQuality?: boolean): Point[]; +declare function simplify(points: T[], tolerance?: number, highQuality?: boolean): T[]; declare namespace simplify {} export = simplify; From c5301b0b0e14ce7b2e67f319ff01c46d6188724d Mon Sep 17 00:00:00 2001 From: Shubham Jain Date: Mon, 31 Jan 2022 23:52:15 +0530 Subject: [PATCH 48/49] Add link to Postgres Port (using PL/Python) (#44) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 626a3b5..20abed1 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,4 @@ Checkout the demo with docs: http://mourner.github.io/simplify-js/ * C# (Portable): [imshz / simplify-net](https://github.com/imshz/simplify-net) (by Shees Ul-Hassan) * Swift: [malcommac / SwiftSimplify](https://github.com/malcommac/SwiftSimplify) (by Daniele Margutti) * Unreal Engine: [SINTEF-9012 / SimplifyUnreal](https://github.com/SINTEF-9012/SimplifyUnreal) (by Antoine Pultier) + * Postgres (using PL/Python): [shubhamjain / simplify-coordinates-sql](https://github.com/shubhamjain/simplify-coordinates-sql) (by Shubham Jain) From 0777f8ac6f81b15239a4dc80b6d83f956b1b7110 Mon Sep 17 00:00:00 2001 From: Kade Date: Sun, 6 Nov 2022 06:38:25 -0500 Subject: [PATCH 49/49] Add link to new Rust port (#46) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 20abed1..808c77a 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Checkout the demo with docs: http://mourner.github.io/simplify-js/ * Processing: [ekeneijeoma / simplify-processing](https://github.com/ekeneijeoma/simplify-processing) (by Ekene Ijeoma) * AS3: [fnicollet / simplify-as3](https://github.com/fnicollet/simplify-as3) (by Fabien Nicollet) * Rust: [calvinmetcalf / simplify-rs](https://github.com/calvinmetcalf/simplify-rs) (by Calvin Metcalf) + * Rust: [kade-robertson / simplify-polyline](https://github.com/kade-robertson/simplify-polyline) (by Kade Robertson) * Ruby: [odlp / simplify_rb](https://github.com/odlp/simplify_rb) (by Oliver Peate) * Go: [yrsh / simplify_go](https://github.com/yrsh/simplify-go) (by Anton Korotkikh) * C# (Portable): [imshz / simplify-net](https://github.com/imshz/simplify-net) (by Shees Ul-Hassan)