1.1.0 • Published 3 years ago

point-in-polygon v1.1.0

Weekly downloads
166,659
License
MIT
Repository
github
Last release
3 years ago

point-in-polygon

Determine if a point is inside of a polygon.

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

If you need a numerically robust solution and are willing to trade some performance for it, use robust-point-in-polygon.

example

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

console.log(pointInPolygon([ 1.5, 1.5 ], polygon)); // true
console.log(pointInPolygon([ 4.9, 1.2 ], polygon)); // false
console.log(pointInPolygon([ 1.8, 1.1 ], polygon)); // true

methods

var pointInPolygon = require('point-in-polygon')
var pointInPolygonFlat = require('point-in-polygon/flat')
var pointInPolygonNested = require('point-in-polygon/nested')

pointInPolygon(point, polygon, start=0, end=polygon.length)

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 or a flat array of coordinates
  • start is an offset into polygon. default 0
  • end is an offset into polygon. default polygon.length

The flat or nested is detected automatically. Or you can use the specific methods if you want to skip the check.

install

npm install point-in-polygon

license

MIT

@shesha/reactjs@publicai01/segment-mark-toolgeotab-data-servicereact-native-ipithos-chart-kitpartitions@openagenda/geocoderreact-native-customte-chart-kitrnck-cakecrusherbuilt-chart-kitleaflet.glify-typed@infinitebrahmanuniverse/nolb-poi@everything-registry/sub-chunk-2453boxfusion-test-moduleosm-tile-listosm-tile-list-jsonnpm-all-packagespic-framerpelias-hierarchy-lookupplotly.js-fix2plotly.jsoalley.jspolygon-lookuppolygon-hashpolygon-intersect-testpoint-is-polishpoint-grouperpoints2polygonspp-which-countrypclipnatninternav2dbellowjs@cloudgakkai/react-native-chart-kitbrc-atlas-bigr@crunchr/plotly.js@comher.de/geometry@davidedelerma/terriajscanvas-node@fuge/modulezubtesttodayzaal-react-native-chart-kitbalanced-pairs@georgedoescode/polywix-restaurants-js-sdkwhich-countrywhich-country-ne-10mco-3gen@heotaein/concavemancoordinates2countryclosest-feature@giangtong/plotly.js@hoangho1147/hoang-sankey-plotly@maptalks/vtfolio-lamp-geometry@mangoweb/geolocation-utils@ltv/leaflet.glify@lunit/insight-viewer2nexudus-floorplan-enginenetpanoramareact-google-map-draw-filterrer3d-terriajsreact-v2react-leaflet-glifyreact-native-customized-chart-kitreact-native-custom-chart-kitreact-native-chart-kitreact-native-chart-kit-barreact-native-chart-kit-cofitreact-native-chart-kit-enhancedreact-native-chart-kit-extensionreact-native-chart-kit-forkedreact-native-chart-kit-johnreact-native-chart-kit-lushureact-native-chart-kit-pathreact-native-chart-kit-samxureact-native-chart-kit-with-pressable-bar-graphreact-native-charts-a2areact-native-charts-kitreact-native-charts-legendsreact-native-noc-chart-kittable-cartogramtp-react-native-chart-kitregion-labelsshesha-reactjsshp2stltekshark-react-native-chart-kitterriajssimple-react-typescript-apps-react-native-chart-kitsvg-to-polysuilibvisitapicker_testetripkit-react@juanezm/terriajsdetect-p@kokokj124/react-native-noc-chart-kit@kausal/plotly-custom@l.degener/geometrydotmapper@giliweb/plotly.js
1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

8 years ago

1.0.0

9 years ago

0.0.0

12 years ago