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