Beaufort support #161

Open
Cattamer opened this Issue Nov 26, 2015 · 5 comments

Projects

None yet

4 participants

@Cattamer

Hi!

I would love to see Beaufort support, that would made simpleWeather even simpler :)
The Beaufort Scale is used by the Netherlands, Germany, Greece, China, Taiwan, Hong Kong, Malta and Macau. It is also used by the BBC 4 UK and Met Éireann IRL.

Two scales are in use, one 'official' 1 - 12 beaufort
and
one extended version which adds 13 - 17 (only in use by China and Taiwan).

https://en.wikipedia.org/wiki/Beaufort_scale

MPH Wind speeds delivered from Yahoo could be calculated to beaufort.

@fleeting
Member

Hmm, this should be pretty easy to add. I'll look at getting it in the next release. Thanks for the suggestion!

@fleeting fleeting self-assigned this Nov 27, 2015
@fleeting fleeting added the Feature label Nov 27, 2015
@fleeting fleeting added this to the v4.0.0 milestone Nov 27, 2015
@georgekaf

I recently had to add support for kmh to Beaufort. Maybe you will find it useful

function KmhB(x) {
var speed = (Math.pow(Math.pow((x / 3.0096), 0.33), 2));
if (isNaN(speed) || (speed) >= 12.5) {
console.log("Beaufort-values are between 0 and 12. Your input is beyond that scale.")
} else {
return speed;
}
}

@georgekaf

Also for miles per hour to Beaufort I used this.

function mphB(x) {
var speed = (Math.pow(Math.pow((x/1.8702),0.33),2));
if (isNaN(speed) || (speed)>=12.5) {
console.log("Beaufort-values are between 0 and 12. Your input is beyond that scale.")
} else {
return speed;
}
}

@georgekaf

I used this site as reference and source for my code (http://www.whiteweather.com/wd/vind/Windspeed.htm).

@ecdcrew
ecdcrew commented Feb 8, 2016

// set windspeed to mph

var windSpeed = (weather.units.speed == "mph") ? weather.wind.speed : KMtoMPH(weather.wind.speed);

    function KMtoMPH(amt){
      return Math.round((amt*0.621371));
    }


function get_beaufort_number ( windMPH ) {
// return a number for the beaufort scale based on wind  speed (native WD format)
  if (windMPH < 1 ) {return("0"); }
  if (windMPH < 3 ) {return("1"); }
  if (windMPH < 7 ) {return("2"); }
  if (windMPH < 12 ) {return("3"); }
  if (windMPH < 18 ) {return("4"); }
  if (windMPH < 24 ) {return("5"); }
  if (windMPH < 31 ) {return("6"); }
  if (windMPH < 38 ) {return("7"); }
  if (windMPH < 46 ) {return("8"); }
  if (windMPH < 54 ) {return("9"); }
  if (windMPH < 63 ) {return("10"); }
  if (windMPH < 72 ) {return("11"); }
  if (windMPH >= 82 ) {return("12"); }

// you can scale as far as needed
  return("0");
}
....

  html += '<li><i class="wi wi-degrees"></i> <i class="wi wi-wind-beaufort-'+get_beaufort_number(windSpeed)+'"></i> Wind Beaufort Index: '+get_beaufort_number(windSpeed)+'</li>';



You will need https://github.com/erikflowers/weather-icons if you want the icon to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment