/usr/share/php/Horde/Service/Weather/Current/Owm.php is in php-horde-service-weather 2.3.2-1ubuntu1.
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 | <?php
/**
* This file contains the Horde_Service_Weather_Current class for abstracting
* access to current observations from OpenWeatherMap.
*
* 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_Wwo class
*
* @author Michael J Rubinsky <mrubinsk@horde.org>
* @category Horde
* @package Service_Weather
*/
class Horde_Service_Weather_Current_Owm extends Horde_Service_Weather_Current_Base
{
protected $_map = array(
'wind_direction' => 'wind_dir'
);
public function __isset($property)
{
return !empty($this->_properties->$property);
}
public function __get($property)
{
// Maybe someday I can add a better $_map array with 'type' fields etc..
// for now, just as easy to manually check for these exceptions.
switch ($property) {
case 'wind_gust':
case 'dewpoint':
case 'heat_index':
case 'wind_chill':
case 'pressure_trend':
case 'logo_url':
case 'visibility':
return null;
case 'condition':
return Horde_Service_Weather_Translation::t($this->_properties->weather[0]->main);
case 'time':
return new Horde_Date($this->_properties->dt, 'UTC');
case 'time_utc':
return $this->time;
case 'temp':
return $this->_properties->main->temp;
case 'wind_speed':
return $this->_properties->wind->speed;
case 'wind_degrees':
return $this->_properties->wind->deg;
case 'wind_dir':
// @todo - Map degrees to direction.
return '';
case 'visibility':
if ($this->_weather->units == Horde_Service_Weather::UNITS_METRIC) {
return $this->_properties->visibility;
} else {
return round($this->_properties->visibility * Horde_Service_Weather::CONVERSION_KPH_TO_MPH);
}
case 'pressure':
return $this->_properties->main->pressure;
case 'humidity':
return $this->_properties->main->humidity . '%';
case 'icon':
return !empty($this->_weather->iconMap[$this->_properties->weather[0]->icon])
? $this->_weather->iconMap[$this->_properties->weather[0]->icon]
: 'na.png';
default:
if (empty($this->_map[$property])) {
throw new Horde_Service_Weather_Exception_InvalidProperty();
}
return Horde_Service_Weather_Translation::t($this->_properties->{$this->_map[$property]});
}
}
}
|