Skip to content

Commit

Permalink
Fix: excluded single point polylines in transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka47000 committed Jun 5, 2024
1 parent 81f48d6 commit d44b243
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/utils/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down

0 comments on commit d44b243

Please sign in to comment.