mapserver->legendIconCacheDir)) { $legendIconCacheDir = $configObj->mapserver->legendIconCacheDir; // check for closing '/' $legendIconCacheDir = str_replace( '\\', '/', trim( $legendIconCacheDir ) ); if ( substr( $legendIconCacheDir, -1 ) != '/' ) { $legendIconCacheDir .= '/'; } $cacheLegendIcons = true; $str = file_get_contents($_SESSION['maps'][$mapName]); /* create a unique location for the map icons based on * the content of the of map file. If the content changes * then the icons should be rebuilt anyway */ $legendIconCacheDir = $legendIconCacheDir.md5($str)."/"; if (!is_dir($legendIconCacheDir)) { mkdir($legendIconCacheDir); } /* TODO: can we figure out what the content type is? */ $legendIconCacheFile = $legendIconCacheDir."_".$REQUEST_VARS['layername']."_".$REQUEST_VARS['classindex'].".png"; /* if the icon exists, return it */ if (file_exists($legendIconCacheFile)) { /* TODO: can we figure out what the content type is? */ header('Content-type: image/png'); readfile($legendIconCacheFile); exit; } } } } $oMap = ms_newMapObj($_SESSION['maps'][$mapName]); $oLayer = $oMap->getLayerByName($REQUEST_VARS['layername']); $oClass = $oLayer->getClass($REQUEST_VARS['classindex']); $width = $oMap->legend->keysizex; $height = $oMap->legend->keysizey; if ($width <=0) $width = 16; if ($height <=0) $height = 16; $oImg = $oClass->createLegendIcon($width, $height); /* TODO: can we figure out what the content type is? */ header('Content-type: image/png'); if ($cacheLegendIcons) { $oImg->saveImage($legendIconCacheFile); readfile($legendIconCacheFile); } else { $oImg->saveImage(""); } $oImg->free(); } ?>