From 65f85b3492af8ffbb1d5509ed3ffe94e8bc53d69 Mon Sep 17 00:00:00 2001 From: Brock Chelle Date: Mon, 15 Dec 2025 19:29:36 -0700 Subject: [PATCH 1/2] Fix convex function ignoring given properties --- packages/turf-convex/index.ts | 2 +- packages/turf-convex/test.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/turf-convex/index.ts b/packages/turf-convex/index.ts index d7969ec59b..9a59a98932 100644 --- a/packages/turf-convex/index.ts +++ b/packages/turf-convex/index.ts @@ -56,7 +56,7 @@ function convex

( // Convex hull should have at least 3 different vertices in order to create a valid polygon if (convexHull.length > 3) { - return polygon([convexHull]); + return polygon

([convexHull], options.properties); } return null; } diff --git a/packages/turf-convex/test.ts b/packages/turf-convex/test.ts index 58b0cde7c5..51c98ffcb5 100644 --- a/packages/turf-convex/test.ts +++ b/packages/turf-convex/test.ts @@ -6,6 +6,7 @@ import { writeJsonFileSync } from "write-json-file"; import { loadJsonFileSync } from "load-json-file"; import { featureCollection } from "@turf/helpers"; import { convex } from "./index.js"; +import { type FeatureCollection } from "geojson"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -32,3 +33,17 @@ test("turf-convex -- empty", (t) => { t.deepEqual(convex(featureCollection([])), null, "corner case: null hull"); t.end(); }); + +test("turf-convex -- properties are transferred to result polygon", (t) => { + const geoJson = loadJsonFileSync( + "./test/in/elevation2.geojson" + ); + const expectedProperties = { cadastralData: [1220, 1290, 1440, 1943] }; + const actualPolygon = convex(geoJson, { properties: expectedProperties }); + t.deepEqual( + actualPolygon?.properties, + expectedProperties, + "properties do not match" + ); + t.end(); +}); From c28007783f521515939861171fe8fea1df4e0324 Mon Sep 17 00:00:00 2001 From: Brock Chelle Date: Mon, 15 Dec 2025 19:34:57 -0700 Subject: [PATCH 2/2] add contributors --- packages/turf-convex/package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/turf-convex/package.json b/packages/turf-convex/package.json index 0471d02073..9ebb5868ac 100644 --- a/packages/turf-convex/package.json +++ b/packages/turf-convex/package.json @@ -3,6 +3,10 @@ "version": "7.3.1", "description": "Creates a convex hull around points", "author": "Turf Authors", + "contributors": [ + "Brock Chelle <@blchelle>", + "Kareem Jeiroudi <@kareemjeiroudi>" + ], "license": "MIT", "bugs": { "url": "https://github.com/Turfjs/turf/issues"