Skip to content

Commit d44b243

Browse files
committed
Fix: excluded single point polylines in transformer
1 parent 81f48d6 commit d44b243

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/utils/transformer.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,24 @@ export const domShapesToJSON = () => {
6060
};
6161

6262
export const domPolylineToJSON = () => {
63-
return d3Extended.selectAll(`[${dataAttributes.elementType}="${ElementType.Polyline}"]`).map((polyline) => {
64-
return {
65-
id: polyline.attr("id"),
66-
points: polyline
67-
.attr("points")
68-
.split(" ")
69-
.map((point) => {
70-
const [x, y] = point.split(",");
71-
return { x: +x, y: +y };
72-
}),
73-
section: polyline.attr(dataAttributes.section),
74-
color: rgbToHex(polyline.style("color")) || polyline.attr("color"),
75-
stroke: rgbToHex(polyline.style("stroke")) || polyline.attr("stroke")
76-
};
77-
});
63+
return d3Extended
64+
.selectAll(`[${dataAttributes.elementType}="${ElementType.Polyline}"]`)
65+
.map((polyline) => {
66+
return {
67+
id: polyline.attr("id"),
68+
points: polyline
69+
.attr("points")
70+
.split(" ")
71+
.map((point) => {
72+
const [x, y] = point.split(",");
73+
return { x: +x, y: +y };
74+
}),
75+
section: polyline.attr(dataAttributes.section),
76+
color: rgbToHex(polyline.style("color")) || polyline.attr("color"),
77+
stroke: rgbToHex(polyline.style("stroke")) || polyline.attr("stroke")
78+
};
79+
})
80+
.filter((polyline) => polyline.points.length > 1);
7881
};
7982

8083
export const domImagesToJSON = () => {

0 commit comments

Comments
 (0)