$db = NewADOConnection($GLOBALS['DSN']); if (!$db) { die('Database connection failed'); } require_once 'geograph/conversions.class.php'; $conv = new Conversions(); $gr = $_GET['gr']; $square = new GridSquare(); $grid_ok = $square->setByFullGridRef($gr); $html = ''; $kml = new kmlFile(); $kml->atom = true; $stylefile = "http://{$CONF['KML_HOST']}/kml/style.kmz"; $folder = $kml->addChild('Document'); $folder->setItem('name', "{$gr} :: Geograph SuperLayer"); $links = new kmlPrimative('Folder'); $links->setItem('name', 'Next Level...'); $prefix = $db->GetRow('select * from gridprefix where prefix=' . $db->Quote($square->gridsquare) . ' limit 1'); $left = $prefix['origin_x'] + intval($square->eastings / 20) * 20; $right = $left + 20 - 1; $bottom = $prefix['origin_y'] + intval($square->northings / 20) * 20; $top = $bottom + 20 - 1; $rectangle = "'POLYGON(({$left} {$bottom},{$right} {$bottom},{$right} {$top},{$left} {$top},{$left} {$bottom}))'"; $sql_where = "CONTAINS(GeomFromText({$rectangle}),point_xy)"; $photos = $db->GetAll("select \r\ngridimage_id,grid_reference,title,title2,imagecount,view_direction,natgrlen,realname,\r\nwgs84_lat,wgs84_long\r\nfrom gridimage_kml \r\nwhere {$sql_where} and tile = 1\r\norder by null"); foreach ($photos as $id => $entry) { $point = new kmlPoint($entry['wgs84_lat'], $entry['wgs84_long']); $title = combineTexts($entry['title'], $entry['title2']); 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']}");
public function __construct() { parent::__construct('Region'); }