Пример #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;
 }
<?php

require_once "../../../bootstrap.php";
WeatherStation::main($_SERVER["argv"]);
Пример #3
0
 /**
  * @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
<?php

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