Horde_Service_Weather::degToDirection PHP 메소드

degToDirection() 공개 정적인 메소드

Utility function to return textual cardinal compass directions from degress.
부터: 2.3.0
public static degToDirection ( integer $degree ) : string
$degree integer The degree direction (0 - 360).
리턴 string The cardinal direction.
    public static function degToDirection($degree)
    {
        $cardinal = array('N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW');
        $deg_delta = (int) ($degree / 22.5 + 0.5);
        return $cardinal[$deg_delta % 16];
    }

Usage Example

예제 #1
0
파일: Owm.php 프로젝트: raz0rsdge/horde
 /**
  * Accessor so we can lazy-parse the results.
  *
  * @param string $property  The property name.
  *
  * @return mixed  The value of requested property
  * @throws Horde_Service_Weather_Exception_InvalidProperty
  */
 public function __get($property)
 {
     switch ($property) {
         case 'humidity':
         case 'precipitation_percent':
         case 'wind_gust':
         case 'snow_total':
         case 'rain_total':
             return false;
         case 'conditions':
             return Horde_Service_Weather_Translation::t($this->_properties->weather[0]->main);
         case 'is_pm':
             return false;
         case 'hour':
             return false;
         case 'date':
             return new Horde_Date($this->_properties->date);
         case 'high':
             return round($this->_properties->temp->day);
         case 'low':
             return round($this->_properties->temp->night);
         case 'icon':
             return $this->_forecast->weather->iconMap[str_replace('.png', '', $this->_properties->weather[0]->icon)];
         case 'wind_direction':
             return Horde_Service_Weather::degToDirection($this->_properties->deg);
         case 'wind_degrees':
             return $this->_properties->deg;
         case 'wind_speed':
             return $this->_properties->speed;
         default:
             throw new Horde_Service_Weather_Exception_InvalidProperty('This provider does not support the "' . $property . '" property');
     }
 }
All Usage Examples Of Horde_Service_Weather::degToDirection