Skip to content
Open
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
17 changes: 14 additions & 3 deletions src/main/java/org/gridsuite/network/map/NetworkMapService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import com.powsybl.commons.PowsyblException;
import com.powsybl.iidm.network.*;
import org.gridsuite.network.map.model.BusMapData;
import org.gridsuite.network.map.model.LineMapData;
import org.gridsuite.network.map.model.SubstationMapData;
import org.gridsuite.network.map.model.VoltageLevelMapData;
Expand Down Expand Up @@ -43,16 +44,26 @@ private Network getNetwork(UUID networkUuid) {

private static VoltageLevelMapData toMapData(VoltageLevel voltageLevel) {
return VoltageLevelMapData.builder()
.name(voltageLevel.getName())
.name(voltageLevel.getNameOrId())
.id(voltageLevel.getId())
.nominalVoltage(voltageLevel.getNominalV())
.buses(voltageLevel.getBusView().getBusStream().map(NetworkMapService::toBusData).collect(Collectors.toList()))
.build();
}

private static BusMapData toBusData(Bus bus) {
BusMapData.BusMapDataBuilder builder = BusMapData.builder()
.id(bus.getId());
if (!Double.isNaN(bus.getV())) {
builder.v(bus.getV());
}
return builder.build();
}

private static SubstationMapData toMapData(Substation substation) {
return SubstationMapData.builder()
.name(substation.getName())
.id(substation.getId())
.name(substation.getNameOrId())
.countryName(substation.getCountry().map(Country::getName).orElse(null))
.voltageLevels(substation.getVoltageLevelStream().map(NetworkMapService::toMapData).collect(Collectors.toList()))
.build();
Expand All @@ -62,8 +73,8 @@ private static LineMapData toMapData(Line line) {
Terminal terminal1 = line.getTerminal1();
Terminal terminal2 = line.getTerminal2();
LineMapData.LineMapDataBuilder builder = LineMapData.builder()
.name(line.getName())
.id(line.getId())
.name(line.getNameOrId())
.terminal1Connected(terminal1.isConnected())
.terminal2Connected(terminal2.isConnected())
.voltageLevelId1(terminal1.getVoltageLevel().getId())
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/org/gridsuite/network/map/model/BusMapData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright (c) 2019, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.network.map.model;

import lombok.Builder;
import lombok.Getter;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
@Builder
@Getter
public class BusMapData {

private String id;

private double v;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import lombok.Builder;
import lombok.Getter;

import java.util.List;

/**
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
*/
Expand All @@ -21,4 +23,6 @@ public class VoltageLevelMapData {
private String name;

private double nominalVoltage;

private List<BusMapData> buses;
}
32 changes: 28 additions & 4 deletions src/test/resources/substations-map-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,24 @@
{
"id": "VLGEN",
"name": "VLGEN",
"nominalVoltage": 24.0
"nominalVoltage": 24.0,
"buses": [
{
"id": "VLGEN_0",
"v": 0.0
}
]
},
{
"id": "VLHV1",
"name": "VLHV1",
"nominalVoltage": 380.0
"nominalVoltage": 380.0,
"buses": [
{
"id": "VLHV1_0",
"v": 0.0
}
]
}
]
},
Expand All @@ -23,12 +35,24 @@
{
"id": "VLHV2",
"name": "VLHV2",
"nominalVoltage": 380.0
"nominalVoltage": 380.0,
"buses": [
{
"id": "VLHV2_0",
"v": 0.0
}
]
},
{
"id": "VLLOAD",
"name": "VLLOAD",
"nominalVoltage": 150.0
"nominalVoltage": 150.0,
"buses": [
{
"id": "VLLOAD_0",
"v": 0.0
}
]
}
]
}
Expand Down