unfallkarte/lib/init.php

110 lines
3.6 KiB
PHP
Raw Permalink Normal View History

2023-10-09 17:52:21 +02:00
<?php
$result= $db->prepare("SELECT count(*) FROM district WHERE district=:district");
$result->bindParam(":district",$strDistrict);
$result->execute();
if ($row=$result->fetch(PDO::FETCH_NUM)) {
if ($row[0]==0) $strDistrict="hamm";
}
//$result = $db->query($strSQL);
$result= $db->prepare("SELECT * FROM district WHERE district=:district");
$result->bindParam(":district",$strDistrict);
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$strDistrict = $row['district'];
$strTitle = $row['title'];
$strGeojson = $row['geojson'];
$numULAND=$row['ULAND'];
$numUREGBEZ=$row['UREGBEZ'];
$numUKREIS=$row['UKREIS'];
$numUGEMEINDE=$row['UGEMEINDE'];
$numInfoLat=$row['lat'];
$numInfoLng=$row['lng'];
$numZoom=$row['zoom'];
$strTitle = "Unfallkarte $strTitle ";
$strIntroText = "$strTitle basierend auf den Daten des Statistischen Bundesamtes.";
$fileGeojson ="geojson/$strGeojson";
$strLocation = " AND ULAND=$numULAND AND UREGBEZ=$numUREGBEZ AND UKREIS=$numUKREIS ";
if ($numUGEMEINDE>0) {
$strLocation .= "AND UGEMEINDE=$numUGEMEINDE";
}
}
$arrDisctrict = array ();
$strSQL = "SELECT district,title FROM district ORDER BY title ASC";
$result=$db->query($strSQL);
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$arrDistrict[$row['district']]=$row['title'];
}
$strIntro ="<h4>".$strTitle."</h4>";
$strIntro .= nl2br2($strIntroText);
switch ($numVehicle) {
case 1:
case 0:
$strWhere ="IstRad = 1";
$topic=2;
break;
case 2:
$strWhere = "IstPKW = 1";
$topic=4;
break;
case 3:
$strWhere = "IstFuss = 1";
$topic=1;
break;
case 4:
$strWhere = "IstKrad = 1";
$topic=0;
break;
case 5:
$strWhere = "IstGkfz = 1";
$topic=5;
break;
case 6:
$strWhere = "IstSonstige = 1";
$topic=3;
break;
default: $strWhere ="IstRad = 1";
$topic=2;
}
$strYear = " AND UJAHR='".$numYear."' ";
$strSQL="SELECT * FROM data WHERE ".$strWhere.$strYear.$strLocation;
$result = $db->query($strSQL);
$arrMarker = array();
$arrDescription = array();
$description="";
$numId=0;
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
//print_r($row);echo "<hr>";
//$id = $row['OBJECTID'];
$id=$numId;
$numLng = $row['XGCSWGS84'];
$numLat = $row['YGCSWGS84'];
if ($row['IstRad']) $description .="mit Fahrradbeteiligung, ";
if ($row['IstPKW']) $description .="mit PKW-Beteiligung, ";
if ($row['IstFuss']) $description .="mit Fußgängerbeteiligung, ";
if ($row['IstKrad']) $description .="mit Kraftradbeteiligung, ";
if ($row['IstGkfz']) $description .="mit Güterkraftzeugbeteiligung, ";
if ($row['IstSonstige']) $description .="mit Beteiligung eines oben nicht genannten Verkehrsmittels";
$strDescription=generate_tooltip_description($row);
$strCategory=generate_category($row);
$arrMarker[]="marker[".$id."] = [L.marker([".$numLat."," .$numLng."],"
." { icon: ".$arrMarkerType[$topic]." }),'".$strCategory."'];\n"
."marker[".$id."][0].addTo(mymap);\n "
."marker[".$id."][0].bindPopup('".$strDescription."');";
$numId++;
}
$markerid=$id+1;