unfallkarte/statistics/gemeinde_detail.php

316 lines
9.6 KiB
PHP
Raw Normal View History

2023-10-09 19:14:10 +02:00
<?php
require_once("../config.php");
2023-10-09 20:46:26 +02:00
require_once("../lib/attributes.php");
require_once("include.php");
2023-10-09 19:14:10 +02:00
$numLand=5; // NRW
$numRegbez=(isset($_GET['regbez'])) ? (int)$_GET['regbez'] : 1;
$numKreis=(isset($_GET['kreis'])) ? (int)$_GET['kreis'] : 1;
$numGemeinde=(isset($_GET['gemeinde'])) ? (int)$_GET['gemeinde'] : 1;
$numJahr=2022;
// Name, Population und Fläche der Gemeinde
$result= $db->prepare("SELECT * FROM community WHERE ULAND=:land AND UREGBEZ=:regbez AND UKREIS=:kreis AND UGEMEINDE=:gemeinde");
$result->bindParam(":land",$numLand);
$result->bindParam(":regbez",$numRegbez);
$result->bindParam(":kreis",$numKreis);
$result->bindParam(":gemeinde",$numGemeinde);
$result->execute();
if ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$strName=$row['Name'];
$numFlaeche=$row['Flaeche'];
$numPopulation=$row['Einwohner'];
2023-10-10 11:04:06 +02:00
$numRegbez=$row['UREGBEZ'];
$numKreis=$row['UKREIS'];
$numGemeinde=$row['UGEMEINDE'];
} else {exit;}
2023-10-09 19:14:10 +02:00
2023-10-09 20:46:26 +02:00
$strLocation=" AND ULAND=$numLand AND UREGBEZ=$numRegbez AND UKREIS=$numKreis AND UGEMEINDE=$numGemeinde ";
2023-10-10 11:04:06 +02:00
$resultUnfallzahlen = get_unfallzahlen($numJahr,$strLocation);
$resultUnfallart = get_unfallart($numJahr,$strLocation);
$resultUnfalltyp = get_unfalltyp($numJahr,$strLocation);
$resultBeteiligte = get_beteiligte($numJahr,$strLocation);
$numGesamt=0;
2023-10-09 20:46:26 +02:00
2023-10-09 19:14:10 +02:00
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fahrrad-Unfallstatistik NRW</title>
<link rel="stylesheet" href="../css/bootstrap.min.css"/>
<link rel="stylesheet" href="//cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
<script src="../js/jquery.min.js"></script>
<script src="//cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
2023-10-10 11:37:55 +02:00
<script src="https://code.highcharts.com/highcharts.js"></script>
2023-10-09 19:14:10 +02:00
<style>
.rechts {text-align:right;background-color:#eee;}
.l {border-left: 1px solid black; }
</style>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Unfallkarte</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbars" aria-controls="navbars" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbars">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="../index.php">Karte</a>
</li>
</ul>
<div>
<ul class="navbar-nav mr-auto right">
<li class="nav-item active">
<a class="nav-link" href="index.php">Statistik <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../impressum.php">Impressum</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="../datenschutz.php">Datenschutzerklärung</a>
</li>
</ul>
</div>
</nav>
<!-- Ende Navbar -->
<div class="container" style="margin-top:4em;">
<h1>Fahrradunfälle in <?=$strName?></h2>
2023-10-09 20:46:26 +02:00
Einwohnerzahl:<?=$numPopulation?>&nbsp;&nbsp; Fläche:<?=$numFlaeche?> km<sup>2</sup>
2023-10-10 11:37:55 +02:00
<!-- Unfallzahlen -->
2023-10-09 19:14:10 +02:00
<h2>Unfallzahlen</h2>
2023-10-09 20:46:26 +02:00
<div class="row">
<div class="col-5">
<table class="table table-sm">
2023-10-10 11:04:06 +02:00
<?php
//DEBUG echo "<pre>"; print_r($resultUnfallzahlen);echo "</pre>";
$numGesamt=0;
foreach ($resultUnfallzahlen as $row) {
echo "<tr><td>".$arrCategory[$row['UKATEGORIE']]."</td><td>".$row['anz']."</td></tr>\n";
$numGesamt+=$row['anz'];
}
?>
2023-10-09 20:46:26 +02:00
<tr><th>Gesamt</th><td><strong><?=$numGesamt?></strong></td></tr>
</table>
2023-10-10 11:37:55 +02:00
<table class="table table-sm">
2023-10-09 20:46:26 +02:00
<tr><th>Quote pro Tausend Einwohner</th><td><?= round($numGesamt/$numPopulation*1000,2) ?></td></tr>
<tr><th>Quote pro Fläche</th><td><?= round($numGesamt/$numFlaeche,1) ?> /km<sup>2</sup></td></tr>
</table>
</div>
2023-10-10 12:23:12 +02:00
<div class="col-7">
2023-10-10 11:37:55 +02:00
<div id="c_unfallzahlen"></div>
</div>
2023-10-09 20:46:26 +02:00
</div>
2023-10-10 11:37:55 +02:00
<!-- Unfallbeteilgte -->
2023-10-09 20:46:26 +02:00
<div class="row">
<div class="col-5">
<h4>Unfallbeteiligte</h4>
2023-10-10 11:04:06 +02:00
<table class='table table-sm'>
2023-10-09 20:46:26 +02:00
<?php
2023-10-10 11:04:06 +02:00
// DEBUG: echo "<pre>"; print_r($resultBeteiligte);echo "</pre>";
foreach ($resultBeteiligte as $key => $numCount) {
echo "<tr><td>".$arrBeteiligte[$key]."</td><td>".$numCount."</td></tr>\n";
}
?>
</table>
2023-10-09 20:46:26 +02:00
</div>
2023-10-10 12:22:16 +02:00
<div class="col-7">
<div id="c_unfallbeteiligte"></div>
</div>
2023-10-09 20:46:26 +02:00
</div>
2023-10-10 11:54:57 +02:00
<!-- Unfalltyp -->
2023-10-09 20:46:26 +02:00
<div class="row">
<div class="col-5">
<h4>Unfalltyp</h4>
2023-10-10 11:04:06 +02:00
<table class='table table-sm'>
2023-10-09 20:46:26 +02:00
<?php
2023-10-10 11:04:06 +02:00
foreach ($resultUnfalltyp as $row) {
echo "<tr><td>".$arrUnfalltyp[$row['UTYP1']]."</td><td>".$row['anz']."</td></tr>\n";
}
2023-10-09 20:46:26 +02:00
?>
2023-10-10 11:04:06 +02:00
</table>
2023-10-09 20:46:26 +02:00
</div>
2023-10-10 11:54:57 +02:00
<div class="col-7">
<div id="c_unfalltyp"></div>
</div>
2023-10-09 20:46:26 +02:00
</div>
2023-10-10 11:37:55 +02:00
<!-- Unfallarten -->
2023-10-09 20:46:26 +02:00
<div class="row">
<div class="col-5">
<h4>Unfallart</h4>
2023-10-10 11:04:06 +02:00
<table class='table table-sm'>
2023-10-09 20:46:26 +02:00
<?php
2023-10-10 11:04:06 +02:00
foreach ($resultUnfallart as $row) {
echo "<tr><td>".$arrUnfallart[$row['UART']]."</td><td>".$row['anz']."</td></tr>\n";
}
?>
</table>
2023-10-09 20:46:26 +02:00
</div>
2023-10-10 11:54:57 +02:00
<div class="col-7">
<div id="c_unfallarten"></div>
</div>
2023-10-09 20:46:26 +02:00
</div>
2023-10-09 19:14:10 +02:00
</div>
2023-10-10 12:22:16 +02:00
<?= get_series_beteiligte($resultBeteiligte,$arrBeteiligte) ?>
2023-10-10 11:37:55 +02:00
</body>
<script>
Highcharts.chart('c_unfallzahlen', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Unfallzahlen',
2023-10-10 11:54:57 +02:00
align: 'center'
2023-10-10 11:37:55 +02:00
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
}
}
},
series: [{
name: 'Unfallzahlen',
colorByPoint: true,
2023-10-10 11:54:57 +02:00
data: <?= get_series($resultUnfallzahlen,$arrCategory,"UKATEGORIE") ?>
}]
});
Highcharts.chart('c_unfallarten', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Unfallarten',
align: 'center'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
}
}
},
series: [{
name: 'Unfallarten',
colorByPoint: true,
data: <?= get_series($resultUnfallart,$arrUnfallart,"UART") ?>
2023-10-10 11:37:55 +02:00
}]
});
2023-10-10 11:54:57 +02:00
Highcharts.chart('c_unfalltyp', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
2023-10-10 12:22:16 +02:00
text: 'Unfalltypen',
2023-10-10 11:54:57 +02:00
align: 'center'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
}
}
},
series: [{
name: 'Unfallarten',
colorByPoint: true,
data: <?= get_series($resultUnfalltyp,$arrUnfalltyp,"UTYP1") ?>
}]
});
2023-10-10 12:22:16 +02:00
Highcharts.chart('c_unfallbeteiligte', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Unfallbeteiligte',
align: 'center'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
}
}
},
series: [{
name: 'Unfallarten',
colorByPoint: true,
data: <?= get_series_beteiligte($resultBeteiligte,$arrBeteiligte) ?>
}]
});
2023-10-10 11:37:55 +02:00
</script>
2023-10-09 19:14:10 +02:00
</html>