[362] | 1 | <?php |
---|
| 2 | /* alkisbaurecht.php - Baurecht |
---|
| 3 | |
---|
[427] | 4 | ALKIS-Auskunft |
---|
| 5 | Author: Frank JÀger, Kommunales Rechenzentrum Minden-Ravensberg/Lippe (Lemgo) |
---|
| 6 | |
---|
[362] | 7 | Version: |
---|
[425] | 8 | 2016-02-24 Version fÃŒr norGIS-ALKIS-Import |
---|
[422] | 9 | .... |
---|
| 10 | 2020-02-20 Authentifizierung ausgelagert in Function darf_ich() |
---|
| 11 | 2020-12-03 function selbstverlinkung() statt $_SERVER['PHP_SELF'] |
---|
| 12 | 2020-12-15 Input-Validation und Strict Comparisation (===) |
---|
[425] | 13 | 2021-12-09 Neue Parameter: $katAmtMix (Kataster-Amt-Mix), $PrntBtn (Drucken-SchaltflÀche) |
---|
[427] | 14 | 2022-01-13 Limit in Variable. Neue Functions LnkStf(), DsKy() |
---|
[430] | 15 | 2022-07-05 PHP 8.1: Connection verwenden bei "pg_prepare" und "pg_execute", keine NULL-Werte in String-Functions verwenden |
---|
[362] | 16 | */ |
---|
[422] | 17 | ini_set("session.cookie_httponly", 1); |
---|
[362] | 18 | session_start(); |
---|
[402] | 19 | $showkey="n"; $nodebug=""; // Var. aus Parameter initalisieren |
---|
[387] | 20 | $cntget = extract($_GET); // Parameter in Variable umwandeln |
---|
| 21 | |
---|
| 22 | // strikte Validierung aller Parameter |
---|
[422] | 23 | if (isset($gmlid)) { |
---|
| 24 | if (!preg_match('#^[0-9A-Za-z]{16}$#', $gmlid)) {die("Eingabefehler gmlid");} |
---|
| 25 | } else { |
---|
| 26 | die("Fehlender Parameter"); |
---|
| 27 | } |
---|
| 28 | if (isset($gkz)) { |
---|
| 29 | if (!preg_match('#^[0-9]{3}$#', $gkz)) {die("Eingabefehler gkz");} |
---|
| 30 | } else { |
---|
| 31 | die("Fehlender Parameter"); |
---|
| 32 | } |
---|
[387] | 33 | if (!preg_match('#^[j|n]{0,1}$#', $showkey)) {die ("Eingabefehler showkey");} |
---|
[422] | 34 | if ($showkey === "j") {$showkey=true;} else {$showkey=false;} |
---|
[402] | 35 | if (!preg_match('#^j{0,1}$#', $nodebug)) {die("Eingabefehler nodebug");} |
---|
[387] | 36 | |
---|
[422] | 37 | include "alkis_conf_location.php"; |
---|
| 38 | include "alkisfkt.php"; |
---|
| 39 | |
---|
[377] | 40 | echo <<<END |
---|
| 41 | <!doctype html> |
---|
| 42 | <html lang="de"> |
---|
[362] | 43 | <head> |
---|
[377] | 44 | <meta charset="utf-8"> |
---|
[387] | 45 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
---|
[362] | 46 | <title>ALKIS Bau-, Raum- oder Bodenordnungsrecht</title> |
---|
| 47 | <link rel="stylesheet" type="text/css" href="alkisauszug.css"> |
---|
| 48 | <link rel="shortcut icon" type="image/x-icon" href="ico/Gericht.ico"> |
---|
| 49 | </head> |
---|
| 50 | <body> |
---|
[377] | 51 | END; |
---|
[362] | 52 | |
---|
[422] | 53 | $erlaubnis = darf_ich(); if ($erlaubnis === 0) {die('<p class="stop1">Abbruch</p></body>');} |
---|
[427] | 54 | $dbg=$debug; |
---|
[425] | 55 | if ($nodebug === "j") {$dbg=0;} |
---|
[377] | 56 | $con = pg_connect($dbconn." options='--application_name=ALKIS-Auskunft_alkisbaurecht.php'"); |
---|
[387] | 57 | if (!$con) echo "\n<p class='err'>Fehler beim Verbinden der DB</p>"; |
---|
[362] | 58 | |
---|
[412] | 59 | // Spalte "a.dokumentation" ist immer leer |
---|
[362] | 60 | $sql ="SELECT r.ogc_fid, r.artderfestlegung as adfkey, r.name, r.stelle, r.bezeichnung AS rechtbez, |
---|
[412] | 61 | a.beschreibung AS adfbez, d.bezeichnung AS stellbez, d.stellenart, wd.beschreibung, wd.dokumentation, round(st_area(r.wkb_geometry)::numeric,0) AS flae |
---|
[362] | 62 | FROM ax_bauraumoderbodenordnungsrecht r |
---|
[412] | 63 | LEFT JOIN ax_artderfestlegung_bauraumoderbodenordnungsrecht a ON r.artderfestlegung = a.wert |
---|
[425] | 64 | LEFT JOIN ax_dienststelle d ON r.land=d.land AND r.stelle=d.stelle ".UnqKatAmt("r","d") |
---|
| 65 | ."LEFT JOIN ax_behoerde wd ON d.stellenart = wd.wert |
---|
[362] | 66 | WHERE r.gml_id= $1 AND r.endet IS NULL AND d.endet IS NULL;"; |
---|
| 67 | |
---|
| 68 | $v = array($gmlid); |
---|
[430] | 69 | $res = pg_prepare($con, "", $sql); |
---|
| 70 | $res = pg_execute($con, "", $v); |
---|
[362] | 71 | if (!$res) { |
---|
[387] | 72 | echo "\n<p class='err'>Fehler bei Baurecht.</p>"; |
---|
[425] | 73 | if ($dbg > 2) {echo "\n<p class='err'>SQL=<br>".htmlentities(str_replace("$1", "'".$gmlid."'", $sql), ENT_QUOTES, "UTF-8")."</p>";} |
---|
[362] | 74 | } |
---|
[425] | 75 | if ($dbg > 0) { |
---|
| 76 | $zeianz=pg_num_rows($res); |
---|
| 77 | if ($zeianz > 1){ |
---|
| 78 | echo "\n<p class='err'>Die Abfrage liefert mehr als ein (".$zeianz.") Baurecht-Objekt!</p>"; |
---|
| 79 | if ($dbg > 2) {echo "\n<p class='dbg'>SQL=<br>".htmlentities(str_replace("$1","'".$gmlid."'",$sql), ENT_QUOTES, "UTF-8")."</p>";} |
---|
| 80 | } |
---|
| 81 | } |
---|
[402] | 82 | if ($row = pg_fetch_assoc($res)) { |
---|
[362] | 83 | $artfest=$row["adfkey"]; // Art der Festlegung, Key |
---|
| 84 | $verfnr=$row["rechtbez"]; // Verfahrens-Nummer |
---|
| 85 | $enam=$row["name"]; |
---|
| 86 | $stellb=$row["stellbez"]; |
---|
| 87 | $stella=$row["stellenart"]; |
---|
[422] | 88 | $behb=$row["beschreibung"]; |
---|
| 89 | $behd=$row["dokumentation"]; |
---|
[362] | 90 | |
---|
[427] | 91 | echo "<p class='balken recht'>ALKIS Bau-, Raum- oder Bodenordnungsrecht ".$artfest."-".$verfnr." </p>"; |
---|
[387] | 92 | echo "\n<h2><img src='ico/Gericht.png' width='16' height='16' alt=''> Bau-, Raum- oder Bodenordnungsrecht</h2>"; |
---|
[362] | 93 | echo "\n<table>" |
---|
| 94 | ."\n<tr>" |
---|
[427] | 95 | ."\n\t<td class='li'>Art der Festlegung:</td>" |
---|
| 96 | ."\n\t<td>".DsKy($artfest, '* Art der Festlegung')."<span class='wichtig'>".$row["adfbez"]."</span></td>" |
---|
[362] | 97 | ."\n</tr>"; |
---|
| 98 | if ($enam != "") { |
---|
| 99 | echo "\n<tr>" |
---|
| 100 | ."\n\t<td class='li'>Eigenname des Gebietes:</td>" |
---|
| 101 | ."\n\t<td>".$enam."</td>" |
---|
| 102 | . "\n</tr>"; |
---|
| 103 | } |
---|
| 104 | if ($verfnr != "") { |
---|
| 105 | echo "\n<tr>" |
---|
| 106 | ."\n\t<td class='li'>Verfahrensnummer:</td>" |
---|
| 107 | ."\n\t<td>".$verfnr."</td>" |
---|
| 108 | ."\n</tr>"; |
---|
| 109 | } |
---|
[427] | 110 | if ($stellb != "") { // z.B. Umlegung *mit* und Baulast *ohne* Dienststelle |
---|
[362] | 111 | echo "\n<tr>" |
---|
[427] | 112 | ."\n\t<td class='li'>Dienststelle:</td>\n\t<td>".DsKy($row["stelle"], 'Dienststelle-*').$stellb."</td>" |
---|
[362] | 113 | ."\n</tr>"; |
---|
| 114 | if ($stella != "") { |
---|
| 115 | echo "\n<tr>" |
---|
[427] | 116 | ."\n\t<td class='li'>Art der Dienststelle:</td>" |
---|
| 117 | ."\n\t<td>".DsKy($stella, '* Art der Dienststelle')."<span title='".$behd."'>".$behb."</span>"."</td>" |
---|
[362] | 118 | ."\n</tr>"; |
---|
| 119 | } |
---|
| 120 | } |
---|
| 121 | echo "\n<tr>" |
---|
| 122 | ."\n\t<td class='li'>Fläche:</td>"; |
---|
| 123 | $flae=number_format($row["flae"],0,",",".")." m²"; |
---|
| 124 | echo "\n\t<td>".$flae."</td>" |
---|
| 125 | ."\n</tr>" |
---|
| 126 | . "\n</table>"; |
---|
| 127 | } else { |
---|
| 128 | echo "\n<p class='err'>Fehler! Kein Treffer bei gml_id=".$gmlid."</p>"; |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | echo "\n<h2><img src='ico/Flurstueck.png' width='16' height='16' alt=''> betroffene Flurstücke</h2>\n" |
---|
| 132 | ."\n<p>Ermittelt durch geometrische Verschneidung. Nach Größe absteigend.</p>"; |
---|
| 133 | |
---|
[427] | 134 | $fslimit=200; |
---|
[425] | 135 | $sql ="SELECT f.gml_id, g.bezeichnung, f.gemarkungsnummer, f.flurnummer, f.zaehler, f.nenner, f.amtlicheflaeche, round(st_area(ST_Intersection(r.wkb_geometry,f.wkb_geometry))::numeric,1) AS schnittflae |
---|
| 136 | FROM ax_flurstueck f |
---|
| 137 | JOIN ax_gemarkung g ON f.gemeindezugehoerigkeit_land=g.land AND f.gemarkungsnummer=g.gemarkungsnummer ".UnqKatAmt("f","g") |
---|
| 138 | ."JOIN ax_bauraumoderbodenordnungsrecht r |
---|
| 139 | ON st_intersects(r.wkb_geometry,f.wkb_geometry) = true AND st_area(st_intersection(r.wkb_geometry,f.wkb_geometry)) > 0.05 |
---|
[377] | 140 | WHERE r.gml_id= $1 AND f.endet IS NULL AND r.endet IS NULL "; |
---|
[425] | 141 | if ($filtgem === '' ) { |
---|
[377] | 142 | $v=array($gmlid); |
---|
| 143 | } else { |
---|
[422] | 144 | $sql.="AND f.gemeindezugehoerigkeit_kreis = $2 AND f.gemeindezugehoerigkeit_gemeinde = $3 "; // ZustÀndiges Gebiet |
---|
[377] | 145 | $v=array($gmlid, $filtkreis, $filtgem); |
---|
| 146 | } |
---|
[427] | 147 | $sql.="ORDER BY schnittflae DESC LIMIT ".$fslimit.";"; |
---|
[362] | 148 | // > 0.0 ist gemeint, Ungenauigkeit durch st_simplify |
---|
[425] | 149 | // Limit: Flurbereinig. kann groà werden! |
---|
[362] | 150 | // Trotz Limit lange Antwortzeit, wegen OrderBy -> intersection |
---|
[377] | 151 | |
---|
[430] | 152 | $res=pg_prepare($con, "", $sql); |
---|
| 153 | $res=pg_execute($con, "", $v); |
---|
[362] | 154 | if (!$res) { |
---|
[422] | 155 | echo "\n<p class='err'>Keine Flurstücke ermittelt.<br></p>"; |
---|
[425] | 156 | //if ($dbg > 2) {echo "\n<p class='err'>SQL=<br>".htmlentities(str_replace("$1", "'".$gmlid."'", $sql), ENT_QUOTES, "UTF-8")."</p>";} // ggf. mehrere Parameter! |
---|
[362] | 157 | } |
---|
| 158 | |
---|
| 159 | echo "\n<table class='fs'>" |
---|
| 160 | ."\n<tr>" |
---|
[425] | 161 | ."\n\t<td class='head' title='Gemarkung'>Gemarkung</td>" |
---|
| 162 | ."\n\t<td class='head' title='Flurnummer'>Flur</td>" |
---|
| 163 | ."\n\t<td class='head' title='Flurstücksnummer Zähler / Nenner'>Flurstück</td>" |
---|
[377] | 164 | ."\n\t<td class='heads fla' title='geometrische Schnittfläche'><img src='ico/sort.png' width='10' height='10' alt='' title='Sortierung'>Fläche</td>" |
---|
[362] | 165 | ."\n\t<td class='head fla' title='amtliche Flurstücksfläche, Buchfläche'>von</td>" |
---|
| 166 | ."\n\t<td class='head nwlink' title='Link zum Flurstück'>weitere Auskunft</td>" |
---|
| 167 | ."\n</tr>"; |
---|
| 168 | |
---|
| 169 | $fscnt=0; |
---|
[402] | 170 | while($row = pg_fetch_assoc($res)) { |
---|
[362] | 171 | $fscnt++; |
---|
[425] | 172 | $gmkgnr=$row["gemarkungsnummer"]; |
---|
| 173 | $gemarkung=$row["bezeichnung"]; |
---|
| 174 | $nen=$row["nenner"]; |
---|
[362] | 175 | echo "\n<tr>" |
---|
[427] | 176 | ."\n\t<td>".DsKy($gmkgnr, 'Gemarkungsnummer').$gemarkung."</td>" |
---|
[425] | 177 | ."\n\t<td>".$row["flurnummer"]."</td>" |
---|
| 178 | ."\n\t<td><span class='wichtig'>".$row["zaehler"]; |
---|
[427] | 179 | if ($nen != "") {echo "/".$nen;} |
---|
[362] | 180 | echo "</span></td>" |
---|
| 181 | ."\n\t<td class='fla'>".$row["schnittflae"]." m²</td>" |
---|
| 182 | ."\n\t<td class='fla'>".$row["amtlicheflaeche"]." m²</td>" |
---|
| 183 | ."\n\t<td class='nwlink noprint'>" |
---|
[427] | 184 | ."\n\t\t<a href='alkisfsnw.php?gkz=".$gkz."&gmlid=".$row["gml_id"].LnkStf()."&eig=n' " |
---|
[362] | 185 | ."title='Flurstücksnachweis'>Flurstück " |
---|
| 186 | ."\n\t\t\t<img src='ico/Flurstueck_Link.png' width='16' height='16' alt=''>" |
---|
| 187 | ."\n\t\t</a>" |
---|
| 188 | ."\n\t</td>" |
---|
| 189 | ."\n</tr>"; |
---|
| 190 | } |
---|
| 191 | echo "\n</table>"; |
---|
| 192 | |
---|
[422] | 193 | if ($fscnt === 0) { // nicht gefunden |
---|
| 194 | if ($filtgem === '' ) { // ungefiltert |
---|
[387] | 195 | echo "\n<p class='err'>Kein Flurstück gefunden.</p>"; |
---|
[377] | 196 | } else { // Wahrscheinliche Ursache = Filter |
---|
[387] | 197 | echo "\n<p class='err'>Kein Flurstück im berechtigten Bereich.</p>"; |
---|
[425] | 198 | // if ($dbg > 2) {echo "\n<p class='err'>SQL=<br>".htmlentities($sql, ENT_QUOTES, "UTF-8")."<br>$1 = ".$gmlid." $2 = ".$filtkreis." $3 = ".$filtgem."</p>";} |
---|
[377] | 199 | } |
---|
[427] | 200 | } elseif ($fscnt >= $fslimit) { |
---|
| 201 | echo "<p>... und weitere Flurstücke (Limit ".$fslimit." erreicht).</p>"; |
---|
[362] | 202 | } |
---|
| 203 | |
---|
| 204 | pg_close($con); |
---|
[425] | 205 | echo " |
---|
| 206 | <div class='buttonbereich noprint'>\n<hr>" |
---|
| 207 | ."\n\t<a title='zurück' href='javascript:history.back()'><img src='ico/zurueck.png' width='16' height='16' alt='zurück' /></a> "; |
---|
| 208 | if ($PrntBtn==true){echo "\n\t<a title='Drucken' href='javascript:window.print()'><img src='ico/print.png' width='16' height='16' alt='Drucken'></a> ";} |
---|
| 209 | echo "\n</div>"; |
---|
[362] | 210 | |
---|
[422] | 211 | footer($gmlid, selbstverlinkung()."?", ""); |
---|
[362] | 212 | ?> |
---|
| 213 | |
---|
| 214 | </body> |
---|
| 215 | </html> |
---|