Exemplo n.º 1
0
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);
    }
    $smarty->assign_by_ref("most", $mostarray);
}
$smarty->display($template, $cacheid);
Exemplo n.º 2
0
 */
require_once 'geograph/global.inc.php';
require_once 'geograph/mapmosaic.class.php';
init_session();
$mosaic = new GeographMapMosaic();
$mosaic->pixels_per_km = 40;
if (isset($_GET['random'])) {
    $db = NewADOConnection($GLOBALS['DSN']);
    $count = $db->cacheGetOne(86400, "SELECT COUNT(*) FROM gridsquare WHERE reference_index=1 AND percent_land = 100");
    $offset = rand(0, $count);
    $str = $db->getOne("SELECT AsText(point_xy) FROM gridsquare WHERE reference_index=1 AND percent_land = 100 AND gridsquare_id > {$offset}");
    //limit 1 is added automaticallu
    preg_match('/\\((\\d+) (\\d+)\\)/', $str, $m);
    if ($str && $m[1]) {
        $mapw = $mosaic->image_w / $mosaic->pixels_per_km / 2;
        $mosaic->setOrigin($m[1] - $mapw, $m[2] - $mapw);
    }
    $token = $mosaic->getToken();
    $cacheid = 'mapper|' . $token;
} elseif (isset($_GET['t'])) {
    $mosaic->setToken($_GET['t']);
    $token = $mosaic->getToken();
    $cacheid = 'mapper|' . $token;
} elseif (isset($_GET['lat'])) {
    require_once 'geograph/conversions.class.php';
    $conv = new Conversions();
    list($x, $y) = $conv->national_to_internal($_GET['lon'], $_GET['lat'], 1);
    if (isset($_GET['zoom'])) {
        switch ($_GET['zoom']) {
            case 0:
                $mosaic->pixels_per_km = 4;
Exemplo n.º 3
0
         $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)) {
         $smarty->assign('hectad', $hectad = $m[1] . $m[2]);
         $db = NewADOConnection($GLOBALS['DSN']);
         $smarty->assign_by_ref('hectad_row', $db->getRow("select * from hectad_complete where hectad_ref = '{$hectad}' limit 1"));
     }
 }
 //assign main map to smarty
 $mosaic->assignToSmarty($smarty, 'mosaic');
 $smarty->assign('mapwidth', round($mosaic->image_w / $mosaic->pixels_per_km));
Exemplo n.º 4
0
    $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);
}
$smarty->display($template, $cacheid);
Exemplo n.º 5
0
                }
            }
        }
        $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);