Ignore:
Timestamp:
07/07/22 08:51:44 (22 months ago)
Author:
frank.jaeger
Message:

ALKIS-Auskunft angepasst an PHP 8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/info/info/alkisn/alkisgebaeudenw.php

    r427 r430  
    1818        2022-01-13 Neue Functions LnkStf(), DsKy() 
    1919        2022-02-17 Neue Bauwerks-Typen 
     20        2022-07-05 PHP 8.1: Connection verwenden bei "pg_prepare" und "pg_execute", keine NULL-Werte in String-Functions verwenden 
    2021*/ 
    2122 
     
    108109."WHERE f.gml_id= $1 AND f.endet IS NULL AND g.endet IS NULL;"; 
    109110$v=array($gmlid); 
    110 $resf=pg_prepare("", $sqlf); 
    111 $resf=pg_execute("", $v); 
     111$resf=pg_prepare($con, "", $sqlf); 
     112$resf=pg_execute($con, "", $v); 
    112113if (!$resf) { 
    113114        echo "\n<p class='err'>Fehler bei Flurst&uuml;cksdaten.</p>"; 
     
    169170 
    170171// GebÀude 
    171 $sqlg ="SELECT g.gml_id, g.name, g.bauweise, g.gebaeudefunktion, h.beschreibung AS bauweise_beschreibung, u.beschreibung AS bezeichner, u.dokumentation AS gfktd, g.zustand, z.beschreibung AS bzustand,  
     172$sqlg ="SELECT g.gml_id, g.name, g.bauweise, g.gebaeudefunktion, coalesce(h.beschreibung, '') AS bauweise_beschreibung, u.beschreibung AS bezeichner, u.dokumentation AS gfktd, g.zustand, coalesce(z.beschreibung, '') AS bzustand,  
    172173round(st_area(g.wkb_geometry)::numeric,2) AS gebflae, "; // GEB-FlÀche, auch ausserhalb des FS 
    173174$sqlg.="round(st_area(ST_Intersection(g.wkb_geometry,f.wkb_geometry))::numeric,2) AS schnittflae, "; // wie viel vom GEB liegt im FS? 
     
    186187 
    187188$v=array($gmlid); 
    188 $resg=pg_prepare("", $sqlg); 
    189 $resg=pg_execute("", $v); 
     189$resg=pg_prepare($con, "", $sqlg); 
     190$resg=pg_execute($con, "", $v); 
    190191if (!$resg) { 
    191192        echo "\n<p class='err'>Fehler bei Geb&auml;ude-Verschneidung.</p>"; 
     
    200201        $ggml=$rowg["gml_id"]; 
    201202        $gebflsum=$gebflsum + $rowg["schnittflae"]; 
    202         $gnam=trim(trim($rowg["name"], "{}"), '"'); // GebÀude-Name ist ein Array in der DB: '{"A","B"}' 
     203        if (is_null($rowg["name"])) { 
     204                $gnam=""; 
     205        } else { 
     206                $gnam=trim(trim($rowg["name"], "{}"), '"'); // GebÀude-Name ist ein Array in der DB: '{"A","B"}' 
     207        } 
    203208        // Mehrfachbelegung nur theoretisch. Entklammern reicht. Mal mit und mal ohne "" drum!? 
    204209        $gfktk=htmlentities($rowg["gebaeudefunktion"], ENT_QUOTES, "UTF-8");  // Geb.-Funktion Key 
     
    263268                $sqll.="ORDER BY bezeichnung, hausnummer, laufendenummer;"; 
    264269                $v = array($ggml); 
    265                 $resl = pg_prepare("", $sqll); 
    266                 $resl = pg_execute("", $v); 
     270                $resl = pg_prepare($con, "", $sqll); 
     271                $resl = pg_execute($con, "", $v); 
    267272                if (!$resl) { 
    268273                        echo "\n<p class='err'>Fehler bei Lage mit HsNr.</p>"; 
     
    439444 
    440445$v=array($gmlid); 
    441 $resb=pg_prepare("", $sqlb); 
    442 $resb=pg_execute("", $v); 
     446$resb=pg_prepare($con, "", $sqlb); 
     447$resb=pg_execute($con, "", $v); 
     448 
     449$baunr=0; // ZÀhler 
     450$bauflsum=0; // FlÀchensumme 
     451$gwbwtyp=0; // Gruppen-Wechsel Bauwerks-Typ 
     452 
    443453if (!$resb) { 
    444454        echo "\n<p class='err'>Fehler bei Bauwerke-Verschneidung.</p>"; 
    445455        if ($dbg > 2) {echo "\n<p class='err'>SQL=<br>".str_replace("$1","'".$gmlid."'",$sqlb)."</p>";} 
    446456        if ($dbg > 1) {echo "<p class='dbg'>Fehler:".pg_result_error($resb)."</p>";} 
    447 } 
    448 $baunr=0; // ZÀhler 
    449 $bauflsum=0; // FlÀchensumme 
    450 $gwbwtyp=0; // Gruppen-Wechsel Bauwerks-Typ 
    451  
    452 while($rowb = pg_fetch_assoc($resb)) { 
    453         $baunr++; 
    454         $btyp=$rowb["bwtyp"]; // Tabelle 
    455         $bgml=$rowb["gml_id"]; 
    456         $bauflsum=$bauflsum + $rowb["schnittflae"]; 
    457         $bbez=htmlentities($rowb["bezeichnung"], ENT_QUOTES, "UTF-8"); 
    458  
    459         $bfktk=htmlentities($rowb["bauwerksfunktion"], ENT_QUOTES, "UTF-8"); 
    460         $bfktv=htmlentities($rowb["beschreibung"], ENT_QUOTES, "UTF-8"); 
    461         $bfktd=htmlentities($rowb["dokumentation"], ENT_QUOTES, "UTF-8");  
    462  
    463         $bnam=htmlentities($rowb["name"], ENT_QUOTES, "UTF-8"); 
    464         $bgeb=$rowb["gehoertzu"]; 
    465         $drin=$rowb["drin"]; 
    466         $bgeotyp=$rowb["bgeotyp"]; 
    467  
    468         // Lage des Bauwerks zum FlurstÃŒck 
    469         if ($bgeotyp === "LINESTRING") { 
    470                 if ($drin === "t") { 
    471                         $bstyle="gin"; 
     457} else { 
     458        while($rowb = pg_fetch_assoc($resb)) { 
     459                $baunr++; 
     460                $btyp=$rowb["bwtyp"]; // Tabelle 
     461                $bgml=$rowb["gml_id"]; 
     462                $bauflsum=$bauflsum + $rowb["schnittflae"]; 
     463                if (is_null($rowb["bezeichnung"])) { 
     464                        $bbez=""; 
    472465                } else { 
    473                         $bstyle="gtl"; 
    474                 } 
    475                 $f1="&nbsp;"; 
    476                 $f2="Linie"; 
    477         } elseif ($bgeotyp === "POINT") { 
    478                 if ($drin === "t") { 
    479                         $bstyle="gin"; 
     466                        $bbez=htmlentities($rowb["bezeichnung"], ENT_QUOTES, "UTF-8"); 
     467                } 
     468                $bfktk=htmlentities($rowb["bauwerksfunktion"], ENT_QUOTES, "UTF-8"); 
     469                $bfktv=htmlentities($rowb["beschreibung"], ENT_QUOTES, "UTF-8"); 
     470                $bfktd=htmlentities($rowb["dokumentation"], ENT_QUOTES, "UTF-8");  
     471                if (is_null($rowb["name"])) { 
     472                        $bnam=""; 
    480473                } else { 
    481                         $bstyle="gtl"; 
    482                 } 
    483                 $f1="&nbsp;"; 
    484                 $f2="Punkt";             
    485         } else { // FlÀche / Multi- 
    486                 if ($drin === "t") { // komplett IM FlurstÃŒck 
    487                         $f1=$rowb["schnittflae"]." m&#178;"; 
    488                         $f2="&nbsp;"; 
    489                         $bstyle="gin"; // siehe .css 
    490                 } else { 
    491                         if ($rowb["schnittflae"] === "0.00") { // nur angrenzend 
    492                                 $bstyle="gan"; 
    493                                 $f1="&nbsp;"; 
    494                                 $f2="angrenzend"; 
    495                         } else { // Teile auf FlurstÃŒck 
     474                        $bnam=htmlentities($rowb["name"], ENT_QUOTES, "UTF-8"); 
     475                } 
     476                $bgeb=$rowb["gehoertzu"]; 
     477                $drin=$rowb["drin"]; 
     478                $bgeotyp=$rowb["bgeotyp"]; 
     479 
     480                // Lage des Bauwerks zum FlurstÃŒck 
     481                if ($bgeotyp === "LINESTRING") { 
     482                        if ($drin === "t") { 
     483                                $bstyle="gin"; 
     484                        } else { 
    496485                                $bstyle="gtl"; 
     486                        } 
     487                        $f1="&nbsp;"; 
     488                        $f2="Linie"; 
     489                } elseif ($bgeotyp === "POINT") { 
     490                        if ($drin === "t") { 
     491                                $bstyle="gin"; 
     492                        } else { 
     493                                $bstyle="gtl"; 
     494                        } 
     495                        $f1="&nbsp;"; 
     496                        $f2="Punkt";             
     497                } else { // FlÀche / Multi- 
     498                        if ($drin === "t") { // komplett IM FlurstÃŒck 
    497499                                $f1=$rowb["schnittflae"]." m&#178;"; 
    498                                 $f2="(von ".$rowb["gebflae"]." m&#178;)"; 
     500                                $f2="&nbsp;"; 
     501                                $bstyle="gin"; // siehe .css 
     502                        } else { 
     503                                if ($rowb["schnittflae"] === "0.00") { // nur angrenzend 
     504                                        $bstyle="gan"; 
     505                                        $f1="&nbsp;"; 
     506                                        $f2="angrenzend"; 
     507                                } else { // Teile auf FlurstÃŒck 
     508                                        $bstyle="gtl"; 
     509                                        $f1=$rowb["schnittflae"]." m&#178;"; 
     510                                        $f2="(von ".$rowb["gebflae"]." m&#178;)"; 
     511                                } 
     512                        }        
     513                } 
     514 
     515                // Gruppenwechsel Bauwerks-Typ (Quell-Tabelle) - Zwischen-Überschrift 
     516                If ($btyp != $gwbwtyp) { 
     517                        $gwbwtyp = $btyp; 
     518                        if ($baunr === 1) {bauw_tab_head();} // Tab.-Kopf 
     519                        switch ($btyp) { 
     520                                case $btyp_verkehr: 
     521                                        $btyptitle='Bauwerk im Verkehrsbereich'; break; 
     522                                case $btyp_gewaesser: 
     523                                        $btyptitle='Bauwerk im Gew&auml;sserbereich'; break; 
     524                                case $btyp_sonst:  
     525                                        $btyptitle='Sonstiges Bauwerk oder sonstige Einrichtung'; break; 
     526                                case $btyp_indu: 
     527                                        $btyptitle="Bauwerk oder Anlage f&uuml;r Industrie und Gewerbe"; break; 
     528                                case $btyp_sport: 
     529                                        $btyptitle="Bauwerk oder Anlage f&uuml;r Sport, Freizeit und Erholung"; break; 
     530                                case $btyp_leitg: 
     531                                        $btyptitle="Leitung"; break; 
     532                                case $btyp_trans: 
     533                                        $btyptitle="Transportanlage"; break; 
     534                                case $btyp_turm: 
     535                                        $btyptitle="Turm"; break; 
     536                                case $btyp_vorrat: 
     537                                        $btyptitle="Vorratsbeh&auml;lter, Speicherbauwerk"; break; 
     538                                case $btyp_hist: 
     539                                        $btyptitle="Historisches Bauwerk oder historische Einrichtung"; break; 
     540                                case $btyp_heil: 
     541                                        $btyptitle="Heilquelle, Gasquelle"; break; 
     542                                case $btyp_oeff: 
     543                                        $btyptitle="Einrichtung in &ouml;ffentlichen Bereichen"; break; 
     544                                case $btyp_bpkt: 
     545                                        $btyptitle="Besonderer Bauwerkspunkt"; break; 
     546                                default: 
     547                                        $btyptitle='Fehler!'; break; 
    499548                        } 
    500                 }        
     549                        echo "<tr><td colspan=3></td><td colspan=2 class='gw'>".$btyptitle."</td></tr>"; // ++ Symbol? 
     550                } 
     551 
     552                echo "\n<tr>"; 
     553                        echo "\n\t<td>"; 
     554                        if ($bbez != "") {echo "<span title='Bezeichnung'>".$bbez."</span> ";} 
     555                        if ($bnam != "") {echo "<span title='Name'>".$bnam."</span> ";} 
     556                        echo "</td>"; 
     557                        echo "\n\t<td class='fla'>".$f1."</td>" 
     558                        ."\n\t<td class='".$bstyle."'>".$f2."</td>"; // FlÀchenangaben 
     559                        echo "\n\t<td>".DsKy($bfktk, 'Bauwerksfunktion-*')."<span title='".$bfktd ."'>".$bfktv."</span></td>"; 
     560 
     561                        // Lage / Haus (nur bei Typ 3 sonstige) 
     562                        echo "\n\t<td class='nwlink noprint'>"; // Link 
     563                        if ($bgeb != "") { // gehört zu GebÀude 
     564                        //      bw_gz_lage($bgeb); // Function: Lage (Adresse) ausgeben 
     565                                echo "\n\t\t<a title='gehört zu' href='alkishaus.php?gkz=".$gkz."&amp;gmlid=".$bgeb.LnkStf() 
     566                                ."'>Haus&nbsp;<img src='ico/Haus.png' width='16' height='16' alt=''></a>"; 
     567                        } 
     568                        echo "\n\t</td>"; 
     569 
     570                        // Bauwerk Details 
     571                        echo "\n\t<td class='nwlink noprint'>" // Link 
     572                        ."\n\t\t<a title='Bauwerksdaten' href='alkisbauwerk.php?gkz=".$gkz."&amp;btyp=".$btyp."&amp;gmlid=".$bgml.LnkStf() 
     573                        ."'>Bauwerk&nbsp;<img src='ico/Haus.png' width='16' height='16' alt=''></a>" // Icon fÃŒr Bauwerk schaffen 
     574                        ."\n\t</td>" 
     575                ."\n</tr>"; 
    501576        } 
    502577 
    503         // Gruppenwechsel Bauwerks-Typ (Quell-Tabelle) - Zwischen-Überschrift 
    504         If ($btyp != $gwbwtyp) { 
    505                 $gwbwtyp = $btyp; 
    506                 if ($baunr === 1) {bauw_tab_head();} // Tab.-Kopf 
    507                 switch ($btyp) { 
    508                         case $btyp_verkehr: 
    509                                 $btyptitle='Bauwerk im Verkehrsbereich'; break; 
    510                         case $btyp_gewaesser: 
    511                                 $btyptitle='Bauwerk im Gew&auml;sserbereich'; break; 
    512                         case $btyp_sonst:  
    513                                 $btyptitle='Sonstiges Bauwerk oder sonstige Einrichtung'; break; 
    514                         case $btyp_indu: 
    515                                 $btyptitle="Bauwerk oder Anlage f&uuml;r Industrie und Gewerbe"; break; 
    516                         case $btyp_sport: 
    517                                 $btyptitle="Bauwerk oder Anlage f&uuml;r Sport, Freizeit und Erholung"; break; 
    518                         case $btyp_leitg: 
    519                                 $btyptitle="Leitung"; break; 
    520                         case $btyp_trans: 
    521                                 $btyptitle="Transportanlage"; break; 
    522                         case $btyp_turm: 
    523                                 $btyptitle="Turm"; break; 
    524                         case $btyp_vorrat: 
    525                                 $btyptitle="Vorratsbeh&auml;lter, Speicherbauwerk"; break; 
    526                         case $btyp_hist: 
    527                                 $btyptitle="Historisches Bauwerk oder historische Einrichtung"; break; 
    528                         case $btyp_heil: 
    529                                 $btyptitle="Heilquelle, Gasquelle"; break; 
    530                         case $btyp_oeff: 
    531                                 $btyptitle="Einrichtung in &ouml;ffentlichen Bereichen"; break; 
    532                         case $btyp_bpkt: 
    533                                 $btyptitle="Besonderer Bauwerkspunkt"; break; 
    534                         default: 
    535                                 $btyptitle='Fehler!'; break; 
    536                 } 
    537                 echo "<tr><td colspan=3></td><td colspan=2 class='gw'>".$btyptitle."</td></tr>"; // ++ Symbol? 
     578        // Footer Bauwerke 
     579        if ($baunr === 0) { 
     580                echo "\n<p>Kein Bauwerk auf diesem Flurst&uuml;ck.</p><br>"; 
     581                // if ($dbg > 2) {echo "\n<p class='err'>SQL=<br>".$sqlb."<br>$1 = gml_id = '".$gmlid."'</p>";} 
     582        } else { 
     583                echo "\n<tr>" 
     584                        ."\n\t<td>Summe:</td>" 
     585                        ."\n\t<td class='fla sum' title='von Bauwerken &uuml;berbaute Fl&auml;che des Flurst&uuml;cks'>".number_format($bauflsum,0,",",".")."&nbsp;&nbsp;&nbsp;&nbsp;m&#178;</td>" 
     586                        ."\n\t<td colspan='6'>&nbsp;</td>" 
     587                ."\n</tr>" 
     588                ."\n</table>\n"; 
    538589        } 
    539  
    540         echo "\n<tr>"; 
    541                 echo "\n\t<td>"; 
    542                 if ($bbez != "") {echo "<span title='Bezeichnung'>".$bbez."</span> ";} 
    543                 if ($bnam != "") {echo "<span title='Name'>".$bnam."</span> ";} 
    544                 echo "</td>"; 
    545                 echo "\n\t<td class='fla'>".$f1."</td>" 
    546                 ."\n\t<td class='".$bstyle."'>".$f2."</td>"; // FlÀchenangaben 
    547                 echo "\n\t<td>".DsKy($bfktk, 'Bauwerksfunktion-*')."<span title='".$bfktd ."'>".$bfktv."</span></td>"; 
    548  
    549                 // Lage / Haus (nur bei Typ 3 sonstige) 
    550                 echo "\n\t<td class='nwlink noprint'>"; // Link 
    551                 if ($bgeb != "") { // gehört zu GebÀude 
    552                 //      bw_gz_lage($bgeb); // Function: Lage (Adresse) ausgeben 
    553                         echo "\n\t\t<a title='gehört zu' href='alkishaus.php?gkz=".$gkz."&amp;gmlid=".$bgeb.LnkStf() 
    554                         ."'>Haus&nbsp;<img src='ico/Haus.png' width='16' height='16' alt=''></a>"; 
    555                 } 
    556                 echo "\n\t</td>"; 
    557  
    558                 // Bauwerk Details 
    559                 echo "\n\t<td class='nwlink noprint'>" // Link 
    560                 ."\n\t\t<a title='Bauwerksdaten' href='alkisbauwerk.php?gkz=".$gkz."&amp;btyp=".$btyp."&amp;gmlid=".$bgml.LnkStf() 
    561                 ."'>Bauwerk&nbsp;<img src='ico/Haus.png' width='16' height='16' alt=''></a>" // Icon fÃŒr Bauwerk schaffen 
    562                 ."\n\t</td>" 
    563         ."\n</tr>"; 
    564 } 
    565  
    566 // Footer Bauwerk 
    567 if ($baunr === 0) { 
    568         echo "\n<p>Kein Bauwerk auf diesem Flurst&uuml;ck.</p><br>"; 
    569         // if ($dbg > 2) {echo "\n<p class='err'>SQL=<br>".$sqlb."<br>$1 = gml_id = '".$gmlid."'</p>";} 
    570 } else { 
    571         echo "\n<tr>" 
    572                 ."\n\t<td>Summe:</td>" 
    573                 ."\n\t<td class='fla sum' title='von Bauwerken &uuml;berbaute Fl&auml;che des Flurst&uuml;cks'>".number_format($bauflsum,0,",",".")."&nbsp;&nbsp;&nbsp;&nbsp;m&#178;</td>" 
    574                 ."\n\t<td colspan='6'>&nbsp;</td>" 
    575         ."\n</tr>" 
    576         ."\n</table>\n"; 
    577 } 
    578 pg_free_result($resb); 
     590        pg_free_result($resb); 
     591} 
    579592 
    580593echo "<div class='buttonbereich noprint'>\n<hr>" 
Note: See TracChangeset for help on using the changeset viewer.