Beispiel #1
0
function setWeather()
{
    $weather = new Weather();
    $temp = $weather->getTemperature();
    $check = filter_var($temp, FILTER_VALIDATE_FLOAT);
    if (!$check) {
        return;
    }
    $temp2 = $weather->getTemperature(2);
    $code = $weather->getWeatherCode();
    $code2 = $weather->getWeatherCode(2);
    $icon = $weather->getWeatherIcon();
    $icon2 = $weather->getWeatherIcon(2);
    $description = $weather->getDescription();
    $description2 = $weather->getDescription(2);
    $id = $weather->getWeatherId();
    $id2 = $weather->getWeatherId(2);
    $date = date('Y-m-d H:i:s');
    $result = array();
    $result[] = array('code' => $code, 'temperature' => $temp, 'description' => $description, 'icon' => $icon, 'id' => $id, 'update' => $date);
    $result[] = array('code' => $code2, 'temperature' => $temp2, 'description' => $description2, 'icon' => $icon2, 'id' => $id2, 'update' => $date);
    $weather->setCachedWeather($result);
}
Beispiel #2
0
$events = $currentData->events;
foreach ($events as $event) {
    if (isset($event->cause) && isset($event->cause->senses)) {
        $cause = $event->cause;
        $senses = $cause->senses;
        foreach ($senses as $sense) {
            $weather->setValue($sense->sId, $sense->val, $sense->ts);
        }
    }
}
$horses = $database->getHorses();
$horseRows = array();
$currentHumidity = $weather->getHumidity();
$currentLuminance = $weather->getLuminance();
$currentPressure = $weather->getPressure();
$currentTemperature = $weather->getTemperature();
foreach ($horses as $horse) {
    $horseRow = $horse;
    $previousRaces = $database->getHorseRaces($horse->horse_id);
    $i = 0;
    $horseRow->temperature = countPercent($previousRaces, $currentTemperature, 'temperature');
    $horseRow->humidity = countPercent($previousRaces, $currentHumidity, 'humidity');
    $horseRow->luminance = countPercent($previousRaces, $currentLuminance, 'luminance');
    $horseRow->pressure = countPercent($previousRaces, $currentPressure, 'pressure');
    $horseRow->totalWinning = ($horseRow->humidity + $horseRow->luminance + $horseRow->pressure + $horseRow->temperature) / 4;
    array_push($horseRows, $horseRow);
}
function countPercent($previousRaces, $currenctHumidity, $field)
{
    $closestHumidity = 0;
    $humidityPosition = 0;