convex-hull-wp
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -5,3 +5,3 @@ (function (global, factory) { | ||
(global = global || self, global.convexHull = factory()); | ||
}(this, function () { 'use strict'; | ||
}(this, (function () { 'use strict'; | ||
@@ -63,2 +63,3 @@ // import {debugQuadrantPoints, debugOutQuadrantHull, debugStartEndHull} from './debug' | ||
processQuadrant4(miny, minx, regionD.length, regionD, out); | ||
out.push(out[0]); | ||
return out | ||
@@ -258,2 +259,2 @@ } | ||
})); | ||
}))); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).convexHull=t()}(this,function(){"use strict";return function(e){const t=e.length;let n=[1/0,1/0],f=[-1/0,-1/0],o=[-1/0,-1/0],i=[1/0,1/0];for(let l=0;l<t;l++)e[l][0]<n[0]&&(n=e[l]),e[l][0]>f[0]&&(f=e[l]),e[l][1]<i[1]&&(i=e[l]),e[l][1]>o[1]&&(o=e[l]);const l=[],s=[],u=[],c=[];for(let h=0;h<t;h++)e[h][0]<=o[0]&&e[h][1]>=n[1]&&l.push(e[h]),e[h][0]>=o[0]&&e[h][1]>=f[1]&&s.push(e[h]),e[h][0]>=i[0]&&e[h][1]<=f[1]&&u.push(e[h]),e[h][0]<=i[0]&&e[h][1]<=n[1]&&c.push(e[h]);const h=[];return function(e,t,n,f,o){let i,l,s,u,c,h,p,r,d=0;i=e[0],l=e[1];do{o.push([i,l]),s=0,c=t[1]-e[1],p=t[0]-e[0],r=!1;for(let e=0;e<n;e++)if(f[e][1]>=l&&f[e][0]>=i)if(f[e][0]===i)f[e][1]!==l&&(u=f[e][1]-l,c>=u&&(c=u,d=e,r=!0));else if(!r){const t=(f[e][1]-l)/(f[e][0]-i);s<t?(p=f[e][0]-i,s=t,d=e):s===t&&(h=f[e][0]-i,p>=h&&(p=h,d=e))}i=f[d][0],l=f[d][1]}while(i!==t[0]||l!==t[1])}(n,o,l.length,l,h),function(e,t,n,f,o){let i,l,s,u,c,h,p,r,d=0;i=e[0],l=e[1];do{o.push([i,l]),s=0,c=e[1]-t[1],p=t[0]-e[0],r=!1;for(let e=0;e<n;e++)if(f[e][0]>=i&&f[e][1]<=l)if(f[e][1]===l)f[e][0]!==i&&(h=f[e][0]-i,p>=h&&(p=h,d=e,r=!0));else if(!r){const t=(f[e][0]-i)/(l-f[e][1]);s<t?(c=l-f[e][1],s=t,d=e):s===t&&(u=l-f[e][1],c>=u&&(c=u,d=e))}i=f[d][0],l=f[d][1]}while(i!==t[0]||l!==t[1])}(o,f,s.length,s,h),function(e,t,n,f,o){let i,l,s,u,c,h,p,r,d=0;i=e[0],l=e[1];do{o.push([i,l]),s=0,c=e[1]-t[1],p=e[0]-t[0],r=!1;for(let e=0;e<n;e++)if(f[e][1]<=l&&f[e][0]<=i)if(f[e][0]===i)f[e][1]!==l&&(u=l-f[e][1],c>=u&&(c=u,d=e,r=!0));else if(!r){const t=(l-f[e][1])/(i-f[e][0]);s<t?(p=i-f[e][0],s=t,d=e):s===t&&(h=i-f[e][0],p>=h&&(p=h,d=e))}i=f[d][0],l=f[d][1]}while(i!==t[0]||l!==t[1])}(f,i,u.length,u,h),function(e,t,n,f,o){let i,l,s,u,c,h,p,r,d=0;i=e[0],l=e[1];do{o.push([i,l]),s=0,c=t[1]-e[1],p=e[0]-t[0],r=!1;for(let e=0;e<n;e++)if(f[e][0]<=i&&f[e][1]>=l)if(f[e][1]===l)f[e][0]!==i&&(h=i-f[e][0],p>=h&&(p=h,d=e,r=!0));else if(!r){const t=(i-f[e][0])/(f[e][1]-l);s<t?(c=f[e][1]-l,s=t,d=e):s===t&&(u=f[e][1]-l,c>=u&&(c=u,d=e))}i=f[d][0],l=f[d][1]}while(i!==t[0]||l!==t[1])}(i,n,c.length,c,h),h}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).convexHull=t()}(this,function(){"use strict";return function(e){const t=e.length;let n=[1/0,1/0],f=[-1/0,-1/0],o=[-1/0,-1/0],i=[1/0,1/0];for(let l=0;l<t;l++)e[l][0]<n[0]&&(n=e[l]),e[l][0]>f[0]&&(f=e[l]),e[l][1]<i[1]&&(i=e[l]),e[l][1]>o[1]&&(o=e[l]);const l=[],s=[],u=[],h=[];for(let c=0;c<t;c++)e[c][0]<=o[0]&&e[c][1]>=n[1]&&l.push(e[c]),e[c][0]>=o[0]&&e[c][1]>=f[1]&&s.push(e[c]),e[c][0]>=i[0]&&e[c][1]<=f[1]&&u.push(e[c]),e[c][0]<=i[0]&&e[c][1]<=n[1]&&h.push(e[c]);const c=[];return function(e,t,n,f,o){let i,l,s,u,h,c,p,r,d=0;i=e[0],l=e[1];do{o.push([i,l]),s=0,h=t[1]-e[1],p=t[0]-e[0],r=!1;for(let e=0;e<n;e++)if(f[e][1]>=l&&f[e][0]>=i)if(f[e][0]===i)f[e][1]!==l&&(u=f[e][1]-l,h>=u&&(h=u,d=e,r=!0));else if(!r){const t=(f[e][1]-l)/(f[e][0]-i);s<t?(p=f[e][0]-i,s=t,d=e):s===t&&(c=f[e][0]-i,p>=c&&(p=c,d=e))}i=f[d][0],l=f[d][1]}while(i!==t[0]||l!==t[1])}(n,o,l.length,l,c),function(e,t,n,f,o){let i,l,s,u,h,c,p,r,d=0;i=e[0],l=e[1];do{o.push([i,l]),s=0,h=e[1]-t[1],p=t[0]-e[0],r=!1;for(let e=0;e<n;e++)if(f[e][0]>=i&&f[e][1]<=l)if(f[e][1]===l)f[e][0]!==i&&(c=f[e][0]-i,p>=c&&(p=c,d=e,r=!0));else if(!r){const t=(f[e][0]-i)/(l-f[e][1]);s<t?(h=l-f[e][1],s=t,d=e):s===t&&(u=l-f[e][1],h>=u&&(h=u,d=e))}i=f[d][0],l=f[d][1]}while(i!==t[0]||l!==t[1])}(o,f,s.length,s,c),function(e,t,n,f,o){let i,l,s,u,h,c,p,r,d=0;i=e[0],l=e[1];do{o.push([i,l]),s=0,h=e[1]-t[1],p=e[0]-t[0],r=!1;for(let e=0;e<n;e++)if(f[e][1]<=l&&f[e][0]<=i)if(f[e][0]===i)f[e][1]!==l&&(u=l-f[e][1],h>=u&&(h=u,d=e,r=!0));else if(!r){const t=(l-f[e][1])/(i-f[e][0]);s<t?(p=i-f[e][0],s=t,d=e):s===t&&(c=i-f[e][0],p>=c&&(p=c,d=e))}i=f[d][0],l=f[d][1]}while(i!==t[0]||l!==t[1])}(f,i,u.length,u,c),function(e,t,n,f,o){let i,l,s,u,h,c,p,r,d=0;i=e[0],l=e[1];do{o.push([i,l]),s=0,h=t[1]-e[1],p=e[0]-t[0],r=!1;for(let e=0;e<n;e++)if(f[e][0]<=i&&f[e][1]>=l)if(f[e][1]===l)f[e][0]!==i&&(c=i-f[e][0],p>=c&&(p=c,d=e,r=!0));else if(!r){const t=(i-f[e][0])/(f[e][1]-l);s<t?(h=f[e][1]-l,s=t,d=e):s===t&&(u=f[e][1]-l,h>=u&&(h=u,d=e))}i=f[d][0],l=f[d][1]}while(i!==t[0]||l!==t[1])}(i,n,h.length,h,c),c.push(c[0]),c}}); |
{ | ||
"name": "convex-hull-wp", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A module for creating a convex hull from an array of points", | ||
"bin": { | ||
"convex-hull-wp": "bin/convex-hull-wp.mjs" | ||
}, | ||
"type": "module", | ||
"main": "dist/convexHull.min.js", | ||
@@ -15,2 +19,7 @@ "module": "src/main.js", | ||
}, | ||
"files": [ | ||
"bin/", | ||
"src/", | ||
"dist/" | ||
], | ||
"ava": { | ||
@@ -26,3 +35,8 @@ "files": [ | ||
"license": "MIT", | ||
"dependencies": {}, | ||
"dependencies": { | ||
"@turf/helpers": "^6.5.0", | ||
"@turf/meta": "^6.5.0", | ||
"write-json-file": "^5.0.0", | ||
"yargs": "^17.5.1" | ||
}, | ||
"devDependencies": { | ||
@@ -42,3 +56,3 @@ "ava": "^1.0.1", | ||
"leaflet": "^1.4.0", | ||
"load-json-file": "^5.1.0", | ||
"load-json-file": "^5.3.0", | ||
"monotone-convex-hull-2d": "^1.0.1", | ||
@@ -45,0 +59,0 @@ "nyc": "^13.1.0", |
@@ -7,2 +7,6 @@ # convex-hull-wp | ||
npm install convex-hull-wp | ||
// Or for CLI usage | ||
npm install convex-hull-wp -g | ||
```` | ||
@@ -20,2 +24,16 @@ | ||
## CLI Documentation | ||
Takes an input geojson file, and writes an output `Feature` `Polygon` | ||
```` | ||
concave-hull-wp --input /Data/in.geojson --output /Data/out.geojson | ||
// => Convex Hull Done | ||
```` | ||
### Options | ||
`--input` **Required** The filepath of an geojson file. Eg `--input some_input.geosjon` | ||
`--output` The filepath to write the output to. Eg `--output hull.geosjon` | ||
`--stdout` Write the output to stdout rather than to file. If true the output file will not be written. | ||
`--quiet` Hides any non-error messages. | ||
### Benchmarks | ||
@@ -40,3 +58,3 @@ This library performs very well compared to equivalent js libraries. | ||
## Further Reading | ||
[An Efficient Convex Hull Algorithm for a Planer Set of Points]() - by Wijeweera & Pinidiyaarachchi | ||
[An Efficient Convex Hull Algorithm for a Planer Set of Points](https://github.com/rowanwins/convex-hull-wp/blob/master/KP_Paper.pdf) - by Wijeweera & Pinidiyaarachchi | ||
Interestingly this algorithm could be sped up by applying parallel processing to each quadant of the hull. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27816
556
57
Yes
4
1
+ Added@turf/helpers@^6.5.0
+ Added@turf/meta@^6.5.0
+ Addedwrite-json-file@^5.0.0
+ Addedyargs@^17.5.1
+ Added@turf/helpers@6.5.0(transitive)
+ Added@turf/meta@6.5.0(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addeddetect-indent@7.0.1(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-plain-obj@4.1.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedsort-keys@5.1.0(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedtypedarray-to-buffer@3.1.5(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedwrite-file-atomic@3.0.3(transitive)
+ Addedwrite-json-file@5.0.0(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)