Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 548 #549

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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())));
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 <florian.dupuy at rte-france.com>
Expand Down Expand Up @@ -100,6 +101,14 @@ private static String normalizeLineSeparator(String str) {
.replace("\r", "\n");
}

protected static String getContentFile(Path svgFile) {
try (Stream<String> lines = Files.lines(svgFile)) {
return lines.collect(Collectors.joining("\n")) + "\n";
} catch (IOException e) {
throw new RuntimeException(e);
}
}

protected LayoutParameters getLayoutParameters() {
return layoutParameters;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 <tadam at silicom.fr>
Expand Down Expand Up @@ -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<String> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,30 @@
*/
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;

/**
* @author Sophie Frasnedo <sophie.frasnedo at rte-france.com>
*/
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)
Expand All @@ -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));
}
}
233 changes: 233 additions & 0 deletions network-area-diagram/src/test/resources/tie_line_filtered.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.