How to use point-in-polygon - 9 common examples

To help you get started, we’ve selected a few point-in-polygon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openmobilityfoundation / mds-core / packages / mds-utils / utils.ts View on Github external
function pointInPolyWithHoles(pt: [number, number], polyWithHoles: number[][][]): boolean {
  const poly = polyWithHoles[0]
  // log('testing', pt, 'in', poly, 'in', polyWithHoles)
  if (pointInPoly(pt, poly)) {
    // log('pt in poly')
    const holes = polyWithHoles.slice(1)
    for (const hole of holes) {
      if (pointInPoly(pt, hole)) {
        // log('pt in hole')
        return false
      }
    }
    // log('pt in poly but not holes')
    return true
  }
  // log('pt in none polys')
  return false
}
github DefinitelyTyped / DefinitelyTyped / types / point-in-polygon / point-in-polygon-tests.ts View on Github external
import inside from 'point-in-polygon';

const polygon = [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ] ];
const inPolygon: boolean = inside([ 1.5, 1.5 ], polygon);
github DefinitelyTyped / DefinitelyTyped / point-in-polygon / point-in-polygon-tests.ts View on Github external
import inside from 'point-in-polygon';

const polygon = [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ] ];
const inPolygon: boolean = inside([ 1.5, 1.5 ], polygon);
github massyao / china-invalid-vaccine-flow / js / model / map-model.js View on Github external
MapModel.prototype.getRandomPointForCountryBorder = function (country, coordinates) {
    if (!this._countryBoundsCache[country]) {
        this._countryBoundsCache[country] = MapModel.getBounds(coordinates);
    }
    var bounds = this._countryBoundsCache[country];
    var la, lo;

    var count = 0;
    do {
        la = Math.random() * (bounds.maxLa - bounds.minLa) + bounds.minLa;
        lo = Math.random() * (bounds.maxLo - bounds.minLo) + bounds.minLo;
        count++;
    } while (!inside([la, lo], coordinates) && count < 100);

    if (count == 100) {
        //console.log('could not create random point for ' + country);
        return [0, 0];
    }
    return [la, lo];
};
github miguelgimenezgimenez / react-google-map-draw-filter / src / Map.js View on Github external
markersArray.forEach(marker=>{
          const x = marker.getPosition().lat();
          const y = marker.getPosition().lng();
          if (!isInside([x,y],polygon)) {
            marker.setMap(null)
          } else {
            insideMarkers.push(marker);
            if (!marker.map) {
              marker.setMap(this.map)
            }
          }
        })
        if (this.props.handleReturnedMarkers) {
github circuitsim / circuit-simulator / src / ui / diagram / boundingBox.js View on Github external
function isPointIn(p: Vector, polygon: Array<[number, number]>) {
  const point = [p.x, p.y];
  return inside(point, polygon);
}
github Financial-Times / x-dash / packages / x-logo / index.js View on Github external
			.filter(point => pointInPolygon(point, this.thickerX));
github Caltech-IPAC / firefly / src / firefly / js / visualize / VisUtil.js View on Github external
    return testPts.every( (p) => pointInPolygon([p.x,p.y], polyPtsAsArray));
}

point-in-polygon

determine if a point is inside a polygon with a ray intersection counting algorithm

MIT
Latest version published 4 years ago

Package Health Score

62 / 100
Full package analysis

Popular point-in-polygon functions