Average out the incoming data from OpenWeatherMaps
This commit is contained in:
@@ -97,10 +97,24 @@ function getOWMWeatherData( location, callback ) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
weather.temp = parseInt( data.list[ 0 ].main.temp );
|
const maxCount = 10;
|
||||||
weather.humidity = parseInt( data.list[ 0 ].main.humidity );
|
weather.temp = 0;
|
||||||
weather.wind = parseInt( data.list[ 0 ].wind.speed );
|
weather.humidity = 0;
|
||||||
weather.precip = data.list[ 0 ].rain ? parseFloat( data.list[ 0 ].rain[ "3h" ] || 0 ) : 0;
|
weather.wind = 0;
|
||||||
|
weather.precip = 0;
|
||||||
|
|
||||||
|
for ( var index = 0; index < maxCount; index++ ) {
|
||||||
|
weather.temp += parseInt( data.list[ index ].main.temp );
|
||||||
|
weather.humidity += parseInt( data.list[ index ].main.humidity );
|
||||||
|
weather.wind += parseInt( data.list[ index ].wind.speed );
|
||||||
|
weather.precip += data.list[ index ].rain ? parseFloat( data.list[ index ].rain[ "3h" ] || 0 ) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
weather.temp = weather.temp / maxCount;
|
||||||
|
weather.humidity = weather.humidity / maxCount;
|
||||||
|
weather.wind = weather.wind / maxCount;
|
||||||
|
weather.precip = weather.precip / maxCount;
|
||||||
|
|
||||||
|
|
||||||
location = location.join( "," );
|
location = location.join( "," );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user