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

- check in interpolation for missing values

parent 1d6b37b6
Branches
No related tags found
No related merge requests found
......@@ -502,6 +502,18 @@ namespace WindStressPRM
return 500;
}
}
/// <summary>
/// missing raster value for cells, if you haven't normal value use this one.
/// потерянное значение для растрового объекта; Если Вы не имеете данных - используйте это значение
/// </summary>
public double kMissingRasterValue
{
get
{
return -9999;
}
}
}
/// <summary>
/// Output
......@@ -980,7 +992,60 @@ namespace WindStressPRM
double valTopLeft = valueForFunction(functionType, rcTopLeft);
double valTopRight = valueForFunction(functionType, rcTopRight);
Coordinate origin = cellToProjection(rcBotLeft, functionType);
//PRM_coordinate last = cellToProjection(rcTopRight, functionType);//test only
bool testBotLeft = valBotLeft == Input.kMissingRasterValue;
bool testBotRight = valBotRight == Input.kMissingRasterValue;
bool testTopLeft = valTopLeft == Input.kMissingRasterValue;
bool testTopRight = valTopRight == Input.kMissingRasterValue;
if (testBotLeft || testBotRight || testTopLeft || testTopRight)
{
// tests indicates that value at test-cell is missed.
if (testTopRight && testTopLeft && testBotLeft && testBotRight)
{
throw new Exception("Current value in such a bad place, you need to fill these place with raster values");
}
int count = 0;
if (testBotLeft)
{
valBotLeft = 0;
count++;
}
if (testBotRight)
{
valBotRight = 0;
count++;
}
if (testTopLeft)
{
valTopLeft = 0;
count++;
}
if (testTopRight)
{
valTopRight = 0;
count++;
}
//of course there is count not 0;
if (count == 0) {
throw new Exception("Interpolation Logic Error");
}
double average = (valTopLeft + valTopRight + valBotLeft + valBotRight)/count;
if (testBotLeft)
{
valBotLeft = average;
}
if (testBotRight)
{
valBotRight = average;
}
if (testTopLeft)
{
valTopLeft = average;
}
if (testTopRight)
{
valTopRight = average;
}
}
// sizes for cell
double hx = cellSizeForFunction(functionType).Width;
double hy = cellSizeForFunction(functionType).Height;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment