Пример #1
0
    $windTrends = explode('#', $ws['windTrends']);
    $gustTrends = explode('#', $ws['gustTrends']);
    $wdirTrends = explode('#', $ws['wdirTrends']);
    $humiTrends = explode('#', $ws['humiTrends']);
    $baroTrends = explode('#', $ws['baroTrends']);
    $rainTrends = explode('#', $ws['rainTrends']);
    if ($haveUV) {
        $uvTrends = explode('#', $ws['uvTrends']);
    }
    if ($haveSolar) {
        $solarTrends = explode('#', $ws['solarTrends']);
    }
    $end_trends = count($minutes);
    for ($i = 0; $i < $end_trends; $i++) {
        $wsTrends[$i]['min'] = $minutes[$i];
        $wsTrends[$i]['temp'] = wsConvertTemperature($tempTrends[$i], $from_temp);
        $wsTrends[$i]['wind'] = wsConvertWindspeed($windTrends[$i], $from_wind);
        $wsTrends[$i]['gust'] = wsConvertWindspeed($gustTrends[$i], $from_wind);
        $wsTrends[$i]['dir'] = wsConvertWinddir($wdirTrends[$i]);
        $wsTrends[$i]['hum'] = $humiTrends[$i];
        $wsTrends[$i]['baro'] = wsConvertBaro($baroTrends[$i], $from_baro);
        $wsTrends[$i]['rain'] = wsConvertRainfall($rainTrends[$i], $from_rain);
        if ($haveUV) {
            $wsTrends[$i]['uv'] = $uvTrends[$i];
        }
        if ($haveSolar) {
            $wsTrends[$i]['sol'] = $solarTrends[$i];
        }
    }
}
if ($wp == 'MB') {
Пример #2
0
 public function getWeatherData($userLocation = '')
 {
     global $SITE, $pageName, $dayNight;
     #----------------------------------------------------------------------------------------------
     # clean user input
     #----------------------------------------------------------------------------------------------
     # location should be 8 chars without any special characters
     #
     $userLocation = trim($userLocation);
     if (strlen($userLocation) > 3) {
         $this->location = $userLocation;
     }
     #----------------------------------------------------------------------------------------------
     # check if data (location and unit) is in cache
     $filename = str_replace('/', '.', $userLocation);
     $this->cachePath = $SITE['cacheDir'];
     $string = $pageName . $this->lang . $userLocation . $SITE['uomTemp'] . $SITE['uomWind'] . $SITE['uomBaro'] . $SITE['uomDistance'];
     $from = array('&deg;', '�', '/', ' ', '.', '-');
     $to = '';
     $string = str_replace($from, $to, $string);
     if ($SITE['uomTemp'] != '&deg;C') {
         $this->apiUrlpart[3] = 'f';
     }
     $this->cacheFile = $this->cachePath . $string . '.txt';
     if ($this->enableCache && !empty($this->cachePath)) {
         $returnArray = $this->loadFromCache();
         // load from cache returns data only when its data is valid
         if (!empty($returnArray)) {
             // if data is in cache and valid return data to calling program
             return $returnArray;
         }
         // eo valid data and return to calling program
     }
     // eo check cache
     #----------------------------------------------------------------------------------------------
     # combine everything into required url
     #----------------------------------------------------------------------------------------------
     #
     $this->apiUrlpart[1] = $this->location;
     $this->weatherApiUrl = '';
     for ($i = 0; $i < count($this->apiUrlpart); $i++) {
         $this->weatherApiUrl .= $this->apiUrlpart[$i];
     }
     #----------------------------------------------------------------------------------------------
     if ($this->makeRequest()) {
         // load xml from url and process
         $this->rawData = str_replace('<yweather:', '<yweather', $this->rawData);
         // clean up unneeded ":" =  Namespace Elements
         $xml = new SimpleXMLElement($this->rawData);
         // process xml
         $returnArray = array();
         #--------------------------------------------------------------------------------------------------
         # first, get and save request infor / units etc
         #--------------------------------------------------------------------------------------------------
         $i = 0;
         $returnArray['request_info'][$i]['type'] = 'type';
         $returnArray['request_info'][$i]['city'] = 'city';
         $returnArray['request_info'][$i]['time'] = 'unixTime';
         $returnArray['request_info'][$i]['uomTemp'] = 'uomTemp';
         $returnArray['request_info'][$i]['uomDistance'] = 'uomDistance';
         $returnArray['request_info'][$i]['uomBaro'] = 'uomBaro';
         $returnArray['request_info'][$i]['uomWind'] = 'uomWind';
         $i = 0;
         $returnArray['request_info'][$i]['type'] = (string) $xml->channel->title;
         $returnArray['request_info'][$i]['city'] = (string) $xml->channel->yweatherlocation['city'] . ' - ' . (string) $xml->channel->yweatherlocation['country'];
         $returnArray['request_info'][$i]['time'] = (string) $xml->channel->lastBuildDate;
         # yweather:units temperature="F" distance="mi" pressure="in" speed="mph"
         # yweather:units temperature="C" distance="km" pressure="mb" speed="km/h"
         $returnArray['request_info'][$i]['uomTemp'] = $this->uomTemp = (string) $xml->channel->yweatherunits['temperature'];
         $returnArray['request_info'][$i]['uomDistance'] = $this->uomDistance = (string) $xml->channel->yweatherunits['distance'];
         $returnArray['request_info'][$i]['uomBaro'] = $this->uomBaro = (string) $xml->channel->yweatherunits['pressure'];
         $returnArray['request_info'][$i]['uomWind'] = $this->uomWind = (string) $xml->channel->yweatherunits['speed'];
         // <lastBuildDate>Tue, 10 Sep 2013 2:25 pm CEST</lastBuildDate>
         // <yweather:location city="Leuven" region="" country="Belgium"/>
         #--------------------------------------------------------------------------------------------------
         # get current condition descriptions
         #--------------------------------------------------------------------------------------------------
         $i = 0;
         $returnArray['ccn'][$i]['humidity'] = 'humidity';
         $returnArray['ccn'][$i]['baroNU'] = 'baro';
         $returnArray['ccn'][$i]['baro'] = 'baro';
         $returnArray['ccn'][$i]['baroTrend'] = 'baroTrend';
         $returnArray['ccn'][$i]['visibNU'] = 'visibility';
         $returnArray['ccn'][$i]['visib'] = 'visibility';
         $returnArray['ccn'][$i]['windNU'] = 'wind';
         $returnArray['ccn'][$i]['wind'] = 'wind';
         $returnArray['ccn'][$i]['windDeg'] = 'windDeg';
         $returnArray['ccn'][$i]['description'] = 'description';
         $returnArray['ccn'][$i]['tempNU'] = 'temp';
         $returnArray['ccn'][$i]['temp'] = 'temp';
         $returnArray['ccn'][$i]['icon'] = 'icon';
         $returnArray['ccn'][$i]['iconUrl'] = 'iconUrl';
         $returnArray['ccn'][$i]['date'] = 'date';
         $returnArray['ccn'][$i]['timestamp'] = 'timestamp';
         $i = 1;
         $returnArray['ccn'][$i]['humidity'] = (string) $xml->channel->yweatheratmosphere['humidity'];
         $amount = (string) $xml->channel->yweatheratmosphere['pressure'];
         $returnArray['ccn'][$i]['baroNU'] = $result = (string) wsConvertBaro($amount, $this->uomBaro, $SITE['uomBaro']);
         $returnArray['ccn'][$i]['baro'] = $result . $SITE['uomBaro'];
         $returnArray['ccn'][$i]['baroTrend'] = (string) $xml->channel->yweatheratmosphere['rising'];
         $amount = (string) $xml->channel->yweatheratmosphere['visibility'];
         $returnArray['ccn'][$i]['visibNU'] = $result = (string) wsConvertDistance($amount, $this->uomDistance, $SITE['uomDistance']);
         $returnArray['ccn'][$i]['visib'] = $result . $SITE['uomDistance'];
         $amount = (string) $xml->channel->yweatherwind['speed'];
         $returnArray['ccn'][$i]['windNU'] = $result = (string) wsConvertWindspeed($amount, $this->uomWind, $SITE['uomWind']);
         $returnArray['ccn'][$i]['wind'] = $result . $SITE['uomWind'];
         $returnArray['ccn'][$i]['windDeg'] = (string) $xml->channel->yweatherwind['direction'];
         $returnArray['ccn'][$i]['text'] = (string) $xml->channel->item->yweathercondition['text'];
         $amount = (string) $xml->channel->item->yweathercondition['temp'];
         $returnArray['ccn'][$i]['tempNU'] = $result = (string) wsConvertTemperature($amount, $this->uomTemp, $SITE['uomTemp']);
         $returnArray['ccn'][$i]['temp'] = $result . $SITE['uomTemp'];
         $yaIconNr = (int) 1.0 * $xml->channel->item->yweathercondition['code'];
         if (!isset($dayNight)) {
             $dayNight = 'daylight';
         }
         $search = array('26', '28', '30', '32', '34');
         $repl = array('27', '27', '29', '31', '33');
         if ($dayNight == 'nighttime') {
             $yaIconNr = str_replace($search, $repl, $yaIconNr);
             // night is icon minus 1 for certain conditions
             if ($returnArray['ccn'][$i]['text'] == 'Sunny') {
                 $returnArray['ccn'][$i]['text'] = 'Clear';
             }
         } else {
             $yaIconNr = str_replace($repl, $search, $yaIconNr);
             // night is icon minus 1 for certain conditions
             if ($returnArray['ccn'][$i]['text'] == 'Clear') {
                 $returnArray['ccn'][$i]['text'] = 'Sunny';
             }
         }
         $returnArray['ccn'][$i]['icon'] = $yaIconNr;
         $returnArray['ccn'][$i]['iconUrl'] = $this->icons_url . $yaIconNr . $this->icons_ext;
         $returnArray['ccn'][$i]['date'] = (string) $xml->channel->item->yweathercondition['date'];
         $returnArray['ccn'][$i]['timestamp'] = strtotime((string) $xml->channel->item->yweathercondition['date']);
         ws_message('<!-- module yahoo.weather2.php (' . __LINE__ . ') Condition text: ' . $returnArray['ccn'][$i]['text'] . '  icon: ' . $yaIconNr . '       -->');
         #--------------------------------------------------------------------------------------------------
         #  get forecast info
         #--------------------------------------------------------------------------------------------------
         $i = 0;
         $returnArray['forecast'][$i]['weekday'] = 'day';
         $returnArray['forecast'][$i]['date'] = 'date';
         $returnArray['forecast'][$i]['timestamp'] = 'timestamp';
         $returnArray['forecast'][$i]['tempLowNU'] = 'tempLow';
         $returnArray['forecast'][$i]['tempLow'] = 'tempLow';
         $returnArray['forecast'][$i]['tempHighNU'] = 'tempHigh';
         $returnArray['forecast'][$i]['tempHigh'] = 'tempHigh';
         $returnArray['forecast'][$i]['icon'] = 'icon';
         $returnArray['forecast'][$i]['condition'] = 'text';
         for ($i = 1; $i <= count($xml->channel->item->yweatherforecast); $i++) {
             $data = $xml->channel->item->yweatherforecast[$i - 1];
             $returnArray['forecast'][$i]['weekday'] = (string) $data['day'];
             $returnArray['forecast'][$i]['date'] = (string) $data['date'];
             $returnArray['forecast'][$i]['timestamp'] = strtotime((string) $data['date']);
             $amount = (string) $data['low'];
             $returnArray['forecast'][$i]['tempLowNU'] = $result = (string) wsConvertTemperature($amount, $this->uomTemp, $SITE['uomTemp']);
             $returnArray['forecast'][$i]['tempLow'] = $result . $SITE['uomTemp'];
             $amount = (string) $data['high'];
             $returnArray['forecast'][$i]['tempHighNU'] = $result = (string) wsConvertTemperature($amount, $this->uomTemp, $SITE['uomTemp']);
             $returnArray['forecast'][$i]['tempHigh'] = $result . $SITE['uomTemp'];
             $returnArray['forecast'][$i]['icon'] = (string) $data['code'];
             $returnArray['forecast'][$i]['condition'] = (string) $data['text'];
             $returnArray['forecast'][$i]['iconUrl'] = $this->icons_url . $returnArray['forecast'][$i]['icon'] . $this->icons_ext;
         }
         // eo for loop forecast
     } else {
         // eo makerequest processing
         ws_message('<!-- module yahoo.weather2.php (' . __LINE__ . ') weatherdata not available, try to load (' . $this->cacheFile . ')  from cache  -->');
         $this->cacheTime = 100 * $this->cacheTime;
         $returnArray = $this->loadFromCache();
         return $returnArray;
     }
     #--------------------------------------------------------------------------------------------------
     #  write to cache
     #--------------------------------------------------------------------------------------------------
     if ($this->enableCache && !empty($this->cachePath)) {
         $this->writeToCache($returnArray);
     }
     return $returnArray;
 }
Пример #3
0
$temp1hourAgo = wsConvertTemperature($wx['chilAct'], $from_temp, $from_temp) - wsConvertTemperature($wx['chilDelta'], $from_temp, $from_temp);
$ws['chilDelta'] = $ws['chilAct'] - wsConvertTemperature($temp1hourAgo, $from_temp);
$ws['chilMinToday'] = wsConvertTemperature($wx['chilMinToday'], $from);
$ws['chilMinTodayTime'] = vws_time($wx['chilMinTodayTime']);
$ws['chilMinYday'] = wsConvertTemperature($wx['chilMinYday'], $from);
$ws['chilMinYdayTime'] = vws_time($wx['chilMinYdayTime']);
$ws['chilMinMonth'] = wsConvertTemperature($wx['chilMinMonth'], $from);
$ws['chilMinMonthTime'] = vws_ymd($wx['chilMinMonthTime']);
$ws['chilMinYear'] = wsConvertTemperature($wx['chilMinYear'], $from);
$ws['chilMinYearTime'] = vws_ymd($wx['chilMinYearTime']);
$ws['chilMaxToday'] = wsConvertTemperature($wx['chilMaxToday'], $from);
$ws['chilMaxTodayTime'] = vws_time($wx['chilMaxTodayTime']);
$ws['appTemp'] = wsConvertTemperature($wx['appTemp'], $from);
$ws['tempActInside'] = wsConvertTemperature($wx['tempActInside'], $from);
$ws['tempActExtra1'] = wsConvertTemperature($wx['tempActExtra1'], $from);
$ws['tempActExtra2'] = wsConvertTemperature($wx['tempActExtra2'], $from);
# ------------------------------------------ pressure / baro -----------
$from_baro = $from = trim(strtolower($wx['frombaro']));
// ' hPa', of ' mb', of ' inHg'
$ws['baroAct'] = wsConvertBaro($wx['baroAct'], $from);
$ws['baroDelta'] = wsConvertBaro($wx['baroDelta'], $from);
$ws['baroMinToday'] = wsConvertBaro($wx['baroMinToday'], $from);
$ws['baroMinTodayTime'] = vws_time($wx['baroMinTodayTime']);
$ws['baroMinYday'] = wsConvertBaro($wx['baroMinYday'], $from);
$ws['baroMinYdayTime'] = vws_time($wx['baroMinYdayTime']);
$ws['baroMinMonth'] = wsConvertBaro($wx['baroMinMonth'], $from);
$ws['baroMinMonthTime'] = vws_ymd($wx['baroMinMonthTime']);
$ws['baroMinYear'] = wsConvertBaro($wx['baroMinYear'], $from);
$ws['baroMinYearTime'] = vws_ymd($wx['baroMinYearTime']);
$ws['baroMaxToday'] = wsConvertBaro($wx['baroMaxToday'], $from);
$ws['baroMaxTodayTime'] = vws_time($wx['baroMaxTodayTime']);
Пример #4
0
# ------------------------------------------ some more -----------------
$ws['wsVersion'] = $wx['wsVersion'];
$ws['wsHardware'] = '';
$ws['wsUptime'] = $wx['wsUptime'];
# ------------------------------------------ soil moist ----------------
# no soil/moist
if ($SITE['soilUsed'] && $SITE['soilCount'] >= '0') {
    $soils = floor($SITE['soilCount']);
    if ($soils > 4) {
        echo '<!-- reset nr of soil sensors from ' . $SITE['soilCount'] . ' to max 4 -->' . PHP_EOL;
        $soils = 4;
    }
    for ($n = 1; $n <= $soils; $n++) {
        $from = $from_temp;
        # Temp sensor 1 actual value
        $ws['soilTempAct'][$n] = wsConvertTemperature($wx['soilTempAct[' . $n . ']'], $from);
        # Moisture sensor 1 actual value
        $ws['moistAct'][$n] = $wx['moistAct_' . $n];
    }
}
if ($SITE['leafUsed'] && $SITE['leafCount'] >= '0') {
    $leafs = round($SITE['leafCount']);
    if ($leafs > 2) {
        echo '<!-- reset nr of leaf sensors from ' . $SITE['leafCount'] . ' to max 2 -->' . PHP_EOL;
        $leafs = 2;
    }
    for ($n = 1; $n <= $leafs; $n++) {
        $ws['leafTempAct'][1] = $wx['leafTempAct_' . $n];
        $ws['leafWetAct'][1] = $wx['leafWetAct_' . $n];
    }
}
Пример #5
0
 $ws['soilTempAct'][$n] = wsConvertTemperature($soilTempAct[$i], $from_temp);
 $ws['soilTempMaxToday'][$n] = wsConvertTemperature($soilTempMaxToday[$i], $from_temp);
 #                $ws['soilTempMaxTodayTime'][$n] = wd_ymd                ($soilTempMaxTodayTime[$i]);
 $ws['soilTempMaxMonth'][$n] = wsConvertTemperature($soilTempMaxMonth[$i], $from_temp);
 $ws['soilTempMaxMonthTime'][$n] = wd_ymd($soilTempMaxMonthTime[$i]);
 $ws['soilTempMaxYear'][$n] = wsConvertTemperature($soilTempMaxYear[$i], $from_temp);
 $ws['soilTempMaxYearTime'][$n] = wd_ymd($soilTempMaxYearTime[$i]);
 $ws['soilTempMaxAll'][$n] = wsConvertTemperature($soilTempMaxAll[$i], $from_temp);
 $ws['soilTempMaxAllTime'][$n] = wd_ymd($soilTempMaxAllTime[$i]);
 $ws['soilTempMinToday'][$n] = wsConvertTemperature($soilTempMinToday[$i], $from_temp);
 #                $ws['soilTempMinTodayTime'][$n] = wd_ymd                ($soilTempMinTodayTime[$i]);
 $ws['soilTempMinMonth'][$n] = wsConvertTemperature($soilTempMinMonth[$i], $from_temp);
 $ws['soilTempMinMonthTime'][$n] = wd_ymd($soilTempMinMonthTime[$i]);
 $ws['soilTempMinYear'][$n] = wsConvertTemperature($soilTempMinYear[$i], $from_temp);
 $ws['soilTempMinYearTime'][$n] = wd_ymd($soilTempMinYearTime[$i]);
 $ws['soilTempMinAll'][$n] = wsConvertTemperature($soilTempMinAll[$i], $from_temp);
 $ws['soilTempMinAllTime'][$n] = wd_ymd($soilTempMinAllTime[$i]);
 $ws['moistAct'][$n] = $soilMoistAct[$i] * 1.0;
 $ws['moistMaxToday'][$n] = $soilMoistMaxToday[$i] * 1.0;
 #                $ws['moistMaxTodayTime'][$n]	= wd_ymd        ($soilMoistMaxTodayTime[$i]);
 if ($n == 1) {
     $ws['moistMaxMonth'][$n] = $soilMoistMaxMonth[$i] * 1.0;
     $ws['moistMaxMonthTime'][$n] = wd_ymd($soilMoistMaxMonthTime[$i]);
     $ws['moistMaxYear'][$n] = $soilMoistMaxYear[$i] * 1.0;
     $ws['moistMaxYearTime'][$n] = wd_ymd($soilMoistMaxYearTime[$i]);
     $ws['moistMaxAll'][$n] = $soilMoistMaxAll[$i] * 1.0;
     $ws['moistMaxAllTime'][$n] = wd_ymd($soilMoistMaxAllTime[$i]);
 }
 $ws['moistMinToday'][$n] = $soilMoistMinToday[$i] * 1.0;
 #                $ws['moistMinTodayTime'][$n]	= wd_ymd        ($soilMoistMinTodayTime[$i]);
 #                $ws['moistMinMonth'][$n]	=                $soilMoistMinMonth[$i]*1.0;
Пример #6
0
#-----------------------------------------------------------------------
if ($SITE['soilUsed'] && $SITE['soilCount'] >= '0') {
    $soils = floor($SITE['soilCount']);
} else {
    $soils = 0;
}
if ($soils > 4) {
    echo $startEcho . ' reset nr of soil sensors from ' . $SITE['soilCount'] . ' to max 4 ' . $endEcho . PHP_EOL;
    $soils = 4;
}
$arr_temp = explode(' ', $wx['soilTempAct']);
$arr_moist = explode(' ', $wx['soilMoistAct']);
$arr_leaf = explode(' ', $wx['leafWetAct']);
for ($n = 1; $n <= $soils; $n++) {
    $i = $n - 1;
    $ws['soilTempAct'][$n] = wsConvertTemperature($arr_temp[$i], $from_temp);
    $ws['moistAct'][$n] = $arr_moist[$i];
}
if ($SITE['leafUsed'] && $SITE['leafCount'] >= '0') {
    $leafs = floor($SITE['leafCount']);
} else {
    $leafs = 0;
}
if ($leafs > 2) {
    echo $startEcho . ' reset nr of leaf sensors from ' . $SITE['leafCount'] . ' to max 2 ' . $endEcho . PHP_EOL;
    $leafs = 2;
}
for ($n = 1; $n <= $leafs; $n++) {
    $i = $n - 1;
    $ws['leafAct'][$n] = $arr_leaf[$i];
}
Пример #7
0
                $s_hr = $value;
            }
            if ($value > $smax) {
                $smax = $value;
            }
            if ($value < $smin) {
                $smin = $value;
            }
        }
    }
}
// eo for every line
$arr = array();
$arr['temp'] = '[' . $tstr;
$arr['tmax'] = wsConvertTemperature($tmax, $wu_unit_temp);
$arr['tmin'] = wsConvertTemperature($tmin, $wu_unit_temp);
$arr['hum'] = '[' . $hstr;
$arr['hmax'] = $hmax;
$arr['hmin'] = $hmin;
$arr['wind'] = '[' . $wstr;
$arr['wmax'] = wsConvertWindspeed($wmax, $wu_unit_wind);
$arr['wmin'] = wsConvertWindspeed($wmin, $wu_unit_wind);
$arr['baro'] = '[' . $bstr;
$arr['bmax'] = wsConvertBaro($bmax, $wu_unit_baro);
$arr['bmin'] = wsConvertBaro($bmin, $wu_unit_baro);
$arr['rain'] = '[' . $rstr;
$arr['rmax'] = wsConvertRainfall($rmax, $wu_unit_rain);
$arr['rmin'] = wsConvertRainfall($rmin, $wu_unit_rain);
$arr['solr'] = '[' . $sstr;
$arr['smax'] = $smax;
$arr['smin'] = $smin;
Пример #8
0
function checkConvertData($textData, $type, $backData)
{
    global $textData, $type, $backData, $iconsWD;
    $input = trim($textData);
    if ($input === '-') {
        return;
    }
    if ($input === '_') {
        $input = '-';
        return;
    }
    switch ($type) {
        case 'B':
            break;
        case 'C':
            if (!is_numeric($input)) {
                $backData = 'yellow';
                return;
            }
            if ($input <= -30 || $input >= 40) {
                $textData .= ' exceptional data? ';
                $backData = 'yellow';
                return;
            }
            $convert = wsConvertTemperature($input, $type, 'f');
            $textData = $input . '&deg;C ( = ' . $convert . ' &deg;F )';
            break;
        case 'D':
            if (!is_numeric($input)) {
                $backData = 'yellow';
                return;
            }
            if ($input < 0 || $input >= 360.1) {
                $textData .= ' exceptional data? ';
                $backData = 'yellow';
                return;
            }
            $convert = wsConvertWinddir($input);
            $textData = $input . '&deg;( = ' . $convert . ' )';
            break;
        case 'F':
            if (!is_numeric($input)) {
                $backData = 'yellow';
                return;
            }
            if ($input < 0 || $input >= 30000) {
                $textData .= ' exceptional data? ';
                $backData = 'yellow';
                return;
            }
            $convert = round($input / 3.28084, 0);
            $textData = $input . ' feet ( = ' . $convert . ' meter )';
            break;
        case 'H':
            if (!is_numeric($input)) {
                $backData = 'yellow';
                return;
            }
            if ($input <= 900 || $input >= 1400) {
                $textData .= ' exceptional data? ';
                $backData = 'yellow';
                return;
            }
            $convertMb = wsConvertBaro($input, 'hpa', 'mb');
            $convertMmhg = wsConvertBaro($input, 'hpa', 'mmhg');
            $convertInhg = wsConvertBaro($input, 'hpa', 'inhg');
            $textData = $input . ' hPa ( = ' . $convertMb . ' mb; ' . $convertMmhg . ' mmHg; ' . $convertInhg . ' inHg )';
            break;
        case 'I':
            if (!is_numeric($input)) {
                $backData = 'yellow';
                return;
            }
            if ($input < 0 || $input > 36) {
                $textData .= ' exceptional data? ';
                $backData = 'yellow';
                return;
            }
            $textData = $input . ' ( ' . $iconsWD[$input]['iconDescription'] . ' )';
            break;
        case 'K':
            if (!is_numeric($input)) {
                $backData = 'yellow';
                return;
            }
            if ($input < 0 || $input >= 100) {
                $textData .= ' exceptional data? ';
                $backData = 'yellow';
                return;
            }
            $convertKmh = wsConvertWindspeed($input, 'kts', 'kmh');
            $convertMs = wsConvertWindspeed($input, 'kts', 'ms');
            $convertMph = wsConvertWindspeed($input, 'kts', 'mph');
            $textData = $input . ' kts ( = ' . $convertKmh . ' k/H; ' . $convertMs . ' ms; ' . $convertMph . ' m/H )';
            break;
        case 'M':
            if (!is_numeric($input)) {
                $backData = 'yellow';
                return;
            }
            if ($input < 0 || $input >= 300) {
                $textData .= ' exceptional data? ';
                $backData = 'yellow';
                return;
            }
            $convert = wsConvertRainfall($input, 'mm', 'in');
            $textData = $input . ' mm ( = ' . $convert . ' in )';
            break;
        case 'N':
            if (!is_numeric($input)) {
                $backData = 'yellow';
                return;
            }
            break;
        case 'P':
            $textData = $input . '%';
            break;
        case 'T':
            if ($input == 0) {
                return;
            }
            $time = strtotime($input);
            $string = date('H:i', $time);
            if ($string != $input) {
                $textData = $string . ' <> ' . $input . ' exceptional data? ';
                $backData = 'yellow';
                return;
            }
            break;
        case 'U':
            break;
    }
}
Пример #9
0
function load_realtime_file($realtime_all, &$error_display)
{
    global $SITE, $ws, $wsDebug, $fileTimeUpload;
    #
    if ($SITE['realtime'] != 'none') {
        if (!isset($SITE['realtime_file'])) {
            $error_display = 'realtime = ' . $SITE['realtime'] . ' but: no realtime-file specified. ';
            ws_message($realtime_all . '(' . __LINE__ . '): ' . $error_display . '- continue  -->');
            return;
        }
        if (!is_file($SITE['realtime_file'])) {
            $error_display = 'realtime = ' . $SITE['realtime'] . ' but: no ' . $SITE['realtime_file'] . ' found. ';
            ws_message($realtime_all . '(' . __LINE__ . '): ' . $error_display . '- continue  -->');
            return;
        }
        if (isset($SITE['realtime_file2']) && !is_file($SITE['realtime_file2'])) {
            $error_display = 'realtime file 2 = ' . $SITE['realtime_file2'] . ' but: no ' . $SITE['realtime_file2'] . ' found. ';
            ws_message($realtime_all . '(' . __LINE__ . '): ' . $error_display . '- continue  -->');
        }
    }
    ws_message($realtime_all . '(' . __LINE__ . '): ' . $SITE['realtime_file'] . ' try to load.  -->');
    $string = file_get_contents($SITE['realtime_file']);
    $filetime = filemtime($SITE['realtime_file']);
    if (isset($fileTimeUpload)) {
        if (30 + $filetime < $fileTimeUpload) {
            ws_message($realtime_all . '(' . __LINE__ . '): realtime file to old Tagfile = ' . $fileTimeUpload . ' realtimefile = ' . $filetime . ' -->');
            return;
        }
    }
    #
    switch ($SITE['realtime']) {
        case 'wflash':
            $pos = strpos(substr($string, 0, 10), 'F=');
            if (!$pos === false) {
                $string = substr($string, $pos + 2);
            }
            $arr_rt = explode(",", $string);
            $fromTemp = 'F';
            // ='&deg;C', ='&deg;F'
            $fromWind = 'mPh';
            // =' km/h', =' kts', =' m/s', =' mph'
            $fromRain = 'in';
            // =' mm', =' in'
            $fromBaro = 'inHg';
            // =' hPa', =' mb', =' inHg'
            #
            $ws['rtTime'] = wdDate(trim($arr_rt[1]));
            $ws['tempAct'] = (string) wsConvertTemperature($arr_rt[9], $fromTemp);
            $ws['tempActInside'] = (string) wsConvertTemperature($arr_rt[8], $fromTemp);
            #               $ws['tempDelta']	= (string)wsConvertTemperature($arr_rt[37],    $fromTemp);
            $temp1hourAgo = (string) wsConvertTemperature($arr_rt[9], $fromTemp, $fromTemp) - (string) wsConvertTemperature($arr_rt[37], $fromTemp, $fromTemp);
            $ws['tempDelta'] = $ws['tempAct'] - wsConvertTemperature($temp1hourAgo, $fromTemp);
            $ws['dewpAct'] = (string) wsConvertTemperature($arr_rt[24], $fromTemp);
            $ws['appTemp'] = (string) wsConvertTemperature($arr_rt[29], $fromTemp);
            # ??
            $ws['chilAct'] = (string) wsConvertTemperature($arr_rt[21], $fromTemp);
            $ws['heatAct'] = (string) wsConvertTemperature($arr_rt[23], $fromTemp);
            $ws['windAct'] = (string) wsConvertWindspeed($arr_rt[4], $fromWind);
            $ws['windActDir'] = 1.0 * $arr_rt[3];
            $ws['gustAct'] = (string) wsConvertWindspeed($arr_rt[5], $fromWind);
            $ws['windBeafort'] = (string) wsBeaufortNumber($ws['windAct'], $SITE['uomWind']);
            $ws['windActDir'] = (string) round($arr_rt[3]);
            $ws['baroAct'] = (string) wsConvertBaro($arr_rt[25], $fromBaro);
            $ws['baroDelta'] = (string) wsConvertBaro($arr_rt[53], $fromBaro);
            $ws['humiAct'] = (string) round($arr_rt[7]);
            $ws['humiInAct'] = (string) round($arr_rt[6]);
            $ws['uvAct'] = (string) round($arr_rt[19], 1);
            #               $ws['uvMaxToday']       = (string)round($arr_rt[46],1);
            $ws['solarAct'] = (string) round($arr_rt[20], 1);
            # process wflash2.txt
            if (isset($SITE['realtime_file2'])) {
                ws_message($realtime_all . '(' . __LINE__ . '): ' . $SITE['realtime_file2'] . ' try to load.  -->');
                $string = file_get_contents($SITE['realtime_file2']);
                $pos = strpos(substr($string, 0, 10), 'S=');
                if (!$pos === false) {
                    $string = substr($string, 9);
                }
                $arr_rt = explode(",", substr($string, 2));
                $rtdate = wdDate(trim($arr_rt[0]));
                if ($rtdate > $ws['rtTime']) {
                    $ws['rtTime'] = $rtdate;
                }
                $ws['tempMinToday'] = (string) wsConvertTemperature($arr_rt[92], $fromTemp);
                $ws['tempMaxToday'] = (string) wsConvertTemperature($arr_rt[36], $fromTemp);
                $ws['dewpMinToday'] = (string) wsConvertTemperature($arr_rt[107], $fromTemp);
                $ws['dewpMaxToday'] = (string) wsConvertTemperature($arr_rt[51], $fromTemp);
                $ws['chilMinToday'] = (string) wsConvertTemperature($arr_rt[104], $fromTemp);
                $ws['heatMaxToday'] = (string) wsConvertTemperature($arr_rt[50], $fromTemp);
                $ws['gustMaxToday'] = (string) wsConvertWindspeed($arr_rt[32], $fromWind);
                $ws['windAvgDir'] = (string) $arr_rt[2];
                $ws['baroMinToday'] = (string) wsConvertBaro($arr_rt[108], $fromBaro);
                $ws['baroMaxToday'] = (string) wsConvertBaro($arr_rt[52], $fromBaro);
                $ws['rainToday'] = (string) wsConvertRainfall($arr_rt[254], $fromRain);
                $ws['rainRateAct'] = (string) wsConvertRainfall($arr_rt[257], $fromRain);
                $ws['rainRateToday'] = (string) wsConvertRainfall($arr_rt[150], $fromRain);
                $ws['humiMinToday'] = (string) round($arr_rt[90]);
                $ws['humiMaxToday'] = (string) round($arr_rt[34]);
                $ws['windAvgDir'] = (string) round($arr_rt[2]);
                $ws['solarMaxToday'] = (string) $arr_rt[47];
                $ws['uvMaxToday'] = (string) round($arr_rt[46], 1);
            }
            // eo realtimefile 2
            break;
        case 'json':
            $oldDegree = iconv('UTF-8', 'windows-1252//TRANSLIT', '°');
            // clean for nonjson characters
            $from = array('&deg;', '°', $oldDegree);
            $string = str_replace($from, '', $string);
            #
            if ($SITE['WXsoftware'] == 'WC') {
                // uses decimal , no point
                $string = str_replace(',', '.', $string);
                $string = str_replace('|', ',', $string);
            }
            $arr_rt = json_decode($string, true);
            $fromTemp = str_replace('&#176;', '', $arr_rt['tempunit']);
            $fromWind = $arr_rt['windunit'];
            $fromRain = $arr_rt['rainunit'];
            $fromBaro = $arr_rt['pressunit'];
            $ws['rtTime'] = wdDate($arr_rt['date']);
            $ws['tempAct'] = (string) wsConvertTemperature($arr_rt['temp'], $fromTemp);
            // "temp":"4,6",
            $ws['tempActInside'] = (string) wsConvertTemperature($arr_rt['intemp'], $fromTemp);
            // "intemp":"18,7",
            $ws['dewpAct'] = (string) wsConvertTemperature($arr_rt['dew'], $fromTemp);
            // "dew":"3,3",
            $ws['appTemp'] = (string) wsConvertTemperature($arr_rt['apptemp'], $fromTemp);
            $ws['chilAct'] = (string) wsConvertTemperature($arr_rt['wchill'], $fromTemp);
            $ws['windAct'] = (string) wsConvertWindspeed($arr_rt['wlatest'], $fromWind);
            $ws['windBeafort'] = (string) wsBeaufortNumber($ws['windAct'], $SITE['uomWind']);
            $ws['gustAct'] = (string) wsConvertWindspeed($arr_rt['wgust'], $fromWind);
            $ws['windActDir'] = (string) $arr_rt['bearing'];
            $ws['windAvgDir'] = (string) $arr_rt['avgbearing'];
            $ws['baroAct'] = (string) wsConvertBaro($arr_rt['press'], $fromBaro);
            $ws['rainToday'] = (string) wsConvertRainfall($arr_rt['rfall'], $fromRain);
            $ws['rainRateAct'] = (string) wsConvertRainfall($arr_rt['rrate'], $fromRain);
            $ws['humiAct'] = (string) $arr_rt['hum'];
            $ws['humiInAct'] = (string) $arr_rt['inhum'];
            $ws['uvAct'] = (string) $arr_rt['UV'];
            if ($ws['uvAct'] > $ws['uvMaxToday']) {
                $ws['uvMaxToday'] = $ws['uvAct'];
            }
            $ws['solarAct'] = (string) $arr_rt['SolarRad'];
            if ($ws['solarAct'] > $ws['solarMaxToday']) {
                $ws['solarMaxToday'] = $ws['solarAct'];
            }
            break;
        case 'cltrw':
            $oldDegree = iconv('UTF-8', 'windows-1252//TRANSLIT', '°');
            $from = array('&deg;', '°', $oldDegree);
            $string = trim(str_replace($from, '', $string));
            $string = preg_replace("/[\r\n]+[\\s\t]*[\r\n]+/", "\n", $string);
            $arr_rt = explode(" ", $string);
            if ($arr_rt[0] != '12345') {
                $errorfile = substr($string, 0, 20);
                ws_message($realtime_all . '(' . __LINE__ . '): This file (' . $SITE['realtime_file'] . ') seems not to be a ' . $SITE['realtime'] . ' type file  
' . $errorfile . ' -->');
                return;
            }
            $fromTemp = 'c';
            $fromWind = 'kts';
            $fromRain = 'mm';
            $fromBaro = 'hpa';
            $arr = explode('-', $arr_rt['32']);
            $last = count($arr) - 1;
            $time = trim(str_replace('_', ' ', $arr[$last]));
            $ws['rtTime'] = wdDate($time);
            $ws['tempAct'] = (string) wsConvertTemperature($arr_rt['4'], $fromTemp);
            $ws['tempActInside'] = (string) wsConvertTemperature($arr_rt['12'], $fromTemp);
            $ws['dewpAct'] = (string) wsConvertTemperature($arr_rt['72'], $fromTemp);
            $ws['appTemp'] = (string) wsConvertTemperature($arr_rt['130'], $fromTemp);
            $ws['chilAct'] = (string) wsConvertTemperature($arr_rt['44'], $fromTemp);
            $ws['windAct'] = (string) wsConvertWindspeed($arr_rt['1'], $fromWind);
            $ws['windBeafort'] = (string) wsBeaufortNumber($ws['windAct'], $SITE['uomWind']);
            $ws['gustAct'] = (string) wsConvertWindspeed($arr_rt['2'], $fromWind);
            $ws['windActDir'] = (string) $arr_rt['3'];
            $ws['windAvgDir'] = (string) $arr_rt['117'];
            $ws['baroAct'] = (string) wsConvertBaro($arr_rt['6'], $fromBaro);
            $ws['rainToday'] = (string) wsConvertRainfall($arr_rt['7'], $fromRain);
            $ws['rainRateAct'] = (string) wsConvertRainfall($arr_rt['10'], $fromRain);
            $ws['humiAct'] = (string) $arr_rt['5'];
            $ws['uvAct'] = (string) $arr_rt['79'];
            $ws['solarAct'] = (string) $arr_rt['127'];
            break;
        case 'http':
            $pos = strpos(substr($string, 0, 20), '|', 0);
            if (!$pos) {
                $split_char = ',';
            } else {
                $split_char = '|';
            }
            $arr_rt = explode($split_char, $string);
            #	$arr_rt[nr]
            #       0       1		2		3		4       5		6		7		8		9
            # [hh]:[mm],[th0temp-act],[th0temp-dmin],[th0temp-dmax],[thb0temp-act],[th0dew-act],[th0dew-dmin],[th0dew-dmax],[wind0chill-act],[wind0chill-dmin],
            #	10		11			12		13		14		15		16		17			18		19
            # [wind0wind-act],[wind0avgwind-act],[wind0wind-max10],[wind0wind-dmax],[wind0dir-act],[wind0dir-avg10:--],[thb0seapress-act],[thb0seapress-dmin],[thb0seapress-dmax],[thb0seapress-ymin],
            #	20		21			22		23		24	   25		26		27		28		29
            # [thb0seapress-ymax],[rain0total-daysum],[rain0rate-act],[rain0rate-dmax],[th0hum-act],[th0hum-dmin],[th0hum-dmax],[thb0hum-act],[th0temp-val60:--],[th0temp-dmintime],
            #	30		31			32		33		34			35		36		37				38			39
            # [th0temp-dmaxtime],[th0dew-dmintime],[th0dew-dmaxtime],[wind0chill-dmin],[rain0rate-dmaxtime],[th0hum-dmintime],[th0hum-dmaxtime],[thb0seapress-dmintime],[thb0seapress-dmaxtime],[thb0seapress-val60:--],
            #		40		41			42		43		44		45		46			47		48				49
            # [wind0wind-act=bft.0],[wind0wind-dmaxtime],[wind0avgwind-dmax],[uv0index-act:--],[sol0rad-act:--],[sol0rad-hmax:--],[sol0rad-dmax:--],[mbsystem-swversion],[mbsystem-buildnum],[YYYY]:[MM]:[DD]:[Uhh]:[Umm]:[Uss]
            #       50
            #[forecast-text]
            $ws['rtTime'] = wdDate(trim($arr_rt['0']));
            $ws['tempAct'] = (string) wsConvertTemperature($arr_rt[1], 'c');
            $ws['dewpAct'] = (string) wsConvertTemperature($arr_rt[5], 'c');
            $ws['chilAct'] = (string) wsConvertTemperature($arr_rt[8], 'c');
            $ws['chilMinToday'] = (string) wsConvertTemperature($arr_rt[9], 'c');
            $ws['windAct'] = (string) wsConvertWindspeed($arr_rt[11], 'm/s');
            $ws['windBeafort'] = (string) wsBeaufortNumber($ws['windAct'], $SITE['uomWind']);
            $ws['gustAct'] = (string) wsConvertWindspeed($arr_rt[12], 'm/s');
            $ws['windActDir'] = (string) $arr_rt[14];
            $ws['windAvgDir'] = (string) $arr_rt[15];
            $ws['baroAct'] = (string) wsConvertBaro($arr_rt[16], 'hpa');
            $ws['rainToday'] = (string) wsConvertRainfall($arr_rt[21], 'mm');
            $ws['rainRateAct'] = (string) wsConvertRainfall($arr_rt[22], 'mm');
            $ws['humiAct'] = (string) $arr_rt[24];
            $ws['humiInAct'] = (string) $arr_rt[27];
            $ws['uvAct'] = (string) $arr_rt[43];
            $ws['solarAct'] = (string) $arr_rt[44];
            break;
        case 'weatherlink':
            #echo $string; exit;
            $arr = explode("\n", $string);
            #                var_dump ($arr); exit;
            $end = count($arr);
            for ($n = 0; $n < $end; $n++) {
                $line = trim($arr[$n]);
                if ($line == '') {
                    continue;
                }
                $substr = substr($line, 1, 5);
                if ($substr == '-----') {
                    continue;
                }
                if (substr($line, 0, 1) != '|') {
                    continue;
                }
                list($skip, $name, $content) = explode('|', $line . '|');
                $name = trim($name);
                $content = trim($content);
                #                       if ($content  == '' ) {ws_message (  $startEcho.$tagsScript.'('.__LINE__.'):empty line '.$n.' name '.$name .$endEcho.PHP_EOL;continue; }
                $arr_rt[$name] = $content;
            }
            #                var_dump ($arr_rt); exit;
            $oldDegree = iconv('UTF-8', 'windows-1252//TRANSLIT', '°');
            $from = array('&deg;', '°', $oldDegree);
            $arr_rt['tempunit'] = str_replace($from, '', $arr_rt['tempunit']);
            $arr_rt['windunit'] = str_replace('r', '', $arr_rt['windunit']);
            $fromTemp = $arr_rt['tempunit'];
            $fromWind = $arr_rt['windunit'];
            $fromRain = $arr_rt['rainunit'];
            $fromBaro = $arr_rt['pressunit'];
            $ws['rtTime'] = wdDate($arr_rt['date']);
            $ws['rtVersion'] = $arr_rt['rtVersion'];
            $ws['tempAct'] = (string) wsConvertTemperature($arr_rt['temp'], $fromTemp);
            // "temp":"4,6",
            $ws['tempActInside'] = (string) wsConvertTemperature($arr_rt['intemp'], $fromTemp);
            // "intemp":"18,7",
            $ws['dewpAct'] = (string) wsConvertTemperature($arr_rt['dew'], $fromTemp);
            // "dew":"3,3",
            $ws['chilAct'] = (string) wsConvertTemperature($arr_rt['wchill'], $fromTemp);
            $ws['windAct'] = (string) wsConvertWindspeed($arr_rt['wlatest'], $fromWind);
            $ws['windBeafort'] = (string) wsBeaufortNumber($ws['windAct'], $SITE['uomWind']);
            $ws['gustAct'] = (string) wsConvertWindspeed($arr_rt['wgust'], $fromWind);
            $ws['windActDir'] = (string) $arr_rt['bearing'];
            $ws['windAvgDir'] = (string) $arr_rt['avgbearing'];
            $ws['baroAct'] = (string) wsConvertBaro($arr_rt['press'], $fromBaro);
            $ws['rainToday'] = (string) wsConvertRainfall($arr_rt['rfall'], $fromRain);
            $ws['rainRateAct'] = (string) wsConvertRainfall($arr_rt['rrate'], $fromRain);
            $ws['humiAct'] = (string) $arr_rt['hum'];
            $ws['uvAct'] = (string) $arr_rt['UV'];
            if ($ws['uvAct'] > $ws['uvMaxToday']) {
                $ws['uvMaxToday'] = $ws['uvAct'];
            }
            $ws['solarAct'] = (string) $arr_rt['SolarRad'];
            if ($ws['solarAct'] > $ws['solarMaxToday']) {
                $ws['solarMaxToday'] = $ws['solarAct'];
            }
            break;
        default:
            ws_message($realtime_all . '(' . __LINE__ . '): unknown realtime type ' . $SITE['realtime'] . ' found    -->');
    }
}
Пример #10
0
    }
    if ($temp > $highTemp) {
        $highTemp = $temp;
        $highTempTime = $arrLine[0];
    } elseif ($temp < $lowTemp) {
        $lowTemp = $temp;
        $lowTempTime = $arrLine[0];
    }
}
$unix = strtotime($highTempTime);
$highTempTime = date('YmdHj', $unix) . '00';
$unix = strtotime($lowTempTime);
$lowTempTime = date('YmdHj', $unix) . '00';
$arr_almanac['last_year_low'] = wsConvertTemperature($lowTemp, $units);
$arr_almanac['last_year_lowT'] = $lowTempTime;
$arr_almanac['last_year_high'] = wsConvertTemperature($highTemp, $units);
$arr_almanac['last_year_highT'] = $highTempTime;
#
wsAlmanacSaveCache();
return;
# ---------------------------------------- almanac functions ---------------------------
function wsAlmanacFindUnits($arr)
{
    $units = '';
    for ($n = 0; $n < 2; $n++) {
        $line = trim($arr[$n]);
        if (strlen($line) < 20) {
            continue;
        }
        $arr2 = explode(',', $line . ',');
        if (trim(strtolower($arr2[0])) == 'time') {
Пример #11
0
        <label>Station: ' . $SITE['organ'] . '</label>
 <!--        <datetime>' . langtransstr('Live weatherdata from') . ' Meteoware</datetime>	-->
        <load>' . langtransstr('Actual data is loaded . . .') . '</load>
        <lastrefresh>' . langtransstr('Actual data from:') . '</lastrefresh>
        <locale>en</locale>			
  </header>';
if ($SITE['uomTemp'] == '&deg;C') {
    $uabbr = '°C';
    $temptext = langtransstr('Celsius');
} else {
    $uabbr = '°F';
    $temptext = langtransstr('Fahrenheit');
}
$limit_low = (string) wsConvertTemperature('-10', 'c');
$limit_low = round(5 * floor($limit_low / 5));
$limit_high = (string) wsConvertTemperature('35', 'c');
$limit_high = round(5 * floor($limit_high / 5));
if ($ws['tempMinYear'] < $limit_low) {
    $limit_low = 5 * floor($ws['tempMinYear'] / 5);
}
if ($ws['dewpMinToday'] < $limit_low) {
    $limit_low = 5 * floor($ws['dewpMinToday'] / 5);
}
if ($ws['chilMinToday'] < $limit_low) {
    $limit_low = 5 * floor($ws['chilMinToday'] / 5);
}
if ($ws['tempMaxYear'] > $limit_high) {
    $limit_high = 5 * ceil($ws['tempMaxYear'] / 5);
}
if ($ws['dewpMaxToday'] > $limit_high) {
    $limit_high = 5 * ceil($ws['dewpMaxToday'] / 5);
Пример #12
0
} else {
    echo '<!-- ';
    for ($n = 0; $n < count($arrConvert); $n++) {
        $number = $fields[$arrConvert[$n]]['unit'];
        $usedunit = $uoms[$number];
        echo '<!-- UOM conversion from = ' . $uoms[$number] . ' to = ' . $uomsTo[$number] . ' -->' . PHP_EOL;
    }
    for ($i = 1; $i < $linesOK; $i++) {
        for ($n = 0; $n < count($arrConvert); $n++) {
            $number = $fields[$arrConvert[$n]]['unit'];
            $usedunit = $uoms[$number];
            $amount = $wsWxsimArray[$i][$arrConvert[$n]];
            switch ($number) {
                case 0:
                    // temp
                    $wsWxsimArray[$i][$arrConvert[$n]] = wsConvertTemperature($amount, $usedunit);
                    break;
                case 1:
                    // rain
                    $wsWxsimArray[$i][$arrConvert[$n]] = wsConvertRainfall($amount, $usedunit);
                    break;
                case 2:
                    // wind
                    $wsWxsimArray[$i][$arrConvert[$n]] = wsConvertWindspeed($amount, $usedunit);
                    break;
                case 3:
                    // baro
                    $wsWxsimArray[$i][$arrConvert[$n]] = wsConvertBaro($amount, $usedunit);
                    break;
                case 4:
                    // snow
Пример #13
0
function convert_testtags()
{
    global $ymd, $ws, $wsTrends, $SITE, $pageFile, $my_date_format;
    echo '<!-- module ' . $pageFile . ' loading  ' . $SITE['wsTags'] . ' -->' . PHP_EOL;
    $ws['originated'] = 'leuven testtags.php -';
    include $SITE['wsTags'];
    // load testtags.php
    if (isset($ws['actTime'])) {
        // it is a leuven one
        $ws['wsVersion'] = str_replace('---', '', $ws['wsVersion']);
        if (!isset($ws['tempActExtra2'])) {
            $ws['tempActExtra2'] = '';
        }
        return;
    }
    # the testtags.php is a Saratoga one ! not leuven
    $ws['originated'] = 'saratoga testtags.php - ' . $date . ' - ' . $time;
    #
    echo '<!-- module ' . $pageFile . ' probable Saratoga testtags - converting -->' . PHP_EOL;
    #
    ob_start();
    $weathercond = $weathercond;
    $ws['wdCurCond'] = $Currentsolardescription;
    $ws['wdCurIcon'] = $iconnumber;
    // Current icon number
    $ws['wdMetarCcn'] = $weatherreport;
    // Current weather conditions from selected METAR
    $ws['wdMetarCld'] = '';
    // Cloud METAR label from the metargif
    # ------------------------------------------ units ---------------------
    if (!isset($uomtemp)) {
        $from_temp = $SITE['uomTemp'];
    } else {
        $from_temp = $uomtemp;
    }
    //  = 'C', 'F',  (or  '�C', '�F', or '&deg;C', '&deg;F' )
    if (!isset($uombaro)) {
        $from_baro = $SITE['uomBaro'];
    } else {
        $from_baro = $uombaro;
    }
    //  = 'inHg', 'hPa', 'kPa', 'mb'
    if (!isset($uomrain)) {
        $from_rain = $SITE['uomRain'];
    } else {
        $from_rain = $uomrain;
    }
    //  = 'mm', 'in'$from	= $uomrain;
    if (!isset($uomwind)) {
        $from_wind = $SITE['uomWind'];
    } else {
        $from_wind = $uomwind;
    }
    //  = 'kts','mph','kmh','km/h','m/s','Bft'
    if (!isset($uomdistance)) {
        $wdDist = $SITE['uomDistance'];
    } else {
        $wdDist = $uomdistance;
    }
    // = 'mi','km'  (for windrun variables)
    # ------------------------------------------- date - time --------------
    if (!isset($datefmt)) {
        $wdDatefmt = $SITE['uomDistance'];
    } else {
        $wdDatefmt = $datefmt;
    }
    //  = 'd/m/y', 'm/d/y'
    $wdSeconds = '00';
    $wdMinute = $time_minute;
    $wdHour = $time_hour;
    $wdDay = $date_day;
    $wdMonth = $date_month;
    $wdYear = $date_year;
    $ymd = (string) $wdYear . $wdMonth . $wdDay;
    //
    $ws['actTime'] = (string) $ymd . $wdHour . $wdMinute . $wdSeconds;
    // '20120523113945';
    # ------------------------------------------ temperature ---------------------------------
    $from = $from_temp;
    $ws['tempMinTodayTime'] = wdDate($mintempt);
    $ws['tempMinYdayTime'] = wdDate($mintempyestt);
    $ws['tempMinMonthTime'] = wdYMD($mrecordlowtempyear, $mrecordlowtempmonth, $mrecordlowtempday);
    $ws['tempMinYearTime'] = wdYMD($yrecordlowtempyear, $yrecordlowtempmonth, $yrecordlowtempday);
    $ws['tempMaxTodayTime'] = wdDate($maxtempt);
    $ws['tempMaxYdayTime'] = wdDate($maxtempyestt);
    //yday
    $ws['tempMaxMonthTime'] = wdYMD($mrecordhightempyear, $mrecordhightempmonth, $mrecordhightempday);
    $ws['tempMaxYearTime'] = wdYMD($yrecordhightempyear, $yrecordhightempmonth, $yrecordhightempday);
    $ws['dewpMinTodayTime'] = wdDate($mindewt);
    $ws['dewpMinYdayTime'] = wdDate($mindewyestt);
    //yday
    $ws['dewpMaxTodayTime'] = wdDate($maxdewt);
    $ws['dewpMaxYdayTime'] = wdDate($maxdewyestt);
    // yday
    $ws['heatMaxTodayTime'] = wdDate($maxheatt);
    $ws['heatMaxYdayTime'] = wdDate($maxheatyestt);
    $ws['heatMaxMonthTime'] = wdYMD($mrecordhighheatindexyear, $mrecordhighheatindexmonth, $mrecordhighheatindexday);
    $ws['heatMaxYearTime'] = wdYMD($yrecordhighheatindexyear, $yrecordhighheatindexmonth, $yrecordhighheatindexday);
    $ws['chilMinTodayTime'] = wdDate($minwindcht);
    $ws['chilMinYdayTime'] = wdDate($minchillyestt);
    // yday
    $ws['chilMinMonthTime'] = wdYMD($mrecordlowchillyear, $mrecordlowchillmonth, $mrecordlowchillday);
    $ws['chilMinYearTime'] = wdYMD($yrecordlowchillyear, $yrecordlowchillmonth, $yrecordlowchillday);
    $ws['tempAct'] = wsConvertTemperature($temperature, $from);
    // convert and clean of units
    if (isset($indoortemp)) {
        $ws['tempActInside'] = wsConvertTemperature($indoortemp, $from);
    } else {
        $ws['tempActInside'] = '';
    }
    if (isset($generalextratemp1)) {
        $ws['tempActExtra1'] = wsConvertTemperature($generalextratemp1, $from);
    } else {
        $ws['tempActExtra1'] = '';
    }
    if (isset($generalextratemp2)) {
        $ws['tempActExtra2'] = wsConvertTemperature($generalextratemp2, $from);
    } else {
        $ws['tempActExtra2'] = '';
    }
    $ws['tempDelta'] = wsConvertTemperature($tempchangehour, $from);
    $ws['tempToday'] = wsConvertTemperature($avtempsincemidnight, $from);
    $ws['tempMinToday'] = wsConvertTemperature($mintemp, $from);
    $ws['tempMinYday'] = wsConvertTemperature($mintempyest, $from);
    $ws['tempMinMonth'] = wsConvertTemperature($mrecordlowtemp, $from);
    $ws['tempMinYear'] = wsConvertTemperature($yrecordlowtemp, $from);
    $ws['tempMaxToday'] = wsConvertTemperature($maxtemp, $from);
    $ws['tempMaxYday'] = wsConvertTemperature($maxtempyest, $from);
    $ws['tempMaxMonth'] = wsConvertTemperature($mrecordhightemp, $from);
    $ws['tempMaxYear'] = wsConvertTemperature($yrecordhightemp, $from);
    $ws['dewpAct'] = wsConvertTemperature($dewpt, $from);
    $ws['dewpDelta'] = wsConvertTemperature($dewchangelasthour, $from);
    $ws['dewpMinToday'] = wsConvertTemperature($mindew, $from);
    $ws['dewpMinYday'] = wsConvertTemperature($mindewyest, $from);
    $ws['dewpMaxToday'] = wsConvertTemperature($maxdew, $from);
    $ws['dewpMaxYday'] = wsConvertTemperature($maxdewyest, $from);
    $ws['heatAct'] = wsConvertTemperature($heati, $from);
    $ws['heatDelta'] = 0;
    $ws['heatMaxToday'] = wsConvertTemperature($maxheat, $from);
    $ws['heatMaxYday'] = wsConvertTemperature($maxheatyest, $from);
    $ws['heatMaxMonth'] = wsConvertTemperature($mrecordhighheatindex, $from);
    $ws['heatMaxYear'] = wsConvertTemperature($yrecordhighheatindex, $from);
    $ws['chilAct'] = wsConvertTemperature($windch, $from);
    $ws['chilDelta'] = 0;
    $ws['chilMinToday'] = wsConvertTemperature($minwindch, $from);
    $ws['chilMinYday'] = wsConvertTemperature($minchillyest, $from);
    $ws['chilMinMonth'] = wsConvertTemperature($mrecordlowchill, $from);
    $ws['chilMinYear'] = wsConvertTemperature($yrecordlowchill, $from);
    $ws['hudxAct'] = wsConvertTemperature($humidexcelsius, 'C');
    $ws['hudxDelta'] = 0;
    $ws['hudxMaxToday'] = wsConvertTemperature($todayhihumidex, 'C');
    # ------------------------------------------ extreme temp   ------------------------------
    $ws['daysXHigh'] = $daysTmaxGT30C;
    $ws['daysHigh'] = $daysTmaxGT25C;
    $ws['daysLow'] = $daysTminLT0C;
    $ws['daysXLow'] = $daysTminLTm15C;
    # ------------------------------------------ pressure / baro -----------------------------
    $from = $from_baro;
    $ws['baroMinTodayTime'] = wdDate($lowbarot);
    $ws['baroMinYdayTime'] = wdDate($minbaroyestt);
    // ytd
    $ws['baroMinMonthTime'] = wdYMD($mrecordlowbaroyear, $mrecordlowbaromonth, $mrecordlowbaroday);
    $ws['baroMinYearTime'] = wdYMD($yrecordlowbaroyear, $yrecordlowbaromonth, $yrecordlowbaroday);
    $ws['baroMaxTodayTime'] = wdDate($highbarot);
    $ws['baroMaxYdayTime'] = wdDate($maxbaroyestt);
    // ytd
    $ws['baroMaxMonthTime'] = wdYMD($mrecordhighbaroyear, $mrecordhighbaromonth, $mrecordhighbaroday);
    $ws['baroMaxYearTime'] = wdYMD($yrecordhighbaroyear, $yrecordhighbaromonth, $yrecordhighbaroday);
    $ws['baroAct'] = wsConvertBaro($baro, $from);
    $ws['baroDelta'] = wsConvertBaro($trend, $from);
    $ws['baroMinToday'] = wsConvertBaro($lowbaro, $from);
    $ws['baroMinYday'] = wsConvertBaro($minbaroyest, $from);
    $ws['baroMinMonth'] = wsConvertBaro($mrecordlowbaro, $from);
    $ws['baroMinYear'] = wsConvertBaro($yrecordlowbaro, $from);
    $ws['baroMaxToday'] = wsConvertBaro($highbaro, $from);
    $ws['baroMaxYday'] = wsConvertBaro($maxbaroyest, $from);
    $ws['baroMaxMonth'] = wsConvertBaro($mrecordhighbaro, $from);
    $ws['baroMaxYear'] = wsConvertBaro($yrecordhighbaro, $from);
    # ------------------------------------------ humidity  -----------------------------------
    $ws['humiMinTodayTime '] = wdDate($lowhumt);
    $ws['humiMinYdayTime '] = wdDate($minhumyestt);
    // ytd
    $ws['humiMaxTodayTime'] = wdDate($highhumt);
    $ws['humiMaxYdayTime'] = wdDate($maxhumyestt);
    // ytd
    $ws['humiAct'] = $humidity * 1.0;
    $ws['humiExtra'] = '';
    # $generalextrahum1*1.0;
    $ws['humiDelta'] = $humchangelasthour * 1.0;
    $ws['humiMinToday'] = $lowhum * 1.0;
    $ws['humiMinYday'] = $minhumyest * 1.0;
    $ws['humiMaxToday'] = $highhum * 1.0;
    $ws['humiMaxYday'] = $maxhumyest * 1.0;
    # ------------------------------------------ rain  ---------------------------------------
    $from = $from_rain;
    $ws['rainDayMnth'] = $dayswithrain;
    // %dayswithrain% 		Days with rain for the month
    $ws['rainDayYear'] = $dayswithrainyear;
    // %dayswithrainyear%	Days with rain for the year
    $ws['rainRateAct'] = wsConvertRainfall($currentrainratehr, $from);
    $ws['rainRateToday'] = wsConvertRainfall($maxrainrate, $from);
    $ws['rainHour'] = wsConvertRainfall($hourrn, $from);
    $ws['rainToday'] = wsConvertRainfall($dayrn, $from);
    $ws['rainYday'] = wsConvertRainfall($yesterdayrain, $from);
    $ws['rainMonth'] = wsConvertRainfall($monthrn, $from);
    $ws['rainYear'] = wsConvertRainfall($yearrn, $from);
    $ws['rainDaysWithNo'] = $dayswithnorain;
    $ws['rainWeek'] = wsConvertRainfall($raincurrentweek, $from);
    # ------------------------------------------ EVAPOTRANSPIRATION --------------------------
    $ws['etToday'] = wsConvertRainfall($VPet, $from);
    $ws['etYday'] = wsConvertRainfall($yesterdaydaviset, $from);
    $ws['etMonth'] = wsConvertRainfall($VPetmonth, $from);
    # ------------------------------------------ wind  ---------------------------------------
    $from = $from_wind;
    $ws['windActDsc'] = $dirlabel;
    $ws['windBeafort'] = $beaufortnum;
    $ws['gustMaxTodayTime'] = wdDate($maxgstt);
    $ws['gustMaxYdayTime'] = wdDate($maxgustyestt);
    $ws['gustMaxMonthTime'] = wdYMD($mrecordhighgustyear, $mrecordhighgustmonth, $mrecordhighgustday);
    $ws['gustMaxYearTime'] = wdYMD($yrecordhighgustyear, $yrecordhighgustmonth, $yrecordhighgustday);
    $ws['windAct'] = wsConvertWindspeed($avgspd, $from);
    $ws['gustAct'] = wsConvertWindspeed($gstspd, $from);
    $ws['gustMaxHour'] = wsConvertWindspeed($maxgsthr, $from);
    $ws['gustMaxToday'] = wsConvertWindspeed($maxgst, $from);
    $ws['gustMaxYday'] = wsConvertWindspeed($maxgustyest, $from);
    $ws['gustMaxMonth'] = wsConvertWindspeed($mrecordwindgust, $from);
    $ws['gustMaxYear'] = wsConvertWindspeed($yrecordwindgust, $from);
    if ($ws['gustAct'] <= $ws['windAct']) {
        $ws['gustAct'] = $ws['windAct'];
    }
    # ------------------------------------------  UV   ---------------------------------------
    $ws['uvMaxTodayTime'] = wdDate($highuvtime);
    $ws['uvMaxYdayTime'] = wdDate($highuvyesttime);
    $ws['uvMaxMonthTime'] = wdYMD($mrecordhighuvyear, $mrecordhighuvmonth, $mrecordhighuvday);
    $ws['uvMaxYearTime'] = wdYMD($yrecordhighuvyear, $yrecordhighuvmonth, $yrecordhighuvday);
    $ws['uvAct'] = $VPuv;
    $ws['uvMaxToday'] = $highuv;
    $ws['uvMaxYday'] = $highuvyest;
    $ws['uvMaxMonth'] = $mrecordhighuv;
    $ws['uvMaxYear'] = $yrecordhighuv;
    # ------------------------------------------ Solar  --------------------------------------
    $ws['solarMaxTodayTime'] = wdDate($highsolartime);
    $ws['solarMaxYdayTime'] = wdDate($highsolaryesttime);
    $ws['solarMaxMonthTime'] = wdYMD($mrecordhighsolaryear, $mrecordhighsolarmonth, $mrecordhighsolarday);
    $ws['solarMaxYearTime'] = wdYMD($yrecordhighsolaryear, $yrecordhighsolarmonth, $yrecordhighsolarday);
    $ws['solarAct'] = $VPsolar * 1.0;
    $ws['solActPerc'] = $currentsolarpercent;
    $ws['solarMaxToday'] = $highsolar;
    $ws['solarMaxYday'] = $highsolaryest;
    $ws['solarMaxMonth'] = $mrecordhighsolar;
    $ws['solarMaxYear'] = $yrecordhighsolar;
    # ------------------------------------------ cloud height --------------------------------
    $from = 'ft';
    $ws['cloudHeight'] = wsConvertDistance($cloudheightfeet, $from);
    # ------------------------------------------ forecasts -----------------------------------
    $ws['fcstWD'] = $iconnumber;
    $ws['fcstTxt'] = $vpforecasttext;
    # ------------------------------------------ sun and moon --------------------------------
    $ws['sunrise'] = date($SITE['timeOnlyFormat'], strtotime($sunrise));
    $ws['sunset'] = date($SITE['timeOnlyFormat'], strtotime($sunset));
    $ws['moonrise'] = date($SITE['timeOnlyFormat'], strtotime($moonrise));
    $ws['moonset'] = date($SITE['timeOnlyFormat'], strtotime($moonset));
    $ws['lunarPhasePerc'] = $moonphase * 1.0;
    $ws['lunarAge'] = substr($moonage, 9, 3);
    // %moonphasename% %moonlunation%
    # ------------------------------------------ some more -----------------------------------
    $ws['wsVersion'] = "version {$wdversiononly} b {$wdbuild}";
    $ws['wsHardware'] = '';
    // unknown
    $ws['wsUptime'] = $windowsuptime;
    if (!isset($wsTrends)) {
        $wsTrends = array();
    }
    $i = 0;
    $wsTrends[$i]['min'] = 0;
    $wsTrends[$i]['temp'] = $temp0minuteago;
    $wsTrends[$i]['wind'] = $wind0minuteago;
    $wsTrends[$i]['gust'] = $gust0minuteago;
    $wsTrends[$i]['dir'] = langtransstr($dir0minuteago);
    $wsTrends[$i]['hum'] = $hum0minuteago;
    $wsTrends[$i]['dew'] = $dew0minuteago;
    $wsTrends[$i]['baro'] = $baro0minuteago;
    $wsTrends[$i]['rain'] = $rain0minuteago;
    $wsTrends[$i]['sol'] = $VPsolar0minuteago;
    $wsTrends[$i]['uv'] = $VPuv0minuteago;
    $i = 1;
    $wsTrends[$i]['min'] = 5;
    $wsTrends[$i]['temp'] = $temp5minuteago;
    $wsTrends[$i]['wind'] = $wind5minuteago;
    $wsTrends[$i]['gust'] = $gust5minuteago;
    $wsTrends[$i]['dir'] = langtransstr($dir5minuteago);
    $wsTrends[$i]['hum'] = $hum5minuteago;
    $wsTrends[$i]['dew'] = $dew5minuteago;
    $wsTrends[$i]['baro'] = $baro5minuteago;
    $wsTrends[$i]['rain'] = $rain5minuteago;
    $wsTrends[$i]['sol'] = $VPsolar5minuteago;
    $wsTrends[$i]['uv'] = $VPuv5minuteago;
    $i = 2;
    $wsTrends[$i]['min'] = 10;
    $wsTrends[$i]['temp'] = $temp10minuteago;
    $wsTrends[$i]['wind'] = $wind10minuteago;
    $wsTrends[$i]['gust'] = $gust10minuteago;
    $wsTrends[$i]['dir'] = langtransstr($dir10minuteago);
    $wsTrends[$i]['hum'] = $hum10minuteago;
    $wsTrends[$i]['dew'] = $dew10minuteago;
    $wsTrends[$i]['baro'] = $baro10minuteago;
    $wsTrends[$i]['rain'] = $rain10minuteago;
    $wsTrends[$i]['sol'] = $VPsolar10minuteago;
    $wsTrends[$i]['uv'] = $VPuv10minuteago;
    $i = 3;
    $wsTrends[$i]['min'] = 15;
    $wsTrends[$i]['temp'] = $temp15minuteago;
    $wsTrends[$i]['wind'] = $wind15minuteago;
    $wsTrends[$i]['gust'] = $gust15minuteago;
    $wsTrends[$i]['dir'] = langtransstr($dir15minuteago);
    $wsTrends[$i]['hum'] = $hum15minuteago;
    $wsTrends[$i]['dew'] = $dew15minuteago;
    $wsTrends[$i]['baro'] = $baro15minuteago;
    $wsTrends[$i]['rain'] = $rain15minuteago;
    $wsTrends[$i]['sol'] = $VPsolar15minuteago;
    $wsTrends[$i]['uv'] = $VPuv15minuteago;
    $i = 4;
    $wsTrends[$i]['min'] = 20;
    $wsTrends[$i]['temp'] = $temp20minuteago;
    $wsTrends[$i]['wind'] = $wind20minuteago;
    $wsTrends[$i]['gust'] = $gust20minuteago;
    $wsTrends[$i]['dir'] = langtransstr($dir20minuteago);
    $wsTrends[$i]['hum'] = $hum20minuteago;
    $wsTrends[$i]['dew'] = $dew20minuteago;
    $wsTrends[$i]['baro'] = $baro20minuteago;
    $wsTrends[$i]['rain'] = $rain20minuteago;
    $wsTrends[$i]['sol'] = $VPsolar20minuteago;
    $wsTrends[$i]['uv'] = $VPuv20minuteago;
    $i = 5;
    $wsTrends[$i]['min'] = 30;
    $wsTrends[$i]['temp'] = $temp30minuteago;
    $wsTrends[$i]['wind'] = $wind30minuteago;
    $wsTrends[$i]['gust'] = $gust30minuteago;
    $wsTrends[$i]['dir'] = langtransstr($dir30minuteago);
    $wsTrends[$i]['hum'] = $hum30minuteago;
    $wsTrends[$i]['dew'] = $dew30minuteago;
    $wsTrends[$i]['baro'] = $baro30minuteago;
    $wsTrends[$i]['rain'] = $rain30minuteago;
    $wsTrends[$i]['sol'] = $VPsolar30minuteago;
    $wsTrends[$i]['uv'] = $VPuv30minuteago;
    $i = 6;
    $wsTrends[$i]['min'] = 45;
    $wsTrends[$i]['temp'] = $temp45minuteago;
    $wsTrends[$i]['wind'] = $wind45minuteago;
    $wsTrends[$i]['gust'] = $gust45minuteago;
    $wsTrends[$i]['dir'] = langtransstr($dir45minuteago);
    $wsTrends[$i]['hum'] = $hum45minuteago;
    $wsTrends[$i]['dew'] = $dew45minuteago;
    $wsTrends[$i]['baro'] = $baro45minuteago;
    $wsTrends[$i]['rain'] = $rain45minuteago;
    $wsTrends[$i]['sol'] = $VPsolar45minuteago;
    $wsTrends[$i]['uv'] = $VPuv45minuteago;
    $i = 7;
    $wsTrends[$i]['min'] = 60;
    $wsTrends[$i]['temp'] = $temp60minuteago;
    $wsTrends[$i]['wind'] = $wind60minuteago;
    $wsTrends[$i]['gust'] = $gust60minuteago;
    $wsTrends[$i]['dir'] = langtransstr($dir60minuteago);
    $wsTrends[$i]['hum'] = $hum60minuteago;
    $wsTrends[$i]['dew'] = $dew60minuteago;
    $wsTrends[$i]['baro'] = $baro60minuteago;
    $wsTrends[$i]['rain'] = $rain60minuteago;
    $wsTrends[$i]['sol'] = $VPsolar60minuteago;
    $wsTrends[$i]['uv'] = $VPuv60minuteago;
    $i = 8;
    $wsTrends[$i]['min'] = 75;
    $wsTrends[$i]['temp'] = $temp75minuteago;
    $wsTrends[$i]['wind'] = $wind75minuteago;
    $wsTrends[$i]['gust'] = $gust75minuteago;
    $wsTrends[$i]['dir'] = langtransstr($dir75minuteago);
    $wsTrends[$i]['hum'] = $hum75minuteago;
    $wsTrends[$i]['dew'] = $dew75minuteago;
    $wsTrends[$i]['baro'] = $baro75minuteago;
    $wsTrends[$i]['rain'] = $rain75minuteago;
    $wsTrends[$i]['sol'] = $VPsolar75minuteago;
    $wsTrends[$i]['uv'] = $VPuv75minuteago;
    $i = 9;
    $wsTrends[$i]['min'] = 90;
    $wsTrends[$i]['temp'] = $temp90minuteago;
    $wsTrends[$i]['wind'] = $wind90minuteago;
    $wsTrends[$i]['gust'] = $gust90minuteago;
    $wsTrends[$i]['dir'] = langtransstr($dir90minuteago);
    $wsTrends[$i]['hum'] = $hum90minuteago;
    $wsTrends[$i]['dew'] = $dew90minuteago;
    $wsTrends[$i]['baro'] = $baro90minuteago;
    $wsTrends[$i]['rain'] = $rain90minuteago;
    $wsTrends[$i]['sol'] = $VPsolar90minuteago;
    $wsTrends[$i]['uv'] = $VPuv90minuteago;
    $i = 10;
    $wsTrends[$i]['min'] = 105;
    $wsTrends[$i]['temp'] = $temp105minuteago;
    $wsTrends[$i]['wind'] = $wind105minuteago;
    $wsTrends[$i]['gust'] = $gust105minuteago;
    $wsTrends[$i]['dir'] = langtransstr($dir105minuteago);
    $wsTrends[$i]['hum'] = $hum105minuteago;
    $wsTrends[$i]['dew'] = $dew105minuteago;
    $wsTrends[$i]['baro'] = $baro105minuteago;
    $wsTrends[$i]['rain'] = $rain105minuteago;
    $wsTrends[$i]['sol'] = $VPsolar105minuteago;
    $wsTrends[$i]['uv'] = $VPuv105minuteago;
    $i = 11;
    $wsTrends[$i]['min'] = 120;
    $wsTrends[$i]['temp'] = $temp120minuteago;
    $wsTrends[$i]['wind'] = $wind120minuteago;
    $wsTrends[$i]['gust'] = $gust120minuteago;
    $wsTrends[$i]['dir'] = langtransstr($dir120minuteago);
    $wsTrends[$i]['hum'] = $hum120minuteago;
    $wsTrends[$i]['dew'] = $dew120minuteago;
    $wsTrends[$i]['baro'] = $baro120minuteago;
    $wsTrends[$i]['rain'] = $rain120minuteago;
    $wsTrends[$i]['sol'] = $VPsolar120minuteago;
    $wsTrends[$i]['uv'] = $VPuv120minuteago;
    for ($i = 0; $i < 12; $i++) {
        $wsTrends[$i]['temp'] = wsConvertTemperature($wsTrends[$i]['temp'], $from_temp);
        $wsTrends[$i]['dew'] = wsConvertTemperature($wsTrends[$i]['dew'], $from_temp);
        $wsTrends[$i]['baro'] = wsConvertBaro($wsTrends[$i]['baro'], $from_baro);
        $wsTrends[$i]['rain'] = wsConvertRainfall($wsTrends[$i]['rain'], $from_rain);
        $wsTrends[$i]['wind'] = wsConvertWindspeed($wsTrends[$i]['wind'], $from_wind);
        $wsTrends[$i]['gust'] = wsConvertWindspeed($wsTrends[$i]['gust'], $from_wind);
    }
    $ws['check_ok'] = '3.00';
    if (!isset($SITE['soilUsed']) || $SITE['soilUsed'] == false) {
        ob_clean();
        return;
    }
    $from = $uomtemp;
    # Temp sensor 1 actual value
    $ws['soilTempAct'][1] = wsConvertTemperature($soiltemp, $from);
    // convert and clean of units
    # Temp sensor 1 maximum value for today month and year
    $ws['soilTempMaxToday'][1] = wsConvertTemperature($maxsoiltemp, $from);
    $ws['soilTempMaxMonth'][1] = wsConvertTemperature($mrecordhighsoil, $from);
    $ws['soilTempMaxMonthTime'][1] = wdYMD($mrecordhighsoilyear, $mrecordhighsoilmonth, $mrecordhighsoilday);
    $ws['soilTempMaxYear'][1] = wsConvertTemperature($yrecordhighsoil, $from);
    $ws['soilTempMaxYearTime'][1] = wdYMD($yrecordhighsoilyear, $yrecordhighsoilmonth, $yrecordhighsoilday);
    $ws['soilTempMaxAlltime'][1] = wsConvertTemperature($recordhighsoil, $from);
    $ws['soilTempMaxAlltimeTime'][1] = wdYMD($recordhighsoilyear, $recordhighsoilmonth, $recordhighsoilday);
    # Temp sensor 1 minimum value for today month and year
    $ws['soilTempMinToday'][1] = wsConvertTemperature($minsoiltemp, $from);
    $ws['soilTempMinMonth'][1] = wsConvertTemperature($mrecordlowsoil, $from);
    $ws['soilTempMinMonthTime'][1] = wdYMD($mrecordlowsoilyear, $mrecordlowsoilmonth, $mrecordlowsoilday);
    $ws['soilTempMinYear'][1] = wsConvertTemperature($yrecordlowsoil, $from);
    $ws['soilTempMinYearTime'][1] = wdYMD($yrecordlowsoilyear, $yrecordlowsoilmonth, $yrecordlowsoilday);
    $ws['soilTempMinAlltime'][1] = wsConvertTemperature($recordlowsoil, $from);
    $ws['soilTempMinAlltimeTime'][1] = wdYMD($recordlowsoilyear, $recordlowsoilmonth, $recordlowsoilday);
    # Temp sensor 2 actual value & Values and time for  min and max  for today - month and year
    $ws['soilTempAct'][2] = wsConvertTemperature($VPsoiltemp2, $from);
    // convert and clean of units
    $ws['soilTempMaxToday'][2] = wsConvertTemperature($hiVPsoiltemp2, $from);
    $ws['soilTempMaxMonth'][2] = wsConvertTemperature($mrecordhighsoil2, $from);
    $ws['soilTempMaxMonthTime'][2] = wdYMD($mrecordhighsoilyear2, $mrecordhighsoilmonth2, $mrecordhighsoilday2);
    $ws['soilTempMaxYear'][2] = wsConvertTemperature($yrecordhighsoil2, $from);
    $ws['soilTempMaxYearTime'][2] = wdYMD($yrecordhighsoilyear2, $yrecordhighsoilmonth2, $yrecordhighsoilday2);
    $ws['soilTempMaxAlltime'][2] = wsConvertTemperature($recordhighsoil2, $from);
    $ws['soilTempMaxAlltimeTime'][2] = wdYMD($recordhighsoilyear2, $recordhighsoilmonth2, $recordhighsoilday2);
    $ws['soilTempMinToday'][2] = wsConvertTemperature($loVPsoiltemp2, $from);
    $ws['soilTempMinMonth'][2] = wsConvertTemperature($mrecordlowsoil2, $from);
    $ws['soilTempMinMonthTime'][2] = wdYMD($mrecordlowsoilyear2, $mrecordlowsoilmonth2, $mrecordlowsoilday2);
    $ws['soilTempMinYear'][2] = wsConvertTemperature($yrecordlowsoil2, $from);
    $ws['soilTempMinYearTime'][2] = wdYMD($yrecordlowsoilyear2, $yrecordlowsoilmonth2, $yrecordlowsoilday2);
    $ws['soilTempMinAlltime'][2] = wsConvertTemperature($recordlowsoil2, $from);
    $ws['soilTempMinAlltimeTime'][2] = wdYMD($recordlowsoilyear2, $recordlowsoilmonth2, $recordlowsoilday2);
    # Temp sensor 3 actual value & Values and time for  min and max  for today - month and year
    $ws['soilTempAct'][3] = wsConvertTemperature($VPsoiltemp3, $from);
    // convert and clean of units
    $ws['soilTempMaxToday'][3] = wsConvertTemperature($hiVPsoiltemp3, $from);
    $ws['soilTempMaxMonth'][3] = wsConvertTemperature($mrecordhighsoil3, $from);
    $ws['soilTempMaxMonthTime'][3] = wdYMD($mrecordhighsoilyear3, $mrecordhighsoilmonth3, $mrecordhighsoilday3);
    $ws['soilTempMaxYear'][3] = wsConvertTemperature($yrecordhighsoil3, $from);
    $ws['soilTempMaxYearTime'][3] = wdYMD($yrecordhighsoilyear3, $yrecordhighsoilmonth3, $yrecordhighsoilday3);
    $ws['soilTempMaxAlltime'][3] = wsConvertTemperature($recordhighsoil3, $from);
    $ws['soilTempMaxAlltimeTime'][3] = wdYMD($recordhighsoilyear3, $recordhighsoilmonth3, $recordhighsoilday3);
    $ws['soilTempMinToday'][3] = wsConvertTemperature($loVPsoiltemp3, $from);
    $ws['soilTempMinMonth'][3] = wsConvertTemperature($mrecordlowsoil3, $from);
    $ws['soilTempMinMonthTime'][3] = wdYMD($mrecordlowsoilyear3, $mrecordlowsoilmonth3, $mrecordlowsoilday3);
    $ws['soilTempMinYear'][3] = wsConvertTemperature($yrecordlowsoil3, $from);
    $ws['soilTempMinYearTime'][3] = wdYMD($yrecordlowsoilyear3, $yrecordlowsoilmonth3, $yrecordlowsoilday3);
    $ws['soilTempMinAlltime'][3] = wsConvertTemperature($recordlowsoil3, $from);
    $ws['soilTempMinAlltimeTime'][3] = wdYMD($recordlowsoilyear3, $recordlowsoilmonth3, $recordlowsoilday3);
    # Temp sensor 4 actual value & Values and time for  min and max  for today - month and year
    $ws['soilTempAct'][4] = wsConvertTemperature($VPsoiltemp4, $from);
    // convert and clean of units
    $ws['soilTempMaxToday'][4] = wsConvertTemperature($hiVPsoiltemp4, $from);
    $ws['soilTempMaxMonth'][4] = wsConvertTemperature($mrecordhighsoil4, $from);
    $ws['soilTempMaxMonthTime'][4] = wdYMD($mrecordhighsoilyear4, $mrecordhighsoilmonth4, $mrecordhighsoilday4);
    $ws['soilTempMaxYear'][4] = wsConvertTemperature($yrecordhighsoil4, $from);
    $ws['soilTempMaxYearTime'][4] = wdYMD($yrecordhighsoilyear4, $yrecordhighsoilmonth4, $yrecordhighsoilday4);
    $ws['soilTempMaxAlltime'][4] = wsConvertTemperature($recordhighsoil4, $from);
    $ws['soilTempMaxAlltimeTime'][4] = wdYMD($recordhighsoilyear4, $recordhighsoilmonth4, $recordhighsoilday4);
    $ws['soilTempMinToday'][4] = wsConvertTemperature($loVPsoiltemp4, $from);
    $ws['soilTempMinMonth'][4] = wsConvertTemperature($mrecordlowsoil4, $from);
    $ws['soilTempMinMonthTime'][4] = wdYMD($mrecordlowsoilyear4, $mrecordlowsoilmonth4, $mrecordlowsoilday4);
    $ws['soilTempMinYear'][4] = wsConvertTemperature($yrecordlowsoil4, $from);
    $ws['soilTempMinYearTime'][4] = wdYMD($yrecordlowsoilyear4, $yrecordlowsoilmonth4, $yrecordlowsoilday4);
    $ws['soilTempMinAlltime'][4] = wsConvertTemperature($recordlowsoil4, $from);
    $ws['soilTempMinAlltimeTime'][4] = wdYMD($recordlowsoilyear4, $recordlowsoilmonth4, $recordlowsoilday4);
    #
    # Moisture sensor 1 actual value
    $ws['moistAct'][1] = $VPsoilmoisture;
    # Moisture sensor 1 maximum value for today month and year
    $ws['moistMaxToday'][1] = $hiVPsoilmoisture;
    $ws['moistMaxMonth'][1] = $mrecordhighsoilmoist;
    $ws['moistMaxMonthTime'][1] = wdYMD($mrecordhighsoilmoistyear, $mrecordhighsoilmoistmonth, $mrecordhighsoilmoistday);
    $ws['moistMaxYear'][1] = $yrecordhighsoilmoist;
    $ws['moistMaxYearTime'][1] = wdYMD($yrecordhighsoilmoistyear, $yrecordhighsoilmoistmonth, $yrecordhighsoilmoistday);
    $ws['moistMaxAlltime'][1] = $recordhighsoilmoist;
    $ws['moistMaxAlltimeTime'][1] = wdYMD($recordhighsoilmoistyear, $recordhighsoilmoistmonth, $recordhighsoilmoistday);
    # Moisture sensor 1 mimimum value for today
    $ws['moistMinToday'][1] = $loVPsoilmoisture;
    # Moisture sensor 1 date/time maximum occured
    # Moisture sensor 2 actual value & Values and time for  min and max  for today - month and year
    $ws['moistAct'][2] = $VPsoilmoisture2;
    $ws['moistMaxToday'][2] = $hiVPsoilmoisture2;
    $ws['moistMinToday'][2] = $loVPsoilmoisture2;
    # Moisture sensor 3 actual value & Values and time for  min and max  for today - month and year
    $ws['moistAct'][3] = $VPsoilmoisture3;
    $ws['moistMaxToday'][3] = $hiVPsoilmoisture3;
    $ws['moistMinToday'][3] = $loVPsoilmoisture3;
    # Moisture sensor 4 actual value & Values and time for  min and max  for today - month and year
    $ws['moistAct'][4] = $VPsoilmoisture4;
    $ws['moistMaxToday'][4] = $hiVPsoilmoisture4;
    $ws['moistMinToday'][4] = $loVPsoilmoisture4;
    #
    $ws['moistAvMonth'][1] = $avtempjansoil;
    // Average soil temperature for january from your data
    $ws['moistAvMonth'][2] = $avtempfebsoil;
    $ws['moistAvMonth'][3] = $avtempmarsoil;
    $ws['moistAvMonth'][4] = $avtempaprsoil;
    $ws['moistAvMonth'][5] = $avtempmaysoil;
    $ws['moistAvMonth'][6] = $avtempjunsoil;
    $ws['moistAvMonth'][7] = $avtempjulsoil;
    $ws['moistAvMonth'][8] = $avtempaugsoil;
    $ws['moistAvMonth'][9] = $avtempsepsoil;
    $ws['moistAvMonth'][10] = $avtempoctsoil;
    $ws['moistAvMonth'][11] = $avtempnovsoil;
    $ws['moistAvMonth'][12] = $avtempdecsoil;
    $ws['moistAvMonthThisyear'][1] = $avtempjannowsoil;
    // Average soil temperature for january from your data, this year
    $ws['moistAvMonthThisyear'][2] = $avtempfebnowsoil;
    $ws['moistAvMonthThisyear'][3] = $avtempmarnowsoil;
    $ws['moistAvMonthThisyear'][4] = $avtempaprnowsoil;
    $ws['moistAvMonthThisyear'][5] = $avtempmaynowsoil;
    $ws['moistAvMonthThisyear'][6] = $avtempjunnowsoil;
    $ws['moistAvMonthThisyear'][7] = $avtempjulnowsoil;
    $ws['moistAvMonthThisyear'][8] = $avtempaugnowsoil;
    $ws['moistAvMonthThisyear'][9] = $avtempsepnowsoil;
    $ws['moistAvMonthThisyear'][10] = $avtempoctnowsoil;
    $ws['moistAvMonthThisyear'][11] = $avtempnovnowsoil;
    $ws['moistAvMonthThisyear'][12] = $avtempdecnowsoil;
    #-----------------------------------------------------------------------------------------
    # leaf sensor 1 - 4
    $ws['leafAct'][1] = $VPleaf;
    $ws['leafWetLast10'][1] = $leafminlast10min;
    // Minutes last 10 minutes leaf wetness was above zero
    $ws['leafWetLast60'][1] = $leafminlast60min;
    // Minutes last 10 minutes leaf wetness was above zero
    $ws['leafMaxToday'][1] = $hiVPleaf;
    $ws['leafMinToday'][1] = $loVPleaf;
    $ws['leafMaxMonth'][1] = $mrecordhighleaf;
    $ws['leafMaxYear'][1] = $yrecordhighleaf;
    $ws['leafMaxMonthTime'][1] = wdYMD($mrecordhighleafyear, $mrecordhighleafmonth, $mrecordhighleafday);
    $ws['leafMaxYearTime'][1] = wdYMD($yrecordhighleafyear, $yrecordhighleafmonth, $yrecordhighleafday);
    $ws['leafAct'][2] = $VPleaf2;
    $ws['leafHighToday'][2] = $hiVPleaf2;
    $ws['leafLowToday'][2] = $loVPleaf2;
    $ws['leafWetLast10'][2] = $leafminlast10min2;
    // Minutes last 10 minutes leaf wetness was above zero
    $ws['leafWetLast60'][2] = $leafminlast60min2;
    // Minutes last 10 minutes leaf wetness was above zero
    $ws['leafAct'][3] = $VPleaf3;
    $ws['leafAct'][4] = $VPleaf4;
    #-----------------------------------------------------------------------------------------
    ob_clean();
}
Пример #14
0
# Temp sensor 4 actual value & Values and time for  min and max  for today - month and year
$ws['soilTempAct'][4] = wsConvertTemperature('255', $from);
// convert and clean of units
$ws['soilTempMaxToday'][4] = wsConvertTemperature('-50.0', $from);
$ws['soilTempMaxMonth'][4] = wsConvertTemperature('%mrecordhighsoil3%', $from);
$ws['soilTempMaxMonthTime'][4] = wdYMD('%mrecordhighsoilyear3%', '%mrecordhighsoilmonth3%', '%mrecordhighsoilday3%');
$ws['soilTempMaxYear'][4] = wsConvertTemperature('%yrecordhighsoil3%', $from);
$ws['soilTempMaxYearTime'][4] = wdYMD('%yrecordhighsoilyear3%', '%yrecordhighsoilmonth3%', '%yrecordhighsoilday3%');
$ws['soilTempMaxAlltime'][4] = wsConvertTemperature('%recordhighsoil3%', $from);
$ws['soilTempMaxAlltimeTime'][4] = wdYMD('%recordhighsoilyear3%', '%recordhighsoilmonth3%', '%recordhighsoilday3%');
$ws['soilTempMinToday'][4] = wsConvertTemperature('100.0', $from);
$ws['soilTempMinMonth'][4] = wsConvertTemperature('%mrecordlowsoil3%', $from);
$ws['soilTempMinMonthTime'][4] = wdYMD('%mrecordlowsoilyear3%', '%mrecordlowsoilmonth3%', '%mrecordlowsoilday3%');
$ws['soilTempMinYear'][4] = wsConvertTemperature('%yrecordlowsoil3%', $from);
$ws['soilTempMinYearTime'][4] = wdYMD('%yrecordlowsoilyear3%', '%yrecordlowsoilmonth3%', '%yrecordlowsoilday3%');
$ws['soilTempMinAlltime'][4] = wsConvertTemperature('%recordlowsoil3%', $from);
$ws['soilTempMinAlltimeTime'][4] = wdYMD('%recordlowsoilyear3%', '%recordlowsoilmonth3%', '%recordlowsoilday3%');
#
# Moisture sensor 1 actual value
$ws['moistAct'][1] = '16.0';
# Moisture sensor 1 maximum value for today month and year
$ws['moistMaxToday'][1] = '16.0';
$ws['moistMaxMonth'][1] = '%mrecordhighsoilmoist%';
$ws['moistMaxMonthTime'][1] = wdYMD('%mrecordhighsoilmoistyear%', '%mrecordhighsoilmoistmonth%', '%mrecordhighsoilmoistday%');
$ws['moistMaxYear'][1] = '%yrecordhighsoilmoist%';
$ws['moistMaxYearTime'][1] = wdYMD('%yrecordhighsoilmoistyear%', '%yrecordhighsoilmoistmonth%', '%yrecordhighsoilmoistday%');
$ws['moistMaxAlltime'][1] = '%recordhighsoilmoist%';
$ws['moistMaxAlltimeTime'][1] = wdYMD('%recordhighsoilmoistyear%', '%recordhighsoilmoistmonth%', '%recordhighsoilmoistday%');
# Moisture sensor 1 mimimum value for today
$ws['moistMinToday'][1] = '0.0';
# Moisture sensor 1 date/time maximum occured
Пример #15
0
function myCommonTemperature($value)
{
    global $SITE, $tempArray2, $tempSimple;
    $color = 'red';
    $temp = round($value);
    if (strpos($SITE['uomTemp'], 'C')) {
        $colorTemp = $temp + 32;
    } else {
        $colorTemp = 32 + round(wsConvertTemperature($value, 'F', 'C'));
    }
    // for the color lookup we need C as unit
    if (!$tempSimple) {
        if ($colorTemp < 0) {
            $colorTemp = 0;
        } elseif ($colorTemp >= count($tempArray2)) {
            $colorTemp = count($tempArray2) - 1;
        }
        $color = $tempArray2[$colorTemp];
        $tempString = '<span class="myTemp" style="text-shadow:1px 1px black; font-weight: bolder; font-size: 200%; color: ' . $color . ';" >' . $temp . '&deg;</span>';
    } else {
        if ($colorTemp < 32) {
            $color = 'blue';
        } else {
            $color = 'red';
        }
        $tempString = '<span class="myTemp" style="text-shadow:1px 1px black; font-weight: bolder; font-size: 150%; color: ' . $color . ';" >' . $temp . '&deg;</span>';
    }
    return $tempString;
}
Пример #16
0
 $ws['solarMaxYday'] = $wx['solarMaxYday'];
 $ws['solarMaxYdayTime'] = $wx['solarMaxYdayTime'];
 $fromYday = $wx['fromtempYday'];
 if (isset($SITE['soilUsed']) && $SITE['soilUsed'] && $SITE['soilCount'] * 1.0 > 0) {
     $soils = round($SITE['soilCount']);
 } else {
     $soils = 0;
 }
 if ($soils > 4) {
     echo '<!-- reset nr of soil sensors from ' . $SITE['soilCount'] . ' to max 4 -->' . PHP_EOL;
     $soils = 4;
 }
 for ($n = 1; $n <= $soils; $n++) {
     $ws['soilTempMaxYday'][$n] = wsConvertTemperature($wx['soilTempMaxYday_' . $n], $fromYday);
     $ws['soilTempMaxYdayTime'][$n] = $wx['soilTempMaxYdayTime_' . $n];
     $ws['soilTempMinYday'][$n] = wsConvertTemperature($wx['soilTempMinYday_' . $n], $fromYday);
     $ws['soilTempMinYdayTime'][$n] = $wx['soilTempMinYdayTime_' . $n];
     $ws['moistMaxYday'][$n] = $wx['moistMaxYday_' . $n];
     $ws['moistMaxYdayTime'][$n] = $wx['moistMaxYdayTime_' . $n];
     $ws['moistMinYday'][$n] = $wx['moistMinYday_' . $n];
     $ws['moistMinYdayTime'][$n] = $wx['moistMinYdayTime_' . $n];
 }
 $leafs = round($SITE['leafCount']);
 if ($leafs > 4) {
     echo '<!-- reset nr of leaf sensors from ' . $SITE['leafCount'] . ' to max 4 -->' . PHP_EOL;
     $leafs = 4;
 }
 for ($n = 1; $n <= $leafs; $n++) {
     $ws['leafWetMaxYday'][$n] = $wx['leafWetMaxYday_' . $n];
     $ws['leafWetMaxYdayTime'][$n] = $wx['leafWetMaxYdayTime_' . $n];
     $ws['leafWetMinYday'][$n] = $wx['leafWetMinYday_' . $n];
Пример #17
0
     echo "&nbsp;";
 }
 echo '</td></tr>' . PHP_EOL;
 $td_left = '  <tr><td style="text-align: right; padding-right: 5px;">';
 $td_right = '      <td style="text-align: left; padding-left: 5px; font-weight: bold;">';
 foreach ($toDisplay as $key => $legend) {
     switch ($key) {
         case 'windchill_c':
         case 'heatindex_c':
         case 'dewpoint_c':
         case 'temp':
             if (!isset($mtr[$key])) {
                 break;
             }
             echo $td_left . $legend . ':</td>';
             $value = round(wsConvertTemperature($mtr[$key], 'c', $SITE["uomTemp"]), $SITE["decTemp"]);
             echo $td_right . $value . $SITE["uomTemp"] . '</td></tr>' . PHP_EOL;
             break;
         case 'humidity':
             if (!isset($mtr[$key])) {
                 break;
             }
             echo $td_left . $legend . ':</td>' . $td_right . $mtr[$key] . '%</td></tr>' . PHP_EOL;
             break;
         case 'slp_hpa':
             if (!isset($mtr[$key])) {
                 break;
             }
             echo $td_left . $legend . ':</td>';
             $value = round(wsConvertBaro($mtr[$key], 'hpa', $SITE["uomBaro"]), $SITE["decBaro"]);
             echo $td_right . $value . $SITE["uomBaro"] . '</td></tr>' . PHP_EOL;
Пример #18
0
 #        $soilMoistMinYearTime   = explode ('#',$wx['soilMoistMinYearTime']);
 #        $soilMoistMinAll        = explode ('#',$wx['soilMoistMinAll']);
 #        $soilMoistMinAllTime    = explode ('#',$wx['soilMoistMinAllTime']);
 for ($n = 1; $n <= $soils; $n++) {
     $i = $n - 1;
     $ws['soilTempAct'][$n] = wsConvertTemperature($soilTempAct[$i], $from_temp);
     $ws['soilTempMaxToday'][$n] = wsConvertTemperature($soilTempMaxToday[$i], $from_temp);
     /*               $ws['soilTempMaxTodayTime'][$n] = cw_ymd                ($soilTempMaxTodayTime[$i]); 
                     $ws['soilTempMaxMonth'][$n]     = wsConvertTemperature  ($soilTempMaxMonth[$i],$from_temp);
                     $ws['soilTempMaxMonthTime'][$n] = cw_ymd                ($soilTempMaxMonthTime[$i]);
                     $ws['soilTempMaxYear'][$n]      = wsConvertTemperature  ($soilTempMaxYear[$i],$from_temp);
                     $ws['soilTempMaxYearTime'][$n]  = cw_ymd                ($soilTempMaxYearTime[$i]); 
                     $ws['soilTempMaxAll'][$n]       = wsConvertTemperature  ($soilTempMaxAll[$i],$from_temp);
                     $ws['soilTempMaxAllTime'][$n]   = cw_ymd                ($soilTempMaxAllTime[$i]);
      */
     $ws['soilTempMinToday'][$n] = wsConvertTemperature($soilTempMinToday[$i], $from_temp);
     /*                $ws['soilTempMinTodayTime'][$n] = cw_ymd                ($soilTempMinTodayTime[$i]);
                     $ws['soilTempMinMonth'][$n]     = wsConvertTemperature  ($soilTempMinMonth[$i],$from_temp);
                     $ws['soilTempMinMonthTime'][$n] = cw_ymd                ($soilTempMinMonthTime[$i]);
                     $ws['soilTempMinYear'][$n]      = wsConvertTemperature  ($soilTempMinYear[$i],$from_temp);
                     $ws['soilTempMinYearTime'][$n]  = cw_ymd                ($soilTempMinYearTime[$i]);
                     $ws['soilTempMinAll'][$n]       = wsConvertTemperature  ($soilTempMinAll[$i],$from_temp);
                     $ws['soilTempMinAllTime'][$n]   = cw_ymd                ($soilTempMinAllTime[$i]);
     */
     $ws['moistAct'][$n] = $soilMoistAct[$i] * 1.0;
     $ws['moistMaxToday'][$n] = $soilMoistMaxToday[$i] * 1.0;
     $ws['moistMinToday'][$n] = $soilMoistMinToday[$i] * 1.0;
     /*                if ($n == 1) {
                             $ws['moistMaxMonth'][$n]	= $soilMoistMaxMonth[$i]*1.0;
                             $ws['moistMaxYear'][$n]	        = $soilMoistMaxYear[$i]*1.0;
                             $ws['moistMaxAlltime'][$n]	= $soilMoistMaxAll[$i]*1.0;
Пример #19
0
// ns
$ws['baroTrends'] = $wx['baroArray'];
$ws['rainTrends'] = $wx['rainArray'];
$ws['uvTrends'] = $wx['uvArray'];
$ws['solarTrends'] = $wx['solarArray'];
# ---------------------------------------     Yesterday ----------------
$from = $wx['fromtempYday'];
$ws['tempMinYday'] = wsConvertTemperature($wx['tempMinYday'], $from);
$ws['tempMinYdayTime'] = $wx['tempMinYdayTime'];
$ws['tempMaxYday'] = wsConvertTemperature($wx['tempMaxYday'], $from);
$ws['tempMaxYdayTime'] = $wx['tempMaxYdayTime'];
$ws['dewpMinYday'] = wsConvertTemperature($wx['dewpMinYday'], $from);
$ws['dewpMinYdayTime'] = $wx['dewpMinYdayTime'];
$ws['dewpMaxYday'] = wsConvertTemperature($wx['dewpMaxYday'], $from);
$ws['dewpMaxYdayTime'] = $wx['dewpMaxYdayTime'];
$ws['chilMinYday'] = wsConvertTemperature($wx['chilMinYday'], $from);
$ws['chilMinYdayTime'] = $wx['chilMinYdayTime'];
$from = $wx['frombaroYday'];
$ws['baroMinYday'] = wsConvertBaro($wx['baroMinYday'], $from);
$ws['baroMinYdayTime'] = $wx['baroMinYdayTime'];
$ws['baroMaxYday'] = wsConvertBaro($wx['baroMaxYday'], $from);
$ws['baroMaxYdayTime'] = $wx['baroMaxYdayTime'];
# hum
$ws['humiMinYday'] = $wx['humiMinYday'];
$ws['humiMinYdayTime'] = $wx['humiMinYdayTime'];
$ws['humiMaxYday'] = $wx['humiMaxYday'];
$ws['humiMaxYdayTime'] = $wx['humiMaxYdayTime'];
$from = $wx['fromrainYday'];
$ws['rainRateYday'] = wsConvertRainfall($wx['rainRateYday'], $from);
$ws['rainYday'] = wsConvertRainfall($wx['rainYday'], $from);
$ws['etYday'] = wsConvertRainfall($wx['etYday'], $from);
Пример #20
0
 public function getWeatherData($userLocation = '')
 {
     global $SITE, $pageName;
     #----------------------------------------------------------------------------------------------
     $this->location = $userLocation = $SITE['latitude'] . ',' . $SITE['longitude'];
     #----------------------------------------------------------------------------------------------
     # try loading data from cache
     #----------------------------------------------------------------------------------------------
     if ($this->enableCache && !empty($SITE['cacheDir'])) {
         $this->cachePath = $SITE['cacheDir'];
         $uoms = $SITE['uomTemp'] . '_' . $SITE['uomWind'] . '_' . $SITE['uomRain'];
         $from = array('&deg;', '∞', '/', ' ', ',');
         $name = $pageName . '_' . $this->location . '_' . $uoms;
         $name = str_replace($from, '', $name);
         $this->cacheFile = $this->cachePath . $name;
         $returnArray = $this->loadFromCache();
         // load from cache returns data only when its data is valid
         if (!empty($returnArray)) {
             // if data is in cache and valid return data to calling program
             return $returnArray;
         }
         // eo return to calling program
     }
     // eo check cache
     #----------------------------------------------------------------------------------------------
     # combine user constants and input (1)location (2)units for temp etc  to required url
     #http://free.worldweatheronline.com/feed/weather.ashx?q=leuven,belgium&format=xml&num_of_days=5&key=0f9bf9919c100150121001
     #----------------------------------------------------------------------------------------------
     $this->apiUrlpart[1] = $this->location;
     $this->apiUrlpart[3] = $this->key;
     for ($i = 0; $i < count($this->apiUrlpart); $i++) {
         $this->weatherApiUrl .= $this->apiUrlpart[$i];
     }
     #----------------------------------------------------------------------------------------------
     if ($this->makeRequest()) {
         $xml = new SimpleXMLElement($this->rawData);
         $returnArray = array();
         #--------------------------------------------------------------------------------------------------
         # first, get and save request info / units etc
         #--------------------------------------------------------------------------------------------------
         $i = 0;
         // headings
         $returnArray['request_info'][$i]['type'] = 'type';
         $returnArray['request_info'][$i]['city'] = 'city';
         $returnArray['request_info'][$i]['time'] = 'time';
         $returnArray['request_info'][$i]['uomTemp'] = 'uomTemp';
         $returnArray['request_info'][$i]['uomDistance'] = 'uomDistance';
         $returnArray['request_info'][$i]['uomBaro'] = 'uomBaro';
         $returnArray['request_info'][$i]['uomWind'] = 'uomWind';
         $i = 1;
         // data
         $returnArray['request_info'][$i]['type'] = (string) $xml->request->type;
         $returnArray['request_info'][$i]['city'] = (string) $xml->request->query;
         $returnArray['request_info'][$i]['time'] = (string) $xml->current_condition->observation_time;
         $returnArray['request_info'][$i]['uomTemp'] = '&deg;C';
         $returnArray['request_info'][$i]['uomDistance'] = ' km';
         $returnArray['request_info'][$i]['uomBaro'] = ' hpa';
         $returnArray['request_info'][$i]['uomWind'] = ' km/h';
         #--------------------------------------------------------------------------------------------------
         # get current condition descriptions
         #--------------------------------------------------------------------------------------------------
         $i = 0;
         // headings
         $returnArray['current_condition'][$i]['time'] = 'time';
         $returnArray['current_condition'][$i]['weatherCode'] = 'weatherCode';
         $returnArray['current_condition'][$i]['iconUrl'] = 'iconUrl';
         $returnArray['current_condition'][$i]['weatherDesc'] = 'description';
         $returnArray['current_condition'][$i]['tempNU'] = 'temp';
         $returnArray['current_condition'][$i]['temp'] = 'temp';
         $returnArray['current_condition'][$i]['windNU'] = 'wind';
         $returnArray['current_condition'][$i]['wind'] = 'wind';
         $returnArray['current_condition'][$i]['rainNU'] = 'rain';
         $returnArray['current_condition'][$i]['rain'] = 'rain';
         $returnArray['current_condition'][$i]['baroNU'] = 'baro';
         $returnArray['current_condition'][$i]['baro'] = 'baro';
         $returnArray['current_condition'][$i]['humidity'] = 'humidity';
         $returnArray['current_condition'][$i]['windDir'] = 'windDir';
         $returnArray['current_condition'][$i]['windDeg'] = 'windDeg';
         $returnArray['current_condition'][$i]['cloudCover'] = 'cloudCover';
         // ?  ??  percent ?
         $i = 1;
         // data
         $returnArray['current_condition'][$i]['time'] = (string) $xml->current_condition->observation_time;
         $returnArray['current_condition'][$i]['weatherCode'] = (string) $xml->current_condition->weatherCode;
         $returnArray['current_condition'][$i]['iconUrl'] = (string) $xml->current_condition->weatherIconUrl;
         $returnArray['current_condition'][$i]['weatherDesc'] = (string) $xml->current_condition->weatherDesc;
         $amount = (string) $xml->current_condition->temp_C;
         $returnArray['current_condition'][$i]['tempNU'] = (string) wsConvertTemperature($amount, $this->uomTemp, $SITE['uomTemp']);
         $returnArray['current_condition'][$i]['temp'] = (string) wsConvertTemperature($amount, $this->uomTemp, $SITE['uomTemp']) . $SITE['uomTemp'];
         $amount = (string) $xml->current_condition->windspeedKmph;
         $returnArray['current_condition'][$i]['windNU'] = (string) wsConvertWindspeed($amount, $this->uomWind, $SITE['uomWind']);
         $returnArray['current_condition'][$i]['wind'] = (string) wsConvertWindspeed($amount, $this->uomWind, $SITE['uomWind']) . $SITE['uomWind'];
         $amount = (string) $xml->current_condition->precipMM;
         $returnArray['current_condition'][$i]['rainNU'] = (string) wsConvertRainfall($amount, $this->uomRain, $SITE['uomRain']);
         $returnArray['current_condition'][$i]['rain'] = (string) wsConvertRainfall($amount, $this->uomRain, $SITE['uomRain']) . $SITE['uomRain'];
         $amount = (string) $xml->current_condition->pressure;
         $returnArray['current_condition'][$i]['baroNU'] = (string) wsConvertBaro($amount, $this->uomBaro, $SITE['uomBaro']);
         $returnArray['current_condition'][$i]['baro'] = (string) wsConvertBaro($amount, $this->uomBaro, $SITE['uomBaro']) . $SITE['uomBaro'];
         $returnArray['current_condition'][$i]['humidityNU'] = (string) $xml->current_condition->humidity;
         $returnArray['current_condition'][$i]['humidity'] = (string) $xml->current_condition->humidity . ' %';
         $returnArray['current_condition'][$i]['windDir'] = (string) $xml->current_condition->winddir16Point;
         $returnArray['current_condition'][$i]['windDeg'] = (string) $xml->current_condition->winddirDegree;
         $returnArray['current_condition'][$i]['cloudCover'] = (string) $xml->current_condition->cloudcover;
         // ?  ??  percent ?
         #--------------------------------------------------------------------------------------------------
         #  get forecast info
         #--------------------------------------------------------------------------------------------------
         $i = 0;
         $returnArray['forecast'][$i]['date'] = 'date';
         $returnArray['forecast'][$i]['weatherCode'] = 'weatherCode';
         $returnArray['forecast'][$i]['iconUrl'] = 'iconUrl';
         $returnArray['forecast'][$i]['weatherDesc'] = 'description';
         $returnArray['forecast'][$i]['tempLowNU'] = 'tempLow';
         $returnArray['forecast'][$i]['tempLow'] = 'tempLow';
         $returnArray['forecast'][$i]['tempHighNU'] = 'tempHigh';
         $returnArray['forecast'][$i]['tempHigh'] = 'tempHigh';
         $returnArray['forecast'][$i]['windNU'] = 'wind';
         $returnArray['forecast'][$i]['wind'] = 'wind';
         $returnArray['forecast'][$i]['rainNU'] = 'rain';
         $returnArray['forecast'][$i]['rain'] = 'rain';
         $returnArray['forecast'][$i]['windDir'] = 'windDir';
         $returnArray['forecast'][$i]['windDeg'] = 'windDeg';
         $i2 = count($xml->weather);
         for ($i = 1; $i <= $i2; $i++) {
             $returnArray['forecast'][$i]['date'] = strtotime((string) $xml->weather[$i - 1]->date);
             $returnArray['forecast'][$i]['weatherCode'] = (string) $xml->weather[$i - 1]->weatherCode;
             $returnArray['forecast'][$i]['iconUrl'] = (string) $xml->weather[$i - 1]->weatherIconUrl;
             $returnArray['forecast'][$i]['weatherDesc'] = langtransstr((string) $xml->weather[$i - 1]->weatherDesc);
             $amount = (string) $xml->weather[$i - 1]->tempMinC;
             $returnArray['forecast'][$i]['tempLowNU'] = (string) wsConvertTemperature($amount, $this->uomTemp, $SITE['uomTemp']);
             $returnArray['forecast'][$i]['tempLow'] = (string) $returnArray['forecast'][$i]['tempLowNU'] . $SITE['uomTemp'];
             $amount = (string) $xml->weather[$i - 1]->tempMaxC;
             $returnArray['forecast'][$i]['tempHighNU'] = (string) wsConvertTemperature($amount, $this->uomTemp, $SITE['uomTemp']);
             $returnArray['forecast'][$i]['tempHigh'] = (string) $returnArray['forecast'][$i]['tempHighNU'] . $SITE['uomTemp'];
             $amount = (string) $xml->weather[$i - 1]->windspeedKmph;
             $returnArray['forecast'][$i]['windNU'] = (string) wsConvertWindspeed($amount, $this->uomWind, $SITE['uomWind']);
             $returnArray['forecast'][$i]['wind'] = (string) $returnArray['forecast'][$i]['windNU'] . $SITE['uomWind'];
             $amount = (string) $xml->weather[$i - 1]->precipMM;
             $returnArray['forecast'][$i]['rainNU'] = (string) wsConvertRainfall($amount, $this->uomRain, $SITE['uomRain']);
             $returnArray['forecast'][$i]['rain'] = (string) $returnArray['forecast'][$i]['rainNU'] . $SITE['uomRain'];
             $returnArray['forecast'][$i]['windDir'] = (string) $xml->weather[$i - 1]->winddir16Point;
             $returnArray['forecast'][$i]['windDeg'] = (string) $xml->weather[$i - 1]->winddirDegree;
         }
         // eo for loop forecasts
         if ($this->enableCache && !empty($this->cachePath)) {
             $this->writeToCache($returnArray);
         }
         $this->rawdata = '';
         return $returnArray;
     }
     // eo makeRequest processing
     return false;
 }
Пример #21
0
 $to = array('-');
 $line = str_replace($from, $to, $line);
 #
 list($ID, $LAT, $LON, $year, $month, $day, $hour, $minute, $WDIR, $WSPD, $GST, $WVHT, $DPD, $APD, $MWD, $PRES, $PTDY, $ATMP, $WTMP, $DEWP, $VIS) = explode(' ', $line . str_repeat(' ', 30));
 # time
 $time = gmmktime($hour, $minute, 00, $month, $day, $year);
 $TIME = date($SITE['timeOnlyFormat'], $time);
 # air temp
 if ($ATMP != '-') {
     $temp = wsConvertTemperature($ATMP, $uom_in['temp']);
     $ATMP = wsNumber($temp, $SITE['decTemp']);
 }
 # water temp
 if ($WTMP != '-') {
     $found_wtmp = true;
     $temp = wsConvertTemperature($WTMP, $uom_in['temp']);
     $WTMP = wsNumber($temp, $SITE['decTemp']);
 }
 # wind description based on wind dir in degrees
 $WDSC = getWindDir($WDIR);
 //  180 degr => S
 # wind speed
 $wind = convertWind($WSPD);
 $WSPD = wsNumber($wind, $SITE['decWind']);
 # wind gust
 if ($GST != '-') {
     $found_gust = true;
     $wind = convertWind($GST);
     $GST = wsNumber($wind, $SITE['decWind']);
 }
 # pressure
Пример #22
0
     // this is the original text part for this day translated to the requested lang
     $wsWxsimPlain[$i]['cond'] = $WXSIMcond[$i];
 }
 $wsWxsimPlain[$i]['temp'] = wsConvertTemperature($WXSIMtempClean[$i], $uoms[0]);
 if ($WXSIMhumidex[$i] != '') {
     $wsWxsimPlain[$i]['humidex'] = wsConvertTemperature($WXSIMhumidex[$i], $uoms[0]);
 } else {
     $wsWxsimPlain[$i]['humidex'] = '';
 }
 if ($WXSIMwindchill[$i] != '') {
     $wsWxsimPlain[$i]['chill'] = wsConvertTemperature($WXSIMwindchill[$i], $uoms[0]);
 } else {
     $wsWxsimPlain[$i]['chill'] = '';
 }
 if ($WXSIMwindchill[$i] != '') {
     $wsWxsimPlain[$i]['heat'] = wsConvertTemperature($WXSIMheatidx[$i], $uoms[0]);
 } else {
     $wsWxsimPlain[$i]['heat'] = '';
 }
 $wsWxsimPlain[$i]['frost'] = $WXSIMfrost[$i];
 $wind = explode('-', $WXSIMwind[$i]);
 // 14-30&rarr;20-34    or 11&rarr;19-30
 $wind1 = $wind[0];
 if (wsFound($WXSIMwind[$i], '&rarr;')) {
     $arr = explode('&rarr;', $WXSIMwind[$i]);
     $wind = explode('-', $arr[1]);
     if ($wind[0] > $wind1) {
         $wind1 = $wind[0];
     }
 }
 echo '<!-- PP wind = ' . $WXSIMwind[$i] . ' result wind = ' . $wind1 . 'units = ' . $WXSIMwindunits[$i] . ' -->' . PHP_EOL;
Пример #23
0
$number_cities = 0;
$start_metar = microtime(true);
if (!function_exists('mtr_conditions')) {
    $script = $metar_folder . 'wsMetarTxt.php';
    ws_message('<!-- module dash_metar.php (' . __LINE__ . '): loading ' . $script . ' -->');
    include $script;
}
foreach ($my_metars as $key => $arr) {
    $mtr = mtr_conditions($key);
    if ($mtr == false) {
        unset($my_metars[$key]);
        continue;
    }
    $number_cities++;
    $my_metars[$key]['found'] = true;
    $my_metars[$key]['temp'] = round(wsConvertTemperature($mtr['temp'], 'C'), 0);
    $my_metars[$key]['iconurl'] = $mtr['icon_url'];
    $extra = $long_text = '';
    if (isset($mtr['conditions']) && $mtr['conditions'] != '') {
        $end = count($mtr['conditions']);
        for ($n1 = 0; $n1 < $end; $n1++) {
            $text = langtransstr($mtr['conditions'][$n1]);
            $long_text .= $extra . $text;
            $extra = ', ';
        }
    }
    if (isset($mtr['covers_max']) && $mtr['covers_max'] != '') {
        $text = langtransstr($mtr['covers_max']);
        $long_text .= $extra . $text;
    }
    $my_metars[$key]['desc'] = $long_text;
Пример #24
0
    $soilMoistMaxYday = explode('#', $wx['soilMoistMaxYday']);
    $soilMoistMaxYdayTime = explode('#', $wx['soilMoistMaxYdayTime']);
    $soilMoistMinToday = explode('#', $wx['soilMoistMinToday']);
    $soilMoistMinTodayTime = explode('#', $wx['soilMoistMinTodayTime']);
    $soilMoistMinYday = explode('#', $wx['soilMoistMinYday']);
    $soilMoistMinYdayTime = explode('#', $wx['soilMoistMinYdayTime']);
    for ($n = 1; $n <= $soils; $n++) {
        $i = $n - 1;
        $ws['soilTempAct'][$n] = wsConvertTemperature($soilTempAct[$i], $from_temp);
        $ws['soilTempMaxToday'][$n] = wsConvertTemperature($soilTempMaxToday[$i], $from_temp);
        $ws['soilTempMaxTodayTime'][$n] = wl_time($soilTempMaxTodayTime[$i]);
        $ws['soilTempMaxYday'][$n] = wsConvertTemperature($soilTempMaxYday[$i], $fromtempYday);
        $ws['soilTempMaxYdayTime'][$n] = wl_time($soilTempMaxYdayTime[$i]);
        $ws['soilTempMinToday'][$n] = wsConvertTemperature($soilTempMinToday[$i], $from_temp);
        $ws['soilTempMinTodayTime'][$n] = wl_time($soilTempMinTodayTime[$i]);
        $ws['soilTempMinYday'][$n] = wsConvertTemperature($soilTempMinYday[$i], $fromtempYday);
        $ws['soilTempMinYdayTime'][$n] = wl_time($soilTempMinYdayTime[$i]);
        $ws['moistAct'][$n] = $soilMoistAct[$i] * 1.0;
        $ws['moistMaxToday'][$n] = $soilMoistMaxToday[$i] * 1.0;
        $ws['moistMaxTodayTime'][$n] = wl_time($soilMoistMaxTodayTime[$i]);
        $ws['moistMaxYday'][$n] = $soilMoistMaxYday[$i] * 1.0;
        $ws['moistMaxYdayTime'][$n] = wl_time($soilMoistMaxYdayTime[$i]);
        $ws['moistMinToday'][$n] = $soilMoistMinToday[$i] * 1.0;
        $ws['moistMinTodayTime'][$n] = wl_time($soilMoistMinTodayTime[$i]);
        $ws['moistMinYday'][$n] = $soilMoistMinYday[$i] * 1.0;
        $ws['moistMinYdayTime'][$n] = wl_time($soilMoistMinYdayTime[$i]);
    }
}
// eo dosoil
if ($SITE['leafUsed'] && $SITE['leafCount'] >= '0') {
    $doleaf = true;
Пример #25
0
 public function getWeatherData($location = '')
 {
     global $SITE, $sunset, $sunrise, $pageName;
     $SITE['hwaIconsDir'] = 'wsHwa/hwa_icons/';
     # check if data (for this location) is in cache
     if ($this->enableCache && !empty($this->cachePath)) {
         $this->cachePath = $SITE['cacheDir'];
         $uoms = $SITE['uomTemp'] . '-' . $SITE['uomBaro'] . '-' . $SITE['uomRain'];
         $from = array('&deg;', '�', '/', ' ');
         $to = array('', '', '', '');
         $uoms = str_replace($from, $to, $uoms);
         $this->cacheFile = $this->cachePath . $pageName . '-' . $uoms;
         $returnArray = $this->loadFromCache();
         // load from cache returns data only when its data is valid
         if (!empty($returnArray)) {
             // if data is in cache and valid return data to calling program
             return $returnArray;
         }
         // eo return to calling program
     }
     // eo check cache
     #----------------------------------------------------------------------------------------------
     # combine user constants and input (1)location (2)units for temp etc  to required url
     #----------------------------------------------------------------------------------------------
     $this->apiUrlpart[0] = 'http://www.hetweeractueel.nl/includes/custom/mosfeed.php?id=';
     $this->apiUrlpart[1] = $SITE['hwaXmlId'];
     $this->apiUrlpart[2] = '&securitycode=';
     $this->apiUrlpart[3] = $SITE['hwaXmlKey'];
     $this->apiUrlpart[4] = '&extended=1';
     //		# combine thew params tinto a correct URL
     $this->weatherApiUrl = '';
     for ($i = 0; $i < count($this->apiUrlpart); $i++) {
         $this->weatherApiUrl .= $this->apiUrlpart[$i];
     }
     #----------------------------------------------------------------------------------------------
     if ($this->makeRequest()) {
         $xml = new SimpleXMLElement($this->rawData);
         //			echo "<pre>"; print_r ($xml);
         $returnArray = array();
         $rainSave = 0;
         $windSave = 0;
         $tempMaxSave = -100;
         $tempMinSave = +100;
         $windSave = 0;
         #--------------------------------------------------------------------------------------------------
         # first, get and save request info / units etc
         #--------------------------------------------------------------------------------------------------
         $i = 0;
         // headings
         $returnArray['request_info'][$i]['type'] = 'type';
         $returnArray['request_info'][$i]['city'] = 'city';
         $returnArray['request_info'][$i]['datum'] = 'date';
         $returnArray['request_info'][$i]['url'] = 'url';
         $returnArray['request_info'][$i]['timestamp'] = 'timestamp';
         $returnArray['request_info'][$i]['uomTemp'] = 'uomTemp';
         $returnArray['request_info'][$i]['uomBaro'] = 'uomBaro';
         $returnArray['request_info'][$i]['uomWind'] = 'uomWind';
         $returnArray['request_info'][$i]['uomRain'] = 'uomRain';
         $i = 1;
         // data
         $returnArray['request_info'][$i]['type'] = (string) $xml->Plaatsen->Plaats['id'];
         $returnArray['request_info'][$i]['city'] = (string) $xml->Plaatsen->Plaats['naam'];
         $returnArray['request_info'][$i]['datum'] = (string) $xml['aanmaakdatum'];
         $returnArray['request_info'][$i]['url'] = (string) $xml->Plaatsen->Plaats['alias'];
         $returnArray['request_info'][$i]['timestamp'] = strtotime($returnArray['request_info'][$i]['datum'] . (string) $xml['aanmaaktijd']);
         $returnArray['request_info'][$i]['uomTemp'] = '&deg;C';
         $returnArray['request_info'][$i]['uomBaro'] = 'hPa';
         $returnArray['request_info'][$i]['uomWind'] = ' bft';
         $returnArray['request_info'][$i]['uomRain'] = 'mm';
         #--------------------------------------------------------------------------------------------------
         #  get forecast info
         #--------------------------------------------------------------------------------------------------
         $i = 0;
         $returnArray['forecast'][$i]['date'] = 'date';
         $returnArray['forecast'][$i]['hour'] = 'hour';
         $returnArray['forecast'][$i]['timestamp'] = 'timestamp';
         #	EXTRA 12 hours data
         $returnArray['forecast'][$i]['iconL'] = 'icon';
         $returnArray['forecast'][$i]['iconUrlL'] = 'iconUrl';
         $returnArray['forecast'][$i]['weatherDescL'] = 'description';
         $returnArray['forecast'][$i]['part'] = 'Day/Night';
         $returnArray['forecast'][$i]['tempLowNU'] = 'tempLow';
         $returnArray['forecast'][$i]['tempLow'] = 'tempLow';
         $returnArray['forecast'][$i]['tempHighNU'] = 'tempHigh';
         $returnArray['forecast'][$i]['tempHigh'] = 'tempHigh';
         $returnArray['forecast'][$i]['rainChance'] = 'CoR';
         $returnArray['forecast'][$i]['snowChance'] = 'CoS';
         $returnArray['forecast'][$i]['thunderChance'] = 'CoT';
         #	6 hours data
         $returnArray['forecast'][$i]['rainNU'] = 'rain';
         $returnArray['forecast'][$i]['rain'] = 'rain';
         #   3 hours data
         $returnArray['forecast'][$i]['icon'] = 'icon';
         $returnArray['forecast'][$i]['iconUrl'] = 'iconUrl';
         $returnArray['forecast'][$i]['weatherDesc'] = 'description';
         $returnArray['forecast'][$i]['tempNU'] = 'temp';
         $returnArray['forecast'][$i]['temp'] = 'temp';
         $returnArray['forecast'][$i]['baro'] = 'baro';
         $returnArray['forecast'][$i]['windSpeedNU'] = 'wind';
         $returnArray['forecast'][$i]['windSpeed'] = 'wind';
         $returnArray['forecast'][$i]['windDir'] = 'windDir';
         $returnArray['forecast'][$i]['windDirIcon'] = 'windDirIcon';
         #
         $i2 = count($xml->Plaatsen->Plaats->Verwachtingen->Verwachting);
         $utcDiff = date('Z');
         // to help to correct utc differences
         for ($n = 1; $n <= $i2; $n++) {
             $arr = $xml->Plaatsen->Plaats->Verwachtingen->Verwachting[$n - 1];
             #				if (!isset($arr->weersymbool_12u) ){continue;}  // skip new 3 hour details
             $i++;
             $returnArray['forecast'][$i]['date'] = $datum = (string) $arr['datum'];
             // [date] => 20130424
             $returnArray['forecast'][$i]['hour'] = $hour = substr('00' . (string) $arr['uur'], -2);
             // [hour] => 12
             $timeString = $datum . 'T' . $hour . '0000';
             $returnArray['forecast'][$i]['timestamp'] = $timeOurs = $utcDiff + strtotime($timeString);
             $returnArray['forecast'][$i]['date'] = date('Ymd', $timeOurs);
             $returnArray['forecast'][$i]['hour'] = date('H', $timeOurs);
             #	12 hour forecast data
             if (isset($arr->weersymbool_12u)) {
                 $tekst = (string) $arr->weersymbool_12u;
                 $returnArray['forecast'][$i]['iconL'] = $tekst;
                 $returnArray['forecast'][$i]['iconUrlL'] = $SITE['hwaIconsDir'] . $tekst . $this->iconType;
                 $tekst = (string) $arr->weersomschrijving_12u;
                 if (!isset($this->descriptions[$tekst])) {
                     $returnArray['forecast'][$i]['weatherDescL'] = $tekst;
                 } else {
                     $returnArray['forecast'][$i]['weatherDescL'] = $this->descriptions[$tekst];
                 }
                 if (isset($arr->maximumtemperatuur)) {
                     $returnArray['forecast'][$i]['part'] = 'daytime';
                     $returnArray['forecast'][$i]['tempLow'] = $returnArray['forecast'][$i]['tempLowNU'] = '';
                     if ($amount < $tempMaxSave) {
                         $amount = $tempMaxSave;
                     }
                     $amount = (string) $arr->maximumtemperatuur;
                     $returnArray['forecast'][$i]['tempHighNU'] = $result = (string) wsConvertTemperature($amount, $this->uomTemp, $SITE['uomTemp']);
                     $returnArray['forecast'][$i]['tempHigh'] = $result . $SITE['uomTemp'];
                 } else {
                     $returnArray['forecast'][$i]['part'] = 'nighttime';
                     $amount = (string) $arr->minimumtemperatuur;
                     if ($amount > $tempMinSave) {
                         $amount = $tempMinSave;
                     }
                     $returnArray['forecast'][$i]['tempLowNU'] = $result = (string) wsConvertTemperature($amount, $this->uomTemp, $SITE['uomTemp']);
                     $returnArray['forecast'][$i]['tempLow'] = $result . $SITE['uomTemp'];
                     $returnArray['forecast'][$i]['tempHigh'] = $returnArray['forecast'][$i]['tempHighNU'] = '';
                 }
                 $returnArray['forecast'][$i]['rainChance'] = (int) $arr->neerslagkans;
                 $returnArray['forecast'][$i]['snowChance'] = (int) $arr->sneeuwkans;
                 $returnArray['forecast'][$i]['thunderChance'] = (int) $arr->onweerkans;
                 #
                 $amount = (string) $arr->neerslaghoeveelheid;
                 $result = (string) wsConvertRainfall($amount, $this->uomRain, $SITE['uomRain']);
                 $returnArray['forecast'][$i]['rainNUL'] = $result + $rainSave;
                 $returnArray['forecast'][$i]['rainL'] = $result + $rainSave . $SITE['uomRain'];
                 $amount = (int) $arr->windsnelheid;
                 if ($windSave > $amount) {
                     $amount = $windSave;
                 }
                 $returnArray['forecast'][$i]['windSpeedL'] = $amount . ' bft';
                 $returnArray['forecast'][$i]['windSpeedNUL'] = $amount;
                 #					echo '<!-- rain at '.$timeString.' '.($result + $rainSave).' == '.$returnArray['forecast'][$i]['rainL'] .'  -->'.PHP_EOL;
             }
             // eo 12 hour data
             # 	6 hours data
             if (isset($arr->neerslaghoeveelheid)) {
                 $amount = (string) $arr->neerslaghoeveelheid;
                 $returnArray['forecast'][$i]['rainNU'] = $result = (string) wsConvertRainfall($amount, $this->uomRain, $SITE['uomRain']);
                 $returnArray['forecast'][$i]['rain'] = $result . $SITE['uomRain'];
                 $rainSave = $rainSave + $result;
                 if (isset($arr->maximumtemperatuur)) {
                     $amount = (string) $arr->maximumtemperatuur;
                     $tempMaxSave = (string) wsConvertTemperature($amount, $this->uomTemp, $SITE['uomTemp']);
                 } else {
                     $amount = (string) $arr->minimumtemperatuur;
                     $tempMinSave = (string) wsConvertTemperature($amount, $this->uomTemp, $SITE['uomTemp']);
                 }
             }
             #	3 hours data
             $tekst = (string) $arr->weersymbool;
             if ($tekst == '') {
                 $string = '<!-- ' . $pageName . ' -- invalid input for ' . $timeString . ' -->' . PHP_EOL;
                 echo $string;
                 unset($returnArray['forecast'][$i]);
                 $i = $i - 1;
                 continue;
             }
             $returnArray['forecast'][$i]['icon'] = $tekst;
             $returnArray['forecast'][$i]['iconUrl'] = $SITE['hwaIconsDir'] . $tekst . $this->iconType;
             (string) $arr->weersymbool;
             $tekst = (string) $arr->weersomschrijving;
             if ($tekst == '') {
                 $string = '<!-- ' . $pageName . ' -- invalid input for ' . $timeString . ' -->' . PHP_EOL;
                 echo $string;
                 unset($returnArray['forecast'][$i]);
                 $i = $i - 1;
                 continue;
             }
             if (!isset($this->descriptions[$tekst])) {
                 $returnArray['forecast'][$i]['weatherDesc'] = $tekst;
             } else {
                 $returnArray['forecast'][$i]['weatherDesc'] = $this->descriptions[$tekst];
             }
             $amount = (string) $arr->temperatuur;
             $returnArray['forecast'][$i]['tempNU'] = $result = (string) wsConvertTemperature($amount, $this->uomTemp, $SITE['uomTemp']);
             $returnArray['forecast'][$i]['temp'] = $result . $SITE['uomTemp'];
             $amount = (string) $arr->luchtdruk;
             $returnArray['forecast'][$i]['baroNU'] = $result = (string) wsConvertBaro($amount, $this->uomBaro, $SITE['uomBaro']);
             $returnArray['forecast'][$i]['baro'] = (string) $arr->luchtdruk . $SITE['uomBaro'];
             $amount = (int) $arr->windsnelheid;
             $returnArray['forecast'][$i]['windSpeed'] = $amount . ' bft';
             $returnArray['forecast'][$i]['windSpeedNU'] = $amount;
             if ($amount > $windSave) {
                 $windSave = $amount;
             }
             $dir = strtoupper($arr->windrichting);
             if ($dir == '') {
                 $dir = 'N';
             }
             $returnArray['forecast'][$i]['windDir'] = $this->windDir[$dir];
             $returnArray['forecast'][$i]['windDirIcon'] = (string) $arr->windrichting;
             //				echo '<!--  '; print_r ($returnArray['forecast'][$i]);  echo ' -->';
             if (isset($arr->weersymbool_12u)) {
                 $rainSave = 0;
                 // 	used to gather 12 hour data for 6 hour data
                 $tempMaxSave = -100;
                 //  12 hours data from 3 hours data
                 $tempMinSave = +100;
                 //  same
                 $windSave = 0;
                 //  same
             }
         }
         // eo for loop forecasts
     }
     // eo makeRequest processing
     $this->rawdata = '';
     if (!isset($returnArray['forecast']) || count($returnArray['forecast']) < 3) {
         return $returnArray;
     }
     if ($this->enableCache && !empty($this->cachePath)) {
         $this->writeToCache($returnArray);
     }
     $this->rawdata = '';
     #		echo '<pre>'.PHP_EOL; print_r ($returnArray); exit;
     return $returnArray;
 }
Пример #26
0
function wsConvertArray($kind, $array, $usedunit, $reqUnit)
{
    if ($usedunit == $reqUnit) {
        return $array;
    }
    foreach ($array as $key => $value) {
        switch ($kind) {
            case 'temp':
                $array[$key] = wsConvertTemperature($value, $usedunit, $reqUnit);
                break;
            case 'wind':
                $array[$key] = wsConvertWindspeed($value, $usedunit, $reqUnit);
                break;
            case 'rain':
                $array[$key] = wsConvertRainfall($value, $usedunit, $reqUnit);
                break;
            case 'baro':
                $array[$key] = wsConvertBaro($value, $usedunit, $reqUnit);
                break;
        }
        // end switch
    }
    // end foreach
    return $array;
}