point-in-polygon
determine if a point is inside a polygon with a ray intersection counting algorithm
Last updated 4 years ago by substack .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install point-in-polygon 
SYNC missed versions from official npm registry.

point-in-polygon

Determine if a point is inside of a polygon.

This module casts a ray from the inquiry point and counts intersections, based on this algorithm.

example

var inside = require('point-in-polygon');
var polygon = [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ] ];

console.dir([
    inside([ 1.5, 1.5 ], polygon),
    inside([ 4.9, 1.2 ], polygon),
    inside([ 1.8, 1.1 ], polygon)
]);

output:

[ true, false, true ]

methods

var inside = require('point-in-polygon')

inside(point, polygon)

Return whether point is contained in polygon.

point should be a 2-item array of coordinates.

polygon should be an array of 2-item arrays of coordinates.

install

npm install point-in-polygon

license

MIT

Current Tags

  • 1.0.1                                ...           latest (4 years ago)

3 Versions

  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           5 years ago
  • 0.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Today 2
This Week 2
This Month 516
Last Day 36
Last Week 852
Last Month 3,300
Dependencies (0)
None
Dev Dependencies (1)
Dependents (88)

Copyright 2014 - 2016 © taobao.org |