powsybl / powsybl-diagram

SVG diagrams generation: single-line substation diagrams and network graph diagrams
Mozilla Public License 2.0
76 stars 13 forks source link

Add a comparator to sort nodes in NAD and SLD #623

Closed antoinebhs closed 3 months ago

antoinebhs commented 5 months ago

Describe the current behavior

Currently, bus nodes within each voltage level are sorted differently between the NAD and SLD implementations. In addition, there is no easy way to override the default sorting behavior.

Describe the expected behavior

We need to extract and expose a comparator in both the NAD and SLD StyleProviders. This will allow us to sort bus nodes consistently across different voltage levels in both systems. The primary goal is to ensure that nodes are sorted consistently, which in turn will allow for consistent coloring of the same nodes between SLD and NAD.

Describe the motivation

In GridSuite, we set the same colors for bus nodes in voltage levels for NAD and SLD so that users can have corresponding node colors in both diagrams. For example, for voltage levels between 300kV and 500kV, the first node color is:

.nad-vl300to500-0 {--nad-vl-color: #ff0000}
.sld-vl300to500-0 {--sld-vl-color: #ff0000}

In some cases, because bus nodes are not sorted in the same way between NAD and SLD, the node colors are not consistent between the two diagrams which is confusing to users.

Extra Information

No response

EstherDarkish commented 4 months ago

The selected solution opts out of a comparator and instead uses the provided order of buses to draw the classes in the NAD, like it is done with the SLDs.