Author Topic: USA Extreme Script  (Read 912 times)

0 Members and 1 Guest are viewing this topic.

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
USA Extreme Script
« on: November 30, 2017, 09:08:46 AM »
Hello All,
  I just installed the latest usaextremes.php script on my site. I see that you can get multiple sites for the high temperature of the day. Is there a way to just display one entry for each category rather then multiple ones?

Jim

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: USA Extreme Script
« Reply #1 on: November 30, 2017, 12:34:16 PM »
The script runs through the listings, finds the maximum and minimum temperatures recorded, then passes through the list again looking for temperatures that match the maximum, also a pass for the minimum.  The script could be modified to stop at the first 'hit' in each category if you like, but it would be arbitrary as to which one (of the multiple ones) would be chosen.  I think that sorta defeats the intent of the script to find all the locations reporting the same max or min for a given day.  :? 
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
Re: USA Extreme Script
« Reply #2 on: November 30, 2017, 12:42:58 PM »
Thanks! I think most people like to know what the high, low, and precip numbers for the US are, not necessarily all the locations but that's my own opinion...

I tried to modify that script in that section but it ended up giving me EVERY location i the list! lol

Jim

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: USA Extreme Script
« Reply #3 on: November 30, 2017, 01:10:53 PM »
Ok.. try changing
Code: [Select]
// now pass through to see if any duplicate high, low, high precip exists and format the strings
foreach ($usaStations as $n => $vals) {
list($tHigh,$tLow,$tPrecip,$tPrecipEstim,$tData,$tState,$tStation) = explode("\t",$vals);
if($tHigh < -90 or $tLow < -90 ) { continue; }

if($tHigh == $usahighValue) {
$usahigh .= "<b>$tHigh$tUOM at $tStation, $tState</b>\n";
}
if($tLow == $usalowValue) {
$usalow .= "<b>$tLow$tUOM at $tStation, $tState</b>\n";
}
if($tPrecip == $usaprecipValue and $tPrecip > 0) {
$tPrecipFmt = sprintf("%01.2f",$tPrecip/100);
$usaprecip .= "<b>$tPrecipFmt$rUOM at $tStation, $tState</b>\n";
}
}
to
Code: [Select]
// now pass through to see if any duplicate high, low, high precip exists and format the strings
$gotLow = false;
$gotHigh = false;
$gotPrecip = false;
foreach ($usaStations as $n => $vals) {
list($tHigh,$tLow,$tPrecip,$tPrecipEstim,$tData,$tState,$tStation) = explode("\t",$vals);
if($tHigh < -90 or $tLow < -90 ) { continue; }

if($tHigh == $usahighValue and ! $gotHigh) {
$usahigh .= "<b>$tHigh$tUOM at $tStation, $tState</b>\n";
$gotHigh = true;
}
if($tLow == $usalowValue and ! $gotLow) {
$usalow .= "<b>$tLow$tUOM at $tStation, $tState</b>\n";
$gotLow = true;
}
if($tPrecip == $usaprecipValue and $tPrecip > 0 and ! $gotPrecip ) {
$tPrecipFmt = sprintf("%01.2f",$tPrecip/100);
$usaprecip .= "<b>$tPrecipFmt$rUOM at $tStation, $tState</b>\n";
$gotPrecip = true;
}
}
and that should stop after the first one found for each of High, Low and Precip.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
Re: USA Extreme Script
« Reply #4 on: November 30, 2017, 01:26:31 PM »
Thanks! That did the trick!   =D&gt;

JIm

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: USA Extreme Script
« Reply #5 on: November 30, 2017, 01:31:16 PM »
:)
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
Re: USA Extreme Script
« Reply #6 on: November 30, 2017, 02:13:47 PM »
Ken,
  Do you get my PM or email regarding my alert code using async vs. sync options within the XMLHTTP Get calls?

Jim

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: USA Extreme Script
« Reply #7 on: November 30, 2017, 04:41:24 PM »
Hi Jim,
Yes, I did receive the email/PM at a time when the house was swarming with relatives so no time to really dig into it.  I'll look today.. sorry!
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 1015
    • Southern Maryland Weather
Re: USA Extreme Script
« Reply #8 on: November 30, 2017, 06:50:04 PM »
Understand... :lol:

 

anything