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

A point in polygon based on the paper Optimal Reliable Point-in-Polygon Test and Differential Coding Boolean Operations on Polygons

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Based on the paper Optimal Reliable Point-in-Polygon Test and Differential Coding Boolean Operations on Polygons

  • Works on polygons with holes
  • Works with degenerate polyons
  • Reports 0 if on the edge

Usage

Install via npm install point-in-polygon-hao

const inside = require('point-in-polygon-hao')
const polygon = [ [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ], [ 1, 1 ] ] ];
inside([ 1.5, 1.5 ], polygon)
// returns true

inside([ 4.9, 1.2 ], polygon)
// returns false

inside([1, 2], polygon)
// returns 0 to indicate on edge

Comparisons

Some rough comparisons to similar libraries. While point-in-polygon is slightly faster in most cases it does not support polygons with holes or degenerate polygons.

// 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)
// 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)

FAQs

Package last updated on 05 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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