/usr/share/php/Horde/Service/Weather/Current/Metar.php is in php-horde-service-weather 2.5.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | <?php
/**
* Copyright 2011-2016 Horde LLC (http://www.horde.org/)
*
* @author Michael J Rubinsky <mrubinsk@horde.org>
* @license http://www.horde.org/licenses/bsd BSD
* @category Horde
* @package Service_Weather
*/
/**
* Horde_Service_Weather_Current_Metar
*
* Responsible for parsing encoded METAR text and presenting human readable
* weather data.
*
* Parsing code adapted from PEAR's Services_Weather_Metar class. Original
* phpdoc attributes as follows:
* @author Alexander Wirtz <alex@pc4p.net>
* @copyright 2005-2011 Alexander Wirtz
* @link http://pear.php.net/package/Services_Weather
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*
* @author Michael J Rubinsky <mrubinsk@horde.org>
* @category Horde
* @package Service_Weather
*/
class Horde_Service_Weather_Current_Metar extends Horde_Service_Weather_Current_Base
{
protected $_map = array(
'dewpoint' => 'dewPoint',
'wind_direction' => 'windDirection',
'wind_degrees' => 'windDegrees',
'wind_speed' => 'wind',
'wind_gust' => 'windGust',
'wind_chill' => 'feltTemperature',
'temp' => 'temperature',
);
/**
* Compatibility layer for old PEAR/Services_Weather data.
*
* @return array The raw parsed data array - keyed by descriptors that are
* compatible with PEAR/Services_Weather. The following keys may be
* returned:
*
* - station:
* - dataRaw:
* - update:
* - updateRaw:
* - wind:
* - windDegrees:
* - windDirection:
* - windGust:
* - windVariability:
* - visibility:
* - visQualifier:
* - clouds:
* - amount
* - height
* - type
* - temperature
* - dewpoint
* - humidity
* - felttemperature
* - pressure
* - trend
* - type
* - from
* - to
* - at
* - remark
* - autostation
* - seapressure
* - presschg
* - snowdepth
* - snowequiv
* - cloudtypes
* - sunduration
* - 1hrtemp
* - 1hrdew
* - 6hmaxtemp
* - 6hmintemp
* - 24hmaxtemp
* - 24hmintemp
* - 3hpresstrend
* - nospeci
* - sensors
* - maintain
* - precipitation
* - amount
* - hours
*/
public function getRawData()
{
$this->_properties['update'] = new Horde_Date($this->_properties['update']);
return $this->_properties;
}
public function __get($property)
{
switch ($property) {
// These are unsupported
case 'logo_url':
case 'heat_index':
case 'icon':
case 'icon_url':
return null;
case 'time':
return new Horde_Date($this->_properties['update'], 'GMT');
case 'pressure_trend':
return !empty($this->_properties['remark']['presschg'])
? $this->_properties['remark']['presschg']
: null;
case 'condition':
case 'conditions':
// Not really translatable from METAR data...but try to generate
// some sensible human readable data.
$units = $this->_weather->getUnits();
$conds = '';
if (!empty($this->_properties['wind'])) {
$conds .= sprintf(
Horde_Service_Weather_Translation::t('Wind from %s at %s%s '),
$this->_properties['windDirection'],
$this->_properties['wind'],
$units['wind']
);
}
// Visibility - this *should* always be here.
$conds .= sprintf(
Horde_Service_Weather_Translation::t('Visibility %s %s %s '),
$this->_properties['visQualifier'],
$this->_properties['visibility'],
$units['vis']
);
// @todo This isn't totally acurate since you could have e.g., BKN
// clouds below OVC cloud cover. Probably should iterate over all
// layers and just include the highest coverage.
if (!empty($this->_properties['clouds'])) {
$conds .= sprintf('Sky %s ',
$this->_properties['clouds'][0]['amount']
);
}
return trim($conds);
default:
if (!empty($this->_properties[$property])) {
return $this->_properties[$property];
} elseif (!empty($this->_map[$property])) {
return $this->_properties[$this->_map[$property]];
}
throw new Horde_Service_Weather_Exception_InvalidProperty();
}
}
}
|