Skip to content

Using booleanContains cannot accurately determine the inclusion result of line segments and concave convex polygons #2441

@Steve245270533

Description

@Steve245270533

Using booleanContains cannot accurately determine the inclusion result of line segments and concave convex polygons.

version: 6.5.0

import { lineString, polygon, booleanContains } from '@turf/turf';

const turf_polygon = polygon([
  [
    [0, 0],
    [4, 0],
    [4, 1],
    [3, 1],
    [3, 2],
    [2, 2],
    [2, 1],
    [1, 1],
    [1, 3],
    [0, 3],
    [0, 0],
  ],
]);

const turf_line = lineString([
  [1, 2],
  [4, 0],
]);

console.log(booleanContains(turf_polygon, turf_line));

The final result is true, and it is evident from the image that this line segment is not completely contained within the polygon.

I'm not sure if there's a problem with my usage. Is there any way to correctly determine the inclusion of line segments and polygons?

image

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions