easy-osm2city-podman/managment/www/index.php
fly 82d5544015 Always sort by priority
Signed-off-by: fly <merspieler@airmail.cc>
2021-06-03 01:26:10 +02:00

92 lines
2.3 KiB
PHP

<?php
include("config.php");
// Returns numbers in string format as needed for file names
function clipNumber($number, $length)
{
$number = abs($number) . "";
while (strlen($number) < $length)
{
$number = "0" . $number;
}
return $number;
}
$con = new mysqli($SQL_SERVER, $SQL_USER, $SQL_PASSWORD, $SQL_DATABASE, $SQL_PORT);
if ($con->connect_error)
{
quit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Osm2City Worldbuild Progress</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<h2>Osm2City Worldbuild Progress</h2>
Colors:
<table border="0">
<?php
$sql = "SELECT id, name, color FROM status ORDER BY priority";
$ret = $con->query($sql)->fetch_all(MYSQLI_ASSOC);
if ($ret != False)
{
foreach($ret as $row)
{
echo '<tr style="background-color: ' . $row["color"] . '"><td>' . $row["name"] . '</td></tr>';
}
}
?>
</table>
Click on a tile to see it's detailed status.<br/>
<ul id="container">
<li>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="720" height="450" version="1.1" xmlns="http://www.w3.org/2000/svg">
<image width="720" height="450" href="map.png"/>
<?php
$sql = "SELECT topLevel.name AS name, status.color AS color FROM topLevel JOIN status ON topLevel.status_id = status.id";
$ret = $con->query($sql)->fetch_all(MYSQLI_ASSOC);
if ($ret != False)
{
$tiles = [];
foreach($ret as $row)
{
$tiles[$row["name"]] = $row["color"];
}
}
for ($i = 80; $i >= -90; $i -= 10)
{
if ($i >= 0)
{
$ns = "n";
}
else
{
$ns = "s";
}
$y = (abs($i - 80) / 10) * 25;
for ($j = -180; $j <= 170; $j += 10)
{
if ($j < 0)
{
$ew = "w";
}
else
{
$ew = "e";
}
$x = 700 - (abs($j - 170) / 10) * 20;
$name = $ew . clipNumber($j, 3) . $ns . clipNumber($i, 2);
echo '<a href="progressinfo.php?tile=' . $name . '" target="progressinfo"><rect x="' . $x . '" y="' . $y . '" width="20" height="25" style="fill: ' . $tiles[$name] . '; opacity: 0.5;"/></a>';
}
}
?>
</svg>
</li>
<li>
<iframe name="progressinfo" style="border: 0px; height: 450px; width: 100%;" src="progressinfo.php"></iframe>
</li>
</ul>
</body>
</html>