Checking if a Point is Inside a Polygon with Turf.js

Checking if a Point is Inside a Polygon with Turf.js

Artikel ini sudah lama

Artikel ini ditulis lebih dari setahun yang lalu. Beberapa informasi mungkin sudah usang.

Need to determine if a point is inside a polygon in javascript? the turf.booleanPointInPolygon function makes it easy!

šŸ”¹ what it does:
it checks whether a given point is inside (or on the boundary of) a polygon.

šŸ”¹ how to use it:

import booleanPointInPolygon from "@turf/boolean-point-in-polygon"; import { point, polygon } from "@turf/helpers"; const pt = point([2, 2]); const poly = polygon([ [ [0, 0], [4, 0], [4, 4], [0, 4], [0, 0], ], ]); const isInside = booleanPointInPolygon(pt, poly); console.log(isInside); // true āœ…

Suka artikel ini? Bagikan ke temanmu atau salin link-nya!