File "view_map_.php"

Full path: /www/shimooguni/view_map_.php
File size: 49.89 KiB (51085 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php


//■■■矢印の作成
//
//A,B,L,Rは[0]:x [1]:y
$Ll[0] = 0;
$Ll[1] = 0;
$Rr[0] = 0;
$Rr[1] = 0;

function arrowPos($A,$B,$w,$h,$Ll,$Rr)
{ 
//   global $Ll[0],$Ll[1],$Rr[0],$Rr[1];
   $Vx= $B[0]-$A[0];
   $Vy= $B[1]-$A[1];
   $v = sqrt($Vx*$Vx+$Vy*$Vy);
   $Ux= $Vx/$v;
   $Uy= $Vy/$v;
   $Ll[0]= $B[0] - $Uy*$w - $Ux*$h;
   $Ll[1]= $B[1] + $Ux*$w - $Uy*$h;
   $Rr[0]= $B[0] + $Uy*$w - $Ux*$h;
   $Rr[1]= $B[1] - $Ux*$w - $Uy*$h;
}


//===============================================
//	CommonUtilities
//	備考		:	
//	更新		:	2012/11/29 KMK-Teraoka
//===============================================
$SCRIPT_TITLE = "簡易気象システム";
$PENTA_OCEAN = "五洋建設株式会社";
$TAIL_PENTA_OCEAN = "penta-ocean";

$HOST = "localhost";
$DB = "observation";
$USER = "postgres";
$PASS = "postgres";

	
// ===============================================
// GD処理準備
// 備考		:	
// 更新		:	2010/09/08 KMK T.Teraoka
// ===============================================
//$img = imagecreatetruecolor(1000,670);			//パレットの作成
$font1 = "/www/fonts/VL-Gothic-Regular.ttf";
//$font1 = "/var/www/fonts/VL-Gothic-Regular.ttf";

//画像データのパス
$MAP_NAME = "map.png";

$imgSize = getimagesize($MAP_NAME);
$src = ImageCreateFromPNG($MAP_NAME);						//パレットへ貼り付ける画像指定(地図画像)
//	$src2 = ImageCreateFromPNG($MAP_NAME_ZOOM);
$img = imagecreatetruecolor($imgSize[0], $imgSize[1]);			//パレットの作成
//	$zoomImg = imagecreatetruecolor($zoomImgSize[0], $zoomImgSize[1]);
imagecopy($img, $src, 0, 0, 0, 0, $imgSize[0], $imgSize[1]);	//画像をパレットへ貼り付け
//	imagecopy($zoomImg, $src2, 0, 0, 0, 0, $zoomImgSize[0], $zoomImgSize[1]);




// 使用色の準備
$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);

imagefill($img, 0, 0, $White);


