From e8202964daef82e0e12b19b839e5d747d56c5437 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Fri, 14 Feb 2025 17:51:33 +0545 Subject: [PATCH] fix(extractGeojsonFromObject): differentiate and visualize Polygon & LineString seperately --- src/frontend/src/utilfunctions/extractGeojsonFromObject.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/utilfunctions/extractGeojsonFromObject.ts b/src/frontend/src/utilfunctions/extractGeojsonFromObject.ts index 788d54a802..edc3c93a00 100644 --- a/src/frontend/src/utilfunctions/extractGeojsonFromObject.ts +++ b/src/frontend/src/utilfunctions/extractGeojsonFromObject.ts @@ -20,7 +20,12 @@ export const convertCoordinateStringToFeature = (key: string, coordinateString: }); return [coordinate[1], coordinate[0]]; }); - feature = { ...feature, geometry: { type: 'Polygon', coordinates: [coordinates] }, properties: { label: key } }; + // if initial and last coordinates are same, it's a Polygon else LineString + if (coordinates?.[0]?.toString() === coordinates?.[coordinates?.length - 1]?.toString()) { + feature = { ...feature, geometry: { type: 'Polygon', coordinates: [coordinates] }, properties: { label: key } }; + } else { + feature = { ...feature, geometry: { type: 'LineString', coordinates: coordinates }, properties: { label: key } }; + } } else { // if feature is Point in JavaRosa format it contains string of array const splittedCoord = coordinateString?.split(' ');