$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;
$links = new kmlPrimative('Folder'); $links->setItem('name', 'Next Level...'); $most = $db->GetAll("select \r\n\tgridimage_id,nateastings,natnorthings,count(*) as c\r\n\tfrom gridimage \r\n\twhere {$sql_where}\r\n\tgroup by nateastings div 100,natnorthings div 100 \r\n\torder by null"); foreach ($most as $id => $entry) { if ($entry['nateastings']) { $e = ($e2 = intval($entry['nateastings'] / 100)) * 100; $n = ($n2 = intval($entry['natnorthings'] / 100)) * 100; $e2 = $e2 % 10; $n2 = $n2 % 10; list($wgs84_lat, $wgs84_long) = $conv->national_to_wgs84($e + 50, $n + 50, $ri); $entry['hunk_square'] = $square->gridsquare . $square->eastings . $e2 . $square->northings . $n2; $name = "{$entry['hunk_square']} :: {$entry['c']} images"; } else { //should be only one of these! $e = $square->getNatEastings(); $n = $square->getNatNorthings(); list($wgs84_lat, $wgs84_long) = $conv->national_to_wgs84($e, $n, $ri); $entry['hunk_square'] = $square->gridsquare . $square->eastings . '_' . $square->northings . '_'; $name = "{$square->grid_reference} :: {$entry['c']} images"; } $c = $entry['c'] > 20 ? 20 : ($entry['c'] > 4 ? 10 : $entry['c']); $point = new kmlPoint($wgs84_lat, $wgs84_long); $placemark = new kmlPlacemark($entry['hunk_square'], $name, $point); $placemark->useHoverStyle('p' . $c); $folder->addChild($placemark); list($south, $west) = $conv->national_to_wgs84($e, $n, $ri); list($north, $east) = $conv->national_to_wgs84($e + 100, $n + 100, $ri); $delta = $entry['gridimage_id'] % 10; $Region = $placemark->addChild('Region'); $Region->setBoundary($north, $south, $east, $west); $Region->setLod(10 + $delta, 600);