File "wave_data_view.php"
Full path: /www/waveheight/wave_data_view.php
File size: 7.66 KiB (7844 bytes)
MIME-type: text/html
Charset: utf-8
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<title>波高・周期データ</title>
<!-- css -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" crossorigin="anonymous">
<link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet">
<!-- page org style -->
<link href="./style/basic2.css" rel="stylesheet">
</head>
<body>
<?php
//現在のフォルダ名をIDとして使用
EXTRACT($_GET);
$path = explode("/" ,getcwd());
$ct = count($path) -1;
$id =$_GET['id'];
$date = $_GET['date'];
//タイトル1
$title[0] = "/www/waveheight/title1.txt";
//タイトル2
$title[1] = "/www/waveheight/title2.txt";
$title_path = ($id == 4324) ? $title[0] :$title[1];
$name = file_get_contents($title_path);
//$name = ($id == 4324) ? "C":"D";
//現在の日付と一緒の場合は自動更新にする
$now_date = strtotime(date("Y-m-d 00:00:00" ,time()));
$reload_flag = ($date == $now_date) ? 1 :0;
$reload_flag = 0;
print "<main>";
print "<div class='container-fluid'";
print "<div class='row mb-2'>";
print "<div class='col-12'>";
print "<div class='title p-2 border rounded text-center'><FONT SIZE='6'>" .$name ."</FONT></div>";
//print "<div class='title p-2 border rounded text-center'><FONT SIZE='6'>波高周期データ[地点" .$name ."]</FONT></div>";
print "</div>";
print "</div>";
$imgFileName = "view_map_w1.php?id=".$id ."&graph_id=1&date=" .$date;
$imgFileName2 = "view_map_w1.php?id=".$id ."&graph_id=2&date=" .$date;
$imgFileName3 = "view_map_w2.php?id=".$id ."&date=" .$date;
print "<SCRIPT LANGUAGE='JavaScript'>";
print "function RefreshImg(URL_,id)";
print "{";
print "console.log(" .URL_ .");";
print "uniq = new Date();";
print "uniq = \"?\"+ \"id=\" + id +\"&\" +uniq.getTime();";
print "newImage = document.imgToLoad.src;";
print "newImage2 = document.imgToLoad2.src;";
print "index = newImage.indexOf(\"?\", 0);";
print "index2 = newImage2.indexOf(\"?\", 0);";
print " if (index > 0)";
print " {";
print " newImage = newImage.substr(0, index);";
print " newImage2 = newImage2.substr(0, index2);";
print " }";
print " if(URL_ == 0)";
print " {";
print " document.imgToLoad.src = 'view_map_w1.php'+uniq;";
print " }";
print " else";
print " {";
print " document.imgToLoad2.src = 'view_map_w2.php'+uniq;";
print " }";
print "}";
print "</SCRIPT>";
print "<TABLE >";
print "<TR><TD valign='top'>";
if($reload_flag)
{
print "<IMG SRC='" .$imgFileName ."' align='top' ALT='LiveCamera' name=imgToLoad onload='setTimeout(\"RefreshImg(0,$id)\", 10000)' onerror='setTimeout(\"RefreshImg(0,$id)\", 5000)' onabort='setTimeout(\"RefreshImg(0,$id)\", 10000)' id=imgToLoad naturalsizeflag=0>";
}
else
{
print "<IMG SRC='" .$imgFileName ."' align='top'>";
}
print "</TD>";
print "<TD width='50'>";
print "</TD>";
print "<TD>";
//print "<div style='height:710px; overflow-y:scroll;'>";
if($reload_flag)
{
print "<IMG SRC='" .$imgFileName2 ."' align='top' ALT='LiveCamera' name=imgToLoad2 onload='setTimeout(\"RefreshImg(1,$id)\", 10000)' onerror='setTimeout(\"RefreshImg(1,$id)\", 5000)' onabort='setTimeout(\"RefreshImg(1,$id)\", 10000)' id=imgToLoad2 naturalsizeflag=0>";
}
else
{
print "<IMG SRC='" .$imgFileName2 ."' align='top'>";
}
print "</div>";
print "</TD>";
print "</TR>";
print "<TR>";
print "<TD valign='top'>";
//print "<div style='height:400px; overflow-y:scroll;'>";
//print "<IMG SRC='" .$imgFileName3 ."' align='top'>";
//ダウンロードパス
$DlPath = "./data/".$id ."/" .date("Ymd",time()) .".csv";
//表示データの読み込み
$DirPath = "/www/waveheight/data/".$id ."/data.csv";
$data = array();
//昇順表示
//exec('cat ' .$DirPath ,$data, $retval);
//降順表示
exec('tac' .' ' .$DirPath , $data, $retval);
$data_ct = count($data);
//データを配列の代入
for($i=0;$i < $data_ct;$i++)
{
$wave_data[$i] = explode(",",$data[$i]);
}
print "<B><A HREF='" .$DlPath ."' target='_BLANK'>CSVダウンロード </A></B>";
//表作成
print "<TABLE BORDER='1'>";
print "<TR ALIGN='center' bgcolor='#00008B'>";
print "<TD WIDTH='200'><FONT COLOR='white'>" ."日時" ."</FONT></TD>";
print "<TD WIDTH='100'><FONT COLOR='white'>" ."最高波高" ."<BR>" ."(m)" ."</FONT></TD>";
print "<TD WIDTH='100'><FONT COLOR='white'>" ."有義 波高" ."<BR>" ."(m)" ."</FONT></TD>";
print "<TD WIDTH='100'><FONT COLOR='white'>" ."ピーク周期" ."<BR>" ."(s)" ."</FONT></TD>";
print "<TD WIDTH='100'><FONT COLOR='white'>" ."平均 周期" ."<BR>" ."(s)" ."</FONT></TD>";
print "<TD WIDTH='100'><FONT COLOR='white'>" ."波向" ."</FONT></TD>";
print "</TR>";
print "</TABLE>";
print "</TD>";
print "</TR>";
print "<TR>";
print "<TD valign='top'>";
print "<div style='height:400px; overflow-y:scroll;'>";
print "<TABLE BORDER='1'>";
for($i = 0;$i < $data_ct;$i++)
{
$datetime_ = date("Y年m月d日 H時i分" ,$wave_data[$i][1]);
$wave_direction_ = conv_wave_direction($wave_data[$i][6]);
print "<TR ALIGN='center'>";
print "<TD WIDTH='200'>" .$datetime_ ."</TD>";
print "<TD WIDTH='100'>" .number_format($wave_data[$i][2], 2, '.', '') ."</TD>";
// if($id != 4324)
// {
// }
// else
// {
// print "<TD WIDTH='100'>" ."---" ."</TD>";
// }
print "<TD WIDTH='100'>" .number_format($wave_data[$i][4], 2, '.', '') ."</TD>";
print "<TD WIDTH='100'>" .number_format($wave_data[$i][3], 1, '.', '') ."</TD>";
print "<TD WIDTH='100'>" .number_format($wave_data[$i][5], 1, '.', '') ."</TD>";
print "<TD WIDTH='100'>" .$wave_direction_ ."</TD>";
print "</TR>";
}
print "</TABLE>";
print "</TD>";
print "</TR>";
print "</TABLE>";
//[関数]
//●波向きの変換
function conv_wave_direction($wave_direction_){
$direction = 0;
if($wave_direction_ == 999)
{
$direction = "--";
}
else if($wave_direction_ >= 348.75 || ($wave_direction_ >= 0 && $wave_direction_ <11.25))
{
$direction = "N";
}
else if($wave_direction_ >= 11.25 && $wave_direction_ <33.75)
{
$direction = "NNE";
}
else if($wave_direction_ >= 33.75 && $wave_direction_ <56.25)
{
$direction = "NE";
}
else if($wave_direction_ >= 56.25 && $wave_direction_ <78.75)
{
$direction = "ENE";
}
else if($wave_direction_ >= 78.75 && $wave_direction_ <101.25)
{
$direction = "E";
}
else if($wave_direction_ >= 101.25 && $wave_direction_ <123.75)
{
$direction = "ESE";
}
else if($wave_direction_ >= 123.75 && $wave_direction_ <146.25)
{
$direction = "SE";
}
else if($wave_direction_ >= 146.25 && $wave_direction_ <168.75)
{
$direction = "SSE";
}
else if($wave_direction_ >= 168.75 && $wave_direction_ <191.25)
{
$direction = "S";
}
else if($wave_direction_ >= 191.25 && $wave_direction_ <213.75)
{
$direction = "SSW";
}
else if($wave_direction_ >= 213.75 && $wave_direction_ <236.25)
{
$direction = "SW";
}
else if($wave_direction_ >= 236.25 && $wave_direction_ <258.75)
{
$direction = "WSW";
}
else if($wave_direction_ >= 258.75 && $wave_direction_ <281.25)
{
$direction = "W";
}
else if($wave_direction_ >= 281.25 && $wave_direction_ <303.75)
{
$direction = "WNW";
}
else if($wave_direction_ >= 303.75 && $wave_direction_ <326.25)
{
$direction = "NW";
}
else if($wave_direction_ >= 326.25 && $wave_direction_ <348.75)
{
$direction = "NNW";
}
return $direction;
}
?>
</main>
</body>
</html>