98 lines
3.2 KiB
PHP
98 lines
3.2 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;
|
|
}
|
|
if (isset($_GET['tile']))
|
|
{
|
|
$tile = $_GET['tile'];
|
|
}
|
|
else
|
|
{
|
|
$tile = "None";
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<link rel="stylesheet" type="text/css" href="style.css"/>
|
|
</head>
|
|
<body id="infobody">
|
|
<?php
|
|
if ($tile == "None")
|
|
{
|
|
echo "No tile selected";
|
|
}
|
|
else
|
|
{
|
|
preg_match_all('/([we])(\d{3})([sn])(\d{2})/m', $tile, $matches, PREG_SET_ORDER, 0);
|
|
$we = $matches[0][1];
|
|
$lon = (int)$matches[0][2];
|
|
$sn = $matches[0][3];
|
|
$lat = (int)$matches[0][4];
|
|
if ($we == "w")
|
|
{
|
|
$lon *= -1;
|
|
}
|
|
if ($sn == "s")
|
|
{
|
|
$lat *= -1;
|
|
}
|
|
echo '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
<svg width="450" height="450" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
|
<image width="450" height="450" href="https://ows.terrestris.de/osm/service?VERSION=1.3.0&SERVICE=WMS&REQUEST=GetMap&LAYERS=OSM-WMS&STYLES=&CRS=EPSG:4326&BBOX=' . (string)$lat . ',' . (string)$lon . ',' . (string)($lat + 10) . ',' . (string)($lon + 10) . '&WIDTH=450&HEIGHT=450&FORMAT=image/png"/>';
|
|
// Connect to DB
|
|
$con = new mysqli($SQL_SERVER, $SQL_USER, $SQL_PASSWORD, $SQL_DATABASE, $SQL_PORT);
|
|
if ($con->connect_error)
|
|
{
|
|
quit();
|
|
}
|
|
$stmt = $con->prepare("SELECT secondLevel.name AS name, status.color AS color FROM secondLevel JOIN status ON secondLevel.status_id = status.id WHERE secondLevel.parent_id = (SELECT id FROM topLevel WHERE name = ?)");
|
|
$stmt->bind_param("s", $tile);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
$ret = $result->fetch_all(MYSQLI_ASSOC);
|
|
if ($ret != False)
|
|
{
|
|
$tiles = [];
|
|
foreach($ret as $row)
|
|
{
|
|
$tiles[$row["name"]] = $row["color"];
|
|
}
|
|
$y = 405;
|
|
for ($i = $lat; $i < $lat + 10; $i++)
|
|
{
|
|
$x = 0;
|
|
for ($j = $lon; $j < $lon + 10; $j++)
|
|
{
|
|
$name = $we . clipNumber($j, 3) . $sn . clipNumber($i, 2);
|
|
//echo '<a href="progressinfo.php?tile=' . $name . '" target="progressinfo"><rect x="' . $x . '" y="' . $y . '" width="45" height="45" style="fill: ' . $tiles[$name] . '; opacity: 0.5;"/></a>';
|
|
echo '<rect x="' . $x . '" y="' . $y . '" width="45" height="45" style="fill: ' . $tiles[$name] . '; opacity: 0.5;"/>';
|
|
$x += 45;
|
|
}
|
|
$y -= 45;
|
|
}
|
|
}
|
|
echo '</svg>';
|
|
$stmt = $con->prepare("SELECT status.name AS status, COUNT(*) AS sCount, status.color AS color FROM secondLevel JOIN status ON secondLevel.status_id = status.id WHERE secondLevel.parent_id = (SELECT id FROM topLevel WHERE name = ?) GROUP BY status.id ORDER BY priority");
|
|
$stmt->bind_param("s", $tile);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
$ret = $result->fetch_all(MYSQLI_ASSOC);
|
|
echo '<table id="statustable" border="1"><tr><td>Tile Name</td><td>' . $tile . '</td></tr>';
|
|
foreach ($ret as $row)
|
|
{
|
|
echo '<tr style="background-color: ' . $row["color"] . '"><td>' . $row["status"] . '</td><td>' . $row["sCount"] . '</td></tr>';
|
|
}
|
|
echo '</table>';
|
|
}
|
|
?>
|
|
</body>
|
|
</html>
|