Re: [Модуль] Погода от Openweather
Добавлено: Сб дек 02, 2017 10:15 am
хм...может только со старыми ключами работает...не требует cnt
А это в 5-дневном апи, или в 16-дневном?
А это в 5-дневном апи, или в 16-дневном?
nick7zmail писал(а):хм...может только со старыми ключами работает...не требует cnt
А это в 5-дневном апи, или в 16-дневном?
Код: Выделить всё
Warning: date() expects parameter 2 to be long, string given in /var/www/modules/app_openweather/app_openweather.class.php on line 280
Warning: date() expects parameter 2 to be long, string given in /var/www/modules/app_openweather/app_openweather.class.php on line 281
Warning: gmdate() expects parameter 2 to be long, string given in /var/www/modules/app_openweather/app_openweather.class.php on line 282Код: Выделить всё
$out["FORECAST"][$i]["sunrise"] = date("H:i:s", strtotime(gg('ow_day'.$i.'.sunrise')));
$out["FORECAST"][$i]["sunset"] = date("H:i:s", strtotime(gg('ow_day'.$i.'.sunset')));
$out["FORECAST"][$i]["day_length"] = gmdate("H:i", strtotime(gg('ow_day'.$i.'.day_length')));Код: Выделить всё
$query = "http://api.openweathermap.org/data/2.5/weather?id=" . $cityID . "&mode=json&units=" . $unit . "&cnt=16" . "&lang=ru" . "&appid=" . $apiKey;Код: Выделить всё
$weatherToday = '<b>Сегодня</b> до ';
$temp=gg('ow_day0.temp_max');
$temp = round($temp);
if($temp>0){$temp="+".$temp;} //Если значение температуры положительно, для наглядности добавляем "+"
$weatherToday.=$temp.'°';
$weatherToday.=', '.gg('ow_day0.weather_type').'. ';
$weatherToday.='Ветер '.round(gg('ow_day0.wind_speed'))." м/с. ";
//$weatherToday.='направление '.round(gg('ow_day0.wind_direction')).". ";
$weatherToday.='Влажность '.round(gg('ow_day0.humidity'))." %. ";
$weatherToday.='Давление '.round(gg('ow_day0.pressure_mmhg')).' миллиметров ртутного столба. ';
$weatherToday.='Ночью до ';
$temp=gg('ow_day0.temp_night');
$temp = round($temp);
if($temp>0){$temp="+".$temp;} //Если значение температуры положительно, для наглядности добавляем "+"
$weatherToday.=$temp.'°.';
$weatherTomorrow = '<b>Завтра</b> днём до ';
$temp=gg('ow_day1.temp_max');
$temp = round($temp);
if($temp>0){$temp="+".$temp;} //Если значение температуры положительно, для наглядности добавляем "+"
$weatherTomorrow.=$temp.'°';
$weatherTomorrow.=', '.gg('ow_day1.weather_type').'. ';
//$weatherTomorrow.='Влажность '.round(gg('ow_day1.humidity')).'. ';
$weatherTomorrow.='Давление '.round(gg('ow_day1.pressure_mmhg')).' миллиметров ртутного столба. ';
$weatherTomorrow.='Ночью до ';
$temp=gg('ow_day1.temp_night');
$temp = round($temp);
if($temp>0){$temp="+".$temp;} //Если значение температуры положительно, для наглядности добавляем "+"
$weatherTomorrow.=$temp.'°.';
$weatherTomorrowAfter = '<b>Послезавтра</b> днём до ';
$temp=gg('ow_day2.temp_max');
$temp = round($temp);
if($temp>0){$temp="+".$temp;} //Если значение температуры положительно, для наглядности добавляем "+"
$weatherTomorrowAfter.=$temp.'°';
$weatherTomorrowAfter.=', '.gg('ow_day2.weather_type').'. ';
//$weatherTomorrowAfter.='Влажность '.round(gg('ow_day2.humidity')).'. ';
$weatherTomorrowAfter.='Давление '.round(gg('ow_day2.pressure_mmhg')).' миллиметров ртутного столба. ';
$weatherTomorrowAfter.='Ночью до ';
$temp=gg('ow_day2.temp_night');
$temp = round($temp);
if($temp>0){$temp="+".$temp;} //Если значение температуры положительно, для наглядности добавляем "+"
$weatherTomorrowAfter.=$temp.'°.';
sg('ThisComputer.weatherToday', $weatherToday);
sg('ThisComputer.weatherTomorrow', $weatherTomorrow);
sg('ThisComputer.weatherTomorrowAfter', $weatherTomorrowAfter); Код: Выделить всё
//Температура 24ч. назад для сравнения
$tempYesterday = getHistoryValue("ow_fact.temperature", strtotime("-1 day"), true);
sg("ow_fact.tempYesterday", $tempYesterday);
//Расчет температуры "По ощущениям"
$t = gg('ow_fact.temperature'); // температура на улице
$h = gg('ow_fact.humidity'); // влажность на улице %
$w = gg('ow_fact.wind_speed'); // данные о ветре из прогноза OpenWeather m/s
$w = $w*3.6/1.609;//m/s -> mph
$tF = $t *1.8+32; // перевод температуры в Farenheit
if ($t > 26.6) { // Считаем HeatIndex по Rothfusz
$_f = -42.379 + 2.04901523*$tF + 10.14333127*$h - 0.22475541*$tF*$h - 0.00683783*$tF*$tF - 0.05481717*$h*$h + 0.00122874*$tF*$tF*$h + 0.00085282*$tF*$h*$h -0.00000199*$tF*$tF*$h*$h;
if(($tF < 112) && ( $h<13 )) { // If the RH is less than 13% and the temperature is between 80 and 112 degrees F, then the following adjustment is subtracted from HI:
$_f = $_f-((13-$h)/4)*sqrt((17-abs($tF-95.))/17);
}
if(($tF < 88) && ($h > 85)) { // On the other hand, if the RH is greater than 85% and the temperature is between 80 and 87 degrees F, then the following adjustment is added to HI:
$_f = $_f + (($h - 85) / 10) * ((87 - $tF) / 5); //ADJUSTMENT = [(RH-85)/10] * [(87-T)/5]
}
} else if ($t <= 10) { // Считаем фактор WindChild
$_f = 35.74 + (0.6215 * $tF) - (35.75 * pow($w, 0.16)) + ((0.4275 * $tF) * pow($w, 0.16));
} else { //считаем по упрощенной формуле
$_f = 0.5*($tF+61+(($tF-68)*1.2)+($h*0.094));
}
// переводим в цельсии
$rf = round(($_f-32)/1.8,1);
sg("ow_fact.realFell", $rf); Да хрен бы его знал как это нормально делается)) Сам с форком МД наверное час промучился пока нормально скопировалось...у меня был полугодовалой давности...че я ток не тыкал.ю..и сносил с диска, снова форкал, и в веб интерфейсе чето тыкал...короче хрен пойми каким чудом, но еле еле получилось...в общем я пока не разобрался =DLogrus писал(а):офф.: Никита, посмотрел, вроде б должен сам справится, но как обновить форк до последних изменений (чет я потыкался и тормозом себя ощутил((( )
ow_setting.forecast_interval засунуть в переменную по примеру апи-ключа и в строку запроса (пока только для 16 дней сделать)
Код: Выделить всё
sg('ow_ws.temperature', $temp); //где $temp - как раз полученная температура. И, соответственно отправляются раз в час, как и забирается вся остальная погода.Parameter Type & Units Description
station_id The internal ID of the station which is generated during creation
dt Unix Timestamp Time of measurement
temperature Celsius The air temperature
wind_speed m/s Wind speed
wind_gust m/s Maximum speed of wind gusts
wind_deg Degrees from 0 to 360 Wind direction
pressure Hectopascal Atmospheric pressure
humidity % Relative air humidity
rain_1h mm Rainfall in the last hour
rain_6h mm Rainfall in the last 6 hours
rain_24h mm Rainfall for the last days
snow_1h mm Snow in the last hour
snow_6h mm Snow in the last 6 hours
snow_24h mm Snow for the last days
dew_point Celsius Dew point
humidex Celsius Index of temperature and humidity
heat_index Celsius Heat index
visibility_distance km Distance of direct visibility, METAR
visibility_prefix N, E, S, W Prefix at distinctions of visibility in the directions, METAR
clouds[]:distance m Height of the lower bound of overcast, METAR
clouds[]:condition SKC, NSC, FEW, SCT, BKN, OVC Cloud amount, METAR
clouds[]:cumulus CB, TCU Convective overcast, METAR
weather[]:precipitation Additional description, METAR
weather[]:descriptor Additional description, METAR
weather[]:intensity Additional description, METAR
weather[]:proximity Additional description, METAR
weather[]:obsruration Additional description, METAR
weather[]:other Additional description, METAR
Код: Выделить всё
sg('ow_ws.dt', time());