Esempio n. 1
0
     $smarty->assign('gridsquare', $square->gridsquare);
     $smarty->assign('eastings', $square->eastings);
     $smarty->assign('northings', $square->northings);
     $smarty->assign('x', $square->x);
     $smarty->assign('y', $square->y);
     //store details the browser manager has figured out
     $smarty->assign('showresult', 1);
     $smarty->assign('imagecount', $square->imagecount);
     //is this just a closest match?
     if (is_object($square->nearest)) {
         $smarty->assign('nearest_distance', $square->nearest->distance);
         $smarty->assign('nearest_gridref', $square->nearest->grid_reference);
     }
     if ($square->percent_land > 0) {
         //find a possible place within 25km
         $smarty->assign('place', $place = $square->findNearestPlace(75000));
         $place_name = strip_tags(smarty_function_place(array('place' => $place)));
         $smarty->assign('meta_description', "Geograph currently has {$square->imagecount} photos in {$square->grid_reference}, {$place_name}");
     }
 }
 $smarty->assign('mode', 'normal');
 if ($grid_ok && !empty($CONF['sphinx_host']) && (isset($_GET['takenfrom']) || isset($_GET['mentioning']))) {
     $sphinx = new sphinxwrapper();
     $sphinx->pageSize = 15;
     if (isset($_GET['takenfrom'])) {
         $ids = $sphinx->returnIdsViewpoint($square->getNatEastings(), $square->getNatNorthings(), $square->reference_index, $square->grid_reference);
         $smarty->assign('viewpoint_query', $sphinx->q);
         $viewpoint_count = 0;
         //set this to zero to suppress the prompt!
         $smarty->assign('mode', 'takenfrom');
     } else {
Esempio n. 2
0
     $stats[$ri] = array();
 }
 foreach ($CONF['references'] as $ri => $rname) {
     $letterlength = $CONF['gridpreflen'][$ri];
     $newstats = $db->CacheGetRow(3 * 3600, "select \n\t\t\tcount(*) as squares_total,\n\t\t\tsum(imagecount) as images_total,\n\t\t\tsum(imagecount > 0) as squares_submitted,\n\t\t\tcount(distinct concat(substring(grid_reference,1," . ($letterlength + 1) . "),substring(grid_reference," . ($letterlength + 3) . ",1))) as tenk_total\n\t\tfrom gridsquare \n\t\twhere reference_index = {$ri} and percent_land > 0");
     $stats[$ri] = array_merge($stats[$ri], $newstats);
     $newstats = $db->CacheGetRow(3 * 3600, "select \n\t\t\tcount(*) as geographs_submitted,\n\t\t\tcount(distinct substring(grid_reference,1,{$letterlength})) as grid_submitted,\n\t\t\tcount(distinct concat(substring(grid_reference,1," . ($letterlength + 1) . "),substring(grid_reference," . ($letterlength + 3) . ",1))) as tenk_submitted,\n\t\t\tavg( x ) as x,\n\t\t\tavg( y ) as y\n\t\tfrom gridsquare \n\t\twhere reference_index = {$ri} and percent_land > 0 and has_geographs > 0");
     $stats[$ri] = array_merge($stats[$ri], $newstats);
     $stats[$ri] += array('images_thisweek' => $db->CacheGetOne(3 * 3600, "select count(*) from gridimage_search where reference_index = {$ri} and (unix_timestamp(now())-unix_timestamp(submitted))<604800"));
     $stats[$ri] += array("grid_total" => $db->CacheGetOne(24 * 3600, "select count(*) from gridprefix where reference_index = {$ri} and landcount > 0"));
     $censquare = new GridSquare();
     $ok = $censquare->loadFromPosition(intval($stats[$ri]['x']), intval($stats[$ri]['y']));
     if ($ok) {
         $stats[$ri] += array("centergr" => $censquare->grid_reference);
         //find a possible place within 35km
         $stats[$ri] += array("place" => $censquare->findNearestPlace(35000));
         $stats[$ri] += array("marker" => $overview->getSquarePoint($censquare));
     } else {
         $stats[$ri] += array("centergr" => 'unknown');
     }
 }
 foreach (array('images_total', 'images_thisweek', 'squares_total', 'squares_submitted', 'tenk_total', 'tenk_submitted', 'geographs_submitted', 'grid_submitted', 'grid_total') as $name) {
     $sum = 0;
     foreach ($CONF['references'] as $ri => $rname) {
         $sum += $stats[$ri][$name];
     }
     $stats[0] += array($name => $sum);
 }
 foreach ($CONF['references_all'] as $ri => $rname) {
     $sqtotal = $stats[$ri]['squares_total'];
     $percentage = $sqtotal == 0 ? 0.0 : $stats[$ri]['squares_submitted'] / $sqtotal * 100;
     #$square->_initFromArray($recordSet->fields);
     //store cols as members
     foreach ($recordSet->fields as $name => $value) {
         if (!is_numeric($name)) {
             $square->{$name} = $value;
         }
     }
     $square->_storeGridRef($square->grid_reference);
     $extra = "";
     if (!isset($square->nateastings)) {
         $square->getNatEastings();
     }
     //to optimise the query, we scan a square centred on the
     //the required point
     $radius = 100000;
     $places = $square->findNearestPlace($radius);
     $pid = $places['pid'];
 } else {
     //to optimise the query, we scan a square centred on the
     //the required point
     $radius = 100000;
     $left = $recordSet->fields['x'] - $radius;
     $right = $recordSet->fields['x'] + $radius;
     $top = $recordSet->fields['y'] - $radius;
     $bottom = $recordSet->fields['y'] + $radius;
     $ofilter = " and placename_id>0 ";
     $rectangle = "'POLYGON(({$left} {$bottom},{$right} {$bottom},{$right} {$top},{$left} {$top},{$left} {$bottom}))'";
     $sql = "select placename_id,\n\t\t\t\t\tpower(x-{$recordSet->fields['x']},2)+power(y-{$recordSet->fields['y']},2) as distance\n\t\t\t\t\tfrom gridsquare where\n\t\t\t\t\tCONTAINS( \t\n\t\t\t\t\t\tGeomFromText({$rectangle}),\n\t\t\t\t\t\tpoint_xy)\n\t\t\t\t\t{$ofilter}\n\t\t\t\t\torder by distance asc limit 1";
     $square = $db->GetRow($sql);
     $pid = 0;
     if (count($square) && ($distance = sqrt($square['distance'])) && $distance <= $radius) {
Esempio n. 4
0
             $en = array($e, $n);
             $_GET['datum'] = "osgb36";
         } else {
             if ($reference_index == 2) {
                 $en = array($e, $n);
                 $_GET['datum'] = "irish";
             }
         }
     }
 }
 if (isset($en) && count($en)) {
     list($gridref, $len) = $conv->national_to_gridref($en[0], $en[1], 0, $reference_index);
     $square = new GridSquare();
     if ($square->setByFullGridRef($gridref)) {
         //find a possible place
         $smarty->assign('place', $square->findNearestPlace(135000));
         //lets add an overview map too
         $overview = new GeographMapMosaic('largeoverview');
         $overview->setCentre($square->x, $square->y);
         //does call setAlignedOrigin
         $overview->assignToSmarty($smarty, 'overview');
         $smarty->assign('marker', $overview->getSquarePoint($square));
         //get a token to show a suroudding geograph map
         $mosaic = new GeographMapMosaic();
         $smarty->assign('map_token', $mosaic->getGridSquareToken($square));
     }
     $smarty->assign('gridref', $gridref);
     list($gridref, $len) = $conv->national_to_gridref($en[0], $en[1], 4, $reference_index);
     $smarty->assign('gridref4', $gridref);
     $smarty->assign('e', $en[0]);
     $smarty->assign('n', $en[1]);