Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/boolean-within

Package Overview
Dependencies
Maintainers
4
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/boolean-within

turf boolean-within module

  • 5.1.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
806K
increased by16.21%
Maintainers
4
Weekly downloads
 
Created

What is @turf/boolean-within?

@turf/boolean-within is a module from the Turf.js library that provides geospatial analysis tools. This specific module is used to determine if a given geometry (point, line, polygon) is within another geometry. It is useful for spatial queries and geographic information system (GIS) applications.

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

Point within Polygon

This feature checks if a point is within a polygon. The code sample creates a point and a polygon, then uses the booleanWithin function to determine if the point is inside the polygon.

const turf = require('@turf/turf');
const point = turf.point([2, 2]);
const polygon = turf.polygon([[
  [0, 0], [0, 5], [5, 5], [5, 0], [0, 0]
]]);
const isWithin = turf.booleanWithin(point, polygon);
console.log(isWithin); // true

LineString within Polygon

This feature checks if a LineString is within a polygon. The code sample creates a LineString and a polygon, then uses the booleanWithin function to determine if the LineString is inside the polygon.

const turf = require('@turf/turf');
const line = turf.lineString([[1, 1], [2, 2], [3, 3]]);
const polygon = turf.polygon([[
  [0, 0], [0, 5], [5, 5], [5, 0], [0, 0]
]]);
const isWithin = turf.booleanWithin(line, polygon);
console.log(isWithin); // true

Polygon within Polygon

This feature checks if a polygon is within another polygon. The code sample creates an inner polygon and an outer polygon, then uses the booleanWithin function to determine if the inner polygon is inside the outer polygon.

const turf = require('@turf/turf');
const innerPolygon = turf.polygon([[
  [1, 1], [1, 4], [4, 4], [4, 1], [1, 1]
]]);
const outerPolygon = turf.polygon([[
  [0, 0], [0, 5], [5, 5], [5, 0], [0, 0]
]]);
const isWithin = turf.booleanWithin(innerPolygon, outerPolygon);
console.log(isWithin); // true

Other packages similar to @turf/boolean-within

Keywords

FAQs

Package last updated on 10 Dec 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc