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