From 0e0ad77f2a2f31611caa1544f5e1f7efd7ce86e3 Mon Sep 17 00:00:00 2001 From: superDoss Date: Mon, 1 Jan 2024 11:40:14 +0200 Subject: [PATCH] fix #checkClosingRing to check for polygon being closed --- packages/turf-boolean-valid/index.ts | 2 +- .../false/Polygon/not-closing-ring.geojson | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 packages/turf-boolean-valid/test/false/Polygon/not-closing-ring.geojson diff --git a/packages/turf-boolean-valid/index.ts b/packages/turf-boolean-valid/index.ts index db24fc5b9b..f50488ac94 100644 --- a/packages/turf-boolean-valid/index.ts +++ b/packages/turf-boolean-valid/index.ts @@ -90,7 +90,7 @@ function booleanValid(feature: Feature | Geometry) { function checkRingsClose(geom: Position[]) { return ( - geom[0][0] === geom[geom.length - 1][0] || + geom[0][0] === geom[geom.length - 1][0] && geom[0][1] === geom[geom.length - 1][1] ); } diff --git a/packages/turf-boolean-valid/test/false/Polygon/not-closing-ring.geojson b/packages/turf-boolean-valid/test/false/Polygon/not-closing-ring.geojson new file mode 100644 index 0000000000..df738d0719 --- /dev/null +++ b/packages/turf-boolean-valid/test/false/Polygon/not-closing-ring.geojson @@ -0,0 +1,20 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-0.703125, 24.84656534821976], + [11.25, 24.84656534821976], + [11.25, 31.353636941500987], + [-0.703125, 31.353636941500987] + ] + ] + } + } + ] +}