Socket
Socket
Sign inDemoInstall

@turf/boolean-intersects

Package Overview
Dependencies
61
Maintainers
7
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @turf/boolean-intersects

turf boolean-intersects module


Version published
Weekly downloads
323K
increased by0.43%
Maintainers
7
Created
Weekly downloads
 

Package description

What is @turf/boolean-intersects?

@turf/boolean-intersects is a module from the Turf.js library that provides geospatial analysis tools. This specific module is used to determine if two geometries intersect. It supports various types of geometries including points, lines, and polygons.

What are @turf/boolean-intersects's main functionalities?

Check if two polygons intersect

This feature checks if two polygons intersect. The code sample creates two polygons and uses the booleanIntersects function to determine if they intersect.

const turf = require('@turf/turf');

const polygon1 = turf.polygon([[
  [-2, 2],
  [2, 2],
  [2, -2],
  [-2, -2],
  [-2, 2]
]]);

const polygon2 = turf.polygon([[
  [1, 1],
  [3, 1],
  [3, -1],
  [1, -1],
  [1, 1]
]]);

const intersects = turf.booleanIntersects(polygon1, polygon2);
console.log(intersects); // true

Check if a line intersects a polygon

This feature checks if a line intersects a polygon. The code sample creates a line and a polygon and uses the booleanIntersects function to determine if they intersect.

const turf = require('@turf/turf');

const line = turf.lineString([
  [-1, 0],
  [1, 0]
]);

const polygon = turf.polygon([[
  [-2, 2],
  [2, 2],
  [2, -2],
  [-2, -2],
  [-2, 2]
]]);

const intersects = turf.booleanIntersects(line, polygon);
console.log(intersects); // true

Check if a point intersects a polygon

This feature checks if a point intersects a polygon. The code sample creates a point and a polygon and uses the booleanIntersects function to determine if they intersect.

const turf = require('@turf/turf');

const point = turf.point([1, 1]);

const polygon = turf.polygon([[
  [-2, 2],
  [2, 2],
  [2, -2],
  [-2, -2],
  [-2, 2]
]]);

const intersects = turf.booleanIntersects(point, polygon);
console.log(intersects); // true

Other packages similar to @turf/boolean-intersects

Readme

Source

@turf/boolean-intersects

booleanIntersects

Boolean-intersects returns (TRUE) two geometries intersect.

Parameters

  • feature1 (Geometry | Feature<any>) GeoJSON Feature or Geometry
  • feature2 (Geometry | Feature<any>) GeoJSON Feature or Geometry

Examples

var point = turf.point([2, 2]);
var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);

turf.booleanIntersects(line, point);
//=true

Returns boolean true/false


This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.

Installation

Install this module individually:

$ npm install @turf/boolean-intersects

Or install the Turf module that includes it as a function:

$ npm install @turf/turf

Keywords

FAQs

Last updated on 09 Nov 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc