services-maps/kml.php

71 lines
2.2 KiB
PHP
Raw Normal View History

2007-07-25 14:12:35 +00:00
<?php
$location = unserialize(file_get_contents('data/locations.data'));
foreach ($location as $id => $array) {
foreach ($array as $key => $value) {
if ($value['coordinates']['latitude'] + $value['coordinates']['longitude'] != 0) {
$data[$value['location']]['coordinates'] = $value['coordinates'];
$i = count($data[$value['location']]['movies']);
$data[$value['location']]['movies'][$i]['id'] = $id;
$data[$value['location']]['movies'][$i]['description'] = $value['description'];
}
}
}
foreach ($data as $key => $value) {
$string = explode(', ', $key);
$index[$key] = implode(', ', array_reverse($string));
}
asort($index);
foreach ($index as $key => $string) {
$kml .= "\t\t<Placemark>\n";
$kml .= "\t\t\t<name><![CDATA[$key]]></name>\n";
$kml .= "\t\t\t<description>\n";
$kml .= "\t\t\t\t<![CDATA[\n";
foreach ($data[$key]['movies'] as $value) {
$kml .= "\t\t\t\t\t<a href=\"http://0xdb.org/" . $value['id'] . "?v=map\">\n";
$kml .= "\t\t\t\t\t\t<img src=\"http://0xdb.org/" . $value['id'] . "/poster.jpg\" border=\"0\" />\n";
$kml .= "\t\t\t\t\t</a>\n";
}
$kml .= "\t\t\t\t]]>\n";
$kml .= "\t\t\t</description>\n";
/*
$kml .= "\t\t\t<LookAt>\n";
$kml .= "\t\t\t\t<latitude>" . $data[$key]['coordinates']['latitude'] . "</latitude>\n";
$kml .= "\t\t\t\t<longitude>" . $data[$key]['coordinates']['longitude'] . "</longitude>\n";
$kml .= "\t\t\t\t<altitude>0</altitude>\n";
$kml .= "\t\t\t\t<range>500</range>\n";
$kml .= "\t\t\t\t<tilt>0</tilt>\n";
$kml .= "\t\t\t\t<heading>0</heading>\n";
$kml .= "\t\t\t</LookAt>\n";
*/
$kml .= "\t\t\t<Point>\n";
$kml .= "\t\t\t\t<coordinates>" . $data[$key]['coordinates']['longitude'] . ',' . $data[$key]['coordinates']['latitude'] . ",0</coordinates>\n";
$kml .= "\t\t\t</Point>\n";
$kml .= "\t\t</Placemark>\n";
$i++;
if ($i == 0)
break;
}
$kml = substr($kml, 0, -1);
header('Content-Type: application/vnd.google-earth.kml+xml kml');
header('Content-Disposition: attachment; filename=0xdb.kml');
echo <<<KML
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<name>0xdb</name>
<LookAt>
<latitude>0</latitude>
<longitude>0</longitude>
<altitude>1000</altitude>
</LookAt>
$kml
</Document>
</kml>
KML;
?>