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