From f8711410be75d975bf67747dc700a955732a4a37 Mon Sep 17 00:00:00 2001 From: Anton Kudryashov <qubabox@mail.ru> Date: Sun, 22 Jan 2017 22:52:25 +0300 Subject: [PATCH] fixed last comments for index, cellsize, powerline and powerstation classes --- WindStressPRM/Objects/PowerStation.cs | 6 +++--- WindStressPRM/Utils/CellSize.cs | 4 ++-- WindStressPRM/Utils/Index.cs | 16 ++++++++++------ WindStressPRM/Utils/Matrix.cs | 2 +- WindStressPRM/WindStressPRM.cs | 20 ++++++++++---------- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/WindStressPRM/Objects/PowerStation.cs b/WindStressPRM/Objects/PowerStation.cs index 0e78460..9012046 100644 --- a/WindStressPRM/Objects/PowerStation.cs +++ b/WindStressPRM/Objects/PowerStation.cs @@ -103,11 +103,11 @@ namespace WindStressPRM { if (Identifier < 0) { - throw new System.ArgumentOutOfRangeException("Identifier", Identifier, "Identifer expected to be more than 0"); + throw new System.ArgumentOutOfRangeException("Identifier", Identifier, "Expected >=0"); } - if (Voltage < 0 || Voltage > 1500) + if (Voltage <= 0 || Voltage > 1500) { - throw new System.ArgumentOutOfRangeException("Voltage", Voltage, "Voltage expected to be in range (0,1500)"); + throw new System.ArgumentOutOfRangeException("Voltage", Voltage, "Expected 0<Voltage<=1500"); } } /// <summary> diff --git a/WindStressPRM/Utils/CellSize.cs b/WindStressPRM/Utils/CellSize.cs index f0e5f19..c0f9848 100644 --- a/WindStressPRM/Utils/CellSize.cs +++ b/WindStressPRM/Utils/CellSize.cs @@ -14,11 +14,11 @@ namespace WindStressPRM /// <summary> /// ширина ячейки (расстояние между соседними по X центрами ячеек, в размерности координат) /// </summary> - public double Width { get; set; } + public double Width { get; private set; } /// <summary> /// высота ячейки (расстояние между соседними по Y центрами ячеек, в размерности координат) /// </summary> - public double Height { get; set; } + public double Height { get; private set; } /// <summary> /// designated constructor /// </summary> diff --git a/WindStressPRM/Utils/Index.cs b/WindStressPRM/Utils/Index.cs index 089241c..bca01ce 100644 --- a/WindStressPRM/Utils/Index.cs +++ b/WindStressPRM/Utils/Index.cs @@ -18,20 +18,24 @@ namespace WindStressPRM /// Inner index /// Внутренний индекс /// </summary> - public int Col { get; private set; } + public int Column { get; private set; } /// <summary> /// designated constructor /// </summary> /// <param name="Row">row index</param> /// <param name="Col">column index</param> - public Index(int Row, int Col) + public Index(int row, int column) { - if (Row <= -1 || Col <= -1) + if (row < 0) { - throw new System.ArgumentOutOfRangeException("Index must be initialized with nonegative integer value"); + throw new System.ArgumentOutOfRangeException("Row", row, "Expected >=0"); } - this.Row = Row; - this.Col = Col; + if (column < 0) + { + throw new System.ArgumentOutOfRangeException("Column", column, "Expected >=0"); + } + this.Row = row; + this.Column = column; } } } diff --git a/WindStressPRM/Utils/Matrix.cs b/WindStressPRM/Utils/Matrix.cs index 51f81f6..abfbbf2 100644 --- a/WindStressPRM/Utils/Matrix.cs +++ b/WindStressPRM/Utils/Matrix.cs @@ -20,7 +20,7 @@ namespace WindStressPRM /// <returns></returns> public Coordinate CellToProjection(Index index) { - return new Coordinate(Origin.X + index.Row*Size.Width, Origin.Y - index.Col*Size.Height); + return new Coordinate(Origin.X + index.Row*Size.Width, Origin.Y - index.Column*Size.Height); } /// <summary> /// get index of cell for coordinate diff --git a/WindStressPRM/WindStressPRM.cs b/WindStressPRM/WindStressPRM.cs index 99f8551..6ee183a 100644 --- a/WindStressPRM/WindStressPRM.cs +++ b/WindStressPRM/WindStressPRM.cs @@ -338,21 +338,21 @@ namespace WindStressPRM } if ((yDiff >= 0 && normalY) || (!normalY && yDiff < 0)) { - col2 = rc.Col >= matrix.ColumnCount() - 1 ? rc.Col - 1 : rc.Col + 1; + col2 = rc.Column >= matrix.ColumnCount() - 1 ? rc.Column - 1 : rc.Column + 1; } else { - col2 = rc.Col > 0 ? rc.Col - 1 : rc.Col + 1; + col2 = rc.Column > 0 ? rc.Column - 1 : rc.Column + 1; } // indexes and values at bounds - Index rcBotLeft = new Index(Math.Min(row2, rc.Row), Math.Min(col2, rc.Col)); - Index rcBotRight = new Index(Math.Max(row2, rc.Row), Math.Min(col2, rc.Col)); - Index rcTopLeft = new Index(Math.Min(row2, rc.Row), Math.Max(col2, rc.Col)); - Index rcTopRight = new Index(Math.Max(row2, rc.Row), Math.Max(col2, rc.Col)); - double valBotLeft = valueGetter(matrix.Cells[rcBotLeft.Row, rcBotLeft.Col]); - double valBotRight = valueGetter(matrix.Cells[rcBotRight.Row, rcBotRight.Col]); - double valTopLeft = valueGetter(matrix.Cells[rcTopLeft.Row, rcTopLeft.Col]); - double valTopRight = valueGetter(matrix.Cells[rcTopRight.Row, rcTopRight.Col]); + Index rcBotLeft = new Index(Math.Min(row2, rc.Row), Math.Min(col2, rc.Column)); + Index rcBotRight = new Index(Math.Max(row2, rc.Row), Math.Min(col2, rc.Column)); + Index rcTopLeft = new Index(Math.Min(row2, rc.Row), Math.Max(col2, rc.Column)); + Index rcTopRight = new Index(Math.Max(row2, rc.Row), Math.Max(col2, rc.Column)); + double valBotLeft = valueGetter(matrix.Cells[rcBotLeft.Row, rcBotLeft.Column]); + double valBotRight = valueGetter(matrix.Cells[rcBotRight.Row, rcBotRight.Column]); + double valTopLeft = valueGetter(matrix.Cells[rcTopLeft.Row, rcTopLeft.Column]); + double valTopRight = valueGetter(matrix.Cells[rcTopRight.Row, rcTopRight.Column]); Coordinate origin = matrix.CellToProjection(rcBotLeft); bool testBotLeft = Double.IsNaN(valBotLeft); -- GitLab