//================================================
//	データベース接続
//	備考		:	
//	更新		:	2012/11/29 KMK-Teraoka
//================================================
$conn = pg_connect("
	host	=	". $HOST. "
	dbname	=	". $DB. "
	user	=	". $USER. "
	password=	". $PASS. "
");
if (!$conn)
{
	throw new Exception("データベースへの接続に失敗しました");
}


$hour_ = sprintf("%02d",rand(0,2));
$minu_ = sprintf("%02d",rand(0,59));
$sec_ =  sprintf("%02d",rand(0,59));

$test_date = "2015-01-30 " .$hour_ .":" .$minu_ .":" .$sec_ ;

//$sql = "SELECT * FROM yokkaichi.wv_avg WHERE regdate < '" .$test_date ."'" ." ORDER BY regdate desc limit 1;";
//$sql = "SELECT * FROM yokkaichi.wv_avg ORDER BY regdate desc limit 1;";
//$res = pg_query($conn,$sql)or die("SQL ERROR!!<br />". $sql.pg_last_error());
//$row = pg_fetch_array($res,0);
//$Data = number_format($row['avg_3s'], 2, '.', '');

//$Data = ($row['avg_3s'] -1000+30) / 2;
//$Data = $row['avg_3s'] * 11;

//$now_time = time() -172800;

$now_time = time();

//雨量用日時(現在の日時)
$time_date = date("Y-m-d",$now_time);

//風速用日時(最終取得日時)
$time_date2 = date ("Y-m-d", filemtime("./iot-30_t_420/log/log_new.txt"));


//////////////////////////////
$fp = fopen("./iot-30_t_420/log/log_new.txt", "r");

$fp2 = fopen("./nl_42/log/log_new_0001.txt", "r");
$fp22 = fopen("./nl_42/log/log_new_0002.txt", "r");
$fp23 = fopen("./nl_42/log/log_new_0003.txt", "r");

$fp3 = fopen("./vm_55/log/log_new_0001.txt", "r");
$fp32 = fopen("./vm_55/log/log_new_0002.txt", "r");
$fp33 = fopen("./vm_55/log/log_new_0003.txt", "r");

$fp4 = fopen("./tc_32k/log/log_new_0001.txt", "r");
$fp42 = fopen("./tc_32k/log/log_new_0002.txt", "r");
$fp43 = fopen("./tc_32k/log/log_new_0003.txt", "r");
$fp44 = fopen("./tc_32k/log/log_new_0004.txt", "r");
$fp45 = fopen("./tc_32k/log/log_new_0005.txt", "r");

$fp5 = fopen("./wqc_24/log/log_new_0001.txt", "r");
$fp52 = fopen("./wqc_24/log/log_new_0002.txt", "r");
$fp53 = fopen("./wqc_24/log/log_new_0003.txt", "r");

$fp6 = fopen("./ld_3k2/log/log_new_0001.txt", "r");
$fp62 = fopen("./ld_3k2/log/log_new_0002.txt", "r");
$fp63 = fopen("./ld_3k2/log/log_new_0003.txt", "r");

$fp7 = fopen("./ctkf_1/log/log_now.txt", "r");
//$fp8 = fopen("./vm_55/log/log_now.txt", "r");
//$fp9 = fopen("./vm_55/log/log_now.txt", "r");

$wvd = fgets($fp);
$noised = fgets($fp2);
$noised2 = fgets($fp22);
$noised3 = fgets($fp23);
$vibd = fgets($fp3);
$vibd2 = fgets($fp32);
$vibd3 = fgets($fp33);
$keisya_d = fgets($fp4);
$keisya_d2 = fgets($fp42);
$keisya_d3 = fgets($fp43);
$keisya_d4 = fgets($fp44);
$keisya_d5 = fgets($fp45);
$suishitsu_d = fgets($fp5);
$suishitsu_d2 = fgets($fp52);
$suishitsu_d3 = fgets($fp53);
$hunjin_d = fgets($fp6);
$hunjin_d2 = fgets($fp62);
$hunjin_d3 = fgets($fp63);
$rain_d = fgets($fp7);

$wv = explode(",", $wvd);
$noise = explode(",", $noised);
$noise2 = explode(",", $noised2);
$noise3 = explode(",", $noised3);
$vib = explode(",", $vibd);
$vib2 = explode(",", $vibd2);
$vib3 = explode(",", $vibd3);
$keisya = explode(",", $keisya_d);
$keisya2 = explode(",", $keisya_d2);
$keisya3 = explode(",", $keisya_d3);
$keisya4 = explode(",", $keisya_d4);
$keisya5 = explode(",", $keisya_d5);
$suishitsu = explode(",", $suishitsu_d);
$suishitsu2 = explode(",", $suishitsu_d2);
$suishitsu3 = explode(",", $suishitsu_d3);
$hunjin = explode(",", $hunjin_d);
$hunjin2 = explode(",", $hunjin_d2);
$hunjin3 = explode(",", $hunjin_d3);
$rain = explode(",", $rain_d);

/////////////////////
fclose($fp);
fclose($fp2);
fclose($fp22);
fclose($fp23);
fclose($fp3);
fclose($fp32);
fclose($fp33);
fclose($fp4);
fclose($fp42);
fclose($fp43);
fclose($fp44);
fclose($fp45);
fclose($fp5);
fclose($fp52);
fclose($fp53);
fclose($fp6);
fclose($fp62);
fclose($fp63);


///////////////////////////////////////////////////////////////////////////
//■■■必要なデータをデータベースから取得■■■
//■風向・風速取得
//現在の最高風速

//$sql_w_max = "SELECT max((wv - 1000) * 0.0175) FROM genkai.wv_data";
//$res_w_max = pg_query($conn,$sql_w_max)or die("SQL ERROR!!<br />". $sql_w_max.pg_last_error());
//$row_w_max = pg_fetch_array($res_w_max,0);
//$wv_max = ($row_w_max[0] != NULL) ? number_format($row_w_max[0], 1, '.', '') : "--";
$wv_max = $wv[0];


//SELECT max( (wv - 1000) * 0.0175)
//  FROM genkai.wv_data where regdate < '2016-09-03 01:40:00' AND regdate >= '2016-09-03 01:30:00';

//●当日の最大風速
$sql_w2_max = "SELECT max((wv - 1000) * 0.0175) FROM genkai.wv_data_24h WHERE regdate < '" .date("Y-m-d H:i:s",$now_time) ."' AND regdate >= '" .date("Y-m-d 00:00:00",$now_time)  ."';";
$res_w2_max = pg_query($conn,$sql_w2_max)or die("SQL ERROR!!<br />". $sql_w2_max.pg_last_error());
$row_w2_max = pg_fetch_array($res_w2_max,0);
$wv_max2 = ($row_w2_max[0] != NULL) ? number_format($row_w2_max[0], 1, '.', '') : "--";


//●10分間の平均風速
//$sql_w_avg = "SELECT avg((wv - 1000) * 0.0175) FROM genkai.wv_data WHERE regdate < '" .date("Y-m-d H:i:s",$now_time) ."' AND regdate >= '" .date("Y-m-d H:i:s",$now_time-600)  ."';";
$sql_w_avg = "SELECT avg((wv - 1000) * 0.0175) FROM genkai.wv_data_10m;";
$res_w_avg = pg_query($conn,$sql_w_avg)or die("SQL ERROR!!<br />". $sql_w_avg.pg_last_error());
$row_w_avg = pg_fetch_array($res_w_avg,0);
$wv_avg_10m = ($row_w_avg[0] != NULL) ? number_format($row_w_avg[0], 1, '.', '') : "--";


//●現在の風向
//$sql_wd = "SELECT (wd - 1000) * 0.135,regdate FROM genkai.wv_data WHERE regdate < '" .date("Y-m-d H:i:s",$now_time) ."' AND regdate >= '" .date("Y-m-d H:i:s",$now_time-600)  ."' ORDER BY regdate desc limit 1";
//$res_wd = pg_query($conn,$sql_wd)or die("SQL ERROR!!<br />". $sql_wd.pg_last_error());
//$row_wd = pg_fetch_array($res_wd,0);
//$wd_data = ($row_wd[0] != NULL) ? $row_wd[0] : "--";
$wd_data = $wv[1];


//■雨量取得
//●24時間雨量
$sql_rain24 = "SELECT count(*) FROM genkai.raingauge WHERE regdate >= '" .date("Y-m-d H:i:s",$now_time - 86400) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."';";
$res_rain24 = pg_query($conn,$sql_rain24)or die("SQL ERROR!!<br />". $sql_rain24.pg_last_error());
$row_rain24 = pg_fetch_array($res_rain24,0);
$row_rain24[0] = $row_rain24[0] * 0.5;

//●1時間雨量
$sql_rain1 = "SELECT count(*) FROM genkai.raingauge WHERE regdate >= '" .date("Y-m-d H:i:s",$now_time -3600) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."';";
$res_rain1 = pg_query($conn,$sql_rain1)or die("SQL ERROR!!<br />". $sql_rain1.pg_last_error());
$row_rain1 = pg_fetch_array($res_rain1,0);
$row_rain1[0] = $row_rain1[0] * 0.5;

//●1時間最大雨量
$sql_rain1max = "SELECT max(data) FROM genkai.raingauge_1h WHERE regdate >= '" .date("Y-m-d H:i:s",$now_time -86400) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."';";
$res_rain1max = pg_query($conn,$sql_rain1max)or die("SQL ERROR!!<br />". $sql_rain1max.pg_last_error());
$row_rain1max = pg_fetch_array($res_rain1max,0);

//■騒音データの取得
//●騒音計1
//Laeq
$sql_noise_data_1 = "SELECT * FROM genkai.noise_data WHERE macid=3  AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_noise_data_1 = pg_query($conn,$sql_noise_data_1)or die("SQL ERROR!!<br />". $sql_noise_data_1.pg_last_error());
$row_noise_data_1 = pg_fetch_array($res_noise_data_1,0);
$noise_laeq_1 = ($row_noise_data_1[2] != NULL) ? round($row_noise_data_1[2]) : "--";
$noise_laeq_date_1 = (strcmp($noise_laeq_1,"--")) ? $row_noise_data_1[7] : "          --";

//max
$sql_noise_max_1 = "SELECT * FROM genkai.noise_data WHERE macid=3 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by lamax desc limit 1;";
$res_noise_max_1 = pg_query($conn,$sql_noise_max_1)or die("SQL ERROR!!<br />". $sql_noise_max_1.pg_last_error());
$row_noise_max_1 = pg_fetch_array($res_noise_max_1,0);
$noise_max_1 = ($row_noise_max_1[3] != NULL) ? round($row_noise_max_1[3]) : "--";
$noise_max_date_1 = (strcmp($noise_max_1,"--")) ? substr($row_noise_max_1[7],11,5) : "  --";
//ImageTTFText ($img, 10, 0, 50, 300, $Blue, $font1, $sql_noise_max_1);


//●騒音計2
//Laeq
$sql_noise_data_2 = "SELECT * FROM genkai.noise_data WHERE macid=1 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_noise_data_2 = pg_query($conn,$sql_noise_data_2)or die("SQL ERROR!!<br />". $sql_noise_data_2.pg_last_error());
$row_noise_data_2 = pg_fetch_array($res_noise_data_2,0);
$noise_laeq_2 = ($row_noise_data_2[2] != NULL) ? round($row_noise_data_2[2]) : "--";
$noise_laeq_date_2 = (strcmp($noise_laeq_2,"--")) ? $row_noise_data_2[7] : "          --";

//max
$sql_noise_max_2 = "SELECT * FROM genkai.noise_data WHERE macid=1 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by lamax desc limit 1;";
$res_noise_max_2 = pg_query($conn,$sql_noise_max_2)or die("SQL ERROR!!<br />". $sql_noise_max_2.pg_last_error());
$row_noise_max_2 = pg_fetch_array($res_noise_max_2,0);
$noise_max_2 = ($row_noise_max_2[3] != NULL) ? round($row_noise_max_2[3]) : "--";
$noise_max_date_2 = (strcmp($noise_max_2,"--")) ? substr($row_noise_max_2[7],11,5) : "  --";

//●騒音計3
//Laeq
$sql_noise_data_3 = "SELECT * FROM genkai.noise_data WHERE macid=2 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_noise_data_3 = pg_query($conn,$sql_noise_data_3)or die("SQL ERROR!!<br />". $sql_noise_data_3.pg_last_error());
$row_noise_data_3 = pg_fetch_array($res_noise_data_3,0);
$noise_laeq_3 = ($row_noise_data_3[2] != NULL) ? round($row_noise_data_3[2]) : "--";
$noise_laeq_date_3 = (strcmp($noise_laeq_3,"--")) ? $row_noise_data_3[7] : "          --";

//max
$sql_noise_max_3 = "SELECT * FROM genkai.noise_data WHERE macid=2 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by lamax desc limit 1;";
$res_noise_max_3 = pg_query($conn,$sql_noise_max_3)or die("SQL ERROR!!<br />". $sql_noise_max_3.pg_last_error());
$row_noise_max_3 = pg_fetch_array($res_noise_max_3,0);
$noise_max_3 = ($row_noise_max_3[3] != NULL) ? $row_noise_max_3[3] : "--";
$noise_max_date_3 = (strcmp($noise_max_3,"--")) ? substr($row_noise_max_3[7],11,5) : "  --";


//■振動データの取得
//●振動計1
//x_Laeq
$sql_vib_data_x1 = "SELECT * FROM genkai.vib_data WHERE macid=3 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_vib_data_x1 = pg_query($conn,$sql_vib_data_x1)or die("SQL ERROR!!<br />". $sql_vib_data_x1.pg_last_error());
$row_vib_data_x1 = pg_fetch_array($res_vib_data_x1,0);
$vib_laeq_x1 = ($row_vib_data_x1[4] != NULL) ? round($row_vib_data_x1[4]) : "--";
$vib_laeq_date_x1 = (strcmp($vib_laeq_x1,"--")) ? $row_vib_data_x1[19] : "          --";


//x_max
$sql_vib_max_x1 = "SELECT * FROM genkai.vib_data WHERE macid=3 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by x_lvmax desc limit 1;";
$res_vib_max_x1 = pg_query($conn,$sql_vib_max_x1)or die("SQL ERROR!!<br />". $sql_vib_max_x1.pg_last_error());
$row_vib_max_x1 = pg_fetch_array($res_vib_max_x1,0);
$vib_max_x1 = ($row_vib_max_x1[7] != NULL) ? round($row_vib_max_x1[7]) : "--";
$vib_max_date_x1 = (strcmp($vib_max_x1,"--")) ? substr($row_vib_max_x1[19],11,5) : "  --";

//y_Laeq
$sql_vib_data_y1 = "SELECT * FROM genkai.vib_data WHERE macid=3 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_vib_data_y1 = pg_query($conn,$sql_vib_data_y1)or die("SQL ERROR!!<br />". $sql_vib_data_y1.pg_last_error());
$row_vib_data_y1 = pg_fetch_array($res_vib_data_y1,0);
$vib_laeq_y1 = ($row_vib_data_y1[5] != NULL) ? round($row_vib_data_y1[5]) : "--";
$vib_laeq_date_y1 = (strcmp($vib_laeq_y1,"--")) ? $row_vib_data_y1[19] : "          --";

//y_max
$sql_vib_max_y1 = "SELECT * FROM genkai.vib_data WHERE macid=3 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by x_lvmax desc limit 1;";
$res_vib_max_y1 = pg_query($conn,$sql_vib_max_y1)or die("SQL ERROR!!<br />". $sql_vib_max_y1.pg_last_error());
$row_vib_max_y1 = pg_fetch_array($res_vib_max_y1,0);
$vib_max_y1 = ($row_vib_max_y1[8] != NULL) ? round($row_vib_max_y1[8]) : "--";
$vib_max_date_y1 = (strcmp($vib_max_y1,"--")) ? substr($row_vib_max_y1[19],11,5) : "  --";

//z_Laeq
$sql_vib_data_z1 = "SELECT * FROM genkai.vib_data WHERE macid=3 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_vib_data_z1 = pg_query($conn,$sql_vib_data_z1)or die("SQL ERROR!!<br />". $sql_vib_data_z1.pg_last_error());
$row_vib_data_z1 = pg_fetch_array($res_vib_data_z1,0);
$vib_laeq_z1 = ($row_vib_data_z1[6] != NULL) ? round($row_vib_data_z1[6]) : "--";
$vib_laeq_date_z1 = (strcmp($vib_laeq_z1,"--")) ? $row_vib_data_z1[19] : "          --";

//z_max
$sql_vib_max_z1 = "SELECT * FROM genkai.vib_data WHERE macid=3 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by x_lvmax desc limit 1;";
$res_vib_max_z1 = pg_query($conn,$sql_vib_max_z1)or die("SQL ERROR!!<br />". $sql_vib_max_z1.pg_last_error());
$row_vib_max_z1 = pg_fetch_array($res_vib_max_z1,0);
$vib_max_z1 = ($row_vib_max_z1[9] != NULL) ? round($row_vib_max_z1[9]) : "--";
$vib_max_date_z1 = (strcmp($vib_max_z1,"--")) ? substr($row_vib_max_z1[19],11,5) : "  --";

//ImageTTFText ($img, 10, 0, 50, 300, $Blue, $font1, $sql_vib_max_1);


//●振動計2
//x_Laeq
$sql_vib_data_x2 = "SELECT * FROM genkai.vib_data WHERE macid=1 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_vib_data_x2 = pg_query($conn,$sql_vib_data_x2)or die("SQL ERROR!!<br />". $sql_vib_data_x2.pg_last_error());
$row_vib_data_x2 = pg_fetch_array($res_vib_data_x2,0);
$vib_laeq_x2 = ($row_vib_data_x2[4] != NULL) ? round($row_vib_data_x2[4]) : "--";
$vib_laeq_date_x2 = (strcmp($vib_laeq_x2,"--")) ? $row_vib_data_x2[19] : "          --";

//x_max
$sql_vib_max_x2 = "SELECT * FROM genkai.vib_data WHERE macid=1 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by x_lvmax desc limit 1;";
$res_vib_max_x2 = pg_query($conn,$sql_vib_max_x2)or die("SQL ERROR!!<br />". $sql_vib_max_x2.pg_last_error());
$row_vib_max_x2 = pg_fetch_array($res_vib_max_x2,0);
$vib_max_x2 = ($row_vib_max_x2[7] != NULL) ? round($row_vib_max_x2[7]) : "--";
$vib_max_date_x2 = (strcmp($vib_max_x2,"--")) ? substr($row_vib_max_x2[19],11,5) : "  --";

//y_Laeq
$sql_vib_data_y2 = "SELECT * FROM genkai.vib_data WHERE macid=1 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_vib_data_y2 = pg_query($conn,$sql_vib_data_y2)or die("SQL ERROR!!<br />". $sql_vib_data_y2.pg_last_error());
$row_vib_data_y2 = pg_fetch_array($res_vib_data_y2,0);
$vib_laeq_y2 = ($row_vib_data_y2[5] != NULL) ? round($row_vib_data_y2[5]) : "--";
$vib_laeq_date_y2 = (strcmp($vib_laeq_y2,"--")) ? $row_vib_data_y2[19] : "          --";

//y_max
$sql_vib_max_y2 = "SELECT * FROM genkai.vib_data WHERE macid=1 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by x_lvmax desc limit 1;";
$res_vib_max_y2 = pg_query($conn,$sql_vib_max_y2)or die("SQL ERROR!!<br />". $sql_vib_max_y2.pg_last_error());
$row_vib_max_y2 = pg_fetch_array($res_vib_max_y2,0);
$vib_max_y2 = ($row_vib_max_y2[8] != NULL) ? round($row_vib_max_y2[8]) : "--";
$vib_max_date_y2 = (strcmp($vib_max_y2,"--")) ? substr($row_vib_max_y2[19],11,5) : "  --";

//z_Laeq
$sql_vib_data_z2 = "SELECT * FROM genkai.vib_data WHERE macid=1 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_vib_data_z2 = pg_query($conn,$sql_vib_data_z2)or die("SQL ERROR!!<br />". $sql_vib_data_z2.pg_last_error());
$row_vib_data_z2 = pg_fetch_array($res_vib_data_z2,0);
$vib_laeq_z2 = ($row_vib_data_z2[6] != NULL) ? round($row_vib_data_z2[6]) : "--";
$vib_laeq_date_z2 = (strcmp($vib_laeq_z2,"--")) ? $row_vib_data_z2[19] : "          --";

//z_max
$sql_vib_max_z2 = "SELECT * FROM genkai.vib_data WHERE macid=1 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by x_lvmax desc limit 1;";
$res_vib_max_z2 = pg_query($conn,$sql_vib_max_z2)or die("SQL ERROR!!<br />". $sql_vib_max_z2.pg_last_error());
$row_vib_max_z2 = pg_fetch_array($res_vib_max_z2,0);
$vib_max_z2 = ($row_vib_max_z2[9] != NULL) ? round($row_vib_max_z2[9]) : "--";
$vib_max_date_z2 = (strcmp($vib_max_z2,"--")) ? substr($row_vib_max_z2[19],11,5) : "  --";


//●振動計3
//x_Laeq
$sql_vib_data_x3 = "SELECT * FROM genkai.vib_data WHERE macid=2 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_vib_data_x3 = pg_query($conn,$sql_vib_data_x3)or die("SQL ERROR!!<br />". $sql_vib_data_x3.pg_last_error());
$row_vib_data_x3 = pg_fetch_array($res_vib_data_x3,0);
$vib_laeq_x3 = ($row_vib_data_x3[4] != NULL) ? round($row_vib_data_x3[4]) : "--";
$vib_laeq_date_x3 = (strcmp($vib_laeq_x3,"--")) ? $row_vib_data_x3[19] : "          --";

//x_max
$sql_vib_max_x3 = "SELECT * FROM genkai.vib_data WHERE macid=2 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by x_lvmax desc limit 1;";
$res_vib_max_x3 = pg_query($conn,$sql_vib_max_x3)or die("SQL ERROR!!<br />". $sql_vib_max_x3.pg_last_error());
$row_vib_max_x3 = pg_fetch_array($res_vib_max_x3,0);
$vib_max_x3 = ($row_vib_max_x3[7] != NULL) ? round($row_vib_max_x3[7]) : "--";
$vib_max_date_x3 = (strcmp($vib_max_x3,"--")) ? substr($row_vib_max_x3[19],11,5) : "  --";

//y_Laeq
$sql_vib_data_y3 = "SELECT * FROM genkai.vib_data WHERE macid=2 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_vib_data_y3 = pg_query($conn,$sql_vib_data_y3)or die("SQL ERROR!!<br />". $sql_vib_data_y3.pg_last_error());
$row_vib_data_y3 = pg_fetch_array($res_vib_data_y3,0);
$vib_laeq_y3 = ($row_vib_data_y3[5] != NULL) ? round($row_vib_data_y3[5]) : "--";
$vib_laeq_date_y3 = (strcmp($vib_laeq_y3,"--")) ? $row_vib_data_y3[19] : "          --";

//y_max
$sql_vib_max_y3 = "SELECT * FROM genkai.vib_data WHERE macid=2 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by x_lvmax desc limit 1;";
$res_vib_max_y3 = pg_query($conn,$sql_vib_max_y3)or die("SQL ERROR!!<br />". $sql_vib_max_y3.pg_last_error());
$row_vib_max_y3 = pg_fetch_array($res_vib_max_y3,0);
$vib_max_y3 = ($row_vib_max_y3[8] != NULL) ? round($row_vib_max_y3[8]) : "--";
$vib_max_date_y3 = (strcmp($vib_max_y3,"--")) ? substr($row_vib_max_y3[19],11,5) : "  --";

//z_Laeq
$sql_vib_data_z3 = "SELECT * FROM genkai.vib_data WHERE macid=2 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_vib_data_z3 = pg_query($conn,$sql_vib_data_z3)or die("SQL ERROR!!<br />". $sql_vib_data_z3.pg_last_error());
$row_vib_data_z3 = pg_fetch_array($res_vib_data_z3,0);
$vib_laeq_z3 = ($row_vib_data_z3[6] != NULL) ? round($row_vib_data_z3[6]) : "--";
$vib_laeq_date_z3 = (strcmp($vib_laeq_z3,"--")) ? $row_vib_data_z3[19] : "          --";

//z_max
$sql_vib_max_z3 = "SELECT * FROM genkai.vib_data WHERE macid=2 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by x_lvmax desc limit 1;";
$res_vib_max_z3 = pg_query($conn,$sql_vib_max_z3)or die("SQL ERROR!!<br />". $sql_vib_max_z3.pg_last_error());
$row_vib_max_z3 = pg_fetch_array($res_vib_max_z3,0);
$vib_max_z3 = ($row_vib_max_z3[9] != NULL) ? round($row_vib_max_z3[9]) : "--";
$vib_max_date_z3 = (strcmp($vib_max_z3,"--")) ? substr($row_vib_max_z3[19],11,5) : "  --";

//■粉塵データの取得
//粉塵計1
//data
$sql_dust_data_1 = "SELECT * FROM genkai.dust_data WHERE macid=3 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_dust_data_1 = pg_query($conn,$sql_dust_data_1)or die("SQL ERROR!!<br />". $sql_dust_data_1.pg_last_error());
$row_dust_data_1 = pg_fetch_array($res_dust_data_1,0);
$dust_data_1 = ($row_dust_data_1[1] != NULL) ? round($row_dust_data_1[1],2) : "--";
$dust_data_date_1 = (strcmp($dust_data_1,"--")) ? $row_dust_data_1[2] : "          --";

//max
$sql_dust_max_1 = "SELECT * FROM genkai.dust_data WHERE macid=3 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by data desc limit 1;";
$res_dust_max_1 = pg_query($conn,$sql_dust_max_1)or die("SQL ERROR!!<br />". $sql_dust_max_1.pg_last_error());
$row_dust_max_1 = pg_fetch_array($res_dust_max_1,0);
$dust_max_1 = ($row_dust_max_1[1] != NULL) ? round($row_dust_max_1[1],2) : "--";
$dust_max_date_1 = (strcmp($dust_max_1,"--")) ? substr($row_dust_max_1[2],11,5) : "  --";


//粉塵計2
//data
$sql_dust_data_2 = "SELECT * FROM genkai.dust_data WHERE macid=1 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_dust_data_2 = pg_query($conn,$sql_dust_data_2)or die("SQL ERROR!!<br />". $sql_dust_data_2.pg_last_error());
$row_dust_data_2 = pg_fetch_array($res_dust_data_2,0);
$dust_data_2 = ($row_dust_data_2[1] != NULL) ? round($row_dust_data_2[1],2) : "--";
$dust_data_date_2 = (strcmp($dust_data_2,"--")) ? $row_dust_data_2[2] : "          --";

//max
$sql_dust_max_2 = "SELECT * FROM genkai.dust_data WHERE macid=1 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by data desc limit 1;";
$res_dust_max_2 = pg_query($conn,$sql_dust_max_2)or die("SQL ERROR!!<br />". $sql_dust_max_2.pg_last_error());
$row_dust_max_2 = pg_fetch_array($res_dust_max_2,0);
$dust_max_2 = ($row_dust_max_2[1] != NULL) ? round($row_dust_max_2[1],2) : "--";
$dust_max_date_2 = (strcmp($dust_max_2,"--")) ? substr($row_dust_max_2[2],11,5) : "  --";

//粉塵計3
//data
$sql_dust_data_3 = "SELECT * FROM genkai.dust_data WHERE macid=2 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by regdate desc limit 1 ;";
$res_dust_data_3 = pg_query($conn,$sql_dust_data_3)or die("SQL ERROR!!<br />". $sql_dust_data_3.pg_last_error());
$row_dust_data_3 = pg_fetch_array($res_dust_data_3,0);
$dust_data_3 = ($row_dust_data_3[1] != NULL) ? round($row_dust_data_3[1],2) : "--";
$dust_data_date_3 = (strcmp($dust_data_3,"--")) ? $row_dust_data_3[2] : "          --";

//max
$sql_dust_max_3 = "SELECT * FROM genkai.dust_data WHERE macid=2 AND regdate >= '" .date("Y-m-d 00:00:00",$now_time) ."' AND regdate < '" .date("Y-m-d H:i:s",$now_time) ."' order by data desc limit 1;";
$res_dust_max_3 = pg_query($conn,$sql_dust_max_3)or die("SQL ERROR!!<br />". $sql_dust_max_3.pg_last_error());
$row_dust_max_3 = pg_fetch_array($res_dust_max_3,0);
$dust_max_3 = ($row_dust_max_3[1] != NULL) ? round($row_dust_max_3[1],2) : "--";
$dust_max_date_3 = (strcmp($dust_max_3,"--")) ? substr($row_dust_max_3[2],11,5) : "  --";




//■水質データの取得
//【水質計1】
//●最新データ取得日時
$new_time = $suishitsu[5];

//●1日の最大PH
$sql_ph_max = "SELECT * FROM genkai.wq_data WHERE macid = 1 AND regdate >= '" .substr($new_time,0,11) ."00:00:00" ."' AND regdate <= '" .$new_time ."' ORDER BY data1 desc limit 1;";
$res_ph_max = pg_query($conn,$sql_ph_max)or die("SQL ERROR!!<br />". $sql_ph_max.pg_last_error());
$row_ph_max = pg_fetch_array($res_ph_max,0);
$ph_max = $row_ph_max[1];
$ph_max_date = substr($row_ph_max[5],11);

//●1日の最大電気伝導率
$sql_el_max = "SELECT * FROM genkai.wq_data WHERE macid = 1 AND regdate >= '" .substr($new_time,0,11) ."00:00:00" ."' AND regdate <= '" .$new_time ."' ORDER BY data2 desc limit 1;";
$res_el_max = pg_query($conn,$sql_el_max)or die("SQL ERROR!!<br />". $sql_el_max.pg_last_error());
$row_el_max = pg_fetch_array($res_el_max,0);
$el_max = $row_el_max[2];
$el_max_date = substr($row_el_max[5],11);

//●1日の最大濁度
$sql_da_max = "SELECT * FROM genkai.wq_data WHERE macid = 1 AND regdate >= '" .substr($new_time,0,11) ."00:00:00" ."' AND regdate <= '" .$new_time ."' ORDER BY data3 desc limit 1;";
$res_da_max = pg_query($conn,$sql_da_max)or die("SQL ERROR!!<br />". $sql_da_max.pg_last_error());
$row_da_max = pg_fetch_array($res_da_max,0);
$da_max = $row_da_max[3];
$da_max_date = substr($row_da_max[5],11);

//【水質計2】
//●最新データ取得日時
$new_time2 = $suishitsu2[5];

//●1日の最大PH
$sql_ph_max = "SELECT * FROM genkai.wq_data WHERE macid = 2 AND regdate >= '" .substr($new_time2,0,11) ."00:00:00" ."' AND regdate <= '" .$new_time2 ."' ORDER BY data1 desc limit 1;";
$res_ph_max = pg_query($conn,$sql_ph_max)or die("SQL ERROR!!<br />". $sql_ph_max.pg_last_error());
$row_ph_max = pg_fetch_array($res_ph_max,0);
$ph_max2 = $row_ph_max[1];
$ph_max_date2 = substr($row_ph_max[5],11);

//●1日の最大電気伝導率
$sql_el_max = "SELECT * FROM genkai.wq_data WHERE macid = 2 AND regdate >= '" .substr($new_time2,0,11) ."00:00:00" ."' AND regdate <= '" .$new_time2 ."' ORDER BY data2 desc limit 1;";
$res_el_max = pg_query($conn,$sql_el_max)or die("SQL ERROR!!<br />". $sql_el_max.pg_last_error());
$row_el_max = pg_fetch_array($res_el_max,0);
$el_max2 = $row_el_max[2];
$el_max_date2 = substr($row_el_max[5],11);

//●1日の最大濁度
$sql_da_max = "SELECT * FROM genkai.wq_data WHERE macid = 2 AND regdate >= '" .substr($new_time2,0,11) ."00:00:00" ."' AND regdate <= '" .$new_time2 ."' ORDER BY data3 desc limit 1;";
$res_da_max = pg_query($conn,$sql_da_max)or die("SQL ERROR!!<br />". $sql_da_max.pg_last_error());
$row_da_max = pg_fetch_array($res_da_max,0);
$da_max2 = $row_da_max[3];
$da_max_date2 = substr($row_da_max[5],11);






//■傾斜計データの取得
//出力ファイルのみ



///////////////////////////////////////////////////////////////////////////


// 更新時間をマップに表示する
$up_check = date("Y-m-d 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, 7, 0, 1, 7, $Blue, $font1, $up_check);

//項目名
//■水質計
imagettftext($img, 10, 0, 338,379, $WBlue, $font1, "★ W2 水質【八田裏貯水池側工事排水】");
//表示範囲
$baseXmin = 350;
$baseYmin = 385;
$baseXmax = $baseXmin+200;
$baseYmax = $baseYmin+75;

imagefilledrectangle($img, $baseXmin,$baseYmin,$baseXmax,$baseYmax, $White);
imagerectangle($img, $baseXmin,$baseYmin,$baseXmax,$baseYmax, $Black);

imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+12, $Blue, $font1, "取得日時:" .$suishitsu[5]);
imagettftext($img, 9, 0, $baseXmin+40,$baseYmin+25, $Red, $font1, "[現在値]");
imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+40, $Blue, $font1, "PH");
imagettftext($img, 9, 0, $baseXmin+50,$baseYmin+40, $Blue, $font1,  number_format($suishitsu[1], 2, '.', ''));
imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+55, $Blue, $font1, "伝導率");
imagettftext($img, 9, 0, $baseXmin+50,$baseYmin+55, $Blue, $font1, number_format($suishitsu[2], 3, '.', ''));
imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+70, $Blue, $font1, "濁度");
imagettftext($img, 9, 0, $baseXmin+50,$baseYmin+70, $Blue, $font1, number_format($suishitsu[3], 2, '.', ''));
//imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+85, $Blue, $font1, "温度");
//imagettftext($img, 9, 0, $baseXmin+50,$baseYmin+85, $Blue, $font1, number_format($suishitsu[4], 2, '.', ''));
imagettftext($img, 9, 0, $baseXmin+90,$baseYmin+25, $Red, $font1, "[最大値]");
//imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+40, $Blue, $font1, number_format($suishitsu[1], 2, '.', ''));
//imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+55, $Blue, $font1, number_format($suishitsu[2], 3, '.', ''));
//imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+70, $Blue, $font1, number_format($suishitsu[3], 2, '.', ''));
imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+40, $Blue, $font1, number_format($ph_max, 2, '.', ''));
imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+55, $Blue, $font1, number_format($el_max, 3, '.', ''));
imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+70, $Blue, $font1, number_format($da_max, 2, '.', ''));

//imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+85, $Blue, $font1, number_format($suishitsu[4], 2, '.', ''));
imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+25, $Red, $font1, "[時刻]");
//imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+40, $Blue, $font1, $max_time[1]);
//imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+55, $Blue, $font1, $max_time2[1]);
//imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+70, $Blue, $font1, $max_time3[1]);
imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+40, $Blue, $font1, $ph_max_date);
imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+55, $Blue, $font1, $el_max_date);
imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+70, $Blue, $font1, $da_max_date);
//imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+85, $Blue, $font1, $max_time4[1]);


imagettftext($img, 10, 0, 422,488, $WBlue, $font1, "★ W3 水質【下場溜池側工事排水】");
//表示範囲
$baseXmin = 434;
$baseYmin = 494;
$baseXmax = $baseXmin+200;
$baseYmax = $baseYmin+75;

imagefilledrectangle($img, $baseXmin,$baseYmin,$baseXmax,$baseYmax, $White);
imagerectangle($img, $baseXmin,$baseYmin,$baseXmax,$baseYmax, $Black);

//テスト用
imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+12, $Blue, $font1, "取得日時:" .$suishitsu2[5]);
imagettftext($img, 9, 0, $baseXmin+40,$baseYmin+25, $Red, $font1, "[現在値]");
imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+40, $Blue, $font1, "PH");
imagettftext($img, 9, 0, $baseXmin+50,$baseYmin+40, $Blue, $font1,  number_format($suishitsu2[1], 2, '.', ''));
imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+55, $Blue, $font1, "伝導率");
imagettftext($img, 9, 0, $baseXmin+50,$baseYmin+55, $Blue, $font1, number_format($suishitsu2[2], 3, '.', ''));
imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+70, $Blue, $font1, "濁度");
imagettftext($img, 9, 0, $baseXmin+50,$baseYmin+70, $Blue, $font1, number_format($suishitsu2[3], 2, '.', ''));
//imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+85, $Blue, $font1, "温度");
//imagettftext($img, 9, 0, $baseXmin+50,$baseYmin+85, $Blue, $font1, number_format($suishitsu2[4], 2, '.', ''));
imagettftext($img, 9, 0, $baseXmin+90,$baseYmin+25, $Red, $font1, "[最大値]");
//imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+40, $Blue, $font1, number_format($suishitsu2[1], 2, '.', ''));
//imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+55, $Blue, $font1, number_format($suishitsu2[2], 3, '.', ''));
//imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+70, $Blue, $font1, number_format($suishitsu2[3], 2, '.', ''));
imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+40, $Blue, $font1, number_format($ph_max2, 2, '.', ''));
imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+55, $Blue, $font1, number_format($el_max2, 3, '.', ''));
imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+70, $Blue, $font1, number_format($da_max2, 2, '.', ''));
//imagettftext($img, 9, 0, $baseXmin+100,$baseYmin+85, $Blue, $font1, number_format($suishitsu2[4], 2, '.', ''));
imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+25, $Red, $font1, "[時刻]");
//imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+40, $Blue, $font1, $max_time2[1]);
//imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+55, $Blue, $font1, $max_time2[1]);
//imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+70, $Blue, $font1, $max_time2[1]);
imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+40, $Blue, $font1, $ph_max_date2);
imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+55, $Blue, $font1, $el_max_date2);
imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+70, $Blue, $font1, $da_max_date2);
//imagettftext($img, 9, 0, $baseXmin+150,$baseYmin+85, $Blue, $font1, $max_time24[1]);


