source: trunk/info/info/alkisn/alkisausk.php @ 362

Revision 362, 9.9 KB checked in by frank.jaeger, 5 years ago (diff)

Anpassung der ALKIS-Buchauskunft an die Datenbank-Struktur des norGIS-ALKIS-Importer.

Line 
1<?php
2/*      alkisausk.php
3
4        ALKIS-Buchauskunft, Kommunales Rechenzentrum Minden-Ravensberg/Lippe (Lemgo).
5        Dies Programm wird aus dem Mapserver-Template (FeatureInfo) aufgerufen.
6        Parameter: &gkz, &gml_id (optional &id)
7        Dies Programm gibt einen kurzen Überblick zum FlurstÃŒck, z.B. Eigentuemer ohne Adresse
8        FÃŒr detaillierte Angaben wird zum GB- oder FS-Nachweis verlinkt.
9        Siehe auch alkisinlayausk.php - eine Variante fÃŒr den Einbau in einen iFrame
10
11        Version:
12        2016-02-24 Version fuer norGIS-ALKIS-Import
13*/
14session_start();
15$cntget = extract($_GET);
16require_once("alkis_conf_location.php");
17if ($auth == "mapbender") {require_once($mapbender);}
18include("alkisfkt.php");
19$keys = isset($_GET["showkey"]) ? $_GET["showkey"] : "n";
20if ($keys == "j") {$showkey=true;} else {$showkey=false;}
21echo <<<END
22<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
23<html>
24<head>
25        <meta name="author" content="b600352" >
26        <meta http-equiv="cache-control" content="no-cache">
27        <meta http-equiv="pragma" content="no-cache">
28        <meta http-equiv="expires" content="0">
29        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
30        <link rel="stylesheet" type="text/css" href="alkisauszug.css">
31        <link rel="shortcut icon" type="image/x-icon" href="ico/Flurstueck.ico">
32        <title>ALKIS-Auskunft</title>
33        <style type='text/css' media='print'>
34                .noprint { visibility: hidden;}
35        </style>
36</head>
37<body>
38END;
39$con = pg_connect("host=".$dbhost." port=".$dbport." dbname=".$dbname." user=".$dbuser." password=".$dbpass);
40if (!$con) {echo "<br>Fehler beim Verbinden der DB.\n<br>";}
41
42// *** F L U R S T U E C K ***
43$sql ="SELECT f.flurnummer, f.zaehler, f.nenner, f.amtlicheflaeche, g.gemarkungsnummer, g.bezeichnung
44FROM ax_flurstueck f LEFT JOIN ax_gemarkung g ON f.land=g.land AND f.gemarkungsnummer=g.gemarkungsnummer
45WHERE f.gml_id= $1 AND f.endet IS NULL;";
46
47$v = array($gmlid);
48$res = pg_prepare("", $sql);
49$res = pg_execute("", $v);
50if (!$res) {
51        echo "\n<p class='err'>Fehler bei Flurstuecksdaten.</p>\n";
52        if ($debug > 2) {echo "<p class='err'>SQL=<br>".$sql."<br>$1 = gml_id = '".$gmlid."'</p>";}
53}
54
55if ($row = pg_fetch_array($res)) {
56        $gemkname=htmlentities($row["bezeichnung"], ENT_QUOTES, "UTF-8");
57        $gmkgnr=$row["gemarkungsnummer"];
58        $flurnummer=$row["flurnummer"];
59        $flstnummer=$row["zaehler"];
60        $nenner=$row["nenner"];
61        if ($nenner > 0) $flstnummer.="/".$nenner; // BruchNr
62        $flae=$row["amtlicheflaeche"];
63        $flae=number_format($flae,0,",",".") . " m&#178;";
64} else {
65        echo "<p class='err'>Kein Treffer fuer gml_id=".$gmlid."</p>";
66}
67
68// Balken
69echo "\n<p class='fsausk'>ALKIS-Auskunft Flurst&uuml;ck-&Uuml;bersicht ".$gmkgnr."-".$flurnummer."-".$flstnummer."</p>";
70
71echo "\n<table class='outer'>\n<tr><td>";
72        // linke Seite
73        echo "\n<h1>ALKIS-Auskunft</h1>"
74        ."\n<h2><img src='ico/Flurstueck.png' width='16' height='16' alt=''> Flurst&uuml;ck - &Uuml;bersicht</h2>";
75echo "</td><td align='right'>";
76        // rechte Seite
77        echo "<img src='pic/AAA.gif' alt=''>"
78."</td></tr></table>";
79
80echo "\n<table class='outer'>\n<tr>\n<td>"
81        ."\n\t<table class='kennzfs' title='Flurst&uuml;ckskennzeichen'>\n\t<tr>"
82        ."\n\t\t<td class='head'>Gmkg</td>\n\t\t<td class='head'>Flur</td>\n\t\t<td class='head'>Flurst-Nr.</td>\n\t</tr>"
83        ."\n\t<tr>\n\t\t<td title='Gemarkung'>";
84        if ($showkey) {echo "<span class='key'>".$gmkgnr."</span><br>";}
85        echo $gemkname."</td>"
86        . "\n\t\t<td title='Flurnummer'>".$flurnummer."</td>"
87        ."\n\t\t<td title='Flurst&uuml;cksnummer (Z&auml;hler / Nenner)'><span class='wichtig'>".$flstnummer."</span></td>\n\t</tr>"
88        ."\n\t</table>"
89."\n</td>\n<td>"
90."\n\t<p class='nwlink'>weitere Auskunft:<br>";
91
92// Flurstuecksnachweis (o. Eigent.)
93echo "\n\t<a href='alkisfsnw.php?gkz=".$gkz."&amp;gmlid=".$gmlid."&amp;eig=n";
94        if ($showkey) {echo "&amp;showkey=j";}
95        echo "' title='Flurst&uuml;cksnachweis, alle Flurst&uuml;cksdaten'>Flurst&uuml;ck "
96        ."<img src='ico/Flurstueck_Link.png' width='16' height='16' alt=''>"
97."</a><br>";
98
99// FS- u. Eigent.-NW
100echo "\n\t\t<a href='alkisfsnw.php?gkz=".$gkz."&amp;gmlid=".$gmlid."&amp;eig=j";
101        if ($showkey) {echo "&amp;showkey=j";}
102        echo "' title='Flurst&uuml;ck mit Eigent&uuml;mer'>Flurst&uuml;ck mit Eigent&uuml;mer "
103        ."<img src='ico/Flurstueck_Link.png' width='16' height='16' alt=''>"
104."</a><br>";
105
106// FS-Historie
107echo "\n\t\t<a href='alkisfshist.php?gkz=".$gkz."&amp;gmlid=".$gmlid;
108        if ($showkey) {echo "&amp;showkey=j";}
109        echo "' title='Vorg&auml;nger des Flurst&uuml;cks'>Historie "
110        ."<img src='ico/Flurstueck_Historisch.png' width='16' height='16' alt=''>"
111."</a><br>";
112
113// Gebaeude-NW
114echo "\n\t\t<a href='alkisgebaeudenw.php?gkz=".$gkz."&amp;gmlid=".$gmlid;
115        if ($showkey) {echo "&amp;showkey=j";}
116        echo "' title='Geb&auml;udenachweis'>Geb&auml;ude "
117        ."<img src='ico/Haus.png' width='16' height='16' alt=''>"
118."</a>"
119. "\n\t</p>\n</td>";
120
121// Lagebezeichnung MIT Hausnummer (Adresse)
122$sql ="SELECT DISTINCT l.gml_id, s.gml_id AS kgml, l.gemeinde, l.lage, l.hausnummer, s.bezeichnung
123FROM ax_flurstueck f JOIN ax_lagebezeichnungmithausnummer l ON l.gml_id=ANY(f.weistauf)
124LEFT JOIN ax_lagebezeichnungkatalogeintrag s ON l.kreis=s.kreis AND l.gemeinde=s.gemeinde AND l.lage=s.lage
125WHERE f.gml_id= $1 AND f.endet IS NULL AND l.endet IS NULL AND s.endet IS NULL ORDER BY l.gemeinde, l.lage, l.hausnummer;";
126
127$v = array($gmlid);
128$res = pg_prepare("", $sql);
129$res = pg_execute("", $v);
130if (!$res) {
131        echo "<p class='err'>Fehler bei Lagebezeichnung mit Hausnummer.</p>";
132        if ($debug > 2) {echo "<p class='err'>SQL=<br>".$sql."<br>$1 = gml_id = '".$gmlid."'</p>";}
133}
134$j=0;
135while($row = pg_fetch_array($res)) {
136        $sname = htmlentities($row["bezeichnung"], ENT_QUOTES, "UTF-8"); // Str.-Name
137        echo "\n<tr>\n\t"
138                ."\n\t<td class='lr'>".$sname."&nbsp;".$row["hausnummer"]."</td>"
139                ."\n\t<td>\n\t\t<p class='nwlink noprint'>"
140                        ."\n\t\t\t<a title='Lagebezeichnung mit Hausnummer' href='alkislage.php?gkz=".$gkz."&amp;ltyp=m&amp;gmlid=".$row["gml_id"]."'>Lage "
141                        ."<img src='ico/Lage_mit_Haus.png' width='16' height='16' alt=''></a>&nbsp;"
142                        ."\n\t\t\t<a href='alkisstrasse.php?gkz=".$gkz."&amp;gmlid=".$row["kgml"]
143                        ."' title='Stra&szlig;e'>Stra&szlig;e <img src='ico/Strassen.png' width='16' height='16' alt=''></a>"
144                ."\n\t\t</p>\n\t</td>"
145        ."\n</tr>";
146        $j++;
147}
148echo "\n</tr>\n</table>\n";
149
150// Flurstuecksflaeche
151echo "\n<p class='fsd'>Flurst&uuml;cksfl&auml;che: <b>".$flae."</b></p>\n";
152
153// *** G R U N D B U C H ***
154echo "\n<h2><img src='ico/Grundbuch_zu.png' width='16' height='16' alt=''> Grundbuch</h2>";
155// ALKIS: FS >istgebucht> GS >istBestandteilVon> GB.
156$sql ="SELECT b.gml_id, b.bezirk, b.buchungsblattnummermitbuchstabenerweiterung as blatt, b.blattart, wa.v AS blattartv,
157s.gml_id AS s_gml, s.buchungsart, s.laufendenummer, s.zaehler, s.nenner, z.bezeichnung, wb.v AS bart
158FROM ax_flurstueck f
159JOIN ax_buchungsstelle s ON f.istgebucht=s.gml_id
160JOIN ax_buchungsblatt b ON s.istbestandteilvon=b.gml_id
161LEFT JOIN ax_buchungsblattbezirk z ON z.land=b.land AND z.bezirk=b.bezirk
162LEFT JOIN alkis_wertearten wa ON cast(b.blattart AS character varying)=wa.k AND wa.element='ax_buchungsblatt' AND wa.bezeichnung='blattart'
163LEFT JOIN alkis_wertearten wb ON cast(s.buchungsart AS character varying)=wb.k AND wb.element='ax_buchungsstelle' AND wb.bezeichnung='buchungsart'
164WHERE f.gml_id= $1 AND f.endet IS NULL AND s.endet IS NULL AND b.endet IS NULL
165ORDER BY b.bezirk, b.buchungsblattnummermitbuchstabenerweiterung, s.laufendenummer;";
166
167$v = array($gmlid);
168$resg = pg_prepare("", $sql);
169$resg = pg_execute("", $v);
170if (!$resg) {
171        echo "\n<p class='err'>Keine Buchungen.</p>\n";
172        if ($debug > 2) {echo "<p class='err'>SQL=<br>".$sql."<br>$1 = gml_id = '".$gmlid."'</p>";}
173}
174
175$j=0; // Z.Blatt
176while($rowg = pg_fetch_array($resg)) {
177        $beznam=$rowg["bezeichnung"];
178        echo "\n<table class='outer'>\n<tr>\n<td>";
179                $blattkey=$rowg["blattart"];
180                $blattart=$rowg["blattartv"];
181                if ($blattkey == 1000) {
182                        echo "\n\t<table class='kennzgb' title='Bestandskennzeichen'>";
183                } else {
184                        echo "\n\t<table class='kennzgbf' title='Bestandskennzeichen'>"; // dotted
185                }
186                        echo "\n\t<tr>"
187                                ."\n\t\t<td class='head'>Bezirk</td>"
188                                ."\n\t\t<td class='head'>".$blattart."</td>"
189                                ."\n\t\t<td class='head'>Lfd-Nr,</td>"
190                                ."\n\t\t<td class='head'>Buchungsart</td>"
191                        ."\n\t</tr>";
192                        echo "\n\t<tr>"
193                                ."\n\t\t<td title='Grundbuchbezirk'>";
194                                        if ($showkey) {echo "<span class='key'>".$rowg["bezirk"]."</span><br>";}
195                                echo $beznam."</td>"
196                                ."\n\t\t<td title='Grundbuch-Blatt'><span class='wichtig'>".$rowg["blatt"]."</span></td>"
197                                ."\n\t\t<td title='Bestandsverzeichnis-Nummer (BVNR, Grundst&uuml;ck)'>".$rowg["laufendenummer"]."</td>"
198                                ."\n\t\t<td title='Buchungsart'>";
199                                        if ($showkey) {echo "<span class='key'>".$rowg["buchungsart"]."</span><br>";}
200                                        echo $rowg["bart"]
201                                ."</td>"
202                        ."\n\t</tr>"
203                ."\n\t</table>";
204
205                if ($rowg["zahler"] <> "") {
206                        echo "\n<p class='ant'>".$rowg["zahler"]."/".$rowg["nenner"]."&nbsp;Anteil am Flurst&uuml;ck</p>";
207                }
208                echo "\n</td>\n<td>"
209                ."\n\t<p class='nwlink'>weitere Auskunft:<br>"
210                        ."\n\t\t<a href='alkisbestnw.php?gkz=".$gkz."&amp;gmlid=".$rowg[0];
211                                if ($showkey) {echo "&amp;showkey=j";}
212                                echo "' title='Grundbuchnachweis'>".$blattart." <img src='ico/GBBlatt_link.png' width='16' height='16' alt=''>"
213                        ."</a>"
214                ."\n\t</p>"
215        ."\n</td>\n</tr>\n</table>";
216
217        // E I G E N T U E M E R
218        if ($blattkey == 5000) { // SchlÃŒssel Blatt-Art
219                echo "\n<p>Keine Angaben zum Eigentum bei fiktivem Blatt</p>\n"
220                ."\n<p>Siehe weitere Grundbuchbl&auml;tter mit Rechten an dem fiktiven Blatt.</p>\n";
221        } else { // kein Eigent. bei fiktiv. Blatt
222                echo "\n<h3><img src='ico/Eigentuemer_2.png' width='16' height='16' alt=''> Angaben zum Eigentum</h3>\n";
223
224                // Ausgabe Name in Function
225                $n = eigentuemer($con, $rowg["gml_id"], false); // ohne Adr.
226
227                if ($n == 0) { // keine NamNum, kein Eigent.
228                        echo "\n<p class='err'>Keine Eigent&uuml;mer gefunden.</p>"
229                        ."\n<p class='err'>Bezirk ".$rowg["bezirk"]." Blatt ".$rowg["blatt"]." Blattart ".$blattkey." (".$blattart.")</p>";
230                }
231        }
232        $j++;
233}
234if ($j == 0) {echo "\n<p class='err'>Keine Buchungen gefunden.</p>";}
235echo "\n<hr>";
236
237footer($gmlid, $_SERVER['PHP_SELF']."?", "");
238
239?>
240</body>
241</html>
Note: See TracBrowser for help on using the repository browser.