コード例 #1
0
 /**
  * @param  \SimpleXMLElement $xml
  * @return WeatherStation
  */
 public static function getWeatherStationFromXml(\SimpleXMLElement $xml)
 {
     $data = Yr::xmlToArray($xml);
     $name = $data['name'];
     $distance = $data['distance'];
     $latLong = array('lat' => $data['lat'], 'long' => $data['lon']);
     $source = $data['source'];
     $station = new WeatherStation($name, $distance, $latLong, $source);
     $forecast = $station->getForecast();
     if (isset($data['symbol'])) {
         $forecast->setSymbol($data['symbol']);
     }
     if (isset($data['temperature'])) {
         $forecast->setTemperature($data['temperature']);
     }
     if (isset($data['windDirection'])) {
         $forecast->setWindDirection($data['windDirection']);
     }
     if (isset($data['windSpeed'])) {
         $forecast->setWindSpeed($data['windSpeed']);
     }
     return $station;
 }
コード例 #2
0
<?php

require_once "../../../bootstrap.php";
WeatherStation::main($_SERVER["argv"]);
コード例 #3
0
ファイル: Yr.php プロジェクト: JanPetterMG/yr-php-library
 /**
  * @param  \SimpleXMLElement $xml
  *
  * @return WeatherStation[]
  */
 public static function getWeatherStationsFromXml(\SimpleXMLElement $xml)
 {
     $weather_stations = array();
     if (!empty($xml->observations)) {
         foreach ($xml->observations->weatherstation as $observation) {
             try {
                 $weather_stations[] = WeatherStation::getWeatherStationFromXml($observation);
             } catch (\Exception $e) {
                 // Skip those we cant create..
             }
         }
     }
     return $weather_stations;
 }
コード例 #4
0
ファイル: index.php プロジェクト: JarJarMP/MyToolbox
<?php

require_once 'WeatherStation.php';
require_once 'WeatherStationHeatIndex.php';
WeatherStation::index();
WeatherStationHeatIndex::index();