//■粉塵・振動・騒音計
$max_time_h_1 = explode(" ",$hunjin[2]);
$max_time_v_1 = explode(" ",$vib[4]);
$max_time_v_12 = explode(" ",$vib[4]);
$max_time_v_13 = explode(" ",$vib[4]);
$max_time_n_1 = explode(" ",$noise[2]);


//■範囲を設定
imagettftext($img, 10, 0, 625,164, $WBlue, $font1, "★ E1 粉塵・振動・騒音【椿園地点】");

//表示範囲
$baseXmin = 637;
$baseYmin = 170;
$baseXmax = $baseXmin+343;
$baseYmax = $baseYmin+95;

imagefilledrectangle($img, $baseXmin,$baseYmin,$baseXmax,$baseYmax, $White);
imageline($img, $baseXmin,$baseYmin+14,$baseXmax,$baseYmin+14, $Black);
imageline($img, $baseXmin,$baseYmin+28,$baseXmax,$baseYmin+28, $Black);
imageline($img, $baseXmin,$baseYmin+74,$baseXmax,$baseYmin+74, $Black);

imageline($img, $baseXmin+31,$baseYmin,$baseXmin+31,$baseYmax, $Black);
imageline($img, $baseXmin+88,$baseYmin,$baseXmin+88,$baseYmax, $Black);
imageline($img, $baseXmin+223,$baseYmin,$baseXmin+223,$baseYmax, $Black);
imageline($img, $baseXmin+287,$baseYmin,$baseXmin+287,$baseYmax, $Black);

