File "view_map.php"
Full path: /www/shimooguni/view_map.php
File size: 6.4 KiB (6555 bytes)
MIME-type: text/x-php
Charset: utf-8
<?php
$direction = array( "北", "北北東", "北東", "東北東", "東", "東南東", "南東", "南南東", "南", "南南西", "南西", "西南西", "西", "西北西", "北西", "北北西");
// ===============================================
// GD処理準備
// 備考 :
// 更新 : 2010/09/08 KMK T.Teraoka
// ===============================================
//$img = imagecreatetruecolor(1000,670); //パレットの作成
$font1 = "/usr/share/fonts/vlgothic/VL-Gothic-Regular.ttf";
$img = imagecreate(1024, 768); //パレットの作成
// 使用色の準備
$Black = imagecolorallocate($img, 0,0,0);
$White = imagecolorallocatealpha($img, 255, 255, 255,75);
$WhiteBg = imagecolorallocatealpha($img, 255, 255, 255);
$Red = imagecolorallocate($img, 255, 0, 0);
$WBlue = imagecolorallocate($img, 37, 235, 253);
$Blue = imagecolorallocate($img, 0, 0, 255);
$Blue2 = imagecolorallocate($img, 30,144,255);
imagefill($img, 0, 0, $White);
$now_time = time();
//////////////////////////////
$fp = fopen("/www/shimooguni/recv/new_data_log.txt", "r");
$fp_wv_data = fopen("/www/shimooguni/recv/new_wv_data.txt", "r");
$fp_rain_data = fopen("/www/shimooguni/recv/new_rain_data.txt", "r");
$data = fgets($fp);
$wv_data = fgets($fp_wv_data);
$rain_data = fgets($fp_rain_data);
$data_d = explode(",", $data);
$wv_data_d = explode(",",$wv_data);
$rain_data_d = explode(",",$rain_data);
/////////////////////
fclose($fp);
fclose($fp_wv_data);
fclose($fp_rain_data);
///////////////////////////////////////////////////////////////////////////
// 更新時間をマップに表示する
$week = array( "日", "月", "火", "水", "木", "金", "土" );
$up_check = "現在時刻:" .date("Y年m月d日(" .$week[date('w')] .") H時i分s秒" ,time());
//imagefilledpolygon($img, array(10, 10, 10, 20, 55, 20, 55, 10), 4, $White);
//ImageTTFText ($img, 8, 0, 10, 20, $Blue, $font1, $test_date);
ImageTTFText ($img, 10, 0, 10, 14, $Black, $font1, $up_check);
$ap_ = $data_d[1];
$temp_ = (!strpos($data_d[2],"+")) ? ltrim($data_d[2], "+") + 0 : $data_d[2] + 0 ;
$hum_ = $data_d[3];
$nechu_ = "";
$hukai_= "";
$wd_no = $data_d[4] +0;
$wd_ = $direction[$wd_no];
$wv_ = $data_d[5];
$wv_max_ = $wv_data_d[1];
$wv_max_time_ = $wv_data_d[0];
$wv_avg_ = $wv_data_d[2];
$rain_1h_ = $rain_data_d[0];
$rain_day_ = $rain_data_d[1];
$rain_month_ = $rain_data_d[2];
$rain_all_ = $rain_data_d[3];
imageline($img, 5,22,1050,22, $Black);
imagettftext($img, 12, 0, 10,52, $Blue, $font1, "■気圧 / 気温 / 湿度");
imageline($img, 5,55,1050,55, $Blue2);
imagettftext($img, 15, 0, 10,100, $Black, $font1, "気圧:");
imagettftext($img, 25, 0, 100,100, $Black, $font1, $ap_);
imagettftext($img, 15, 0, 220,100, $Black, $font1, "hPs");
imageline($img, 10,105,250,105, $Black);
imagettftext($img, 15, 0, 10,170, $Black, $font1, "気温:");
imagettftext($img, 25, 0, 120,170, $Black, $font1, $temp_);
imagettftext($img, 15, 0, 220,170, $Black, $font1, "℃");
imageline($img, 10,175,250,175, $Black);
imagettftext($img, 15, 0, 10,240, $Black, $font1, "湿度:");
imagettftext($img, 25, 0, 100,240, $Black, $font1, $hum_);
imagettftext($img, 15, 0, 220,240, $Black, $font1, "%");
imageline($img, 10,245,250,245, $Black);
/*
imagettftext($img, 12, 0, 10,292, $Blue, $font1, "■熱中度(WBGT) / 不快指数");
imageline($img, 5,295,1050,295, $Blue2);
imagettftext($img, 15, 0, 10,340, $Black, $font1, "熱中指数:");
imagettftext($img, 25, 0, 100,340, $Black, $font1, $nechu_);
//imagettftext($img, 15, 0, 220,340, $Black, $font1, "hPs");
imageline($img, 10,345,250,345, $Black);
imagettftext($img, 15, 0, 510,340, $Black, $font1, "不快指数:");
imagettftext($img, 25, 0, 600,340, $Black, $font1, $hukai_);
//imagettftext($img, 15, 0, 220,500, $Black, $font1, "hPs");
imageline($img, 510,345,750,345, $Black);
*/
imagettftext($img, 12, 0, 10,392, $Blue, $font1, "■風向 / 風速");
imageline($img, 5,395,1050,395, $Blue2);
imagettftext($img, 15, 0, 10,440, $Black, $font1, "風向:");
imagettftext($img, 25, 0, 200,440, $Black, $font1, $wd_);
imageline($img, 10,445,400,445, $Black);
imagettftext($img, 15, 0, 460,440, $Black, $font1, "風速:");
imagettftext($img, 25, 0, 620,440, $Black, $font1, $wv_);
imagettftext($img, 15, 0, 720,440, $Black, $font1, "m/s");
imageline($img, 460,445,900,445, $Black);
imagettftext($img, 15, 0, 10,490, $Black, $font1, "平均風速:");
imagettftext($img, 13, 0, 10,510, $Black, $font1, "(前10分間の平均値)");
imagettftext($img, 25, 0, 200,510, $Black, $font1, $wv_avg_);
imagettftext($img, 15, 0, 320,510, $Black, $font1, "m/s");
imageline($img, 10,515,400,515, $Black);
imagettftext($img, 15, 0, 460,510, $Black, $font1, "最大瞬間風速:");
imagettftext($img, 25, 0, 620,510, $Black, $font1, $wv_max_);
imagettftext($img, 15, 0, 720,510, $Black, $font1, "m/s");
imagettftext($img, 15, 0, 770,510, $Black, $font1, "[" .$wv_max_time_ ."]");
imageline($img, 460,515,900,515, $Black);
imagettftext($img, 12, 0, 10,562, $Blue, $font1, "■降雨量");
imageline($img, 5,565,1050,565, $Blue2);
imagettftext($img, 15, 0, 10,610, $Black, $font1, "1時間:");
imagettftext($img, 25, 0, 200,610, $Black, $font1, $rain_1h_);
imagettftext($img, 15, 0, 320,610, $Black, $font1, "mm");
imageline($img, 10,615,400,615, $Black);
imagettftext($img, 15, 0, 460,610, $Black, $font1, "今月:");
imagettftext($img, 25, 0, 640,610, $Black, $font1, $rain_month_);
imagettftext($img, 15, 0, 780,610, $Black, $font1, "mm");
imageline($img, 460,615,900,615, $Black);
imagettftext($img, 15, 0, 10,660, $Black, $font1, "本日:");
imagettftext($img, 25, 0, 200,660, $Black, $font1, $rain_day_);
imagettftext($img, 15, 0, 320,660, $Black, $font1, "mm");
imageline($img, 10,665,400,665, $Black);
imagettftext($img, 15, 0, 460,660, $Black, $font1, "トータル:");
imagettftext($img, 25, 0, 640,660, $Black, $font1, $rain_all_);
imagettftext($img, 15, 0, 780,660, $Black, $font1, "mm");
imageline($img, 460,665,900,665, $Black);
// ===============================================
// 描画した画像を保存 & パレットを削除
// 備考 :
// 更新 : 2010/09/08 KMK T.Teraoka
// ===============================================
header('Content-Type: image/png');
// imagepng($img, $imgFileName);
imagepng($img);
imagedestroy($img);
//===============================================
// HTML終了処理
// 備考 :
// 更新 : 2012/10/18 KMK-Teraoka
//===============================================
//print "</body>";
//print "</html>";
?>