diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java b/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java index 5d405742e..2659aee24 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/build/iidm/VoltageLevelFilter.java @@ -147,6 +147,13 @@ private void visitTerminal(Terminal terminal) { nextDepthVoltageLevels.add(voltageLevel); } } + + @Override + public void visitDanglingLine(DanglingLine danglingLine) { + if (danglingLine.isPaired()) { + danglingLine.getTieLine().ifPresent(tieline -> visitBranch(tieline, tieline.getSide(danglingLine.getTerminal()))); + } + } } } diff --git a/network-area-diagram/src/test/java/com/powsybl/nad/AbstractTest.java b/network-area-diagram/src/test/java/com/powsybl/nad/AbstractTest.java index 9cc96f44d..b79f9a1b7 100644 --- a/network-area-diagram/src/test/java/com/powsybl/nad/AbstractTest.java +++ b/network-area-diagram/src/test/java/com/powsybl/nad/AbstractTest.java @@ -25,6 +25,7 @@ import java.nio.file.Path; import java.util.Objects; import java.util.function.Predicate; +import java.util.stream.*; /** * @author Florian Dupuy @@ -100,6 +101,14 @@ private static String normalizeLineSeparator(String str) { .replace("\r", "\n"); } + protected static String getContentFile(Path svgFile) { + try (Stream lines = Files.lines(svgFile)) { + return lines.collect(Collectors.joining("\n")) + "\n"; + } catch (IOException e) { + throw new RuntimeException(e); + } + } + protected LayoutParameters getLayoutParameters() { return layoutParameters; } diff --git a/network-area-diagram/src/test/java/com/powsybl/nad/NetworkAreaDiagramTest.java b/network-area-diagram/src/test/java/com/powsybl/nad/NetworkAreaDiagramTest.java index 8f34133d9..3fa7c4792 100644 --- a/network-area-diagram/src/test/java/com/powsybl/nad/NetworkAreaDiagramTest.java +++ b/network-area-diagram/src/test/java/com/powsybl/nad/NetworkAreaDiagramTest.java @@ -10,11 +10,7 @@ import com.google.common.jimfs.Configuration; import com.google.common.jimfs.Jimfs; import com.powsybl.iidm.network.Network; -import com.powsybl.nad.build.iidm.IdProvider; -import com.powsybl.nad.build.iidm.IntIdProvider; import com.powsybl.nad.build.iidm.VoltageLevelFilter; -import com.powsybl.nad.layout.BasicForceLayoutFactory; -import com.powsybl.nad.layout.LayoutFactory; import com.powsybl.nad.layout.LayoutParameters; import com.powsybl.nad.svg.LabelProvider; import com.powsybl.diagram.test.Networks; @@ -27,11 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.BeforeEach; -import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; -import java.util.stream.Collectors; -import java.util.stream.Stream; /** * @author Thomas Adam @@ -60,22 +52,6 @@ protected LabelProvider getLabelProvider(Network network) { }; } - private LayoutFactory getLayoutFactory() { - return new BasicForceLayoutFactory(); - } - - private IdProvider getIdProvider() { - return new IntIdProvider(); - } - - private String getContentFile(Path svgFile) { - try (Stream lines = Files.lines(svgFile)) { - return lines.collect(Collectors.joining("\n")) + "\n"; - } catch (IOException e) { - throw new RuntimeException(e); - } - } - @Test void testDrawSvg() { Network network = Networks.createThreeVoltageLevelsFiveBuses(); diff --git a/network-area-diagram/src/test/java/com/powsybl/nad/svg/TieLineTest.java b/network-area-diagram/src/test/java/com/powsybl/nad/svg/TieLineTest.java index d404c6042..c926c9041 100644 --- a/network-area-diagram/src/test/java/com/powsybl/nad/svg/TieLineTest.java +++ b/network-area-diagram/src/test/java/com/powsybl/nad/svg/TieLineTest.java @@ -7,15 +7,18 @@ */ package com.powsybl.nad.svg; +import com.google.common.jimfs.*; import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; -import com.powsybl.nad.AbstractTest; +import com.powsybl.nad.*; import com.powsybl.nad.layout.LayoutParameters; import com.powsybl.nad.svg.iidm.DefaultLabelProvider; import com.powsybl.nad.svg.iidm.NominalVoltageStyleProvider; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.nio.file.*; + import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -23,8 +26,11 @@ */ class TieLineTest extends AbstractTest { + protected java.nio.file.FileSystem fileSystem; + @BeforeEach void setup() { + fileSystem = Jimfs.newFileSystem(Configuration.unix()); setLayoutParameters(new LayoutParameters()); setSvgParameters(new SvgParameters() .setSvgWidthAndHeightAdded(true) @@ -48,4 +54,16 @@ void testTieLine() { assertEquals(toString("/tie_line.svg"), generateSvgString(network, "/tie_line.svg")); } + @Test + void testDanglingLinePaired() { + Network network = EurostagTutorialExample1Factory.createWithTieLine(); + NetworkAreaDiagram nad = new NetworkAreaDiagram(network, "VLHV1", 1); + Path svgFile = fileSystem.getPath("tie_line_filtered.svg"); + nad.draw(svgFile, + getSvgParameters(), + getLayoutParameters(), + getStyleProvider(network)); + + assertEquals(toString("/tie_line_filtered.svg"), getContentFile(svgFile)); + } } diff --git a/network-area-diagram/src/test/resources/tie_line_filtered.svg b/network-area-diagram/src/test/resources/tie_line_filtered.svg new file mode 100644 index 000000000..d5fdb9d1d --- /dev/null +++ b/network-area-diagram/src/test/resources/tie_line_filtered.svg @@ -0,0 +1,233 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 606 + + + + + + + + + + + + -605 + + + + + + + + + + + + + + + + + + 302 + + + + + + + + + + + + -300 + + + + + + + + + + + + + + + 302 + + + + + + + + + + + + -300 + + + + + + + + + + + + + + + 601 + + + + + + + + + + + + + + + + + +
+
VLGEN
+ + + + + +
+
+
24.5 kV / 2.3°
+
+
+ +
+
VLHV1
+ + + + + +
+
+
402.1 kV / 0.0°
+
+
+ +
+
VLHV2
+ + + + + +
+
+
390.0 kV / -3.5°
+
+
+
+