[362] | 1 | <?php |
---|
| 2 | /* alkisbaurecht.php - Baurecht |
---|
| 3 | ALKIS-Buchauskunft, Kommunales Rechenzentrum Minden-Ravensberg/Lippe (Lemgo). |
---|
| 4 | |
---|
| 5 | Version: |
---|
| 6 | 2016-02-24 Version fuer norGIS-ALKIS-Import |
---|
[377] | 7 | 2016-11-29 HTML5, Gemeinsam genutzte Datenbanken ermöglichen |
---|
[387] | 8 | 2017-06-08 Validierung Eingabeparameter, Feinkorrekturen |
---|
[389] | 9 | 2017-10-09 Sauber filtern auf endet IS NULL |
---|
[402] | 10 | 2018-04-23 &nodebug |
---|
[362] | 11 | */ |
---|
| 12 | session_start(); |
---|
[402] | 13 | $showkey="n"; $nodebug=""; // Var. aus Parameter initalisieren |
---|
[387] | 14 | $cntget = extract($_GET); // Parameter in Variable umwandeln |
---|
| 15 | |
---|
| 16 | // strikte Validierung aller Parameter |
---|
| 17 | if (!isset($gmlid) or !preg_match('#^[0-9A-Za-z]{16}$#', $gmlid)) {die("Eingabefehler gmlid");} |
---|
| 18 | if (!isset($gkz) or !preg_match('#^[0-9]{3}$#', $gkz)) {die("Eingabefehler gkz");} |
---|
| 19 | if (!preg_match('#^[j|n]{0,1}$#', $showkey)) {die ("Eingabefehler showkey");} |
---|
| 20 | if ($showkey == "j") {$showkey=true;} else {$showkey=false;} |
---|
[402] | 21 | if (!preg_match('#^j{0,1}$#', $nodebug)) {die("Eingabefehler nodebug");} |
---|
[387] | 22 | |
---|
[362] | 23 | require_once("alkis_conf_location.php"); |
---|
| 24 | if ($auth == "mapbender") {require_once($mapbender);} |
---|
| 25 | include("alkisfkt.php"); // f. Footer |
---|
[377] | 26 | echo <<<END |
---|
| 27 | <!doctype html> |
---|
| 28 | <html lang="de"> |
---|
[362] | 29 | <head> |
---|
[377] | 30 | <meta charset="utf-8"> |
---|
[387] | 31 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
---|
[362] | 32 | <title>ALKIS Bau-, Raum- oder Bodenordnungsrecht</title> |
---|
| 33 | <link rel="stylesheet" type="text/css" href="alkisauszug.css"> |
---|
| 34 | <link rel="shortcut icon" type="image/x-icon" href="ico/Gericht.ico"> |
---|
| 35 | </head> |
---|
| 36 | <body> |
---|
[377] | 37 | END; |
---|
[362] | 38 | |
---|
[402] | 39 | // Mit URL-Parameter "&nodebug=j" kann man die Entwicklungsumgebung (in Conf definiert) ausschalten. |
---|
| 40 | // Manuell an die URL anfügen, wirkt nur temporär und wird nicht in Links weiter gereicht. |
---|
| 41 | if ($nodebug == "j") {$debug=0;} |
---|
| 42 | |
---|
[377] | 43 | $con = pg_connect($dbconn." options='--application_name=ALKIS-Auskunft_alkisbaurecht.php'"); |
---|
[387] | 44 | if (!$con) echo "\n<p class='err'>Fehler beim Verbinden der DB</p>"; |
---|
[362] | 45 | |
---|
| 46 | // Spalte "a.d" ist immer leer |
---|
| 47 | $sql ="SELECT r.ogc_fid, r.artderfestlegung as adfkey, r.name, r.stelle, r.bezeichnung AS rechtbez, |
---|
| 48 | a.v AS adfbez, d.bezeichnung AS stellbez, d.stellenart, wd.v, wd.d, round(st_area(r.wkb_geometry)::numeric,0) AS flae |
---|
| 49 | FROM ax_bauraumoderbodenordnungsrecht r |
---|
| 50 | LEFT JOIN alkis_wertearten a ON cast(r.artderfestlegung AS character varying)=a.k AND a.element='ax_bauraumoderbodenordnungsrecht' AND a.bezeichnung='artderfestlegung' |
---|
| 51 | LEFT JOIN ax_dienststelle d ON r.land=d.land AND r.stelle=d.stelle |
---|
| 52 | LEFT JOIN alkis_wertearten wd ON cast(d.stellenart AS character varying)=wd.k AND wd.element='ax_dienststelle' AND wd.bezeichnung='stellenart' |
---|
| 53 | WHERE r.gml_id= $1 AND r.endet IS NULL AND d.endet IS NULL;"; |
---|
| 54 | |
---|
| 55 | $v = array($gmlid); |
---|
| 56 | $res = pg_prepare("", $sql); |
---|
| 57 | $res = pg_execute("", $v); |
---|
| 58 | if (!$res) { |
---|
[387] | 59 | echo "\n<p class='err'>Fehler bei Baurecht.</p>"; |
---|
| 60 | if ($debug > 2) {echo "\n<p class='err'>SQL=<br>".htmlentities($sql, ENT_QUOTES, "UTF-8")."<br>$1 = ".$gmlid."</p>";} |
---|
[362] | 61 | } |
---|
[402] | 62 | if ($row = pg_fetch_assoc($res)) { |
---|
[362] | 63 | $artfest=$row["adfkey"]; // Art der Festlegung, Key |
---|
| 64 | $verfnr=$row["rechtbez"]; // Verfahrens-Nummer |
---|
| 65 | $enam=$row["name"]; |
---|
| 66 | $stellb=$row["stellbez"]; |
---|
| 67 | $stella=$row["stellenart"]; |
---|
| 68 | |
---|
| 69 | // Balken |
---|
[387] | 70 | echo "<p class='recht'>ALKIS Bau-, Raum- oder Bodenordnungsrecht ".$artfest."-".$verfnr." </p>"; |
---|
[362] | 71 | |
---|
[387] | 72 | echo "\n<h2><img src='ico/Gericht.png' width='16' height='16' alt=''> Bau-, Raum- oder Bodenordnungsrecht</h2>"; |
---|
[362] | 73 | |
---|
| 74 | echo "\n<table>" |
---|
| 75 | ."\n<tr>" |
---|
| 76 | ."\n\t<td class='li'>Art der Festlegung:</td>\n\t<td>"; |
---|
| 77 | if ($showkey) {echo "<span class='key'>(".$artfest.")</span> ";} |
---|
| 78 | echo "<span class='wichtig'>".$row["adfbez"]."</span></td>" |
---|
| 79 | ."\n</tr>"; |
---|
| 80 | if ($enam != "") { |
---|
| 81 | echo "\n<tr>" |
---|
| 82 | ."\n\t<td class='li'>Eigenname des Gebietes:</td>" |
---|
| 83 | ."\n\t<td>".$enam."</td>" |
---|
| 84 | . "\n</tr>"; |
---|
| 85 | } |
---|
| 86 | if ($verfnr != "") { |
---|
| 87 | echo "\n<tr>" |
---|
| 88 | ."\n\t<td class='li'>Verfahrensnummer:</td>" |
---|
| 89 | ."\n\t<td>".$verfnr."</td>" |
---|
| 90 | ."\n</tr>"; |
---|
| 91 | } |
---|
| 92 | if ($stellb != "") { // z.B. Umlegung *mit* und Baulast *ohne* Dienststelle, darum bezirk testen |
---|
| 93 | echo "\n<tr>" |
---|
| 94 | ."\n\t<td class='li'>Dienststelle:</td>\n\t<td>"; |
---|
| 95 | if ($showkey) {echo "<span class='key'>(".$row["stelle"].")</span> ";} |
---|
| 96 | echo $stellb |
---|
| 97 | ."</td>" |
---|
| 98 | ."\n</tr>"; |
---|
| 99 | if ($stella != "") { |
---|
| 100 | echo "\n<tr>" |
---|
| 101 | ."\n\t<td class='li'>Art der Dienststelle:</td>" |
---|
| 102 | ."\n\t<td>"; |
---|
| 103 | if ($showkey) {echo " <span class='key'>(".$stella.")</span>";} |
---|
| 104 | echo "<span title='".$row["d"]."'>".$row["v"]."</span>"; |
---|
| 105 | echo "</td>" |
---|
| 106 | ."\n</tr>"; |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | echo "\n<tr>" |
---|
| 110 | ."\n\t<td class='li'>Fläche:</td>"; |
---|
| 111 | $flae=number_format($row["flae"],0,",",".")." m²"; |
---|
| 112 | echo "\n\t<td>".$flae."</td>" |
---|
| 113 | ."\n</tr>" |
---|
| 114 | . "\n</table>"; |
---|
| 115 | } else { |
---|
| 116 | echo "\n<p class='err'>Fehler! Kein Treffer bei gml_id=".$gmlid."</p>"; |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | echo "\n<h2><img src='ico/Flurstueck.png' width='16' height='16' alt=''> betroffene Flurstücke</h2>\n" |
---|
| 120 | ."\n<p>Ermittelt durch geometrische Verschneidung. Nach Größe absteigend.</p>"; |
---|
| 121 | |
---|
| 122 | $sql ="SELECT f.gml_id, f.flurnummer, f.zaehler, f.nenner, f.amtlicheflaeche, round(st_area(ST_Intersection(r.wkb_geometry,f.wkb_geometry))::numeric,1) AS schnittflae |
---|
| 123 | FROM ax_flurstueck f, ax_bauraumoderbodenordnungsrecht r |
---|
[377] | 124 | WHERE r.gml_id= $1 AND f.endet IS NULL AND r.endet IS NULL "; |
---|
| 125 | if ($filtgem == '' ) { // ungefiltert |
---|
| 126 | $v=array($gmlid); |
---|
| 127 | } else { |
---|
| 128 | $sql.="AND f.kreis = $2 AND f.gemeinde = $3 "; // Zuständiges Gebiet |
---|
| 129 | $v=array($gmlid, $filtkreis, $filtgem); |
---|
| 130 | } |
---|
| 131 | $sql.="AND st_intersects(r.wkb_geometry,f.wkb_geometry) = true |
---|
[362] | 132 | AND st_area(st_intersection(r.wkb_geometry,f.wkb_geometry)) > 0.05 |
---|
| 133 | ORDER BY schnittflae DESC LIMIT 50;"; |
---|
| 134 | // > 0.0 ist gemeint, Ungenauigkeit durch st_simplify |
---|
| 135 | // Limit: Flurbereinig. kann gross werden! |
---|
| 136 | // Trotz Limit lange Antwortzeit, wegen OrderBy -> intersection |
---|
[377] | 137 | |
---|
[362] | 138 | $res=pg_prepare("", $sql); |
---|
| 139 | $res=pg_execute("", $v); |
---|
| 140 | if (!$res) { |
---|
[387] | 141 | echo "\n<p class='err'>Keine Flurstücke ermittelt.<br>\nSQL=<br></p>"; |
---|
| 142 | // if ($debug > 2) {echo "\n<p class='err'>SQL=<br>".htmlentities($sql, ENT_QUOTES, "UTF-8")."<br>$1 = ".$gmlid."</p>";} |
---|
[362] | 143 | } |
---|
| 144 | |
---|
| 145 | echo "\n<table class='fs'>" |
---|
| 146 | ."\n<tr>" |
---|
| 147 | ."\n\t<td class='head' title='Flur- und Flurstücksnummer'>Flurstück</td>" |
---|
[377] | 148 | ."\n\t<td class='heads fla' title='geometrische Schnittfläche'><img src='ico/sort.png' width='10' height='10' alt='' title='Sortierung'>Fläche</td>" |
---|
[362] | 149 | ."\n\t<td class='head fla' title='amtliche Flurstücksfläche, Buchfläche'>von</td>" |
---|
| 150 | ."\n\t<td class='head nwlink' title='Link zum Flurstück'>weitere Auskunft</td>" |
---|
| 151 | ."\n</tr>"; |
---|
| 152 | |
---|
| 153 | $fscnt=0; |
---|
[402] | 154 | while($row = pg_fetch_assoc($res)) { |
---|
[362] | 155 | $fscnt++; |
---|
| 156 | echo "\n<tr>" |
---|
| 157 | ."\n\t<td>".$row["flurnummer"]."-<span class='wichtig'>".$row["zaehler"]; |
---|
| 158 | $nen=$row["nenner"]; |
---|
| 159 | if ($nen != "") {echo "/".$nen;} |
---|
| 160 | echo "</span></td>" |
---|
| 161 | ."\n\t<td class='fla'>".$row["schnittflae"]." m²</td>" |
---|
| 162 | ."\n\t<td class='fla'>".$row["amtlicheflaeche"]." m²</td>" |
---|
| 163 | ."\n\t<td class='nwlink noprint'>" |
---|
| 164 | ."\n\t\t<a href='alkisfsnw.php?gkz=".$gkz."&gmlid=".$row["gml_id"]."&eig=n' " |
---|
| 165 | ."title='Flurstücksnachweis'>Flurstück " |
---|
| 166 | ."\n\t\t\t<img src='ico/Flurstueck_Link.png' width='16' height='16' alt=''>" |
---|
| 167 | ."\n\t\t</a>" |
---|
| 168 | ."\n\t</td>" |
---|
| 169 | ."\n</tr>"; |
---|
| 170 | } |
---|
| 171 | echo "\n</table>"; |
---|
| 172 | |
---|
[377] | 173 | if ($fscnt == 0) { // nicht gefunden |
---|
| 174 | if ($filtgem == '' ) { // ungefiltert |
---|
[387] | 175 | echo "\n<p class='err'>Kein Flurstück gefunden.</p>"; |
---|
[377] | 176 | } else { // Wahrscheinliche Ursache = Filter |
---|
[387] | 177 | echo "\n<p class='err'>Kein Flurstück im berechtigten Bereich.</p>"; |
---|
| 178 | // if ($debug > 2) {echo "\n<p class='err'>SQL=<br>".htmlentities($sql, ENT_QUOTES, "UTF-8")."<br>$1 = ".$gmlid." $2 = ".$filtkreis." $3 = ".$filtgem."</p>";} |
---|
[377] | 179 | } |
---|
| 180 | } elseif ($fscnt == 50) { |
---|
[362] | 181 | echo "<p>... und weitere Flurstücke (Limit 50 erreicht).</p>"; |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | pg_close($con); |
---|
| 185 | echo <<<END |
---|
| 186 | |
---|
[377] | 187 | <div class='buttonbereich noprint'> |
---|
| 188 | <hr> |
---|
| 189 | <a title="zurück" href='javascript:history.back()'><img src="ico/zurueck.png" width="16" height="16" alt="zurück" /></a> |
---|
| 190 | <a title="Drucken" href='javascript:window.print()'><img src="ico/print.png" width="16" height="16" alt="Drucken" /></a> |
---|
| 191 | </div> |
---|
[362] | 192 | END; |
---|
| 193 | |
---|
| 194 | footer($gmlid, $_SERVER['PHP_SELF']."?", ""); |
---|
| 195 | |
---|
| 196 | ?> |
---|
| 197 | |
---|
| 198 | </body> |
---|
| 199 | </html> |
---|