Skip to content

Commit

Permalink
add tie line equipment
Browse files Browse the repository at this point in the history
  • Loading branch information
ghazwarhili committed Mar 20, 2024
1 parent 4fb0752 commit 47f17df
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/gridsuite/geodata/server/GeoDataService.java
Original file line number Diff line number Diff line change
Expand Up @@ -481,20 +481,25 @@ public List<LineGeoData> getLinesByCountries(Network network, Set<Country> count
StopWatch stopWatch = StopWatch.createStarted();

List<Line> lines = network.getLineStream().collect(Collectors.toList());
List<TieLine> tieLines = network.getTieLineStream().collect(Collectors.toList());
List<HvdcLine> hvdcLines = network.getHvdcLineStream().collect(Collectors.toList());

// read lines from DB
Set<String> ids = new HashSet<>();
Set<String> lineIds = lines.stream().map(Line::getId).collect(Collectors.toSet());
Set<String> tieLineIds = tieLines.stream().map(TieLine::getId).collect(Collectors.toSet());
Set<String> hvdcLineIds = hvdcLines.stream().map(HvdcLine::getId).collect(Collectors.toSet());
ids.addAll(lineIds);
ids.addAll(tieLineIds);
ids.addAll(hvdcLineIds);
Map<String, LineGeoData> linesGeoDataDb = lineRepository.findAllById(ids).stream().collect(Collectors.toMap(LineEntity::getId, this::toDto));

// we also want the destination substation (so we add the neighbouring country)
Set<Country> countryAndNextTo =
lines.stream().flatMap(line -> line.getTerminals().stream().map(term -> term.getVoltageLevel().getSubstation().orElseThrow().getNullableCountry()).filter(Objects::nonNull))
.collect(Collectors.toSet());
countryAndNextTo.addAll(tieLines.stream().map(tieLine -> tieLine.getDanglingLine1().getTerminal().getVoltageLevel().getSubstation().orElseThrow().getNullableCountry()).filter(Objects::nonNull).collect(Collectors.toSet()));
countryAndNextTo.addAll(tieLines.stream().map(tieLine -> tieLine.getDanglingLine2().getTerminal().getVoltageLevel().getSubstation().orElseThrow().getNullableCountry()).filter(Objects::nonNull).collect(Collectors.toSet()));
countryAndNextTo.addAll(hvdcLines.stream().map(hvdcLine -> hvdcLine.getConverterStation1().getTerminal().getVoltageLevel().getSubstation().orElseThrow().getNullableCountry()).filter(Objects::nonNull).collect(Collectors.toSet()));
countryAndNextTo.addAll(hvdcLines.stream().map(hvdcLine -> hvdcLine.getConverterStation2().getTerminal().getVoltageLevel().getSubstation().orElseThrow().getNullableCountry()).filter(Objects::nonNull).collect(Collectors.toSet()));
Map<String, SubstationGeoData> substationGeoDataDb = getSubstationMapByCountries(network, countryAndNextTo);
Expand All @@ -505,11 +510,16 @@ public List<LineGeoData> getLinesByCountries(Network network, Set<Country> count
line.getTerminal1().getVoltageLevel().getSubstation().orElseThrow(),
line.getTerminal2().getVoltageLevel().getSubstation().orElseThrow()))
.filter(Objects::nonNull).collect(Collectors.toList());
List<LineGeoData> tieLineGeoData = tieLines.stream().map(tieLine -> getLineGeoDataWithEndSubstations(linesGeoDataDb, substationGeoDataDb, tieLine.getId(),
tieLine.getDanglingLine1().getTerminal().getVoltageLevel().getSubstation().orElseThrow(),
tieLine.getDanglingLine2().getTerminal().getVoltageLevel().getSubstation().orElseThrow()))
.filter(Objects::nonNull).collect(Collectors.toList());
List<LineGeoData> hvdcLineGeoData = hvdcLines.stream().map(hvdcLine -> getLineGeoDataWithEndSubstations(linesGeoDataDb, substationGeoDataDb, hvdcLine.getId(),
hvdcLine.getConverterStation1().getTerminal().getVoltageLevel().getSubstation().orElseThrow(),
hvdcLine.getConverterStation2().getTerminal().getVoltageLevel().getSubstation().orElseThrow()))
.filter(Objects::nonNull).collect(Collectors.toList());
geoData.addAll(lineGeoData);
geoData.addAll(tieLineGeoData);
geoData.addAll(hvdcLineGeoData);
LOGGER.info("{} lines read from DB in {} ms", linesGeoDataDb.size(), stopWatch.getTime(TimeUnit.MILLISECONDS));

Expand Down

0 comments on commit 47f17df

Please sign in to comment.