$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) { $x = intval(($entry['x'] - $prefix['origin_x']) / 10) * 10 + $prefix['origin_x']; $y = intval(($entry['y'] - $prefix['origin_y']) / 10) * 10 + $prefix['origin_y']; list($south, $west) = $conv->internal_to_wgs84($x, $y, $ri);
} $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%>"; print $kml->returnKML(); print "</textarea>"; } exit;