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

Matrix zone layout : keep voltagelevel as exclusion area #586

Merged
merged 4 commits into from
Mar 19, 2024
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 @@ -107,7 +107,7 @@ protected List<Point> calculatePolylineSnakeLine(LayoutParameters layoutParamete
// Add starting point
polyline.add(p1);
// Find snakeline path
polyline.addAll(model.buildSnakeline(pathFinder, ss1Graph.getId(), p1, dNode1, ss2Graph.getId(), p2, dNode2));
polyline.addAll(model.buildSnakeline(pathFinder, ss1Graph.getId(), p1, dNode1, ss2Graph.getId(), p2, dNode2, layoutParameters));
// Add ending point
polyline.add(p2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,35 @@ public void addSubstationGraph(SubstationGraph graph, int row, int col) {

public List<Point> buildSnakeline(PathFinder pathfinder,
String ss1Id, Point p1, Direction d1,
String ss2Id, Point p2, Direction d2) {
matrix.get(ss1Id).ifPresent(matrixCell -> insertFreePathInSubstation(matrixCell.row(), p1, d1));
matrix.get(ss2Id).ifPresent(matrixCell -> insertFreePathInSubstation(matrixCell.row(), p2, d2));
String ss2Id, Point p2, Direction d2,
LayoutParameters layoutParameters) {
matrix.get(ss1Id).ifPresent(matrixCell -> insertFreePathInSubstation(matrixCell, p1, d1, layoutParameters));
matrix.get(ss2Id).ifPresent(matrixCell -> insertFreePathInSubstation(matrixCell, p2, d2, layoutParameters));

// Use path finding algo
return pathfinder.findShortestPath(pathFinderGrid, p1, p2);
}

private void insertFreePathInSubstation(int row, Point p, Direction d) {
int x1 = (int) p.getX();
int y1 = (int) p.getY();
int ssY = matrix.getY(row);
int min1Y = ssY - snakelinePadding;
int max1Y = y1;
private void insertFreePathInSubstation(MatrixCell cell, Point p, Direction d, LayoutParameters layoutParameters) {
LayoutParameters.Padding vlPadding = layoutParameters.getVoltageLevelPadding();
double x1 = p.getX();
double y1 = p.getY();
double min1Y = y1 - vlPadding.getTop();
double max1Y = y1;
if (d == Direction.BOTTOM) {
min1Y = y1;
max1Y = ssY + (int) matrix.getMatrixCellHeight(row) + snakelinePadding;
max1Y = y1 + vlPadding.getBottom();
}
for (int y = min1Y; y <= max1Y; y++) {
for (int y = (int) min1Y; y <= max1Y; y++) {
pathFinderGrid.setAvailability(x1, y, true);
}
// Make available a horizontal line large as matrix width + left and right zone layout snakeline padding
// In order to allow snakeline between 2 vertical voltagelevels
int col = cell.col();
int ssX = this.matrix.getX(col);
for (int x = ssX - snakelinePadding; x < ssX + matrix.getMatrixCellWidth(col) + snakelinePadding; x++) {
pathFinderGrid.setAvailability(x, d == Direction.TOP ? min1Y : max1Y, true);
}
}

public void computePathFindingGrid(ZoneGraph graph, LayoutParameters layoutParameters) {
Expand Down Expand Up @@ -92,8 +100,10 @@ private void computeSubstationsAvailability(LayoutParameters layoutParameters) {
int xGraph = (int) vlGraph.getX();
int yGraph = (int) vlGraph.getY();

for (int x = xGraph; x < xGraph + widthNoPadding; x++) {
for (int y = yGraph; y < yGraph + heightNoPadding; y++) {
LayoutParameters.Padding vlPadding = layoutParameters.getVoltageLevelPadding();

for (int x = xGraph - ((int) vlPadding.getLeft() - 1); x < xGraph + widthNoPadding + (int) vlPadding.getRight(); x++) {
for (int y = yGraph - ((int) vlPadding.getTop() - 1); y < yGraph + heightNoPadding + (int) vlPadding.getBottom(); y++) {
pathFinderGrid.setAvailability(x, y, false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6128,20 +6128,20 @@
"node1" : "line1_ONE",
"node2" : "line1_TWO"
} ],
"snakeLine" : [ 586.0, 331.0, 586.0, 331.0, 586.0, 61.0, 2196.0, 61.0, 2196.0, 268.0, 2196.0, 268.0 ]
"snakeLine" : [ 586.0, 331.0, 586.0, 331.0, 586.0, 271.0, 2051.0, 271.0, 2051.0, 208.0, 2196.0, 208.0, 2196.0, 268.0, 2196.0, 268.0 ]
}, {
"id" : "hvdc_lcc",
"nodes" : [ {
"node1" : "hvdc_lcc_ONE",
"node2" : "hvdc_lcc_TWO"
} ],
"snakeLine" : [ 136.0, 331.0, 136.0, 331.0, 136.0, 31.0, 2096.0, 31.0, 2096.0, 268.0, 2096.0, 268.0 ]
"snakeLine" : [ 136.0, 331.0, 136.0, 331.0, 136.0, 271.0, 2021.0, 271.0, 2021.0, 208.0, 2096.0, 208.0, 2096.0, 268.0, 2096.0, 268.0 ]
}, {
"id" : "hvdc_vsc",
"nodes" : [ {
"node1" : "hvdc_vsc_ONE",
"node2" : "hvdc_vsc_TWO"
} ],
"snakeLine" : [ 186.0, 331.0, 186.0, 331.0, 186.0, 31.0, 2051.0, 31.0, 2051.0, 245.0, 2146.0, 245.0, 2146.0, 268.0, 2146.0, 268.0 ]
"snakeLine" : [ 186.0, 331.0, 186.0, 331.0, 186.0, 271.0, 2021.0, 271.0, 2021.0, 208.0, 2146.0, 208.0, 2146.0, 268.0, 2146.0, 268.0 ]
} ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6129,20 +6129,20 @@
"node1" : "line1_ONE",
"node2" : "line1_TWO"
} ],
"snakeLine" : [ 736.0, 271.0, 736.0, 271.0, 736.0, 61.0, 1346.0, 61.0, 1346.0, 176.0, 1346.0, 176.0 ]
"snakeLine" : [ 736.0, 271.0, 736.0, 271.0, 736.0, 211.0, 1201.0, 211.0, 1201.0, 116.0, 1346.0, 116.0, 1346.0, 176.0, 1346.0, 176.0 ]
}, {
"id" : "hvdc_lcc",
"nodes" : [ {
"node1" : "hvdc_lcc_ONE",
"node2" : "hvdc_lcc_TWO"
} ],
"snakeLine" : [ 286.0, 271.0, 286.0, 271.0, 286.0, 31.0, 1246.0, 31.0, 1246.0, 176.0, 1246.0, 176.0 ]
"snakeLine" : [ 286.0, 271.0, 286.0, 271.0, 286.0, 211.0, 1171.0, 211.0, 1171.0, 116.0, 1246.0, 116.0, 1246.0, 176.0, 1246.0, 176.0 ]
}, {
"id" : "hvdc_vsc",
"nodes" : [ {
"node1" : "hvdc_vsc_ONE",
"node2" : "hvdc_vsc_TWO"
} ],
"snakeLine" : [ 336.0, 271.0, 336.0, 271.0, 336.0, 31.0, 1201.0, 31.0, 1201.0, 152.0, 1296.0, 152.0, 1296.0, 176.0, 1296.0, 176.0 ]
"snakeLine" : [ 336.0, 271.0, 336.0, 271.0, 336.0, 211.0, 1171.0, 211.0, 1171.0, 116.0, 1296.0, 116.0, 1296.0, 176.0, 1296.0, 176.0 ]
} ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6128,20 +6128,20 @@
"node1" : "line1_ONE",
"node2" : "line1_TWO"
} ],
"snakeLine" : [ 586.0, 331.0, 586.0, 331.0, 586.0, 125.0, 91.0, 125.0, 91.0, 1041.0, 316.0, 1041.0, 316.0, 1060.0, 316.0, 1060.0 ]
"snakeLine" : [ 586.0, 331.0, 586.0, 331.0, 586.0, 271.0, 91.0, 271.0, 91.0, 1000.0, 316.0, 1000.0, 316.0, 1060.0, 316.0, 1060.0 ]
}, {
"id" : "hvdc_lcc",
"nodes" : [ {
"node1" : "hvdc_lcc_ONE",
"node2" : "hvdc_lcc_TWO"
} ],
"snakeLine" : [ 136.0, 331.0, 136.0, 331.0, 136.0, 305.0, 91.0, 305.0, 91.0, 1000.0, 216.0, 1000.0, 216.0, 1060.0, 216.0, 1060.0 ]
"snakeLine" : [ 136.0, 331.0, 136.0, 331.0, 136.0, 271.0, 91.0, 271.0, 91.0, 1000.0, 216.0, 1000.0, 216.0, 1060.0, 216.0, 1060.0 ]
}, {
"id" : "hvdc_vsc",
"nodes" : [ {
"node1" : "hvdc_vsc_ONE",
"node2" : "hvdc_vsc_TWO"
} ],
"snakeLine" : [ 186.0, 331.0, 186.0, 331.0, 186.0, 305.0, 156.0, 305.0, 156.0, 275.0, 136.0, 275.0, 136.0, 245.0, 126.0, 245.0, 126.0, 91.0, 61.0, 91.0, 61.0, 970.0, 266.0, 970.0, 266.0, 1060.0, 266.0, 1060.0 ]
"snakeLine" : [ 186.0, 331.0, 186.0, 331.0, 186.0, 271.0, 91.0, 271.0, 91.0, 1000.0, 266.0, 1000.0, 266.0, 1060.0, 266.0, 1060.0 ]
} ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6129,20 +6129,20 @@
"node1" : "line1_ONE",
"node2" : "line1_TWO"
} ],
"snakeLine" : [ 736.0, 271.0, 736.0, 271.0, 736.0, 61.0, 61.0, 61.0, 61.0, 1983.0, 271.0, 1983.0, 271.0, 2043.0, 271.0, 2043.0 ]
"snakeLine" : [ 736.0, 271.0, 736.0, 271.0, 736.0, 211.0, 61.0, 211.0, 61.0, 1983.0, 271.0, 1983.0, 271.0, 2043.0, 271.0, 2043.0 ]
}, {
"id" : "hvdc_lcc",
"nodes" : [ {
"node1" : "hvdc_lcc_ONE",
"node2" : "hvdc_lcc_TWO"
} ],
"snakeLine" : [ 286.0, 271.0, 286.0, 271.0, 286.0, 61.0, 91.0, 61.0, 91.0, 31.0, 31.0, 31.0, 31.0, 1953.0, 171.0, 1953.0, 171.0, 2043.0, 171.0, 2043.0 ]
"snakeLine" : [ 286.0, 271.0, 286.0, 271.0, 286.0, 211.0, 61.0, 211.0, 61.0, 1983.0, 171.0, 1983.0, 171.0, 2043.0, 171.0, 2043.0 ]
}, {
"id" : "hvdc_vsc",
"nodes" : [ {
"node1" : "hvdc_vsc_ONE",
"node2" : "hvdc_vsc_TWO"
} ],
"snakeLine" : [ 336.0, 271.0, 336.0, 271.0, 336.0, 1.0, 1.0, 1.0, 1.0, 1923.0, 221.0, 1923.0, 221.0, 2043.0, 221.0, 2043.0 ]
"snakeLine" : [ 336.0, 271.0, 336.0, 271.0, 336.0, 211.0, 61.0, 211.0, 61.0, 1983.0, 221.0, 1983.0, 221.0, 2043.0, 221.0, 2043.0 ]
} ]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading