From d44b2433f353af2a44124ae1b5c2a78e91aa4e80 Mon Sep 17 00:00:00 2001 From: Akalanka Perera Date: Wed, 5 Jun 2024 10:22:35 +0530 Subject: [PATCH] Fix: excluded single point polylines in transformer --- src/utils/transformer.ts | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/utils/transformer.ts b/src/utils/transformer.ts index 2330e37..596e54a 100644 --- a/src/utils/transformer.ts +++ b/src/utils/transformer.ts @@ -60,21 +60,24 @@ export const domShapesToJSON = () => { }; export const domPolylineToJSON = () => { - return d3Extended.selectAll(`[${dataAttributes.elementType}="${ElementType.Polyline}"]`).map((polyline) => { - return { - id: polyline.attr("id"), - points: polyline - .attr("points") - .split(" ") - .map((point) => { - const [x, y] = point.split(","); - return { x: +x, y: +y }; - }), - section: polyline.attr(dataAttributes.section), - color: rgbToHex(polyline.style("color")) || polyline.attr("color"), - stroke: rgbToHex(polyline.style("stroke")) || polyline.attr("stroke") - }; - }); + return d3Extended + .selectAll(`[${dataAttributes.elementType}="${ElementType.Polyline}"]`) + .map((polyline) => { + return { + id: polyline.attr("id"), + points: polyline + .attr("points") + .split(" ") + .map((point) => { + const [x, y] = point.split(","); + return { x: +x, y: +y }; + }), + section: polyline.attr(dataAttributes.section), + color: rgbToHex(polyline.style("color")) || polyline.attr("color"), + stroke: rgbToHex(polyline.style("stroke")) || polyline.attr("stroke") + }; + }) + .filter((polyline) => polyline.points.length > 1); }; export const domImagesToJSON = () => {