diff --git a/WindStressPRM/WindStressPRM.cs b/WindStressPRM/WindStressPRM.cs index 51770c1a0d36141fe61a719d4cb6606a9d36461d..cba01cbb64e18af5e39a51c28967640a150577d3 100644 --- a/WindStressPRM/WindStressPRM.cs +++ b/WindStressPRM/WindStressPRM.cs @@ -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;