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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/********************************************************************************
*! FILE NAME : display_kml.php
*! DESCRIPTION: displays KML records on the page
*! VERSION: 1.0
*! AUTHOR: Oleg Dzhimiev <oleg@elphel.com>
*! Copyright (C) 2011 Elphel, Inc
*! -----------------------------------------------------------------------------**
*! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version.
*!
*! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details.
*!
*! The four essential freedoms with GNU GPL software:
*! * the freedom to run the program for any purpose
*! * the freedom to study how the program works and change it to make it do what you wish
*! * the freedom to redistribute copies so you can help your neighbor
*! * the freedom to distribute copies of your modified versions to others
*!
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------**
*! $Log: display_kml.php,v $
*!
*/
include("pano_db_functions.php");
if (isset($_GET['id'])) $id = $_GET['id'];
else die("Error Code: 13542");
if (is_file("kml_files/".$id)) {
$content = file_get_contents("kml_files/".$id);
header("Content-Type: text/xml\n");
header("Content-Length: ".strlen($content)."\n");
header("Pragma: no-cache\n");
echo $content;
}else{
ConnectMySQL();
$Nodes = GetNodesByRoute($id);
$kml = "";
if (isset($Nodes['error'])) {
send_response("<?xml version=\"1.0\"?>\n<result><node><error>".$Nodes['error']."</error></node></result>");
die();
}
foreach ($Nodes as $Node) {
if (!isset($Node['error'])) $kml .= CreateKMLEntry($Node);
else {
send_response(CreateXMLStringFromArray($Node['error']));
die();
}
}
if ($kml!="") PrintKML2($kml);
else send_response("<?xml version=\"1.0\"?>\n<result><node><error>Some error, no apologies</error></node></result>");
}
function PrintKML2($kml) {
$content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$content .= "<kml xmlns=\"http://earth.google.com/kml/2.2\">\n";
$content .= "<Document>\n";
$content .= $kml;
$content .= "</Document></kml>";
header("Content-Type: text/xml\n");
header("Content-Length: ".strlen($content)."\n");
header("Pragma: no-cache\n");
echo $content;
}