Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

point-in-polygon-hao

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

point-in-polygon-hao - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

34

dist/pointInPolygon.js

@@ -25,3 +25,3 @@ (function (global, factory) {

ii = 0;
const contourLen = polygon[i].length - 1;
const contourLen = polygon[i].length;
const contour = polygon[i];

@@ -39,3 +39,2 @@

nextP = contour[ii + 1];
v2 = nextP[1] - y;

@@ -55,16 +54,33 @@

if (f > 0) k = k + 1;
else if (f === 0) return 0
else if (f === 0) {
contour.pop();
return 0
}
} else if (v1 > 0 && v2 <= 0) {
f = (u1 * v2) - (u2 * v1);
if (f < 0) k = k + 1;
else if (f === 0) return 0
else if (f === 0) {
contour.pop();
return 0
}
} else if (v2 === 0 && v1 < 0) {
f = (u1 * v2) - (u2 * v1);
if (f === 0) return 0
if (f === 0) {
contour.pop();
return 0
}
} else if (v1 === 0 && v2 < 0) {
f = u1 * v2 - u2 * v1;
if (f === 0) return 0
if (f === 0) {
contour.pop();
return 0
}
} else if (v1 === 0 && v2 === 0) {
if (u2 <= 0 && u1 >= 0) return 0
else if (u1 <= 0 && u2 >= 0) return 0
if (u2 <= 0 && u1 >= 0) {
contour.pop();
return 0
} else if (u1 <= 0 && u2 >= 0) {
contour.pop();
return 0
}
}

@@ -75,3 +91,3 @@ currentP = nextP;

}
contour.pop();
}

@@ -78,0 +94,0 @@

@@ -1,1 +0,1 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).pointInPolygon=n()}(this,function(){"use strict";return function(e,n){let f=0,t=0,i=0,r=0,o=0,u=0,l=0,s=0,c=null,d=null;const p=e[0],h=e[1],y=n.length;for(;f<y;f++){t=0;const y=n[f].length-1,g=n[f];for(g.push(g[1]),u=(c=g[0])[0]-p,o=c[1]-h;t<y;t++)if(s=(d=g[t+1])[1]-h,u<0&&s<0||u>0&&s>0)u=s,o=(c=d)[0]-p;else{if(l=d[0]-e[0],s>0&&u<=0){if((r=o*s-l*u)>0)i+=1;else if(0===r)return 0}else if(u>0&&s<=0){if((r=o*s-l*u)<0)i+=1;else if(0===r)return 0}else if(0===s&&u<0){if(0==(r=o*s-l*u))return 0}else if(0===u&&s<0){if(0==(r=o*s-l*u))return 0}else if(0===u&&0===s){if(l<=0&&o>=0)return 0;if(o<=0&&l>=0)return 0}c=d,u=s,o=l}}return i%2!=0}});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).pointInPolygon=n()}(this,function(){"use strict";return function(e,n){let f=0,t=0,o=0,i=0,p=0,r=0,u=0,l=0,s=null,c=null;const d=e[0],h=e[1],y=n.length;for(;f<y;f++){t=0;const y=n[f].length,g=n[f];for(g.push(g[1]),r=(s=g[0])[0]-d,p=s[1]-h;t<y;t++)if(l=(c=g[t+1])[1]-h,r<0&&l<0||r>0&&l>0)r=l,p=(s=c)[0]-d;else{if(u=c[0]-e[0],l>0&&r<=0){if((i=p*l-u*r)>0)o+=1;else if(0===i)return g.pop(),0}else if(r>0&&l<=0){if((i=p*l-u*r)<0)o+=1;else if(0===i)return g.pop(),0}else if(0===l&&r<0){if(0==(i=p*l-u*r))return g.pop(),0}else if(0===r&&l<0){if(0==(i=p*l-u*r))return g.pop(),0}else if(0===r&&0===l){if(u<=0&&p>=0)return g.pop(),0;if(p<=0&&u>=0)return g.pop(),0}s=c,r=l,p=u}g.pop()}return o%2!=0}});
{
"name": "point-in-polygon-hao",
"version": "0.0.3",
"version": "0.0.4",
"description": "A point in polygon based on the paper Optimal Reliable Point-in-Polygon Test and Differential Coding Boolean Operations on Polygons",

@@ -5,0 +5,0 @@ "main": "dist/pointInPolygon.js",

@@ -31,6 +31,6 @@ Based on the paper [Optimal Reliable Point-in-Polygon Test and

// For a point in bounding box check
point-in-poly-hao x 25,473,702 ops/sec ±2.35% (81 runs sampled)
turf-point-in-polygon x 6,511,498 ops/sec ±1.04% (93 runs sampled)
point-in-polygon x 37,437,762 ops/sec ±0.68% (94 runs sampled)
robust-point-in-polygon x 18,344,949 ops/sec ±1.69% (83 runs sampled)
point-in-poly-hao x 22,139,049 ops/sec ±0.75% (91 runs sampled)
turf-point-in-polygon x 7,449,504 ops/sec ±0.67% (97 runs sampled)
point-in-polygon x 45,114,360 ops/sec ±0.37% (97 runs sampled)
robust-point-in-polygon x 22,621,987 ops/sec ±0.48% (91 runs sampled)
````

@@ -40,6 +40,6 @@

// For a point in a much larger geometry (700+ vertices)
point-in-poly-hao x 449,670 ops/sec ±0.80% (90 runs sampled)
turf-point-in-polygon x 204,064 ops/sec ±0.69% (91 runs sampled)
point-in-polygon x 469,503 ops/sec ±1.43% (93 runs sampled)
robust-point-in-polygon x 364,994 ops/sec ±0.63% (94 runs sampled)
point-in-poly-hao x 467,835 ops/sec ±0.97% (96 runs sampled)
turf-point-in-polygon x 207,265 ops/sec ±0.79% (90 runs sampled)
point-in-polygon x 503,046 ops/sec ±1.04% (91 runs sampled)
robust-point-in-polygon x 372,612 ops/sec ±0.66% (94 runs sampled)
````

@@ -17,2 +17,2 @@ import {terser} from 'rollup-plugin-terser'

output('./dist/pointInPolygon.min.js', [terser()])
]
]

