Skip to content
Snippets Groups Projects
Commit ba0d62ae authored by Антон Кудряшов's avatar Антон Кудряшов
Browse files

fixed interpol with null index value

parent f442cb8c
Branches
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ namespace WindStressPRM ...@@ -25,7 +25,7 @@ namespace WindStressPRM
/// get index of cell for coordinate /// get index of cell for coordinate
/// </summary> /// </summary>
/// <param name="coordinate"></param> /// <param name="coordinate"></param>
/// <returns></returns> /// <returns>null if it doesn't exist</returns>
public Index ProjectionToCell(Coordinate coordinate) public Index ProjectionToCell(Coordinate coordinate)
{ {
double rwDiff = (coordinate.X - Origin.X) / Size.Width; double rwDiff = (coordinate.X - Origin.X) / Size.Width;
...@@ -35,7 +35,7 @@ namespace WindStressPRM ...@@ -35,7 +35,7 @@ namespace WindStressPRM
if (iRow < 0 || iCol < 0 || iRow >= RowsCount() || iCol >= ColumnCount()) if (iRow < 0 || iCol < 0 || iRow >= RowsCount() || iCol >= ColumnCount())
{ {
throw new Exception("projectionToCell method trying to find uncorrect index"); return null;
} }
return new Index(iRow, iCol); return new Index(iRow, iCol);
} }
......
...@@ -319,6 +319,10 @@ namespace WindStressPRM ...@@ -319,6 +319,10 @@ namespace WindStressPRM
const bool normalX = true;// true - East, false West const bool normalX = true;// true - East, false West
const bool normalY = false;// true - North, false South const bool normalY = false;// true - North, false South
Index rc = matrix.ProjectionToCell(coords); Index rc = matrix.ProjectionToCell(coords);
if (rc == null) {
// return NaN, because there is no correct index
return Double.NaN;
}
Coordinate center = matrix.CellToProjection(rc); Coordinate center = matrix.CellToProjection(rc);
double xDiff = coords.X - center.X; double xDiff = coords.X - center.X;
double yDiff = coords.Y - center.Y; double yDiff = coords.Y - center.Y;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment