コード例 #1
0
 /**
  * get pan url, if possible - return empty string if limit is hit
  * @param xdir = amount of left/right panning, e.g. -1 to pan left
  * @param ydir = amount of up/down panning, e.g. 1 to pan up
  * @access public
  */
 function getPanToken($xdir, $ydir)
 {
     $out = new GeographMap();
     //no panning unless you are zoomed in
     if ($this->pixels_per_km >= 1) {
         //start with same params
         $out->setScale($this->pixels_per_km);
         $out->setImageSize($this->image_w, $this->image_h);
         $out->type_or_user = $this->type_or_user;
         //pan half a map
         //figure out image size in km
         $mapw = $out->image_w / $out->pixels_per_km;
         $maph = $out->image_h / $out->pixels_per_km;
         //figure out how many pixels to pan by
         $panx = round($mapw / 2);
         $pany = round($maph / 2);
         $out->setOrigin($this->map_x + $panx * $xdir, $this->map_y + $pany * $ydir, true);
     }
     return $out->getToken();
 }
コード例 #2
0
    if (!empty($_GET['u'])) {
        $map->type_or_user = max(0, intval($_GET['u']));
    } else {
        $map->type_or_user = 0;
    }
} elseif (isset($_GET['depth'])) {
    if ($_GET['depth']) {
        $smarty->assign('depth', 1);
        $map->type_or_user = -1;
    } else {
        $map->type_or_user = 0;
    }
}
$template = $map->pixels_per_km == 4 ? $map->type_or_user == -1 ? 'mapsheet100kdepth.tpl' : 'mapsheet100k.tpl' : 'mapsheet.tpl';
//get token, we'll use it as a cache id
$token = $map->getToken();
//regenerate html?
$cacheid = 'mapsheet|' . $token;
if ($map->pixels_per_km == 4) {
    $smarty->cache_lifetime = 3600 * 24;
}
//24hr cache
if (isset($_GET['gridref_from']) && preg_match('/^[a-zA-Z]{1,3}\\d{4}$/', $_GET['gridref_from'])) {
    $smarty->assign('gridref_from', $_GET['gridref_from']);
    $cacheid .= '.' . $_GET['gridref_from'];
}
//regenerate?
if (!$smarty->is_cached($template, $cacheid)) {
    dieUnderHighLoad();
    if ($map->type_or_user > 0) {
        $profile = new GeographUser($map->type_or_user);