$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 { $sphinx->prepareQuery("{$square->grid_reference} -grid_reference:{$square->grid_reference}"); $ids = $sphinx->returnIds(1, "_images"); $smarty->assign('mode', 'mentioning'); $mention_count = 0; //set this to zero to suppress the prompt! } if (!empty($ids) && count($ids)) { $images = new ImageList(); $images->getImagesByIdList($ids); $square->totalimagecount = $sphinx->resultCount;
} else { $gid = $recordSet->fields['gridsquare_id']; #$from_stratch = 1; if ($from_stratch || $recordSet->fields['reference_index'] == 2) { $square = new GridSquare(); #$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 ";