Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

map.php

Go to the documentation of this file.
00001 <?php
00012 /***************************************************************************
00013  This program is free software; you can redistribute it and/or
00014  modify it under the terms of the GNU General Public License
00015  as published by the Free Software Foundation; either version 2
00016  of the License, or (at your option) any later version.
00017 
00018  This program is distributed in the hope that it will be useful,
00019  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  GNU General Public License for more details.
00022 
00023  You should have received a copy of the GNU General Public License
00024  along with this program; if not, write to the Free Software
00025  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00026  ***************************************************************************/
00027 
00028 require_once ('./general.php');
00029 require_once ('./lib/map.php');
00030 
00031 // activate map mode, no table template will be used
00032 $booMap = true;
00033 
00034 // get styles
00035 $oStyle->setTemplate ( 'map.html' );
00036 $oStyle->split_area('Anzeige');
00037 
00038 $oMap = new Map ( $oMysql, $oUser );
00039 
00040 $booWaypointing = false;
00041 $strWaytext = '';
00042 
00043 // NEW STYLE ROUTING
00044 if ( $oMap->xs > 0 && $oMap->ys > 0 && $oMap->ye > 0 && $oMap->xe > 0 &&
00045      $oMap->xs < $intMapSize && $oMap->ys < $intMapSize && $oMap->xe < $intMapSize && $oMap->ye < $intMapSize )
00046 {
00047     //Wegberechnung START
00048     $sqlResult = $oMysql->query("SELECT m.x, m.y, m.terrain, md.street ".
00049                                 "FROM ".$oMysql->tblMap." m ".
00050                                 "LEFT JOIN ".$oMysql->tblMapData." md ON (m.x=md.x AND m.y=md.y) ".
00051                                 "WHERE m.x BETWEEN $oMap->xx0 AND $oMap->xx1 AND m.y BETWEEN $oMap->yy0 AND $oMap->yy1 ");
00052 
00053     //Schreibe Karteninfos in Array
00054     $mapdata = array();
00055     while ( $aRow = $oMysql->fetch_assoc($sqlResult))
00056     {
00057         $mapdata[$aRow['x']][$aRow['y']] = $aRow;
00058     }
00059 
00060     require_once ('./lib/bestway.php');
00061     ini_set ('memory_limit', '-1');
00062 
00063     $oBestWay = new BestWay ( $oMap->aTerrainPoints );
00064 
00065      $waypoints = array();
00066      if ( ($oMap->xs>=$oMap->xx0)&&($oMap->xs<=$oMap->xx1) && ($oMap->xe>=$oMap->xx0)&&($oMap->xe<=$oMap->xx1) &&
00067           ($oMap->ys>=$oMap->yy0)&&($oMap->ys<=$oMap->yy1) && ($oMap->ye>=$oMap->yy0)&&($oMap->ye<=$oMap->yy1) )
00068      {
00069           // erstmal nur, wenn das im bereich liegt...
00070           $booWaypointing = true;
00071           list ( $strWaypoints, $dblEffort, $strWaytext )= $oBestWay->calcWay( $oMap->xs, $oMap->ys, $oMap->xe, $oMap->ye, $mapdata );
00072      }
00073      //Wegberechnung ENDE
00074 }
00075 // NEW STYLE ROUTING
00076 
00077 $xx = $oMap->xx;
00078 $yy = $oMap->yy;
00079 $x  = $oMap->x;
00080 $y  = $oMap->y;
00081 
00082 // Erzeuge Karten-Links zur Navigation
00083 
00084 // stronghold directions
00085 // oben
00086 $strMapNimg = '<a href="map.php?x='.$x.'&amp;y='. ($y-5)   . '"><img src="img/m_up5.jpg" style="height: 17px; width: 35px; margin: 0px 2px;" alt="5" /></a>';
00087 $strMapNimg .= '<a href="map.php?x='.$x.'&amp;y='. ($y-20)  . '"><img src="img/m_up20.jpg" style="height: 17px; width: 35px; margin: 0px 2px;" alt="20" /></a>';
00088 $strMapNimg .= '<a href="map.php?x='.$x.'&amp;y='. ($y-50)  . '"><img src="img/m_up50.jpg" style="height: 17px; width: 35px; margin: 0px 2px;" alt="50" /></a>';
00089 $strMapNimg .= '<a href="map.php?x='.$x.'&amp;y='. ($y-100) . '"><img src="img/m_up100.jpg" style="height: 17px; width: 35px; margin: 0px 2px;" alt="100" /></a>';
00090 
00091 // unten
00092 $strMapSimg  = '<a href="map.php?x='.$x.'&amp;y='. ($y+5)   . '"><img src="img/m_down5.jpg" style="height: 17px; width: 35px; margin: 0px 2px;" alt="5" /></a>';
00093 $strMapSimg .= '<a href="map.php?x='.$x.'&amp;y='. ($y+20)  . '"><img src="img/m_down20.jpg" style="height: 17px; width: 35px; margin: 0px 2px;" alt="20" /></a>';
00094 $strMapSimg .= '<a href="map.php?x='.$x.'&amp;y='. ($y+50)  . '"><img src="img/m_down50.jpg" style="height: 17px; width: 35px; margin: 0px 2px;" alt="50" /></a>';
00095 $strMapSimg .= '<a href="map.php?x='.$x.'&amp;y='. ($y+100) . '"><img src="img/m_down100.jpg" style="height: 17px; width: 35px; margin: 0px 2px;" alt="100" /></a>';
00096 
00097 // links
00098 $strMapWimg  = '<a href="map.php?x='. ($x-5)   .'&amp;y='.$y.'"><img src="img/m_left5.jpg" style="height: 35px; width: 17px; margin: 2px 0px;" alt="5" /></a>';
00099 $strMapWimg .= '<a href="map.php?x='. ($x-20)  .'&amp;y='.$y.'"><img src="img/m_left20.jpg" style="height: 35px; width: 17px; margin: 2px 0px;" alt="20" /></a>';
00100 $strMapWimg .= '<a href="map.php?x='. ($x-50)  .'&amp;y='.$y.'"><img src="img/m_left50.jpg" style="height: 35px; width: 17px; margin: 2px 0px;" alt="50" /></a>';
00101 $strMapWimg .= '<a href="map.php?x='. ($x-100) .'&amp;y='.$y.'"><img src="img/m_left100.jpg" style="height: 35px; width: 17px; margin: 2px 0px;" alt="100" /></a>';
00102 
00103 // rechts
00104 $strMapOimg  = '<a href="map.php?x='. ($x+5)   .'&amp;y='.$y.'"><img src="img/m_right5.jpg" style="height: 35px; width: 17px; margin: 2px 0px;" alt="5" /></a>';
00105 $strMapOimg .= '<a href="map.php?x='. ($x+20)  .'&amp;y='.$y.'"><img src="img/m_right20.jpg" style="height: 35px; width: 17px; margin: 2px 0px;" alt="20" /></a>';
00106 $strMapOimg .= '<a href="map.php?x='. ($x+50)  .'&amp;y='.$y.'"><img src="img/m_right50.jpg" style="height: 35px; width: 17px; margin: 2px 0px;" alt="50" /></a>';
00107 $strMapOimg .= '<a href="map.php?x='. ($x+100) .'&amp;y='.$y.'"><img src="img/m_right100.jpg" style="height: 35px; width: 17px; margin: 2px 0px;" alt="100" /></a>';
00108 
00109 // skip half
00110 $map_x = $x;
00111 $map_y = $y-div($yy,2);
00112 $strMapN = '<a class="compass" href="map.php?x='.$map_x.'&amp;y='.$map_y.'">N</a>';
00113 $map_x = $x;
00114 $map_y = $y+div($yy,2);
00115 $strMapS = '<a class="compass" href="map.php?x='.$map_x.'&amp;y='.$map_y.'">S</a>';
00116 $map_x = $x-div($xx,2);
00117 $map_y = $y;
00118 $strMapW = '<a class="compass" href="map.php?x='.$map_x.'&amp;y='.$map_y.'">W</a>';
00119 $map_x = $x+div($xx,2);
00120 $map_y = $y;
00121 $strMapO = '<a class="compass" href="map.php?x='.$map_x.'&amp;y='.$map_y.'">O</a>';
00122 
00123 // oben links
00124 $map_y = $y-div($yy,2);
00125 $map_x = $x-div($xx,2);
00126 $strMapNWimg = '<a href=map.php?x='.$map_x.'&amp;y='.$map_y.'><img src="img/m_nw.gif" style="height: 17px; width: 17px;" alt="NW" /></a>';
00127 $strMapNW = '<a class="compass" href="map.php?x='.$map_x.'&amp;y='.$map_y.'">NW</a>';
00128 
00129 // oben rechts
00130 $map_y = $y-div($yy,2);
00131 $map_x = $x+div($xx,2);
00132 $strMapNOimg = '<a href=map.php?x='.$map_x.'&amp;y='.$map_y.'><img src="img/m_no.gif" style="height: 17px; width: 17px;" alt="NW" /></a>';
00133 $strMapNO = '<a class="compass" href="map.php?x='.$map_x.'&amp;y='.$map_y.'">NO</a>';
00134 
00135 // unten links
00136 $map_y = $y+div($yy,2);
00137 $map_x = $x-div($xx,2);
00138 $strMapSWimg = '<a href=map.php?x='.$map_x.'&amp;y='.$map_y.'><img src="img/m_sw.gif" style="height: 17px; width: 17px;" alt="NW" /></a>';
00139 $strMapSW = '<a class="compass" href="map.php?x='.$map_x.'&amp;y='.$map_y.'">SW</a>';
00140 
00141 // unten rechts
00142 $map_y = $y+div($yy,2);
00143 $map_x = $x+div($xx,2);
00144 $strMapSOimg = '<a href=map.php?x='.$map_x.'&amp;y='.$map_y.'><img src="img/m_so.gif" style="height: 17px; width: 17px;" alt="NW" /></a>';
00145 $strMapSO = '<a class="compass" href="map.php?x='.$map_x.'&amp;y='.$map_y.'">SO</a>';
00146 
00147 
00148 $strMapScriptData =
00149     '   var koord_top   = ' . $oMap->yy0 . ";\n" .
00150     '   var koord_left  = ' . $oMap->xx0 . ";\n" .
00151     '   var koord_right = ' . $oMap->xx1 . ";\n" .
00152     '   var koord_bottom= ' . $oMap->yy1 . ";\n" .
00153     '   var field_width = ' . $oMap->intFieldWidth . ";\n" .
00154     '   var field_height= ' . $oMap->intFieldHeight . ";\n";
00155 
00156 // Zoom Stufen Anzeigen
00157 $strMapZoom = '';
00158 $aZoomstufen = array( 4, 6, 8, 10, 12, 14, 18 );
00159 for ( $i = 0; $i < count ( $aZoomstufen ); $i++ )
00160 {
00161     if ( $aZoomstufen[$i] == $oMap->intZoom )
00162     {
00163         $intZoom = $i;
00164         $strMapZoom .= '&nbsp;<b><u>'.$aZoomstufen[$i].'</u></b>&nbsp;';
00165     }
00166     else
00167     {
00168         $strMapZoom .= '&nbsp;<a href="map.php?x='.$oMap->x.'&amp;y='.$oMap->y.'&amp;show_fog='.$oMap->booShowFog.
00169 //                     '&amp;xs='.$xs.'&amp;ys='.$ys.'&amp;xe='.$xe.'&amp;ye='.$ye.
00170                      '&amp;zoom='.$i.'">'.$aZoomstufen[$i].'</a>&nbsp;';
00171     }
00172 }
00173 
00174 $strMapWay = ($booWaypointing) ? '&amp;effort='.$dblEffort.'&amp;xs='.$oMap->xs.'&amp;ys='.$oMap->ys.'&amp;waytext='.$strWaytext : '';
00175 
00176 // Karte Anzeigen
00177 $strMapImg = '<img style="position: relative;" id="imgmap" src="mapimg.php?x='.$oMap->x.'&amp;y='.$oMap->y.
00178              '&amp;show_fog='.$oMap->booShowFog.'&amp;zoom='.$intZoom.$strMapWay.'" border="0" alt="Andaloria Karte... loading" />';
00179 
00180 //$strMapImg = '<iframe id="imgmap" width="'.$oUser->intSizeX.'" height="'.$oUser->intSizeY.'" src="maphtml.php?x='.$oMap->x.'&amp;y='.$oMap->y.
00181 //             '&amp;show_fog='.$oMap->booShowFog.'&amp;zoom='.$intZoom.$strMapWay.'" frameborder="0" style="border:0px; margin:0px; padding:0px;"></iframe>';
00182 
00183 $strLegend = '';
00184 if( $booDetailedMap && $intZoom > 3 )
00185 {
00186     $aPoints = $aTerrainPoints;
00187     asort( $aPoints );
00188     foreach( $aPoints AS $intId => $intCost )
00189     {
00190         $oStyle->addReplacements( array(
00191             'ID' => $intId,
00192             'COST' => $intCost,
00193             'NAME' => $aTerrainText[$intId] ) );
00194         $strLegend .= $oStyle->get_area( 'Legend' );
00195     }
00196 }
00197 
00198 $oStyle->addReplacements ( array ( 'MAP_ZOOM_LINKS' => $strMapZoom,
00199                                    'MAP_WAYTEXT' => $strWaytext,
00200                                    'MAP_NW' => $strMapNW,
00201                                    'MAP_N' => $strMapN,
00202                                    'MAP_NO' => $strMapNO,
00203                                    'MAP_W' => $strMapW,
00204                                    'MAP_O' => $strMapO,
00205                                    'MAP_SW' => $strMapSW,
00206                                    'MAP_S' => $strMapS,
00207                                    'MAP_SO' => $strMapSO,
00208 
00209                                    'MAP_NW_IMG' => $strMapNWimg,
00210                                    'MAP_N_IMG' => $strMapNimg,
00211                                    'MAP_NO_IMG' => $strMapNOimg,
00212                                    'MAP_W_IMG' => $strMapWimg,
00213                                    'MAP_O_IMG' => $strMapOimg,
00214                                    'MAP_SW_IMG' => $strMapSWimg,
00215                                    'MAP_S_IMG' => $strMapSimg,
00216                                    'MAP_SO_IMG' => $strMapSOimg,
00217 
00218                                    'MAP_IMG' => $strMapImg,
00219                                    'MAP_ZOOM' => $intZoom,
00220                                    'MAP_XS' => $oMap->xs,
00221                                    'MAP_YS' => $oMap->ys,
00222                                    'MAP_XE' => $oMap->xe,
00223                                    'MAP_YE' => $oMap->ye,
00224                                    'MAP_X' => $oMap->x,
00225                                    'MAP_Y' => $oMap->y,
00226                                    'LEGEND' => $strLegend,
00227                                    'MAP_WIDTH' => $oMap->intFieldWidth,
00228                                    'MAP_HEIGHT' => $oMap->intFieldHeight,
00229                                    'MAP_SCRIPT_DATA' => $strMapScriptData
00230                                  )
00231                           );
00232 
00233 $strTmpl_inhalt = $oStyle->get_area( 'Anzeige' );
00234 output();

Generated on Sun May 8 19:29:45 2005 for PhpMap by  doxygen 1.4.2