[wxqc] Text to Degrees

Keith Miller kdmiller at oldsgmail.com
Mon Apr 9 00:40:51 CDT 2007


> -----Original Message-----
> From: wxqc-bounces at lists.gladstonefamily.net
> [mailto:wxqc-bounces at lists.gladstonefamily.net]On Behalf Of Steve
> Hatchett
> Sent: Monday, April 09, 2007 1:09 AM
> To: 'Discussion of weather data quality issues'
> Subject: Re: [wxqc] Text to Degrees
> 
> 
> Yes, yours is more straightforward. I think he chose fmod so 
> his function would handle any positive degree value such as 450
> degrees without referencing a non-existent array element.

That would be error handling, and after seeing the other function,
I added the error handling line:

  if (!isset($degrees) || $degrees > 360) {return "---";}

That should handle anything short of passing it a string, and
even then fail somewhat gracefully.

> As for why I suggested the +11 to him instead of Round, my 
> own code for this is object pascal, and for performance I
> used all integer arithmetic wherever possible as it was at
> one time much faster than floating point (although I don't know
> if it makes that much difference now).

No complaint there, I haven't actually tested to see which would
be faster in php. Fact is, I had in mind writing a function to do
this and had half started, but didn't complete it until this
thread came up. My weather program reports the mean wind direction
in degrees, and I never felt that was something the average person
would quickly comprehend. So this thread got me thinking about it
again and finally got me to finish that.


Keith
--
CW5250 => http://weather.stadhaugh.com
 


More information about the wxqc mailing list