コード例 #1
0
 /**
  * get a url that will zoom us out one level from this gridsquare
  * @access public
  */
 function getGridSquareToken($gridsquare)
 {
     if (is_numeric($gridsquare)) {
         $id = $gridsquare;
         $gridsquare = new GridSquare();
         $gridsquare->loadFromId($id);
     }
     $out = new GeographMapMosaic();
     //start with same params
     $out->setScale(40);
     $out->setMosaicFactor(2);
     $out->setCentre($gridsquare->x, $gridsquare->y, true);
     //true to align to 10x10 map
     return $out->getToken();
 }
コード例 #2
0
    // lifetime is per cache
    $smarty->cache_lifetime = 3600 * 24;
    //24hr cache
}
if (isset($_GET['refresh']) && $USER->hasPerm('admin')) {
    $smarty->clear_cache($template, $cacheid);
}
$smarty->assign_by_ref('references_real', $CONF['references']);
if (!$smarty->is_cached($template, $cacheid)) {
    $db = NewADOConnection($GLOBALS['DSN']);
    if (!$db) {
        die('Database connection failed');
    }
    #$db->debug = true;
    $mosaic = new GeographMapMosaic();
    $mosaic->setScale(40);
    $mosaic->setMosaicFactor(2);
    $mostarray = array();
    foreach ($CONF['references'] as $ri => $rname) {
        $letterlength = $CONF['gridpreflen'][$ri];
        $most = $db->GetAll("select \n\t\tgrid_reference,x,y,\n\t\tconcat(substring(grid_reference,1," . ($letterlength + 1) . "),substring(grid_reference," . ($letterlength + 3) . ",1)) as tenk_square,\n\t\tsum(has_geographs) as geograph_count,\n\t\tsum(percent_land >0) as land_count\n\t\tfrom gridsquare \n\t\twhere reference_index = {$ri} \n\t\tgroup by tenk_square \n\t\thaving geograph_count = 0 and land_count > 0\n\t\torder by tenk_square");
        $i = 1;
        $lastgeographs = -1;
        foreach ($most as $id => $entry) {
            $most[$id]['x'] = intval(($most[$id]['x'] - $CONF['origins'][$ri][0]) / 10) * 10 + $CONF['origins'][$ri][0];
            $most[$id]['y'] = intval(($most[$id]['y'] - $CONF['origins'][$ri][1]) / 10) * 10 + $CONF['origins'][$ri][1];
            //get a token to show a suroudding geograph map
            $mosaic->setOrigin($most[$id]['x'], $most[$id]['y']);
            $most[$id]['map_token'] = $mosaic->getToken();
        }
        $mostarray += array($ri => $most);
コード例 #3
0
    // lifetime is per cache
    $smarty->cache_lifetime = 3600 * 6;
    //6hr cache
}
$smarty->assign_by_ref('references_real', $CONF['references']);
if (!$smarty->is_cached($template, $cacheid)) {
    $db = NewADOConnection($GLOBALS['DSN']);
    if (!$db) {
        die('Database connection failed');
    }
    #$db->debug = true;
    $mosaic = new GeographMapMosaic();
    $mosaic->setScale(40);
    $mosaic->setMosaicFactor(2);
    $largemosaic = new GeographMapMosaic();
    $largemosaic->setScale(80);
    $largemosaic->setMosaicFactor(2);
    $largemosaic->setMosaicSize(800, 800);
    $censquare = new GridSquare();
    function cmp($a, $b)
    {
        if ($a['sort'] == $b['dateraw']) {
            return 0;
        }
        return $a['dateraw'] > $b['dateraw'] ? -1 : 1;
    }
    $db->Execute("TRUNCATE hectad_complete");
    $mostarray = array();
    foreach ($CONF['references'] as $ri => $rname) {
        $letterlength = $CONF['gridpreflen'][$ri];
        $prev_fetch_mode = $ADODB_FETCH_MODE;
コード例 #4
0
$token = $mosaic->getToken();
//regenerate html?
$cacheid = 'maplarge|' . $token;
//regenerate?
if (!$smarty->is_cached($template, $cacheid)) {
    dieUnderHighLoad();
    //assign overview to smarty
    if ($mosaic->type_or_user > 0) {
        $overview->type_or_user = $mosaic->type_or_user;
        $profile = new GeographUser($mosaic->type_or_user);
        $smarty->assign('realname', $profile->realname);
        $smarty->assign('user_id', $mosaic->type_or_user);
    }
    if ($mosaic->pixels_per_km >= 40) {
        //largeoverview
        $overview->setScale(1);
        list($x, $y) = $mosaic->getCentre();
        $overview->setCentre($x, $y);
        //does call setAlignedOrigin
    }
    $overview->assignToSmarty($smarty, 'overview');
    $smarty->assign('marker', $overview->getBoundingBox($mosaic));
    //assign main map to smarty
    $mosaic->assignToSmarty($smarty, 'mosaic');
    //assign all the other useful stuff
    $gridref = $mosaic->getGridRef(-1, -1);
    $smarty->assign('gridref', $gridref);
    $smarty->assign('mapwidth', round($mosaic->image_w / $mosaic->pixels_per_km));
    preg_match("/([A-Z]+\\d)5(\\d)5\$/", $gridref, $matches);
    $smarty->assign('gridref2', $matches[1] . $matches[2]);
    if ($mosaic->pixels_per_km >= 40) {
コード例 #5
0
ファイル: myriad.php プロジェクト: s-a-r-id/geograph-project
if (empty($myriad)) {
    $db = NewADOConnection($GLOBALS['DSN']);
    $myriad = $db->getOne("select prefix from gridprefix where landcount > 0 order by rand()");
}
$cacheid = $myriad;
//regenerate?
if (!$smarty->is_cached($template, $cacheid)) {
    require_once 'geograph/map.class.php';
    require_once 'geograph/mapmosaic.class.php';
    if (!$db) {
        $db = NewADOConnection($GLOBALS['DSN']);
    }
    $prefix = $db->getRow("select * from gridprefix where prefix= '{$myriad}'");
    $mosaic = new GeographMapMosaic();
    //start with same params
    $mosaic->setScale(4);
    $mosaic->setMosaicFactor(2);
    $mosaic->setOrigin($prefix['origin_x'], $prefix['origin_y']);
    $mosaic->type_or_user = -1;
    $smarty->assign('token', $mosaic->getToken());
    $left = $prefix['origin_x'];
    $right = $prefix['origin_x'] + $prefix['width'] - 1;
    $top = $prefix['origin_y'] + $prefix['height'] - 1;
    $bottom = $prefix['origin_y'];
    $rectangle = "'POLYGON(({$left} {$bottom},{$right} {$bottom},{$right} {$top},{$left} {$top},{$left} {$bottom}))'";
    $sql_where .= "CONTAINS(GeomFromText({$rectangle}),point_xy)";
    $sql_where .= ' and gs.reference_index = ' . $prefix['reference_index'] . ' ';
    $gridsquare = $db->getRow("select * from gridsquare gs where {$sql_where} and imagecount > 3 and imagecount < 20 order by rand() limit 1");
    $smarty->assign_by_ref('gridsquare', $gridsquare);
    $smarty->assign('myriad', $myriad);
}
コード例 #6
0
     if (count($profile->stats) == 0) {
         $profile->getStats();
     }
     //the map is only useful for people with images!
     if (!empty($profile->stats['images'])) {
         $smarty->assign('realname', $profile->realname);
         $smarty->assign('nickname', $profile->nickname);
         $smarty->assign('user_id', $mosaic->type_or_user);
         $overview->type_or_user = $mosaic->type_or_user;
     } else {
         $mosaic->type_or_user = 0;
     }
 }
 if ($mosaic->pixels_per_km == 40) {
     //largeoverview
     $overview->setScale(1);
     list($x, $y) = $mosaic->getCentre();
     $overview->setCentre($x, $y);
     //does call setAlignedOrigin
     #$mosaic->fillGridMap(true); //true = for imagemap
 } else {
     //set it back incase we come from a largeoverview
     $overview->setScale(0.13);
     $overview->setOrigin(0, -10);
 }
 $overview->assignToSmarty($smarty, 'overview');
 $smarty->assign('marker', $overview->getBoundingBox($mosaic));
 //assign all the other useful stuff
 if ($gridref = $mosaic->getGridRef(-1, -1)) {
     $smarty->assign('gridref', $gridref);
     if ($mosaic->pixels_per_km == 40 && preg_match('/([A-Z]+\\d)5(\\d)5$/', $gridref, $m)) {
コード例 #7
0
ファイル: squares.php プロジェクト: s-a-r-id/geograph-project
                }
            }
        }
        $smarty->assign_by_ref('data', $data);
        $smarty->assign_by_ref('searchdesc', $searchdesc);
        //geotag the page
        require_once 'geograph/conversions.class.php';
        $conv = new Conversions();
        list($lat, $long) = $conv->gridsquare_to_wgs84($square);
        $smarty->assign('lat', $lat);
        $smarty->assign('long', $long);
        $smarty->assign_by_ref('square', $square);
        //get a token to show a suroudding geograph map
        $mosaic = new GeographMapMosaic();
        $smarty->assign('map_token', $mosaic->getGridSquareToken($square));
        //lets add an overview map too
        $overview = new GeographMapMosaic('largeoverview');
        $overview->setCentre($square->x, $square->y);
        //does call setAlignedOrigin
        #$smarty->assign('marker', $overview->getSquarePoint($square));
        //actully lets make it the approximate size!
        $mosaic = new GeographMapMosaic('overview');
        $mosaic->setMosaicSize($d * 2, $d * 2);
        $mosaic->setScale($overview->pixels_per_km);
        #$mosaic->setCentre($square->x,$square->y); //does call setAlignedOrigin which we dont want!
        $mosaic->setOrigin($square->x - $d, $square->y - $d);
        $smarty->assign('marker', $overview->getBoundingBox($mosaic));
        $overview->assignToSmarty($smarty, 'overview');
    }
}
$smarty->display($template, $cacheid);