-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuroraNetwork_Web.php
More file actions
141 lines (103 loc) · 6.68 KB
/
AuroraNetwork_Web.php
File metadata and controls
141 lines (103 loc) · 6.68 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
$garbage = $_REQUEST['time'];
include_once 'constants.php';
include_once 'dataParsing.php';
//Set up the G.E. header and create the folders
$dom=new DOMDocument('1.0','iso-8859-1');
$google = $dom->createElementNS('http://earth.google.com/kml/2.2', 'kml');
$googleNode = $dom->appendChild($google);
$folder = $dom->createElement('Folder');
$folderNode = $googleNode->appendChild($folder);
$open = $dom->createElement('open','1');
$openNode = $folderNode->appendChild($open);
//Set up the document node for the Aurora Network
$document = $dom->createElement('Document');
$documentNode = $folderNode->appendChild($document);
$name = $dom->createElement('name','Montana Aurora Detector Network');
$nameNode = $documentNode->appendChild($name);
$descriptionText = '<p><h3 style = "margin-right: 130px; font-size: 12px; font-weight: normal;">Overlays the current status of each of the eight detectors in the Montana Aurora Detector Network.<br><br>This network is operated by the Optical Remote Sensor Laboratory on the campus of Montana State University, Bozeman.</p><p></h3><h6 style = "font-size: 10px; font-weight: normal; text-align: center;">The data refreshes every minute to provide you with the most current information possible.</h6></p>';
//TODO: Make this lower link dynamic
$descriptionText = $descriptionText.'<img style = "position:absolute;left:275px;top:15;"; src = http://orsl.coe.montana.edu/aurora/images/msulogo.jpg>';
$description = $dom->createElement('description',$descriptionText);
$descriptionNode = $documentNode->appendChild($description);
$snippet = $dom->createElement('Snippet','');
$snippetNode = $documentNode->appendChild($snippet);
$snippetNode->setAttribute('maxLines', '2');
$style = $dom->createElement('Style');
$styleNode = $documentNode->appendChild($style);
$styleNode->setAttribute('id', 'aurora_network');
$balloonStyle = $dom->createElement('BalloonStyle');
$balloonStyleNode = $styleNode->appendChild($balloonStyle);
$balloonText = $dom->createElement('text', '$[description]');
$balloonTextNode = $balloonStyleNode->appendChild($balloonText);
//Tell google Earth to look at MT when the Aurora Network is clicked
$lookAt = $dom->createElement('LookAt');
$lookAtNode = $documentNode->appendChild($lookAt);
$lookAtNode->setAttribute('id','Montana');
$latitude = $dom->createElement('latitude','45.5');
$latitudeNode = $lookAtNode->appendChild($latitude);
$longitude = $dom->createElement('longitude','-105.5');
$longitudeNode = $lookAtNode->appendChild($longitude);
$range = $dom->createElement('range','1500000');
$rangeNode = $lookAtNode->appendChild($range);
$tilt = $dom->createElement('tilt','0');
$tiltNode = $lookAtNode->appendChild($tilt);
$heading = $dom->createElement('heading','0');
$headingNode = $lookAtNode->appendChild($heading);
//Set up the detectors placemarks and status icons
for ($ii = 0; $ii < count($detectors['IDs']); $ii++) {
$placemark = $dom->createElement('Placemark');
$placemarkNode = $documentNode->appendChild($placemark);
$name = $dom->createElement('name',$detectors['names'][$ii]);
$nameNode = $placemarkNode->appendChild($name);
$snippet = $dom->createElement('Snippet','Aurora detector on the campus of '.$detectors['names'][$ii]);
$snippetNode = $placemarkNode->appendChild($snippet);
$snippetNode->setAttribute('maxLines', '2');
$style = $dom->createElement('Style');
$styleNode = $placemarkNode->appendChild($style);
$styleNode->setAttribute('id', $detectors['IDs'][$ii].' balloon');
$balloonStyle = $dom->createElement('BalloonStyle');
$balloonStyleNode = $styleNode->appendChild($balloonStyle);
$balloonText = $dom->createElement('text', '$[description]');
$balloonTextNode = $balloonStyleNode->appendChild($balloonText);
$iconStyle = $dom->createElement('Icon');
$iconStyleNode = $styleNode->appendChild($iconStyle);
//TODO: Make this lower link dynamic
$iconImageLink = 'http://orsl.eps.montana.edu/betaWebsite/aurora/stationImage.php?ID='.($detectors['IDs'][$ii]).'&date='.$expiration_time;
$iconLink = $dom->createElement('href', htmlspecialchars($iconImageLink));
$iconLinkNode = $iconStyleNode->appendChild($iconLink);
$descriptionText = '<h3 style = "text-align: left; font-family: Arial,sans-serif;">'.$detectors['names'][$ii].'</h3>';
$descriptionText = $descriptionText.'<p><h3 style = "font-size: 12px; font-weight: normal; font-family: Arial,sans-serif;">Aurora detector on the campus of '.$detectors['names'][$ii].'.</h3>';
$descriptionText = $descriptionText.'</p><text style = "font-size: 12px; font-weight: normal; font-family: Arial,sans-serif;">';
$PMTData = getRecentPMTAuroraData($detectors['IDs'][$ii]);
$PDData = getRecentPDAuroraData($detectors['IDs'][$ii]);
//Commented Out to ignore inactive warnings
/*if ($PMTData == 'NaN' || $PDData == 'NaN') {
$descriptionText = $descriptionText.'Detector Status: Standby';
$descriptionText = $descriptionText.'<br>Light Status:<rad style = "text-align: left; margin-left: 10px;"> '.'Sunlight'.'</rad>';
}
else if ($PMTData == '' || $PDData == '') {
$descriptionText = $descriptionText.'Detector Status: Inactive';
}
else {
$descriptionText = $descriptionText.'Detector Status: On';
$descriptionText = $descriptionText.'<br>PMT:<rad style = "text-align: left; margin-left: 10px;"> '.$PMTData.' μ<i>W</i>/<i>m</i><sup>2</sup><i>Sr</i></rad>';
$descriptionText = $descriptionText.'<br>PD:<rad style = "text-align: left; margin-left: 15px;"> '.$PDData.' μ<i>W</i>/<i>m</i><sup>2</sup><i>Sr</i></rad>';
}
$descriptionText = $descriptionText.'<p>Current Status: No Aurora';
$descriptionText = $descriptionText.'<br>PMT:<rad style = "text-align: left; margin-left: 10px;">'.$PMTData.' μW/m<sup>2</sup>Sr</rad>';
$descriptionText = $descriptionText.'<br>PD:<rad style = "text-align: left; margin-left: 15px;">'.$PDData.' μW/m<sup>2</sup>Sr</rad></p></text>';*/
//REMOVE Single line below when readoing detector statuses
$descriptionText = $descriptionText.'</p></text>';
$description = $dom->createElement('description', $descriptionText);
$descriptionNode = $placemarkNode->appendChild($description);
$point = $dom->createElement('Point');
$pointNode = $placemarkNode->appendChild($point);
$coordinates = $dom->createElement('coordinates', $detectors['coordinates'][$ii]);
$coordinatesNode = $pointNode->appendChild($coordinates);
}
//Tell the browser the output is XML via the 'Content-Type' HTTP header
header('Content-Type: text/xml');
//Display DOM document
echo $dom->saveXML();
?>