Skip to content

pointToPolygonDistance with hole return unsigned values #2824

@ata-electronics

Description

@ata-electronics

Hello,
The pointToPolygonDistance function return positive value for a point in polygon with an hole:

How to reproduce :
Use this file in https://turf-sandbox.netlify.app/
turfSandbox_scipt_pointToPolygonDistance.txt

Fix:
I think that the issue is on line 72 of file https://github.com/Turfjs/turf/blob/master/packages/turf-point-to-polygon-distance/index.ts
return Math.min(smallestInteriorDistance, Math.abs(exteriorDistance));
should be replaced by
return Math.max(smallestInteriorDistance*-1, exteriorDistance);

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions