00001 <?php
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 require_once ('./general.php');
00029 require_once ('./lib/map.php');
00030
00031
00032 $booMap = true;
00033
00034
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
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
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
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
00070 $booWaypointing = true;
00071 list ( $strWaypoints, $dblEffort, $strWaytext )= $oBestWay->calcWay( $oMap->xs, $oMap->ys, $oMap->xe, $oMap->ye, $mapdata );
00072 }
00073
00074 }
00075
00076
00077 $xx = $oMap->xx;
00078 $yy = $oMap->yy;
00079 $x = $oMap->x;
00080 $y = $oMap->y;
00081
00082
00083
00084
00085
00086 $strMapNimg = '<a href="map.php?x='.$x.'&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.'&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.'&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.'&y='. ($y-100) . '"><img src="img/m_up100.jpg" style="height: 17px; width: 35px; margin: 0px 2px;" alt="100" /></a>';
00090
00091
00092 $strMapSimg = '<a href="map.php?x='.$x.'&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.'&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.'&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.'&y='. ($y+100) . '"><img src="img/m_down100.jpg" style="height: 17px; width: 35px; margin: 0px 2px;" alt="100" /></a>';
00096
00097
00098 $strMapWimg = '<a href="map.php?x='. ($x-5) .'&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) .'&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) .'&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) .'&y='.$y.'"><img src="img/m_left100.jpg" style="height: 35px; width: 17px; margin: 2px 0px;" alt="100" /></a>';
00102
00103
00104 $strMapOimg = '<a href="map.php?x='. ($x+5) .'&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) .'&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) .'&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) .'&y='.$y.'"><img src="img/m_right100.jpg" style="height: 35px; width: 17px; margin: 2px 0px;" alt="100" /></a>';
00108
00109
00110 $map_x = $x;
00111 $map_y = $y-div($yy,2);
00112 $strMapN = '<a class="compass" href="map.php?x='.$map_x.'&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.'&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.'&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.'&y='.$map_y.'">O</a>';
00122
00123
00124 $map_y = $y-div($yy,2);
00125 $map_x = $x-div($xx,2);
00126 $strMapNWimg = '<a href=map.php?x='.$map_x.'&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.'&y='.$map_y.'">NW</a>';
00128
00129
00130 $map_y = $y-div($yy,2);
00131 $map_x = $x+div($xx,2);
00132 $strMapNOimg = '<a href=map.php?x='.$map_x.'&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.'&y='.$map_y.'">NO</a>';
00134
00135
00136 $map_y = $y+div($yy,2);
00137 $map_x = $x-div($xx,2);
00138 $strMapSWimg = '<a href=map.php?x='.$map_x.'&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.'&y='.$map_y.'">SW</a>';
00140
00141
00142 $map_y = $y+div($yy,2);
00143 $map_x = $x+div($xx,2);
00144 $strMapSOimg = '<a href=map.php?x='.$map_x.'&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.'&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
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 .= ' <b><u>'.$aZoomstufen[$i].'</u></b> ';
00165 }
00166 else
00167 {
00168 $strMapZoom .= ' <a href="map.php?x='.$oMap->x.'&y='.$oMap->y.'&show_fog='.$oMap->booShowFog.
00169 // '&xs='.$xs.'&ys='.$ys.'&xe='.$xe.'&ye='.$ye.
00170 '&zoom='.$i.'">'.$aZoomstufen[$i].'</a> ';
00171 }
00172 }
00173
00174 $strMapWay = ($booWaypointing) ? '&effort='.$dblEffort.'&xs='.$oMap->xs.'&ys='.$oMap->ys.'&waytext='.$strWaytext : '';
00175
00176
00177 $strMapImg = '<img style="position: relative;" id="imgmap" src="mapimg.php?x='.$oMap->x.'&y='.$oMap->y.
00178 '&show_fog='.$oMap->booShowFog.'&zoom='.$intZoom.$strMapWay.'" border="0" alt="Andaloria Karte... loading" />';
00179
00180
00181
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();