Closed Privacywonk closed 6 years ago
If swellCompassDirection = config Swell = +1 if swellHeight = between config swell min + max = +1 if wind direction = config wind = +1 if wind speed <= 15mph = +1 if Multiple swell count is 2 or less = +1 if solid rating = +1 for each star
if wind direction = opposite of config wind (e.g. onshore): -1 if wind speed >= 15mph -1 if wind Gusts >=20mph -1
Compute the score and stick it back in the array against each forecast line
Loop the array and find the highest score per day.
If all scores are 0 or tied, display 10am
Implemented with following code:
var forecastScore = 0;
if (data[i].solidRating > 0) {forecastScore = data[i].solidRating;}
if (data[i].swell.components.primary.height >= this.config.spotSwellMin && data[i].swell.components.primary.height <= this.config.spotSwellMax) {forecastScore++;}
if (data[i].swell.components.primary.period >=8) {forecastScore++;}
for (z = 0, countz = this.config.spotSwellHold.length; z < countz; z++) {
if (this.config.spotSwellHold[z] == data[i].swell.components.primary.compassDirection) {forecastScore++;}
}
for (x = 0, countx = this.config.spotWind.length; x < countx; x++) {
if (this.config.spotWind[x] == data[i].wind.compassDirection) {forecastScore++;}
}
if (Object.keys(data[i].swell.components).length <=2) {forecastScore++;}
if (data[i].wind.speed < 15) {forecastScore++;}
if (data[i].wind.speed >= 15) {forecastScore--;}
if (data[i].wind.gusts >= 20) {forecastScore--;}
if (moment.unix(data[i].localTimestamp).format('HH') == 01 ||
moment.unix(data[i].localTimestamp).format('HH') == 19 ||
moment.unix(data[i].localTimestamp).format('HH') == 22) {forecastScore--;} //Penalizes times that are generally unsurfable (1am, 7pm, 10pm)
data[i].forecastScore = forecastScore;
data[i].forecastDay = moment.unix(data[i].localTimestamp).format('ddd');
Current magicseaweed forecast is hard coded to display 10am forecast. Need to identify a way to rank attributes of the forecast and pick the best forecast area.