Skip to content

An adaptation of the original pointinpolygon algorithm developed in php at assemblysys.com

License

Notifications You must be signed in to change notification settings

daniel-brenot/point-in-polygon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Point in polygon

Detects if 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.

About

An adaptation of the original pointinpolygon algorithm developed in php at assemblysys.com

Resources

License

Stars

Watchers

Forks

Packages

No packages published