assemblysys-point-in-polygon
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Point in polyggon

Detects is a given point is in a given polygon. Based off of http://assemblysys.com/php-point-in-polygon-algorithm/

Getting Started

Installation

  • The Point in polygon package is published on the npm Registry.
  • Install the package : npm install assemblysys-point-in-polygon

Usage

Import assemblysys-point-in-polygon into any files that depend on the function

import * as pointInPolygon from 'assemblysys-point-in-polygon';

Call the function anywhere you want to use it

import * as pointInPolygon from 'assemblysys-point-in-polygon';

let polygon = [[0,0],[4,0],[4,4],[0,4]];

let result1 = pointInPolygon([1,1],polygon);//Should return inside
let result2 = pointInPolygon([1,5],polygon);//Should return outside
let result3 = pointInPolygon([0,3],polygon);//should return boundary
let result4 = pointInPolygon([0,0],polygon);//Should return vertex
let result4 = pointInPolygon([0,0],polygon,false);//Should return outside

You can also optionally specify the minimum and maximum x and y coordinates for the polygon to speed up mass processing

let polygon = [[0,0],[4,0],[4,4],[0,4]];
let result4 = pointInPolygon([5,5],polygon,true,0,4,0,4);//Should return outside

License

LGPL-3.0 License.

Package Sidebar

Install

npm i assemblysys-point-in-polygon

Weekly Downloads

13

Version

0.0.3

License

GPL-3.0

Unpacked Size

10.8 kB

Total Files

6

Last publish

Collaborators

  • daniel.brenot