@@ -19,3 +19,3 @@ export default function pointInPolygon(p, polygon) {

ii = 0
const contourLen = polygon[i].length - 1
const contourLen = polygon[i].length
const contour = polygon[i]

@@ -25,2 +25,3 @@

// Not 100% sure if it's legit
// Big downside is that it involves mutating the input
contour.push(contour[1])

@@ -34,3 +35,2 @@

nextP = contour[ii + 1]
v2 = nextP[1] - y

@@ -50,16 +50,33 @@

if (f > 0) k = k + 1
else if (f === 0) return 0
else if (f === 0) {
contour.pop()
return 0
}
} else if (v1 > 0 && v2 <= 0) {
f = (u1 * v2) - (u2 * v1)
if (f < 0) k = k + 1
else if (f === 0) return 0
else if (f === 0) {
contour.pop()
return 0
}
} else if (v2 === 0 && v1 < 0) {
f = (u1 * v2) - (u2 * v1)
if (f === 0) return 0
if (f === 0) {
contour.pop()
return 0
}
} else if (v1 === 0 && v2 < 0) {
f = u1 * v2 - u2 * v1
if (f === 0) return 0
if (f === 0) {
contour.pop()
return 0
}
} else if (v1 === 0 && v2 === 0) {
if (u2 <= 0 && u1 >= 0) return 0
else if (u1 <= 0 && u2 >= 0) return 0
if (u2 <= 0 && u1 >= 0) {
contour.pop()
return 0
} else if (u1 <= 0 && u2 >= 0) {
contour.pop()
return 0
}
}

@@ -70,3 +87,3 @@ currentP = nextP

}
contour.pop()
}

@@ -73,0 +90,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc