-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsfc_template.html
More file actions
180 lines (156 loc) · 6.91 KB
/
sfc_template.html
File metadata and controls
180 lines (156 loc) · 6.91 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CLAMPS2 Surface Data</title>
<style>
#map {
height: 350px;
width: 100%;
}
#goCenterUI {
background-color: #fff;
border: 2px solid #fff;
border-radius: 3px;
box-shadow: 0 2px 6px rgba(0,0,0,.3);
cursor: pointer;
float: left;
margin-bottom: 22px;
margin-top: 10px;
text-align: center;
}
#goCenterText {
color: rgb(25,25,25);
font-family: Roboto,Arial,sans-serif;
font-size: 10px;
line-height: 25px;
padding-left: 5px;
padding-right: 5px;
}
</style>
</head>
<body>
<table style="font-size:200%" border="1" width="100%">
<tr><td align="right">Pressure:</td><td id="press"></td><td align="right">Mag Heading:</td><td id="mag_heading"></td><td align="right">Declination:</td><td id="declination"></td></tr>
<tr><td align="right">Temperature:</td><td id="temp"></td><td align="right">Roll:</td><td id="roll"></td><td align="right">Latitude:</td><td id="lat"></td></tr>
<tr><td align="right">RH:</td><td id="RH"></td><td align="right">Pitch:</td><td id="pitch"></td><td align="right">Longitude:</td><td id="lon"></td></tr>
<tr><td align="right">Wind Direction:</td><td id="wind_dir"></td><td align="right">Speed:</td><td id="spd"></td><td align="right">GPS course:</td><td id="course"></td></tr>
<tr><td align="right">Wind Speed:</td><td id="wind_spd"></td><td align="right">Altitude:</td><td id="alt"></td><td align="right">True heading:</td><td id="true_heading"></td></tr>
</table>
<p></p>
<a id="location" target="map" href="http://www.google.com/maps/place/">Location on Google Maps</a>
<p></p>
<div id="map"></div>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDPRqXLKN0OTL5tX6-Hpc5VMdRbMsnrhdU&callback=initMap">
</script>
<script>
function CenterControl(controlDiv, map, center) {
var control = this;
// Set the center property upon construction
control.center_ = center;
controlDiv.style.clear = 'both';
// Set CSS for the control border
var goCenterUI = document.createElement('div');
goCenterUI.id = 'goCenterUI';
goCenterUI.title = 'Click to recenter the map';
controlDiv.appendChild(goCenterUI);
// Set CSS for the control interior
var goCenterText = document.createElement('div');
goCenterText.id = 'goCenterText';
goCenterText.innerHTML = 'Center Map on CLAMPS2';
goCenterUI.appendChild(goCenterText);
// Set up the click event listener for 'Center Map':
// Set the center of the map
// to the current center of the control.
goCenterUI.addEventListener('click', function() {
var currentCenter = control.getCenter();
map.setCenter(currentCenter);
});
}
// define a property to hold the center state.
CenterControl.prototype.center_ = null;
CenterControl.prototype.getCenter = function() {
return this.center_;
};
// Sets the map center
// @param {?googlemaps.LatLng} center
CenterControl.prototype.setCenter = function(center) {
this.center_ = center;
};
function lookupMag(lat, lon) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
parser = new DOMParser();
xmlDoc = parser.parseFromString(this.responseText, "text/xml");
var declination = parseFloat(document.getElementById("declination").innerHTML = xmlDoc.getElementsByTagName("declination")[0].childNodes[0].nodeValue);
document.getElementById("declination").innerHTML = declination.toFixed(2) + " deg E";
document.getElementById("true_heading").innerHTML = (parseFloat(x.mag_heading) + declination).toFixed(2) + " deg";
}
xhttp.open("GET", 'https://www.ngdc.noaa.gov/geomag-web/calculators/calculateDeclination?lat1='+lat+'&lon1='+lon+'&resultFormat=xml', true);
xhttp.send();
}
function loadDoc(callback) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
x = JSON.parse(this.responseText)
document.getElementById("press").innerHTML = x.press.toFixed(1)+" hPa";
document.getElementById("RH").innerHTML = x.RH.toFixed(1) + " %";
document.getElementById("temp").innerHTML = x.temp.toFixed(1) + " deg C";
document.getElementById("wind_dir").innerHTML = x.wind_dir.toFixed(0) + " deg";
document.getElementById("wind_spd").innerHTML = x.wind_spd.toFixed(1) + " m/s";
document.getElementById("mag_heading").innerHTML = x.mag_heading.toFixed(1) + " deg";
document.getElementById("roll").innerHTML = x.roll.toFixed(1) + " deg";
document.getElementById("pitch").innerHTML = x.pitch.toFixed(1) + " deg";
if (x.spd.toFixed(1) >= 0.0 & x.spd.toFixed(1) != -999.0) {
document.getElementById("spd").innerHTML = Math.round(x.spd*1.15078) + " mph";
} else {
document.getElementById("spd").innerHTML = "-999 mph";
}
document.getElementById("location").href = "http://www.google.com/maps/place/" + x.lat + ","
+ x.lon;
document.getElementById("alt").innerHTML = x.alt.toFixed(1) + " MSL";
document.getElementById("declination").innerHTML = x.declination.toFixed(1) + " deg E";
document.getElementById("lat").innerHTML = x.lat.toFixed(6) + " deg N";
document.getElementById("lon").innerHTML = x.lon.toFixed(6) + " deg E";
document.getElementById("course").innerHTML = x.course.toFixed(1) + " deg";
document.getElementById("true_heading").innerHTML = x.true_heading.toFixed(1) + " deg";
//lookupMag(x.lat, x.lon);
//marker.setPosition( new google.maps.LatLng(x.lat, x.lon));
//map.panTo( new google.maps.LatLng(x.lat, x.lon));
//setTimeout(loadDoc, 7000);
callback();
}
};
xhttp.open("GET", "/data", true);
xhttp.send();
}
function initMap() {
loadDoc( function() {
var uluru = {lat: x.lat, lng: x.lon};
map = new google.maps.Map(document.getElementById('map'), {
zoom: 8,
center: uluru
});
marker = new google.maps.Marker({
position: uluru,
map: map
});
centerControlDiv = document.createElement('div');
centerControl = new CenterControl(centerControlDiv, map, uluru);
map.controls[google.maps.ControlPosition.TOP_LEFT].push(centerControlDiv);
setTimeout(mainLoop, 100);
})
}
function mainLoop() {
loadDoc( function() {
var position = new google.maps.LatLng(x.lat, x.lon);
marker.setPosition( position );
centerControl.setCenter( position );
});
setTimeout(mainLoop, 9500);
}
</script>
</body>
</html>