Added ability to set reference weather conditions (Temp, Rain, Humidty) to the Zimmerman adjustment method

This commit is contained in:
Peter Basham
2016-03-11 17:57:49 +00:00
parent 02e5e233c7
commit 5a71213c80

13
routes/weather.js Normal file → Executable file
View File

@@ -311,10 +311,17 @@ function calculateWeatherScale( adjustmentMethod, adjustmentOptions, weather ) {
return 100; return 100;
} }
// Get baseline conditions for 100% water level, if provided
if ( adjustmentOptions ) {
humidityBase = adjustmentOptions.hasOwnProperty( "bh" ) ? adjustmentOptions.bh : 30;
tempBase = adjustmentOptions.hasOwnProperty( "bt" ) ? adjustmentOptions.bt : 70;
precipBase = adjustmentOptions.hasOwnProperty( "br" ) ? adjustmentOptions.br : 0;
}
var temp = ( ( weather.maxTemp + weather.minTemp ) / 2 ) || weather.temp, var temp = ( ( weather.maxTemp + weather.minTemp ) / 2 ) || weather.temp,
humidityFactor = ( 30 - weather.humidity ), humidityFactor = ( humidityBase - weather.humidity ),
tempFactor = ( ( temp - 70 ) * 4 ), tempFactor = ( ( temp - tempBase ) * 4 ),
precipFactor = ( weather.precip * -200 ); precipFactor = ( (precipBase - weather.precip ) * 200 );
// Apply adjustment options, if provided, by multiplying the percentage against the factor // Apply adjustment options, if provided, by multiplying the percentage against the factor
if ( adjustmentOptions ) { if ( adjustmentOptions ) {