imagerectangle($img, $baseXmin,$baseYmin,$baseXmax,$baseYmax, $Black);
imagettftext($img, 9, 0, $baseXmin+35,$baseYmin+12, $Red, $font1, "[現在値]");
imagettftext($img, 9, 0, $baseXmin+125,$baseYmin+12, $Red, $font1, "[取得日時]");
imagettftext($img, 9, 0, $baseXmin+232,$baseYmin+12, $Red, $font1, "[最大値]");
imagettftext($img, 9, 0, $baseXmin+297,$baseYmin+12, $Red, $font1, "[時刻]");
imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+26, $Blue, $font1, "粉塵");
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+26, $Blue, $font1, $dust_data_3);
imagettftext($img, 9, 0, $baseXmin+90,$baseYmin+26, $Blue, $font1, $dust_data_date_3);
imagettftext($img, 9, 0, $baseXmin+245,$baseYmin+26, $Blue, $font1, $dust_max_3);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+26, $Blue, $font1,  $dust_max_date_3);

imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+55, $Blue, $font1, "振動");
imagettftext($img, 9, 0, $baseXmin+35,$baseYmin+40, $Blue, $font1, "X=");
imagettftext($img, 9, 0, $baseXmin+35,$baseYmin+55, $Blue, $font1, "Y=");
imagettftext($img, 9, 0, $baseXmin+35,$baseYmin+70, $Blue, $font1, "Z=");
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+40, $Blue, $font1, $vib_laeq_x3);
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+55, $Blue, $font1, $vib_laeq_y3);
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+70, $Blue, $font1, $vib_laeq_z3);
imagettftext($img, 9, 0, $baseXmin+90,$baseYmin+55, $Blue, $font1, $vib_laeq_date_x3);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+40, $Blue, $font1, $vib_max_x3);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+55, $Blue, $font1, $vib_max_y3);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+70, $Blue, $font1, $vib_max_z3);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+40, $Blue, $font1,  $vib_max_date_x3);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+55, $Blue, $font1,  $vib_max_date_y3);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+70, $Blue, $font1,  $vib_max_date_z3);

imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+90, $Blue, $font1, "騒音");
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+90, $Blue, $font1, $noise_laeq_3);
imagettftext($img, 9, 0, $baseXmin+90,$baseYmin+90, $Blue, $font1, $noise_laeq_date_3);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+90, $Blue, $font1, $noise_max_3);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+90, $Blue, $font1,  $noise_max_date_3);



imagettftext($img, 10, 0, 828,296, $WBlue, $font1, "★ E2 粉塵・振動・騒音【佐和屋旅館地点】");
$max_time_h_2 = explode(" ",$hunjin2[2]);
$max_time_v_21 = explode(" ",$vib2[4]);
$max_time_v_22 = explode(" ",$vib2[4]);
$max_time_v_23 = explode(" ",$vib2[4]);
$max_time_n_2 = explode(" ",$noise2[2]);


//表示範囲
$baseXmin = 840;
$baseYmin = 302;
$baseXmax = $baseXmin+343;
$baseYmax = $baseYmin+95;

imagefilledrectangle($img, $baseXmin,$baseYmin,$baseXmax,$baseYmax, $White);
imageline($img, $baseXmin,$baseYmin+14,$baseXmax,$baseYmin+14, $Black);
imageline($img, $baseXmin,$baseYmin+28,$baseXmax,$baseYmin+28, $Black);
imageline($img, $baseXmin,$baseYmin+74,$baseXmax,$baseYmin+74, $Black);

