Following a couple of requests (specifically from Henriette Roued-Cunliffe), I’ve re-enabled KML feeds for searches on the PAS database. There’s a few caveats:
- Only records without a Known As pseudonym are returned
- Only the first 1500 results are returned
- Findspots are degraded to 1Km square
To gain access to this feed, either append format/kml to any search results URL or scroll to the bottom of the page and look for the kml link at the end of the contexts available link.
This does provide enough detail to generate broad brush maps for quick analysis. The map below gives the output since the 3rd December 2012 and is generated by entering the URL for the KML feed into the search bar in Google Maps – see for example.
The code in Zend Framework to generate a KML view is as such (remember to enable the KML context in the controller context switch:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
<?php //Create the kml document $dom = new DomDocument("1.0", "UTF-8"); // Creates the root KML element and appends it to the root document. $node = $dom->createElementNS('http://earth.google.com/kml/2.1', 'kml'); $parNode = $dom->appendChild($node); // Creates a KML Document element and append it to the KML element. $dnode = $dom->createElement('Document'); $docNode = $parNode->appendChild($dnode); //In the controller, assign the results foreach($this->results as $result){ // Creates a Placemark and append it to the Document. $node = $dom->createElement('Placemark'); $placeNode = $docNode->appendChild($node); // Creates an id attribute and assign it the value of id column. $placeNode->setAttribute('id', 'placemark-' . $result['id']); if(!is_null($result['description'])){ $html = ''; if(!is_null($result['thumbnail'])){ $html .= '<img src="' . $this->serverUrl() . '/images/thumbnails/' . $result['thumbnail'] . '.jpg" style="float:right" />'; } $html .= '<p>'; $html .= $result['description']; $html .= '</p>'; } $url = $this->serverUrl() . '/database/artefacts/record/id/' . $result['id']; $html .= 'Stable URI: <a href="' . $url . '">' . $url . '</a><br />'; $name = $result['old_findID'] . ': ' . $result['objecttype']; // Create name, and description elements and assigns them the values of the name and address columns from the results. $nameNode = $dom->createElement('name',htmlentities($name)); $placeNode->appendChild($nameNode); $descriptionNode = $dom->createElement('description',htmlspecialchars($html, ENT_QUOTES, 'UTF-8')); $placeNode->appendChild($descriptionNode); // Creates a Point element. $pointNode = $dom->createElement('Point'); $placeNode->appendChild($pointNode); // Creates a coordinates element and gives it the value of the lng and lat columns from the results. $coorStr = $result['fourFigureLon'] . ',' . $result['fourFigureLat']; $coorNode = $dom->createElement('coordinates', $coorStr); $pointNode->appendChild($coorNode); } $kmlOutput = $dom->saveXML(); $filename = 'KMLExport_' . Zend_Date::now()->toString('yyyyMMddHHmmss') . '.kml'; $response = Zend_Controller_Front::getInstance()->getResponse(); $response->setHeader('Content-type', 'application/vnd.google-earth.kml+xml'); $response->setHeader('Content-Disposition', 'attachment; filename=' . $filename); echo $kmlOutput; |