if ($entry['imagecount'] == 1) { $placemark = new kmlPlacemark($entry['gridimage_id'], $entry['grid_reference'] . ' :: ' . $title, $point); $placemark->useCredit($entry['realname'], "http://{$_SERVER['HTTP_HOST']}/photo/{$entry['gridimage_id']}"); $html .= getHtmlLinkP($placemark->link, $entry['grid_reference'] . ' :: ' . $entry['title'] . ' by ' . $entry['realname']); $placemark->setItem('description', $placemark->link); $r = $entry['natgrlen'] > 4 ? '' : 'r'; if ($entry['view_direction'] != -1) { $placemark->useHoverStyle('p1d' . $r); $Style = $placemark->addChild('Style'); $IconStyle = $Style->addChild('IconStyle'); $IconStyle->setItem('heading', $entry['view_direction']); } else { $placemark->useHoverStyle('p1' . $r); } } else { $placemark = new kmlPlacemark($entry['grid_reference'], $entry['grid_reference'] . ' :: ' . $entry['imagecount'] . ' images e.g. ' . $title, $point); $placemark->setItem('description', "http://{$_SERVER['HTTP_HOST']}/gridref/{$entry['grid_reference']}"); $c = $entry['imagecount'] > 20 ? 20 : ($entry['imagecount'] > 4 ? 10 : $entry['imagecount']); $placemark->useHoverStyle('p' . $c); } $Region = $placemark->addChild('Region'); $Region->setPoint($point, 0.01); $delta = $entry['gridimage_id'] % 30; $Region->setLod(50 + $delta, 1300 + $delta * $delta); $Region->setFadeExtent(10, 100); $folder->addChild($placemark); } $letterlength = $CONF['gridpreflen'][$prefix['reference_index']]; $sql_column = "concat(substring(grid_reference,1,{$letterlength}+1),substring(grid_reference,{$letterlength}+3,1))"; $most = $db->GetAll("select \r\ngrid_reference,x,y,\r\n{$sql_column} as hunk_square,\r\nsum(imagecount) as images\r\nfrom gridsquare \r\nwhere {$sql_where}\r\ngroup by hunk_square \r\nhaving images > 0 \r\norder by hunk_square"); foreach ($most as $id => $entry) {
$conv = new Conversions(); $db = NewADOConnection($GLOBALS['DSN']); if (!$db) { die('Database connection failed'); } $kml = new kmlFile(); $kml->atom = true; $stylefile = "http://{$CONF['KML_HOST']}/kml/style.kmz"; $kml->filename = "Geograph-Members.kml"; $folder = $kml->addChild('Document'); $folder->setItem('name', "Geograph British Isles Members"); $users = $db->GetAssoc("select\r\n\t\tuser.user_id,nickname,user.realname,images,gs.x,gs.y,gs.reference_index\r\n\t\tfrom user\r\n\t\t\tleft join user_stat using (user_id)\r\n\t\t\tinner join gridsquare gs on (home_gridsquare = gridsquare_id)\r\n\t\torder by realname"); foreach ($users as $user_id => $user) { list($wgs84_lat, $wgs84_long) = $conv->internal_to_wgs84($user['x'], $user['y']); $point = new kmlPoint($wgs84_lat, $wgs84_long); $placemark = new kmlPlacemark($user_id, $user['realname'] . ' :: ' . $user['images'], $point); $placemark->useCredit($entry['realname'], "http://{$_SERVER['HTTP_HOST']}/profile/{$user_id}"); if (empty($user['nickname'])) { $placemark->setItemCDATA('description', $placemark->link); } else { $placemark->setItemCDATA('description', "Nickname: {$user['nickname']}<br/>{$placemark->link}"); } $placemark->useHoverStyle('def'); $folder->addChild($placemark); } $base = $_SERVER['DOCUMENT_ROOT']; $file = "/kml/members.kmz"; $kml->outputFile('kmz', false, $base . $file); if (isset($_GET['debug'])) { print "<a href=?download>Open in Google Earth</a><br/>"; print "<textarea rows=35 style=width:100%>";
public function __construct($id, $itemname = '', $kmlPoint = null) { parent::__construct($id, $itemname, $kmlPoint); $this->tag = 'PhotoOverlay'; }
$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); $Region->setFadeExtent(50, 200); $networklink = new kmlNetworkLink(null, $name); $file = getKmlFilepath($kml->extension, 7, $square, $entry['hunk_square']); $UrlTag = $networklink->useUrl("http://" . $CONF['KML_HOST'] . $file); $html .= getHtmlLink($file, $entry['hunk_square']); if (!isset($_GET['debug'])) { if (isset($_GET['newonly'])) {
public function __construct($id, $itemname = '', $kmlPoint = null, $d = 10000) { parent::__construct($id, $itemname, $kmlPoint); if (is_object($kmlPoint)) { $this->addCircle($kmlPoint, $d); } }