How to use @turf/boolean-within - 4 common examples

To help you get started, we’ve selected a few @turf/boolean-within 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 Turfjs / turf / packages / turf-point-grid / index.js View on Github external
var bboxWidth = (east - west);
    var bboxHeight = (north - south);
    var columns = Math.floor(bboxWidth / cellWidth);
    var rows = Math.floor(bboxHeight / cellHeight);
    // adjust origin of the grid
    var deltaX = (bboxWidth - columns * cellWidth) / 2;
    var deltaY = (bboxHeight - rows * cellHeight) / 2;

    var currentX = west + deltaX;
    while (currentX <= east) {
        var currentY = south + deltaY;
        while (currentY <= north) {
            var cellPt = point([currentX, currentY], properties);
            if (mask) {
                if (within(cellPt, mask)) results.push(cellPt);
            } else {
                results.push(cellPt);
            }
            currentY += cellHeight;
        }
        currentX += cellWidth;
    }

    return featureCollection(results);
}
github ngageoint / geopackage-js / lib / features / user / featureDao.js View on Github external
function verifyFeature(geometry, boundingBox) {
  try {
    if (geometry.type == 'Point') {
      return geometry;
    } else if (geometry.type == 'LineString') {
      var intersect = LineIntersect(geometry, boundingBox.toGeoJSON().geometry);
      if (intersect.features.length) {
        return geometry;
      } else if (BooleanWithin(geometry, boundingBox.toGeoJSON().geometry)) {
        return geometry;
      }
    } else if (geometry.type == 'Polygon') {
      var polyIntersect = Intersect(geometry, boundingBox.toGeoJSON().geometry);
      if (polyIntersect) {
        return geometry;
      } else if (BooleanWithin(geometry, boundingBox.toGeoJSON().geometry)) {
        return geometry;
      }
    }
  } catch (e) {}
}
github ngageoint / geopackage-js / lib / features / user / featureDao.js View on Github external
function verifyFeature(geometry, boundingBox) {
  try {
    if (geometry.type == 'Point') {
      return geometry;
    } else if (geometry.type == 'LineString') {
      var intersect = LineIntersect(geometry, boundingBox.toGeoJSON().geometry);
      if (intersect.features.length) {
        return geometry;
      } else if (BooleanWithin(geometry, boundingBox.toGeoJSON().geometry)) {
        return geometry;
      }
    } else if (geometry.type == 'Polygon') {
      var polyIntersect = Intersect(geometry, boundingBox.toGeoJSON().geometry);
      if (polyIntersect) {
        return geometry;
      } else if (BooleanWithin(geometry, boundingBox.toGeoJSON().geometry)) {
        return geometry;
      }
    }
  } catch (e) {}
}

@turf/boolean-within

turf boolean-within module

MIT
Latest version published 3 months ago

Package Health Score

96 / 100
Full package analysis

Popular @turf/boolean-within functions