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

get number of voltage levels in nad diagram #486

Merged
merged 10 commits into from
Jan 31, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,10 @@ public String drawToString(SvgParameters svgParameters) {
throw new UncheckedIOException(e);
}
}

public int getNbVoltageLevels() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some discussion to remove NetworkAreaDiagram object, as it is of no use so far and to correspond to SingleLineDiagram static class.

return voltageLevelFilter instanceof VoltageLevelFilter
? ((VoltageLevelFilter) voltageLevelFilter).getNbVoltageLevels()
: network.getVoltageLevelCount();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public VoltageLevelFilter(Set<VoltageLevel> voltageLevels) {
this.voltageLevels = voltageLevels;
}

public int getNbVoltageLevels() {
return voltageLevels.size();
}

@Override
public boolean test(VoltageLevel voltageLevel) {
return voltageLevels.contains(voltageLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ public void testDiamond() {
checkLayoutWithInitialPositions(LayoutNetworkFactory.createDiamond());
}

@Test
public void testNbVoltageLevels() {
Network network = LayoutNetworkFactory.createDiamond();

assertEquals(1, new NetworkAreaDiagram(network, VoltageLevelFilter.createVoltageLevelDepthFilter(network, "A 400", 0)).getNbVoltageLevels());
assertEquals(4, new NetworkAreaDiagram(network, VoltageLevelFilter.createVoltageLevelDepthFilter(network, "A 400", 3)).getNbVoltageLevels());
assertEquals(7, new NetworkAreaDiagram(network, VoltageLevelFilter.createVoltageLevelDepthFilter(network, "A 400", 5)).getNbVoltageLevels());
assertEquals(1, new NetworkAreaDiagram(network, VoltageLevelFilter.createVoltageLevelDepthFilter(network, "A 400", 0)).getNbVoltageLevels());
assertEquals(15, new NetworkAreaDiagram(network, VoltageLevelFilter.NO_FILTER).getNbVoltageLevels());
}

private void checkLayoutWithInitialPositions(Network network) {
Predicate<VoltageLevel> filter = vl -> vl.getNominalV() >= 100;

Expand Down