-
Notifications
You must be signed in to change notification settings - Fork 0
/
global-map-inc.php
367 lines (326 loc) · 12.6 KB
/
global-map-inc.php
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<?php
############################################################################
# Main processing for Affiliated Regional Networks Global Map
#
# Version 4.00 - 12-Aug-2018 - initial release for Leaflet/OpenStreetMaps
# Version 4.01 - 12-Aug-2018 - update to use base64 decode of translation table
#
# note: settings for this script should be done in global-map-settings.php, not here.
############################################################################
$GMVersion = "Version 4.00 - 12-Aug-2018";
if (isset($_REQUEST['sce']) && strtolower($_REQUEST['sce']) == 'view' ) {
//--self downloader --
$filenameReal = __FILE__;
$download_size = filesize($filenameReal);
header('Pragma: public');
header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header("Content-type: text/plain");
header("Accept-Ranges: bytes");
header("Content-Length: $download_size");
header('Connection: close');
readfile($filenameReal);
exit;
}
include_once("global-map-settings.php");
global $firstPart,$secondPart,$thirdPart,$SITE, $LTRANS;
print "<!-- global-map-inc.php - $GMVersion -->\n";
;
gmGenBoilerplate(); // load default text for first, second and third part of page display
if (isset($SITE['lang']) and $SITE['lang'] <> 'en') {
// handle included files for other language instructions-XX.html
file_exists("wxglobal-".$SITE['lang'].'.html')?include_once("wxglobal-".$SITE['lang'].'.html'):
print "<!-- Sorry, no wxglobal-".$SITE['lang'].".html version of this page can be found. -->\n";
file_exists("wxglobal-".$SITE['lang'].'.html')? print '':include_once("wxglobal-en.html");
} else {
if(file_exists("wxglobal-en.html")) {include_once("wxglobal-en.html");}
}// end of non-english inclusion
?>
<div class="tabber" style="width: 99%; margin: 0 auto;"><!-- MAP tab begin -->
<div class="tabbertab" style="padding: 0;">
<h2><?php langtrans("Map"); ?></h2>
<div style="width: 99%;">
<div id="GMNETmap-container">
<div id="GMNETmap">Map is loading...<br/><?php print $firstPart; ?></div>
<?php
include_once("global-map-genjs-inc.php"); // generate the JavaScript
?>
<table width="100%" style="border: none">
<tr>
<?php if($doRotatingLegends) { ?>
<td style="width: 180px">
<form action="#">
<div id="GMNETcontrols">
<input type="button" value="<?php echo GMNET_RUN; ?>" name="run" onclick="GMNET_set_run(1);" />
<input type="button" value="<?php echo GMNET_PAUSE; ?>" name="pause" onclick="GMNET_set_run(0);" />
<input type="button" value="<?php echo GMNET_STEP; ?>" name="step" onclick="GMNET_step_content();" />
</div>
</form>
<?php } else { ?>
<td>
<?php } // end no rotating legends ?>
</td>
<?php if($doRotatingLegends) { ?>
<td style="text-align: center;">
<div id="GMNETlegend">
<span class="GMNETcontent0" style="text-align: left;"><?php echo GMNET_TEMPL; ?> [ <span id="curTempUOM"><?php print $gmTempUOM; ?></span>° ]</span>
<span class="GMNETcontent1" style="text-align: left;"><?php echo GMNET_DEWPT; ?> [ <span id="curTempUOM2"><?php print $gmTempUOM; ?></span>° ]</span>
<span class="GMNETcontent2" style="text-align: left;"><?php echo GMNET_HUML; ?> [ % ]</span>
<span class="GMNETcontent3" style="text-align: left;"><?php echo GMNET_WIND; ?> [ <span id="curWindUOM"><?php print $gmWindUOM; ?></span> ]</span>
<span class="GMNETcontent4" style="text-align: left;"><?php echo GMNET_PRECIPSL; ?> [ <span id="curRainUOM"><?php print $gmRainUOM; ?></span> ]</span>
<span class="GMNETcontent5" style="text-align: left;"><?php echo GMNET_BAROB; ?> [ <span id="curBaroUOM"><?php print $gmBaroUOM; ?></span> ]</span>
<!-- <span class="GMNETcontent6" style="text-align: left;"><?php echo GMNET_BAROT; ?></span> -->
<?php if($gmShowFireDanger) { ?>
<span class="GMNETcontent6" style="text-align: left;"><?php
echo preg_replace('|<[^>]+>|',' ',GMNET_CBILEGEND); ?></span>
<?php }// end ShowFireDanger headings ?>
</div>
<?php } else { ?>
<td>
<?php } // end no rotating legends ?>
</td>
<td style="text-align:right;">
<form action="#">
<div id="GMcontrolsUOM">
<select id="selTemp" name="selTemp" onchange="GMNET_ChangeSelTemp(this.value);">
<?php
foreach (array('C','F') as $i => $val) {
if($val == $gmTempUOM) {
print " <option value=\"$val\" selected=\"selected\">°$val</option>\n";
} else {
print " <option value=\"$val\">°$val</option>\n";
}
}
?>
</select>
<select id="selWind" name="selWind" onchange="GMNET_ChangeSelWind(this.value);">
<?php
foreach (array('km/h','mph','m/s','kts') as $i => $val) {
if($val == $gmWindUOM) {
print " <option value=\"$val\" selected=\"selected\">$val</option>\n";
} else {
print " <option value=\"$val\">$val</option>\n";
}
}
?>
</select>
<select id="selRain" name="selRain" onchange="GMNET_ChangeSelRain(this.value);">
<?php
foreach (array('mm','in') as $i => $val) {
if($val == $gmRainUOM) {
print " <option value=\"$val\" selected=\"selected\">$val</option>\n";
} else {
print " <option value=\"$val\">$val</option>\n";
}
}
?>
</select>
<select id="selBaro" name="selBaro" onchange="GMNET_ChangeSelBaro(this.value);">
<?php
foreach (array('hPa','inHg','mb') as $i => $val) {
if($val == $gmBaroUOM) {
print " <option value=\"$val\" selected=\"selected\">$val</option>\n";
} else {
print " <option value=\"$val\">$val</option>\n";
}
}
?>
</select>
</div>
</form>
</td>
</tr>
</table>
</div>
<?php if(isset($firstPart)) { print $firstPart; } ?>
<p><small>[<img src="./MESO-images/mma_20_red.png" height="20" width="12" alt="Weather, Webcam, Lightning" style="vertical-align:middle"/>] <?php gmLTS('Weather, Lightning, WebCam'); ?>,
[<img src="./MESO-images/mma_20_yellow.png" height="20" width="12" alt="Weather, Lightning" style="vertical-align:middle"/>] <?php gmLTS('Weather, Lightning'); ?>,
[<img src="./MESO-images/mma_20_green.png" height="20" width="12" alt="Weather, Webcam" style="vertical-align:middle"/>] <?php gmLTS('Weather, WebCam'); ?>,
[<img src="./MESO-images/mma_20_blue.png" height="20" width="12" alt="Weather" style="vertical-align:middle"/>] <?php gmLTS('Weather'); ?></small>
</p>
<?php print $secondPart; ?>
</div> <!-- end map display area tab -->
<?php print "<!-- $GMVersion; -->\n";
$sTarget = $doLinkTarget?' target="_blank"':'';
?>
<p><small>Global mesonet-map script by
<a href="https://saratoga-weather.org/scripts-mesomap.php"<?php echo $sTarget; ?>>Saratoga-Weather.org</a></small></p>
</div> <!-- end first tab -->
<div class="tabbertab" style="padding: 0;"><!-- begin second tab -->
<h3><?php langtrans("Regional Mesonets"); ?></h3>
<div style="width: 99%;">
<?php
if(file_exists($netLinksPath."global-links.php")) {
include_once($netLinksPath."global-links.php");
print " <h3>".langtransstr('Affiliated Regional Weather Networks')."</h3>\n";
print "<p>"; include($netLinksPath."member-count.txt"); print "</p>\n";
include($netLinksPath."network-list-inc.html");
}
if(isset($thirdPart)) {print $thirdPart; }
?>
<p>Regional Networks created by <a href="https://saratoga-weather.org/"<?php echo $sTarget; ?>>Saratoga-Weather.org</a> along with the Global Afilliated Regional Networks hub site at <a href="https://www.northamericanweather.net/"<?php echo $sTarget; ?>>NorthAmericanWeather.net</a>.
[<a href="https://www.northamericanweather.net/about.php"<?php echo $sTarget; ?>>About</a>]</p>
</div><!-- end Regional Mesonet list include -->
</div><!-- end second tab -->
</div><!-- end tabs display -->
<?php
// --- functions
function gmGenBoilerplate () {
global $firstPart,$secondPart,$thirdPart;
# The $firstPart is what gets printed when the page is first presented.
$firstPart = <<<EOT
<noscript><b>JavaScript must be enabled in order for you to use the map.</b>
However, it seems JavaScript is either disabled or not supported by your browser.
To view the maps, enable JavaScript by changing your browser options, and then
try again.
</noscript>
EOT;
// do not remove the above EOT line
# The $secondPart is what gets printed under the legend on the map.
$secondPart = <<<EOT
<p>This map shows the locations of current affiliated regional weather network member stations.</p>
<p><span style="width: 25px; height: 25px; background-color: rgba(110, 204, 57, 0.6); border-radius: 10px;"> </span> Markers with numbers indicate clusters of stations - click to zoom the map to show station markers.
If you click on a marker for a station, a descriptive window will open and show the station features,
a link to the station"e;s homepage, the regional network affiliations for the station,
and current conditions at the station (where available).</p>
EOT;
// do not remove the above EOT line
# The $thirdPart is what gets printed at the bottom of the page.
$thirdPart = <<<EOT
<p><small>Map data from <a href="https://www.northamericanweather.net/">Affiliated Regional Networks</a> and scripts from
<a href="https://saratoga-weather.org/">Saratoga-Weather.org</a>.<br/>
If you have a personal weather station publishing to a personal weather website, you can submit a request to have your
data included in this display by visiting the network for your geography from the list above.</small></p>
EOT;
// do not remove the above EOT line
}
function GMNET_genTranslate($lang) {
global $LTRANS,$L;
if(isset($L[$lang]['text']['charset'])) {
$LT = $L[$lang];
} else {
$LT = $L['en']; // use English as the default for missing language
}
// Generate the JavaScript lookups for wind, features, Baro Trend, Conditions from
// the associated [netid]-meso-lang-LL.txt configuration file.
$txtdir = array(
'N' => 'N',
'NNE' => 'NNE',
'NE' => 'NE',
'ENE' => 'ENE',
'E' => 'E',
'ESE' => 'ESE',
'SE' => 'SE',
'SSE' => 'SSE',
'S' => 'S',
'SSW' => 'SSW',
'SW' => 'SW',
'WSW' => 'WSW',
'W' => 'W',
'WNW' => 'WNW',
'NW' => 'NW',
'NNW' => 'NNW',
);
foreach ($txtdir as $key) {
if(isset($LT['winddir'][$key])) {
$val = $LT['winddir'][$key];
} else {
$val = $key;
}
print " langTransLookup['$key'] = '$val';\n";
$LTRANS[$key] = $val;
}
$txtbarot = array(
'Rising' => 'Rising',
'Falling' => 'Falling',
'Rising Rapidly' => 'Rising Rapidly',
'Falling Rapidly' => 'Falling Rapidly',
'Rising Slowly' => 'Rising Slowly',
'Falling Slowly' => 'Falling Slowly',
'Steady' => 'Steady'
);
foreach ($txtbarot as $key) {
if(isset($LT['barotrend'][$key])) {
$val = $LT['barotrend'][$key];
} else {
$val = $key;
}
print " langTransLookup['$key'] = '$val';\n";
$LTRANS[$key] = $val;
}
$txtfeat = array(
'Weather, Lightning, WebCam' => 'Weather, WebCam, Lightning',
'Weather, WebCam, Lightning' => 'Weather, WebCam, Lightning',
'Weather, WebCam' => 'Weather, WebCam',
'Weather, Lightning' => 'Weather, Lightning',
'Weather' => 'Weather'
);
foreach ($txtfeat as $key => $val2) {
if(isset($LT['features'][$key])) {
$val = $LT['features'][$key];
} else {
$val = $val2;
}
print " langTransLookup['$key'] = '$val';\n";
$LTRANS[$key] = $val;
}
$txticon = array(
'Sunny' => 'Sunny',
'Clear' => 'Clear',
'Cloudy' => 'Cloudy',
'Cloudy2' => 'Cloudy2',
'Partly Cloudy' => 'Partly Cloudy',
'Dry' => 'Dry',
'Fog' => 'Fog',
'Haze' => 'Haze',
'Heavy Rain' => 'Heavy Rain',
'Mainly Fine' => 'Mainly Fine',
'Mist' => 'Mist',
'Fog' => 'Fog',
'Heavy Rain' => 'Heavy Rain',
'Overcast' => 'Overcast',
'Rain' => 'Rain',
'Showers' => 'Showers',
'Snow' => 'Snow',
'Thunder' => 'Thunder',
'Overcast' => 'Overcast',
'Partly Cloudy' => 'Partly Cloudy',
'Rain' => 'Rain',
'Rain2' => 'Rain2',
'Showers2' => 'Showers2',
'Sleet' => 'Sleet',
'Sleet Showers' => 'Sleet Showers',
'Snow' => 'Snow',
'Snow Melt' => 'Snow Melt',
'Snow Showers2' => 'Snow Showers2',
'Sunny' => 'Sunny',
'Thunder Showers' => 'Thunder Showers',
'Thunder Showers2' => 'Thunder Showers2',
'Thunder Storms' => 'Thunder Storms',
'Tornado' => 'Tornado',
'Windy' => 'Windy',
'Stopped Raining' => 'Stopped Raining',
'Wind/Rain' => 'Wind/Rain'
);
foreach ($txticon as $key) {
if(isset($LT['condtext'][$key])) {
$val = $LT['condtext'][$key];
} else {
$val = $key;
}
$t = str_replace("'","\'",$val);
print " langTransLookup['$key'] = '$t';\n";
$LTRANS[$key] = $val;
}
return;
}
# built-in quickie langtrans using the global-map-lang-inc.php language arrays
function gmLTS($instr) {
global $LTRANS;
if(isset($LTRANS[$instr])) {
print $LTRANS[$instr];
} else {
print $instr;
}
}
// end of global-map-inc.php