[362] | 1 | <?php |
---|
| 2 | /* alkisstrasse.php |
---|
| 3 | |
---|
[427] | 4 | ALKIS-Auskunft |
---|
| 5 | Author: Frank JÀger, Kommunales Rechenzentrum Minden-Ravensberg/Lippe (Lemgo) |
---|
| 6 | |
---|
[425] | 7 | Alle FlurstÃŒcke an einer StraÃe anzeigen, egal ob "mit" oder "ohne" Hausnummer |
---|
[362] | 8 | Parameter: "gml_id" aus der Tabelle "ax_lagebezeichnungkatalogeintrag" |
---|
| 9 | |
---|
| 10 | Version: |
---|
[425] | 11 | 2016-02-24 Version fÃŒr norGIS-ALKIS-Import |
---|
[422] | 12 | ... |
---|
| 13 | 2020-02-20 Authentifizierung ausgelagert in Function darf_ich() |
---|
| 14 | 2020-12-15 Input-Validation und Strict Comparisation (===) |
---|
[425] | 15 | 2021-12-09 Neue Parameter: $katAmtMix (Kataster-Amt-Mix), $PrntBtn (Drucken-SchaltflÀche) |
---|
[427] | 16 | 2022-01-13 Neue Functions LnkStf(), DsKy() |
---|
[430] | 17 | 2022-07-05 PHP 8.1: Connection verwenden bei "pg_prepare" und "pg_execute", keine NULL-Werte in String-Functions verwenden |
---|
[362] | 18 | */ |
---|
[422] | 19 | ini_set("session.cookie_httponly", 1); |
---|
[362] | 20 | session_start(); |
---|
[402] | 21 | $showkey="n"; $nodebug=""; // Var. aus Parameter initalisieren |
---|
[387] | 22 | $cntget = extract($_GET); // Parameter in Variable umwandeln |
---|
| 23 | |
---|
| 24 | // strikte Validierung aller Parameter |
---|
[422] | 25 | if (isset($gmlid)) { |
---|
| 26 | if (!preg_match('#^[0-9A-Za-z]{16}$#', $gmlid)) {die("Eingabefehler gmlid");} |
---|
| 27 | } else { |
---|
| 28 | die("Fehlender Parameter"); |
---|
| 29 | } |
---|
| 30 | if (isset($gkz)) { |
---|
| 31 | if (!preg_match('#^[0-9]{3}$#', $gkz)) {die("Eingabefehler gkz");} |
---|
| 32 | } else { |
---|
| 33 | die("Fehlender Parameter"); |
---|
| 34 | } |
---|
[387] | 35 | if (!preg_match('#^[j|n]{0,1}$#', $showkey)) {die ("Eingabefehler showkey");} |
---|
[422] | 36 | if ($showkey === "j") {$showkey=true;} else {$showkey=false;} |
---|
[402] | 37 | if (!preg_match('#^j{0,1}$#', $nodebug)) {die("Eingabefehler nodebug");} |
---|
[387] | 38 | |
---|
[422] | 39 | include "alkis_conf_location.php"; |
---|
| 40 | include "alkisfkt.php"; |
---|
[362] | 41 | ?> |
---|
[377] | 42 | <!doctype html> |
---|
| 43 | <html lang="de"> |
---|
[362] | 44 | <head> |
---|
[377] | 45 | <meta charset="utf-8"> |
---|
[387] | 46 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
---|
[362] | 47 | <title>ALKIS Straße</title> |
---|
| 48 | <link rel="stylesheet" type="text/css" href="alkisauszug.css"> |
---|
| 49 | <link rel="shortcut icon" type="image/x-icon" href="ico/Strassen.ico"> |
---|
| 50 | <script type="text/javascript"> |
---|
[378] | 51 | function ALKISexport(phaus) { |
---|
| 52 | window.open(<?php echo "'alkisexport.php?gkz=".$gkz."&tabtyp=strasse&gmlid=".$gmlid."&haus='"; ?> + phaus); |
---|
[362] | 53 | } |
---|
| 54 | </script> |
---|
| 55 | </head> |
---|
| 56 | <body> |
---|
| 57 | <?php |
---|
[422] | 58 | $erlaubnis = darf_ich(); if ($erlaubnis === 0) { die('<p class="stop1">Abbruch</p></body>'); } |
---|
[425] | 59 | $dbg=$debug; // CONF in Arbeits-Variable |
---|
| 60 | if ($nodebug === "j") {$dbg=0;} |
---|
[402] | 61 | |
---|
[377] | 62 | $con = pg_connect($dbconn." options='--application_name=ALKIS-Auskunft_alkisstrasse.php'"); |
---|
[387] | 63 | if (!$con) echo "\n<p class='err'>Fehler beim Verbinden der DB</p>"; |
---|
[362] | 64 | |
---|
| 65 | $sql ="SELECT s.land, s.regierungsbezirk, s.kreis, s.gemeinde, s.lage, s.bezeichnung AS snam, |
---|
| 66 | b.bezeichnung AS bnam, r.bezeichnung AS rnam, k.bezeichnung AS knam, g.bezeichnung AS gnam, o.gml_id AS ogml |
---|
[389] | 67 | FROM ax_lagebezeichnungkatalogeintrag s |
---|
[425] | 68 | JOIN ax_bundesland b ON s.land=b.land ".UnqKatAmt("s","b") |
---|
| 69 | ."JOIN ax_regierungsbezirk r ON s.land=r.land AND s.regierungsbezirk=r.regierungsbezirk ".UnqKatAmt("s","r") |
---|
| 70 | ."JOIN ax_kreisregion k ON s.land=k.land AND s.regierungsbezirk=k.regierungsbezirk AND s.kreis=k.kreis ".UnqKatAmt("s","k") |
---|
| 71 | ."JOIN ax_gemeinde g ON s.land=g.land AND s.regierungsbezirk=g.regierungsbezirk AND s.kreis=g.kreis AND s.gemeinde=g.gemeinde ".UnqKatAmt("s","g") |
---|
| 72 | ."LEFT JOIN ax_lagebezeichnungohnehausnummer o ON s.land=o.land AND s.regierungsbezirk=o.regierungsbezirk AND s.kreis=o.kreis AND s.gemeinde=o.gemeinde AND s.lage=o.lage |
---|
[389] | 73 | WHERE s.gml_id= $1 AND s.endet IS NULL AND b.endet IS NULL AND r.endet IS NULL AND k.endet IS NULL AND g.endet IS NULL AND o.endet IS NULL ;"; |
---|
[362] | 74 | |
---|
| 75 | $v=array($gmlid); |
---|
[430] | 76 | $res=pg_prepare($con, "", $sql); |
---|
| 77 | $res=pg_execute($con, "", $v); |
---|
[362] | 78 | if (!$res) { |
---|
[387] | 79 | echo "\n<p class='err'>Fehler bei Lagebezeichnungskatalogeintrag.</p>"; |
---|
[425] | 80 | if ($dbg > 2) {echo "\n<p class='err'>SQL=<br>".htmlentities(str_replace("$1", "'".$gmlid."'", $sql), ENT_QUOTES, "UTF-8")."</p>";} |
---|
[362] | 81 | } |
---|
[425] | 82 | if ($dbg > 0) { |
---|
| 83 | $zeianz=pg_num_rows($res); |
---|
| 84 | if ($zeianz > 1){ |
---|
| 85 | echo "\n<p class='err'>Die Abfrage liefert mehr als ein (".$zeianz.") Straßen-Objekt!</p>"; |
---|
| 86 | if ($dbg > 2) {echo "\n<p class='dbg'>SQL=<br>".htmlentities(str_replace("$1","'".$gmlid."'",$sql), ENT_QUOTES, "UTF-8")."</p>";} |
---|
| 87 | } |
---|
| 88 | } |
---|
[402] | 89 | if ($row = pg_fetch_assoc($res)) { |
---|
[427] | 90 | $lage=$row["lage"]; // Str.schl. |
---|
| 91 | $snam=$row["snam"]; // Str.name |
---|
[362] | 92 | $gem=$row["gemeinde"]; |
---|
[427] | 93 | $kennz=$gem."-".$lage." (".$snam.")"; // SchlÃŒssel als Sucheingabe in NAV brauchbar? |
---|
| 94 | echo "\n<p class='balken strasse'>ALKIS Straße ".$kennz." </p>"; |
---|
[362] | 95 | } else { |
---|
[387] | 96 | echo "\n<p class='err'>Kein Treffer bei Lagebezeichnungskatalogeintrag.</p>"; |
---|
[362] | 97 | } |
---|
| 98 | |
---|
[402] | 99 | echo "\n<h2>Straße</h2>"; |
---|
[362] | 100 | |
---|
| 101 | // Tabelle Kennzeichen |
---|
[402] | 102 | echo "\n<table class='outer'>\n<tr>" |
---|
| 103 | ."\n\t<td class='ll'><img src='ico/Strassen.png' width='16' height='16' alt=''> Straßenname:</td>" |
---|
| 104 | ."\n\t<td>" |
---|
| 105 | ."\n\t\t<table class='kennzstra' title='Lage'>" |
---|
| 106 | ."\n\t\t<tr>" |
---|
| 107 | ."\n\t\t\t<td class='head'>Land</td>" |
---|
| 108 | ."\n\t\t\t<td class='head'>Reg.-Bez.</td>" |
---|
| 109 | ."\n\t\t\t<td class='head'>Kreis</td>" |
---|
| 110 | ."\n\t\t\t<td class='head'>Gemeinde</td>" |
---|
[427] | 111 | ."\n\t\t\t<td class='head'>Straße</td>" |
---|
[402] | 112 | ."\n\t\t</tr>" |
---|
| 113 | ."\n\t\t<tr>"; |
---|
[427] | 114 | echo "\n\t\t\t<td title='Bundesland'>".DsKy($row["land"], 'Bundesland-*').$row["bnam"]." </td>" |
---|
| 115 | ."\n\t\t\t<td title='Regierungsbezirk'>".DsKy($row["regierungsbezirk"], 'Regierungsbezirk-*').$row["rnam"]." </td>" |
---|
| 116 | ."\n\t\t\t<td title='Kreis'>".DsKy($row["kreis"], 'Kreis-*').$row["knam"]." </td>" |
---|
| 117 | ."\n\t\t\t<td title='Gemeinde'>".DsKy($gem, 'Gemeinde-*').$row["gnam"]." </td>" |
---|
| 118 | ."\n\t\t\t<td title='Straße'>".DsKy($lage, 'Straßen-*')."<span class='wichtig'>".$snam."</span> </td>" |
---|
[402] | 119 | ."\n\t\t</tr>" |
---|
| 120 | ."\n\t\t</table>"; |
---|
[362] | 121 | echo "\n\t</td>\n\t<td>"; |
---|
| 122 | |
---|
| 123 | // Kopf Rechts: |
---|
| 124 | $ogml=$row["ogml"]; // ID von "Lage Ohne HsNr" |
---|
| 125 | if ($ogml != "") { |
---|
| 126 | echo "\n\t\t<p class='nwlink noprint'>" |
---|
[427] | 127 | ."\n\t\t<a href='alkislage.php?gkz=".$gkz."&ltyp=o&gmlid=".$ogml.LnkStf() |
---|
| 128 | ."' title='Lage Ohne Hausnummer'>Lage <img src='ico/Lage_an_Strasse.png' width='16' height='16' alt=''></a>" |
---|
[362] | 129 | ."\n\t\t</p>"; |
---|
| 130 | } |
---|
| 131 | echo "\n\t</td>\n</tr>\n</table>"; |
---|
| 132 | pg_free_result($res); |
---|
| 133 | |
---|
[425] | 134 | // F L U R S T Ã C K E |
---|
[387] | 135 | echo "\n\n<h3 id='fs'><img src='ico/Flurstueck.png' width='16' height='16' alt=''> Flurstücke</h3>" |
---|
| 136 | ."\n<p>Zusammenfassung von 'Lage mit Hausnummer' und 'Lage ohne Hausnummer' an dieser StraÃe</p>"; |
---|
[362] | 137 | |
---|
[389] | 138 | // ax_Flurstueck >weistAuf> ax_LagebezeichnungMitHausnummer > = h = Hauptgebaeude |
---|
| 139 | // ax_Flurstueck >zeigtAuf> ax_LagebezeichnungOhneHausnummer > = s = Strasse |
---|
[362] | 140 | // Suchkriterium: gml_id aus Katalog |
---|
[425] | 141 | $sql ="SELECT fh.gemarkungsnummer, gh.bezeichnung, fh.gml_id, fh.flurnummer, fh.zaehler, fh.nenner, fh.amtlicheflaeche, lh.gml_id AS lgml, lh.hausnummer, 'm' AS ltyp |
---|
[389] | 142 | FROM ax_flurstueck fh |
---|
| 143 | JOIN ax_lagebezeichnungmithausnummer lh ON lh.gml_id=ANY(fh.weistAuf) |
---|
[425] | 144 | JOIN ax_gemarkung gh ON fh.land=gh.land AND fh.gemarkungsnummer=gh.gemarkungsnummer ".UnqKatAmt("fh","gh") |
---|
| 145 | ."JOIN ax_lagebezeichnungkatalogeintrag sh ON lh.land=sh.land AND lh.regierungsbezirk=sh.regierungsbezirk AND lh.kreis=sh.kreis AND lh.gemeinde=sh.gemeinde AND lh.lage=sh.lage |
---|
[389] | 146 | WHERE sh.gml_id = $1 AND fh.endet IS NULL AND lh.endet IS NULL AND gh.endet IS NULL AND sh.endet IS NULL |
---|
| 147 | UNION SELECT fs.gemarkungsnummer, gs.bezeichnung, fs.gml_id, fs.flurnummer, fs.zaehler, fs.nenner, fs.amtlicheflaeche, ls.gml_id AS lgml, '' AS hausnummer, 'o' AS ltyp |
---|
| 148 | FROM ax_flurstueck fs |
---|
| 149 | JOIN ax_lagebezeichnungohnehausnummer ls ON ls.gml_id=ANY(fs.zeigtauf) |
---|
[425] | 150 | JOIN ax_gemarkung gs ON fs.land=gs.land AND fs.gemarkungsnummer=gs.gemarkungsnummer ".UnqKatAmt("fs","gs") |
---|
| 151 | ."JOIN ax_lagebezeichnungkatalogeintrag ss ON ls.land=ss.land AND ls.regierungsbezirk=ss.regierungsbezirk AND ls.kreis=ss.kreis AND ls.gemeinde=ss.gemeinde AND ls.lage=ss.lage |
---|
[389] | 152 | WHERE ss.gml_id = $1 AND fs.endet IS NULL AND ls.endet IS NULL AND gs.endet IS NULL AND ss.endet IS NULL |
---|
[377] | 153 | ORDER BY gemarkungsnummer, flurnummer, zaehler, nenner;"; |
---|
[362] | 154 | |
---|
| 155 | $v=array($gmlid); |
---|
[430] | 156 | $resf=pg_prepare($con, "", $sql); |
---|
| 157 | $resf=pg_execute($con, "", $v); |
---|
[362] | 158 | if (!$resf) { |
---|
[387] | 159 | echo "\n<p class='err'>Fehler bei Flurstück.</p>"; |
---|
[425] | 160 | if ($dbg > 2) {echo "\n<p class='err'>SQL=<br>".htmlentities(str_replace("$1", "'".$gmlid."'", $sql), ENT_QUOTES, "UTF-8")."</p>";} |
---|
[362] | 161 | } |
---|
| 162 | |
---|
| 163 | echo "\n<table class='fs'>" |
---|
| 164 | ."\n<tr>" |
---|
[377] | 165 | ."\n\t<td class='heads' title='Name der Gemarkung (Ortsteil)'>Gemarkung<img src='ico/sort.png' width='10' height='10' alt='' title='Sortierung'></td>" |
---|
| 166 | ."\n\t<td class='heads' title='Flur-Nummer'>Flur<img src='ico/sort.png' width='10' height='10' alt='' title='Sortierung'></td>" |
---|
| 167 | ."\n\t<td class='heads' title='Flurstücksnummer (Zähler / Nenner)'><img src='ico/sort.png' width='10' height='10' alt='' title='Sortierung'>Flurst.</td>" |
---|
[362] | 168 | ."\n\t<td class='head fla' title='amtliche Fläche in Quadratmeter'>Fläche</td>" |
---|
| 169 | ."\n\t<td class='head hsnr' title='Hausnummer aus der Lagebezeichnung des Flurstücks'>HsNr.</td>" |
---|
[387] | 170 | ."\n\t<td class='head nwlink noprint' title='Verlinkung zu anderen Nachweis-Arten und verbundenen Objekten'>weitere Auskunft</td>" |
---|
[362] | 171 | ."\n</tr>"; |
---|
| 172 | $j=0; |
---|
| 173 | $gwgmkg=""; // Gruppenwechsel |
---|
| 174 | $gwflur=""; |
---|
[425] | 175 | $cnths=0; // Count Haus-Lagebez. |
---|
[362] | 176 | |
---|
[387] | 177 | $zpaar=false; // Zeilen-Farbwechsel |
---|
[402] | 178 | while($rowf = pg_fetch_assoc($resf)) { |
---|
[362] | 179 | $gmkg=$rowf["bezeichnung"]; |
---|
| 180 | $flur=str_pad($rowf["flurnummer"], 3, "0", STR_PAD_LEFT); |
---|
| 181 | $fskenn=$rowf["zaehler"]; // Bruchnummer |
---|
| 182 | if ($rowf["nenner"] != "") {$fskenn.="/".$rowf["nenner"];} |
---|
| 183 | $flae=number_format($rowf["amtlicheflaeche"],0,",",".") . " m²"; |
---|
[387] | 184 | $lgml=$rowf["lgml"]; // ID von "Lage Mit/Ohne" |
---|
[377] | 185 | $ltyp=$rowf["ltyp"]; // mit/ohne HsNr |
---|
[362] | 186 | |
---|
[387] | 187 | if ($zpaar) {$trclass='paa';} else {$trclass='unp';} |
---|
| 188 | $zpaar=!$zpaar; |
---|
| 189 | echo "\n<tr class='".$trclass."'>" |
---|
[427] | 190 | ."\n\t<td>".DsKy($rowf["gemarkungsnummer"], 'Gemarkungsnummer'); |
---|
[362] | 191 | if ($gwgmkg != $gmkg) { |
---|
| 192 | echo "<b>".$gmkg."</b></td>"; |
---|
| 193 | $gwgmkg=$gmkg; |
---|
| 194 | $gwflur=""; |
---|
| 195 | } else { |
---|
| 196 | echo $gmkg."</td>"; |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | if ($gwflur != $flur) { |
---|
| 200 | echo "\n\t<td><b>".$flur."</b></td>"; |
---|
| 201 | $gwflur=$flur; |
---|
| 202 | } else { |
---|
| 203 | echo "\n\t<td>".$flur."</td>"; |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | echo "\n\t<td><span class='wichtig'>".$fskenn."</span></td>" |
---|
| 207 | ."\n\t<td class='fla'>".$flae."</td>" |
---|
| 208 | ."\n\t<td class='hsnr'>".$rowf["hausnummer"]."</td>" |
---|
| 209 | ."\n\t<td>\n\t\t<p class='nwlink noprint'>"; |
---|
[422] | 210 | if ($ltyp === 'm') { // nur Typ "Mit Haus" anzeigen. Dar Typ 'o' ist immer gleich und identisch mit dem Link im Kopf |
---|
[427] | 211 | echo "\n\t\t<a href='alkislage.php?gkz=".$gkz."&ltyp=".$ltyp."&gmlid=".$lgml.LnkStf() |
---|
| 212 | ."' title='Lagebezeichnung mit Hausnummer'>Lage <img src='ico/Lage_mit_Haus.png' width='16' height='16' alt=''></a> "; |
---|
[362] | 213 | $cnths++; |
---|
| 214 | } |
---|
[377] | 215 | // Link FlurstÃŒcksnachweis |
---|
[427] | 216 | echo "\n\t\t<a href='alkisfsnw.php?gkz=".$gkz."&gmlid=".$rowf["gml_id"].LnkStf()."&eig=n" |
---|
| 217 | ."' title='Flurstücksnachweis'>Flurstück <img src='ico/Flurstueck_Link.png' width='16' height='16' alt=''></a>" |
---|
| 218 | ."\n\t\t</p>\n\t</td>" |
---|
[362] | 219 | ."\n</tr>"; |
---|
| 220 | $j++; |
---|
| 221 | } |
---|
| 222 | echo "\n</table>"; |
---|
| 223 | if ($j > 6) { |
---|
| 224 | echo "<p class='cnt'>".$j." Flurstücke"; |
---|
[387] | 225 | if ($cnths > 1) {echo " und ".$cnths." Hauptgebäude";} |
---|
[427] | 226 | echo " mit dieser Straße in der Lagebezeichnung</p>"; |
---|
[362] | 227 | } |
---|
| 228 | pg_free_result($resf); |
---|
| 229 | |
---|
[425] | 230 | echo "\n<div class='buttonbereich noprint'>\n<hr>" |
---|
| 231 | ."\n\t<a title='zurück' href='javascript:history.back()'><img src='ico/zurueck.png' width='16' height='16' alt='zurück'></a> "; |
---|
| 232 | 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> ";} |
---|
| 233 | echo "\n\t<a title='Export als CSV' href=\"javascript:ALKISexport('')\">alle<img src='ico/download.png' width='16' height='16' alt='Export'></a> " |
---|
| 234 | ."\n\t<a title='CSV - nur Flurstücke mit Hausnummer' href=\"javascript:ALKISexport('m')\">mit HsNr<img src='ico/download.png' width='16' height='16' alt='Export'></a> " |
---|
| 235 | ."\n\t<a title='CSV - nur Flurstücke ohne Hausnummer' href=\"javascript:ALKISexport('o')\">ohne<img src='ico/download.png' width='16' height='16' alt='Export'></a> " |
---|
| 236 | ."\n</div>"; |
---|
[362] | 237 | |
---|
[425] | 238 | footer($gmlid, selbstverlinkung()."?", ""); |
---|
| 239 | ?> |
---|
[362] | 240 | |
---|
| 241 | </body> |
---|
| 242 | </html> |
---|