-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpano.inc
executable file
·84 lines (77 loc) · 2.17 KB
/
pano.inc
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
80
81
82
83
84
<?php
$world=array();
$currentNode=-1;
$currentValue="";
$imgOn=false;
$urlPrefix;
function startElement($parser, $name, $attrs)
{
global $world,$currentNode,$currentValue,$imgOn;
switch ($name) {
case 'PhotoOverlay':
$currentNode=count($world);
$world[$currentNode]=array();
break;
case 'Icon':
$imgOn=true;;
break;
}
}
function endElement($parser, $name)
{
global $world,$currentNode,$currentValue,$imgOn,$urlPrefix;
switch ($name) {
case 'longitude':
$world[$currentNode]['longitude']=$currentValue;
break;
case 'latitude':
$world[$currentNode]['latitude']=$currentValue;
break;
case 'altitude':
$world[$currentNode]['altitude']=$currentValue;
break;
case 'heading':
$world[$currentNode]['heading']=$currentValue;
break;
case 'tilt':
$world[$currentNode]['tilt']=$currentValue;
break;
case 'roll':
$world[$currentNode]['roll']=$currentValue;
break;
case 'Icon':
$imgOn=false;
break;
case 'href':
if ($imgOn) $world[$currentNode]['href']=$urlPrefix.$currentValue;
break;
}
}
function characterData($parser, $data)
{
global $currentValue;
$currentValue=$data;
}
// $base - directory, where there is the .kml file, root directory for image files
function parseKML($prefix,$name) {
global $world, $urlPrefix;
$urlPrefix=$prefix;
$xml_parser = xml_parser_create();
// use case-folding so we are sure to find the tag in $map_array
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($name, "r"))) {
die("could not open XML input");
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
return $world;
}
?>