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
 /**
  * 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();
 }
Exemplo n.º 3
0
    $ri = $second['reference_index'];
    $letterlength = $CONF['gridpreflen'][$ri];
    $smarty->assign('ofe', $letterlength + 1);
    $smarty->assign('ofn', $letterlength + 3);
    //assign all the other useful stuff
    $gr = $map->getGridRef(-1, -1);
    $smarty->assign('gridref', $gr);
    if ($map->pixels_per_km == 4) {
        $starte = substr($gr, $letterlength, 2);
        $starte = intval($starte) - 50;
        if ($starte < 0) {
            $starte += 100;
        }
        $startn = substr($gr, $letterlength + 2, 2);
        $startn = intval($startn) + 50;
        if ($startn > 100) {
            $startn -= 100;
        }
        $smarty->assign('starte', $starte);
        $smarty->assign('startn', $startn - 1);
    } else {
        $mosaic = new GeographMapMosaic();
        $mosaic->setToken($_GET['t'], true);
        $smarty->assign('mosaic_token', $mosaic->getToken());
        $smarty->assign('token_north', $map->getPanToken(0, 1));
        $smarty->assign('token_south', $map->getPanToken(0, -1));
        $smarty->assign('token_west', $map->getPanToken(-1, 0));
        $smarty->assign('token_east', $map->getPanToken(1, 0));
    }
}
$smarty->display($template, $cacheid);
    foreach ($CONF['references'] as $ri => $rname) {
        $letterlength = $CONF['gridpreflen'][$ri];
        $prev_fetch_mode = $ADODB_FETCH_MODE;
        $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
        $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\t(sum(has_geographs) * 100 / sum(percent_land >0)) as percentage\n\t\tfrom gridsquare \n\t\twhere reference_index = {$ri} \n\t\tgroup by tenk_square \n\t\thaving geograph_count > 0 and percentage >=100\n\t\torder by percentage desc,tenk_square");
        $ADODB_FETCH_MODE = $prev_fetch_mode;
        $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();
            //get a token to show a suroudding geograph map
            $largemosaic->setOrigin($most[$id]['x'], $most[$id]['y']);
            $most[$id]['largemap_token'] = $largemosaic->getToken();
            //actully we don't need the full loading of a square
            //$ok = $censquare->loadFromPosition($most[$id]['x'],$most[$id]['y']);
            $censquare->x = $most[$id]['x'];
            $censquare->y = $most[$id]['y'];
            $crit = substr($most[$id]['tenk_square'], 0, $letterlength + 1) . '_' . substr($most[$id]['tenk_square'], $letterlength + 1, 1) . '_';
            list($most[$id]['date'], $most[$id]['dateraw']) = $db->getRow("SELECT DATE_FORMAT(MAX(submitted),'%D %b %Y'),MAX(submitted)\n\t\t\tFROM gridimage_search\n\t\t\tWHERE grid_reference LIKE '{$crit}' AND moderation_status = 'geograph' AND ftf = 1");
            $db->Execute(sprintf("INSERT IGNORE INTO hectad_complete SET\n\t\t\t\thectad_ref = %s,\n\t\t\t\tcompleted = %s,\n\t\t\t\tlandcount = %d,\n\t\t\t\treference_index = %d,\n\t\t\t\tlargemap_token = %s", $db->Quote($most[$id]['tenk_square']), $db->Quote($most[$id]['dateraw']), intval($most[$id]['land_count']), intval($ri), $db->Quote($most[$id]['largemap_token'])));
        }
        uasort($most, "cmp");
        $mostarray += array($ri => $most);
    }
    $smarty->assign_by_ref("most", $mostarray);
    $db->Execute("ALTER TABLE `hectad_complete` ORDER BY `completed` DESC");
}
$smarty->display($template, $cacheid);
Exemplo n.º 5
0
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;
                break;
            case 1: