hanze/iwa-panda2

humidity check + cleaned up output (43ceaed84fbbf8826a005cf6c28b71b6feb9bcd4)
Repositories | README.md

commit 43ceaed84fbbf8826a005cf6c28b71b6feb9bcd4
parent eb41e6a27c8cf969c1396ac06646a9300e2cb1ec
Author: Johs <[email protected]>
Date:   Wed,  7 Jun 2023 12:08:49 +0200

humidity check + cleaned up output

Diffstat:
MModel/Key.php38++++++++++++++++++++++++++------------
Mindex.php2+-
2 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/Model/Key.php b/Model/Key.php @@ -2,7 +2,7 @@ Class Key{ function myfunction($key){ if ($key['data'] != '3jvl7yb5sRr80s6lTdeOyxV9VTQZkCPRp7bKOWKFWxfL2vhsU4Hhpgcmz9qe0zEk'){ - return 'no'; + echo("no"); } else{ $db = new mysqli("86.92.67.21", "friedel", "hailiwa", "wap2"); $t = new Lollipop\Template(); @@ -31,11 +31,10 @@ Class Key{ <th> Wind speed </th> <th> Wind chill corrected temp </th> <th> Humidity </th> + <th> Warning </th> </tr> </thead> <tbody> - - </tbody> <?php foreach($weather_data as $data) { echo "<tr>"; @@ -44,6 +43,7 @@ Class Key{ echo "<td>" . $data['wind_speed'] . "</td>"; echo "<td>" . windchill($data["temperature"], $data['wind_speed']) . "</td>"; echo "<td>" . humid($data["temperature"], $data['dew_point']) . "</td>"; + echo "<td>" . checkHumid($data["temperature"], $data['dew_point']) . "</td>"; echo "</tr>"; } ?> @@ -56,25 +56,39 @@ Class Key{ } } } -function windchill($temp, $wind){ +function windchill($temp, $wind): float +{ return 13.12 + 0.6215*$temp - 11.37 * ($wind^0.16) + 0.3965* $temp * ($wind^0.16); } -function humid($temp, $dewp){ +function humid($temp, $dewp): float|int +{ $specific_humidity = exp((17.625*$dewp)/(243.04+$dewp)); $saturation_point = exp((17.625*$temp)/(243.04+$temp)); return ($specific_humidity / $saturation_point) * 100; } + +function checkHumid($temp, $dewp): string +{ + $specific_humidity = exp((17.625*$dewp)/(243.04+$dewp)); + $saturation_point = exp((17.625*$temp)/(243.04+$temp)); + $humidity = ($specific_humidity / $saturation_point) * 100; + if ($humidity<50){ + return "warning"; + } else { + return "dontchu worry"; + } +} ?> -//SELECT * -//FROM weather_data wd -//JOIN station s ON wd.station_name = s.name -//JOIN contract_station cs ON cs.station_name = s.name -//JOIN contract c ON cs.contract_id = c.contract_id -//WHERE c.token = "3jvl/yb?sRr80s6lTdeOyxV9VTQZkCPRp/bKOWKFWxfL2vhsU4Hhpgcmz9qe0zEk" -\ No newline at end of file +<!--//SELECT *--> +<!--//FROM weather_data wd--> +<!--//JOIN station s ON wd.station_name = s.name--> +<!--//JOIN contract_station cs ON cs.station_name = s.name--> +<!--//JOIN contract c ON cs.contract_id = c.contract_id--> +<!--//WHERE c.token = "3jvl/yb?sRr80s6lTdeOyxV9VTQZkCPRp/bKOWKFWxfL2vhsU4Hhpgcmz9qe0zEk"--> +\ No newline at end of file diff --git a/index.php b/index.php @@ -17,7 +17,7 @@ $router->addRoute(["POST"], "/", function($vars){ $router->addRoute(["GET"], "/dashboard", "views/dashboard.php"); $router->addRoute(["GET"], "/api/:data", function($vars) { $key = new Key; - var_dump($key->myfunction($vars)); + $key->myfunction($vars); }); $router->route(); \ No newline at end of file