imageline($img, $baseXmin+31,$baseYmin,$baseXmin+31,$baseYmax, $Black);
imageline($img, $baseXmin+88,$baseYmin,$baseXmin+88,$baseYmax, $Black);
imageline($img, $baseXmin+223,$baseYmin,$baseXmin+223,$baseYmax, $Black);
imageline($img, $baseXmin+287,$baseYmin,$baseXmin+287,$baseYmax, $Black);

imagerectangle($img, $baseXmin,$baseYmin,$baseXmax,$baseYmax, $Black);
imagettftext($img, 9, 0, $baseXmin+35,$baseYmin+12, $Red, $font1, "[現在値]");
imagettftext($img, 9, 0, $baseXmin+125,$baseYmin+12, $Red, $font1, "[取得日時]");
imagettftext($img, 9, 0, $baseXmin+232,$baseYmin+12, $Red, $font1, "[最大値]");
imagettftext($img, 9, 0, $baseXmin+297,$baseYmin+12, $Red, $font1, "[時刻]");
imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+26, $Blue, $font1, "粉塵");
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+26, $Blue, $font1, $dust_data_2);
imagettftext($img, 9, 0, $baseXmin+90,$baseYmin+26, $Blue, $font1, $dust_data_date_2);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+26, $Blue, $font1, $dust_max_2);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+26, $Blue, $font1,  $dust_max_date_2);

imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+55, $Blue, $font1, "振動");
imagettftext($img, 9, 0, $baseXmin+35,$baseYmin+40, $Blue, $font1, "X=");
imagettftext($img, 9, 0, $baseXmin+35,$baseYmin+55, $Blue, $font1, "Y=");
imagettftext($img, 9, 0, $baseXmin+35,$baseYmin+70, $Blue, $font1, "Z=");
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+40, $Blue, $font1, $vib_laeq_x2);
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+55, $Blue, $font1, $vib_laeq_y2);
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+70, $Blue, $font1, $vib_laeq_z2);
imagettftext($img, 9, 0, $baseXmin+90,$baseYmin+55, $Blue, $font1, $vib_laeq_date_x2);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+40, $Blue, $font1, $vib_max_x2);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+55, $Blue, $font1, $vib_max_y2);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+70, $Blue, $font1, $vib_max_z2);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+40, $Blue, $font1,  $vib_max_date_x2);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+55, $Blue, $font1,  $vib_max_date_y2);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+70, $Blue, $font1,  $vib_max_date_z2);

imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+90, $Blue, $font1, "騒音");
imagettftext($img, 9, 0, $baseXmin+58,$baseYmin+90, $Blue, $font1, $noise_laeq_2);
imagettftext($img, 9, 0, $baseXmin+90,$baseYmin+90, $Blue, $font1, $noise_laeq_date_2);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+90, $Blue, $font1, $noise_max_2);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+90, $Blue, $font1, $noise_max_date_2);


imagettftext($img, 10, 0, 786,567, $WBlue, $font1, "★");
imagettftext($img, 10, 0, 790,517, $WBlue, $font1, "E5 粉塵・振動・騒音【旅館地点】");
//imagefilledrectangle($img, 798,573,1198,633, $White);

$max_time_h_3 = explode(" ",$hunjin3[2]);
$max_time_v_31 = explode(" ",$vib3[4]);
$max_time_v_32 = explode(" ",$vib3[4]);
$max_time_v_33 = explode(" ",$vib3[4]);
$max_time_n_3 = explode(" ",$noise3[2]);


//表示範囲
$baseXmin = 798;
$baseYmin = 523;
$baseXmax = $baseXmin+343;
$baseYmax = $baseYmin+95;


imagefilledrectangle($img, $baseXmin,$baseYmin,$baseXmax,$baseYmax, $White);
imageline($img, $baseXmin,$baseYmin+14,$baseXmax,$baseYmin+14, $Black);
imageline($img, $baseXmin,$baseYmin+28,$baseXmax,$baseYmin+28, $Black);
imageline($img, $baseXmin,$baseYmin+74,$baseXmax,$baseYmin+74, $Black);

imageline($img, $baseXmin+31,$baseYmin,$baseXmin+31,$baseYmax, $Black);
imageline($img, $baseXmin+88,$baseYmin,$baseXmin+88,$baseYmax, $Black);
imageline($img, $baseXmin+223,$baseYmin,$baseXmin+223,$baseYmax, $Black);
imageline($img, $baseXmin+287,$baseYmin,$baseXmin+287,$baseYmax, $Black);

imagerectangle($img, $baseXmin,$baseYmin,$baseXmax,$baseYmax, $Black);
imagettftext($img, 9, 0, $baseXmin+35,$baseYmin+12, $Red, $font1, "[現在値]");
imagettftext($img, 9, 0, $baseXmin+125,$baseYmin+12, $Red, $font1, "[取得日時]");
imagettftext($img, 9, 0, $baseXmin+232,$baseYmin+12, $Red, $font1, "[最大値]");
imagettftext($img, 9, 0, $baseXmin+297,$baseYmin+12, $Red, $font1, "[時刻]");
imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+26, $Blue, $font1, "粉塵");
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+26, $Blue, $font1, $dust_data_1);
imagettftext($img, 9, 0, $baseXmin+90,$baseYmin+26, $Blue, $font1, $dust_data_date_1);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+26, $Blue, $font1, $dust_max_1);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+26, $Blue, $font1,  $dust_max_date_1);

imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+55, $Blue, $font1, "振動");
imagettftext($img, 9, 0, $baseXmin+35,$baseYmin+40, $Blue, $font1, "X=");
imagettftext($img, 9, 0, $baseXmin+35,$baseYmin+55, $Blue, $font1, "Y=");
imagettftext($img, 9, 0, $baseXmin+35,$baseYmin+70, $Blue, $font1, "Z=");
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+40, $Blue, $font1, $vib_laeq_x1);
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+55, $Blue, $font1, $vib_laeq_y1);
imagettftext($img, 9, 0, $baseXmin+55,$baseYmin+70, $Blue, $font1, $vib_laeq_z1);
imagettftext($img, 9, 0, $baseXmin+90,$baseYmin+55, $Blue, $font1, $vib_laeq_date_x1);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+40, $Blue, $font1, $vib_max_x1);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+55, $Blue, $font1, $vib_max_y1);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+70, $Blue, $font1, $vib_max_z1);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+40, $Blue, $font1,  $vib_max_date_x1);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+55, $Blue, $font1,  $vib_max_date_y1);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+70, $Blue, $font1,  $vib_max_date_z1);

imagettftext($img, 9, 0, $baseXmin+2,$baseYmin+90, $Blue, $font1, "騒音");
imagettftext($img, 9, 0, $baseXmin+58,$baseYmin+90, $Blue, $font1, $noise_laeq_1);
imagettftext($img, 9, 0, $baseXmin+90,$baseYmin+90, $Blue, $font1, $noise_laeq_date_1);
imagettftext($img, 9, 0, $baseXmin+248,$baseYmin+90, $Blue, $font1, $noise_max_1);
imagettftext($img, 9, 0, $baseXmin+298,$baseYmin+90, $Blue, $font1, $noise_max_date_1);






//■雨量
imagettftext($img, 10, 0, 337,25, $WBlue, $font1, "■★ 雨量【現場事務所】");
imagefilledrectangle($img, 347,35,502,115, $White);
imagerectangle($img, 347,35,502,115, $Black);

