How to use the geolib.isPointInPolygon function in geolib

To help you get started, we’ve selected a few geolib 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 pelias / api / controller / placeholder.js View on Github external
function getBoundaryRectangleFilter(clean, do_geometric_filters_apply) {
  // check to see if boundary.rect.min_lat/min_lon/max_lat/max_lon are all available
  if (do_geometric_filters_apply && ['min_lat', 'min_lon', 'max_lat', 'max_lon'].every((f) => {
    return _.has(clean, `boundary.rect.${f}`);
  })) {
    const polygon = [
      { latitude: clean['boundary.rect.min_lat'], longitude: clean['boundary.rect.min_lon'] },
      { latitude: clean['boundary.rect.max_lat'], longitude: clean['boundary.rect.min_lon'] },
      { latitude: clean['boundary.rect.max_lat'], longitude: clean['boundary.rect.max_lon'] },
      { latitude: clean['boundary.rect.min_lat'], longitude: clean['boundary.rect.max_lon'] }
    ];
    // isPointInPolygon takes polygon last, so create a function that has it pre-populated
    const isPointInsidePolygon = _.partialRight(geolib.isPointInPolygon, polygon);

    return _.partial(isInsideGeometry, isPointInsidePolygon);

  }

  // there's no bbox filter, so return a function that always returns true
  return () => true;

}

geolib

Library to provide basic geospatial operations like distance calculation, conversion of decimal coordinates to sexagesimal and vice versa, etc. This library is currently **2D**, meaning that altitude/elevation is not yet supported by any of its functions!

MIT
Latest version published 1 year ago

Package Health Score

66 / 100
Full package analysis

Similar packages