imagettftext($img, 9, 0, 350,49, $Blue, $font1, $time_date);
imagettftext($img, 9, 0, 350,70, $Blue, $font1, "1時間降水量  :" .$row_rain1[0]);
imagettftext($img, 9, 0, 480,70, $Blue, $font1, "mm");
imagettftext($img, 9, 0, 350,90, $Blue, $font1, "最大1時間降水量:".$row_rain1max[0]);
imagettftext($img, 9, 0, 480,90, $Blue, $font1, "mm");
imagettftext($img, 9, 0, 350,110, $Blue, $font1, "24時間降水量  :".$row_rain24[0]);
imagettftext($img, 9, 0, 480,110, $Blue, $font1, "mm");

//■風向風速計
imagettftext($img, 10, 0, 179,40, $WBlue, $font1, "風向・風速【現場事務所】◎");
imagefilledrectangle($img, 184,50,325,230, $White);
imagerectangle($img, 184,50,325,230, $Black);

//imagettftext($img, 9, 0, 187,64, $Blue, $font1, $time_date);
imagettftext($img, 9, 0, 187,64, $Blue, $font1, $time_date2);
imagettftext($img, 9, 0, 187,85, $Blue, $font1,  "現在の最大風速:" .$wv_max);
imagettftext($img, 9, 0, 307,85, $Blue, $font1,  "m/s");
imagettftext($img, 9, 0, 187,105, $Blue, $font1, "当日の最大風速:".$wv_max2);
imagettftext($img, 9, 0, 307,105, $Blue, $font1, "m/s");
imagettftext($img, 9, 0, 187,125, $Blue, $font1, "10分間平均風速:".$wv_avg_10m);
imagettftext($img, 9, 0, 307,125, $Blue, $font1, "m/s");

imagettftext($img, 9, 0, 187,145, $Blue, $font1, "【風向】");
//矢印作成
//$wd_data = 270;
if(strcmp($wd_data,"--"))
{

	$xpm2 = 28 * sin(($wd_data) * (pi() / 180));
	$ypm2 = 28 * cos(($wd_data) * (pi() / 180));
	$xpm1 = (28 * sin(($wd_data) * (pi() / 180))) * -1;
	$ypm1 = (28 * cos(($wd_data) * (pi() / 180))) * -1;

	$Ww = 4;
	$Hh = 28;

	$Aa[0] = 255+$xpm2;
	$Aa[1] = 180 -$ypm2;
	$Bb[0] = 255+$xpm1;
	$Bb[1] = 180 -$ypm1;

	$Vx= $Bb[0]-$Aa[0];
	$Vy= $Bb[1]-$Aa[1];
	$v = sqrt($Vx*$Vx+$Vy*$Vy);
	$Ux= $Vx/$v;
	$Uy= $Vy/$v;
	$Ll[0]= $Bb[0] - $Uy*$Ww - $Ux*$Hh;
	$Ll[1]= $Bb[1] + $Ux*$Ww - $Uy*$Hh;
	$Rr[0]= $Bb[0] + $Uy*$Ww - $Ux*$Hh;
	$Rr[1]= $Bb[1] - $Ux*$Ww - $Uy*$Hh;

	imagesetthickness($img,2);
//	imageline($img, 255+$xpm1,180 -$ypm1,255+$xpm2,180 -$ypm2, $Black);
//	imageline($img, 255+$xpm1,180 -$ypm1,$Ll[0],$Ll[1], $Black);
//	imageline($img, 255+$xpm1,180 -$ypm1,$Rr[0],$Rr[1], $Black);
//	imageline($img, $Rr[0],$Rr[1],$Ll[0],$Ll[1], $Black);
	$values = array(
	            255+$xpm1,180 -$ypm1,  // Point 1 (x, y)
	            $Rr[0],$Rr[1], // Point 2 (x, y)
	            $Ll[0],$Ll[1]  // Point 3 (x, y)
	            );
	imagefilledpolygon($img, $values, 3, $Red);

	$values2 = array(
	            255+$xpm2,180 -$ypm2,  // Point 1 (x, y)
	            $Rr[0],$Rr[1], // Point 2 (x, y)
	            $Ll[0],$Ll[1]  // Point 3 (x, y)
	            );
	imagefilledpolygon($img, $values2, 3, $Black);

	imagesetthickness($img,1);
	imageellipse($img, 255, 180, 60, 60, $Black);
	imagettftext($img, 12, 0, 252,148, $Red, $font1, "N");
	imagettftext($img, 12, 0, 288,184, $Blue, $font1, "E");
	imagettftext($img, 12, 0, 252,225, $Blue, $font1, "S");
	imagettftext($img, 12, 0, 213,184, $Blue, $font1, "W");
}
else
{
	imagettftext($img, 11, 0, 260,160, $Blue, $font1, $wd_data);
}



//■傾斜計
imagettftext($img, 10, 0, 185,330, $WBlue, $font1, "▲ 傾斜計データロガー");
imagefilledrectangle($img, 190,340,275,450, $White);
imagerectangle($img, 190,340,275,450, $Black);

$keisya[2] = substr($keisya[2],0,10);
$keisya[1] = substr($keisya[1],0,1) .substr($keisya[1],1,7) * 0.1;
$keisya2[1] = substr($keisya2[1],0,1) .substr($keisya2[1],1,7) * 0.1;
$keisya3[1] = substr($keisya3[1],0,1) .substr($keisya3[1],1,7) * 0.1;
$keisya4[1] = substr($keisya4[1],0,1) .substr($keisya4[1],1,7) * 0.1;
$keisya5[1] = substr($keisya5[1],0,1) .substr($keisya5[1],1,7) * 0.1;

imagettftext($img, 9, 0, 193,354, $Blue, $font1, $keisya[2]);
imagettftext($img, 9, 0, 193,375, $Blue, $font1, "CH0:");
imagettftext($img, 9, 0, 240,375, $Blue, $font1,  substr($keisya[1],0,1));
imagettftext($img, 9, 0, 275- strlen(substr($keisya[1],1))* 7,375, $Blue, $font1,  substr($keisya[1],1));
imagettftext($img, 9, 0, 193,390, $Blue, $font1, "CH1:");
imagettftext($img, 9, 0, 240,390, $Blue, $font1,  substr($keisya2[1],0,1));
imagettftext($img, 9, 0, 275- strlen(substr($keisya2[1],1))* 7,390, $Blue, $font1,  substr($keisya2[1],1));
imagettftext($img, 9, 0, 193,405, $Blue, $font1, "CH2:");
imagettftext($img, 9, 0, 240,405, $Blue, $font1,  substr($keisya3[1],0,1));
imagettftext($img, 9, 0, 275- strlen(substr($keisya3[1],1))* 7,405, $Blue, $font1,  substr($keisya3[1],1));
imagettftext($img, 9, 0, 193,420, $Blue, $font1, "CH3:");
imagettftext($img, 9, 0, 240,420, $Blue, $font1,  substr($keisya4[1],0,1));
imagettftext($img, 9, 0, 275- strlen(substr($keisya4[1],1))* 7,420, $Blue, $font1,  substr($keisya4[1],1));
imagettftext($img, 9, 0, 193,435, $Blue, $font1, "CH4:");
imagettftext($img, 9, 0, 240,435, $Blue, $font1,  substr($keisya5[1],0,1));
imagettftext($img, 9, 0, 275- strlen(substr($keisya5[1],1))* 7,435, $Blue, $font1,  substr($keisya5[1],1));


// ===============================================
// 描画した画像を保存 & パレットを削除
// 備考		:	
// 更新		:	2010/09/08 KMK T.Teraoka
// ===============================================
header('Content-Type: image/png');

//	imagepng($img, $imgFileName);
imagepng($img);
imagedestroy($img);

//===============================================
//	Postgresql終了処理
//	備考		:	
//	更新		:	2012/10/19 KMK-Teraoka
//===============================================
pg_close($conn);

//===============================================
//	HTML終了処理
//	備考		:	
//	更新		:	2012/10/18 KMK-Teraoka
//===============================================
//print "</body>";
//print "</html>";

?>

PHP File Manager