-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
417 lines (339 loc) · 16.2 KB
/
index.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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<?php
//
// APEX WEB GIS interface
//
// This uses the Openlayers Javascript library to setup and display WEPP GIS runs. A few things are
// required:
// 2. OpenLayers javascript library. (openlayers.org)
// 3. Mapserver install. (mapserver.org)
// 4. apex databases, DEM, WEPP support php pages and programs.
//
// September 2018
// Qingyu Feng
// Department of Agricultural and Biological Engineering
// Purdue University
// 225 South University Street
// West Lafayette, IN47907
//
require_once("config.php");
?>
<!DOCTYPE html>
<html class="no-js">
<head>
<title>Geo APEX Online</title>
<meta charset='UTF-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="lib/custom/style.css" />
<link rel="stylesheet" type="text/css" href="lib/custom/legendcell.css" />
<link rel="stylesheet" href="lib/ol.css" type="text/css" />
<link rel="stylesheet" href="lib/ol-layerswitcher.css" type="text/css" />
<link rel="stylesheet" href="lib/ol-popup.css" type="text/css" />
<script language="JavaScript" src ="lib/proj4js.js"></script>
<script language="JavaScript" src="lib/ol.js"></script>
<script language="JavaScript" src="lib/ol-layerswitcher.js"></script>
<script language="JavaScript" src="lib/ol-popup.js"></script>
<script language="JavaScript" src="javascripts/panes.js"></script>
<script language="Javascript" src="lib/proj4.js"></script>
<script language="javascript" src="lib/proj4-src.js"></script>
<script language="Javascript" src="lib/jquery-3.3.1.js"></script>
<?php
include('php/olmap.php');
?>
</head>
<body onload="initol()">
<?php
//check for any errors
if(isset($error)){
echo("<h2>");
echo('Error messages: <br>');
foreach($error as $err){
echo '<p class="bg-danger">'.$err.'</p>';
}
echo("</h2>");
}
?>
<form method="POST" name="mapserv" action="index.php">
<input type="hidden" name="DOZOOM" value="<?=$_SESSION["SSVAR"]["izoom"]?>">
<input type="hidden" name="DOSTVR" value="0">
<input type="hidden" name="DOSTRM" value="0">
<input type="hidden" name="EXTENT" value="0">
<input type="hidden" name="DOWSOT" value="0">
<input type="hidden" name="JSONOT" value="0">
<input type="hidden" name="JSO3857" value="0">
<input type="hidden" name="EXTENTVIEW" value="0">
<input type="hidden" name="DOWSFD" value="0">
<input type="hidden" name="JSONFD" value="0">
<input type="hidden" name="JSF3857" value="0">
<input type="hidden" name="DORAPEX" value="0">
<!--Start of zoom control containerr -->
<div id="zoomctnr">
<table style="width:100%">
<!-- First table: zoom to user location-->
<tr>
<td <?php if (($_SESSION["SSVAR"]["fldstep"] > 1) or ($_SESSION["SSVAR"]["oltstep"]> 2)) {echo " colspan = \"2\""; }?> style="width:100%">
Zoom to Zip Code or City,State: (Example: 47906 or Pullman,WA) <br>
<input class="button" type="button" value="Start Over" name="startoverbtn" onClick="javascript:doStartOver();">
<input type="text" name="ZLOC" id="zoomLocation" onkeypress="javascript:checkEnter(event);" size="50">
<input class="button" type="button" value="Go" name="btnZoom" onClick="javascript:doSearch();">
</td>
</tr>
<tr>
<td <?php if (($_SESSION["SSVAR"]["fldstep"] > 1) or ($_SESSION["SSVAR"]["oltstep"]> 2)) {echo " colspan = \"1\" style=\"width:60%\" display:inline-block "; }?> style="width:60%">
<div id="tags"></div>
<div id="shortdesc"></div>
<div id="map" class="smallmap"></div>
</td>
<?php if (($_SESSION["SSVAR"]["fldstep"] > 1) or ($_SESSION["SSVAR"]["oltstep"]> 2)) {
// Appear a new td
echo("<td colspan = \"1\" style=\"width:40%\" display:inline-block>");
// Get the legend file
$fdapexoutlay = $workingDir . "/apexoutjsonmap";
$fnlgd = $fdapexoutlay . "/susrsltclassesglobal.json";
$jslgd = json_decode(file_get_contents($fnlgd), true);
echo("<table display:inline-block>");
echo("<tr> <td style=\"width:10%\" colspan= \"2\">Runoff (mm)</td>");
echo("<td style=\"width:10%\" colspan= \"2\">Erosion (t/ha)</td>");
echo("<td style=\"width:10%\" colspan= \"2\">Total N (kg/ha)</td>");
echo("<td style=\"width:10%\" colspan= \"2\">Total P (kg/ha)</td>");
echo("<tr>");
for ($lidx=1;$lidx<=10; $lidx++ )
{
$lv = "level" . $lidx;
echo("<tr>");
$rmin = number_format((float)$jslgd["runoff"][$lv]["min"], 0, '.', '');
$rmax = number_format((float)$jslgd["runoff"][$lv]["max"], 0, '.', '');
$cssid = "rlvl" . $lidx;
echo("<td style=\"width:5%\" display:inline-block id= \"".$cssid."\"></td>");
echo("<td style=\"width:5%\" display:inline-block>" . $rmin. " to " . $rmax . "</td> ");
$emin = number_format((float)$jslgd["soilerosion"][$lv]["min"], 2, '.', '');
$emax = number_format((float)$jslgd["soilerosion"][$lv]["max"], 2, '.', '');
$cssid = "selvl" . $lidx;
echo("<td style=\"width:5%\" display:inline-block id= \"".$cssid."\"></td>");
echo("<td style=\"width:5%\" display:inline-block>" . $emin. " to " . $emax . "</td> ");
$nmin = number_format((float)$jslgd["nitrogen"][$lv]["min"], 2, '.', '');
$nmax = number_format((float)$jslgd["nitrogen"][$lv]["max"], 2, '.', '');
$cssid = "nlvl" . $lidx;
echo("<td style=\"width:5%\" display:inline-block id= \"".$cssid."\"></td>");
echo("<td style=\"width:5%\" display:inline-block>" . $nmin. " to " . $nmax . "</td> ");
$pmin = number_format((float)$jslgd["phosphorus"][$lv]["min"], 2, '.', '');
$pmax = number_format((float)$jslgd["phosphorus"][$lv]["max"], 2, '.', '');
$cssid = "plvl" . $lidx;
echo("<td style=\"width:5%\" display:inline-block id= \"".$cssid."\"></td>");
echo("<td style=\"width:5%\" display:inline-block>" . $pmin. " to " . $pmax . "</td> ");
echo("</tr>");
}
echo("</table>");
echo("</td>");
} ?>
</tr>
<tr>
<td<?php if (($_SESSION["SSVAR"]["fldstep"] > 1) or ($_SESSION["SSVAR"]["oltstep"]> 2)) {echo " colspan = \"2\""; }?>>
Critical Source Area (<?=$areaStr?>): <input type="text" name="CRIT" size="10" value=<?=$_SESSION["SSVAR"]["criticalarea"]?>> <a href="javascript:helpCSA();"><img alt="Help!" src="/images/help-icon.jpg" /></a>
Tile drainge depth (<?=$lenStr?>):<input type="text" name="TILED" size="15" value=<?=$_SESSION["SSVAR"]["tiledep"]?>>
</td>
</tr>
<tr>
<td<?php if (($_SESSION["SSVAR"]["fldstep"] > 1) or ($_SESSION["SSVAR"]["oltstep"]> 2)) {echo " colspan = \"2\""; }?>>
<p>Simulate a watershed</p>
</td>
</tr>
<tr>
<td<?php if (($_SESSION["SSVAR"]["fldstep"] > 1) or ($_SESSION["SSVAR"]["oltstep"]> 2)) {echo " colspan = \"2\""; }?>>
<input class="button" type="button" value="Stream Network" name="strnetButton" <?php if ($_SESSION["SSVAR"]["fldstep"] > 0){ ?> disabled <?php } ?> onClick="javascript:doStreamNet();">
<input class="button" type="button" value="Set Outlet" name="outletButton" <?php if ($_SESSION["SSVAR"]["oltstep"] < 1){ ?> disabled <?php } ?> onClick="javascript:enableDrawOutlet();">
<input class="button" type="button" value="Get watersheds" name="wsoltButton" <?php if ($_SESSION["SSVAR"]["oltstep"] < 2){ ?> disabled <?php } ?> onClick="javascript:doWatershedOlt();">
</td>
</tr>
<!-- Third Table: Watershed Delineation with field boundary-->
<tr>
<td<?php if (($_SESSION["SSVAR"]["fldstep"] > 1) or ($_SESSION["SSVAR"]["oltstep"]> 2)) {echo " colspan = \"2\""; }?>>
<p>Simulate a Field</p>
</td>
</tr>
<tr>
<td<?php if (($_SESSION["SSVAR"]["fldstep"] > 1) or ($_SESSION["SSVAR"]["oltstep"]> 2)) {echo " colspan = \"2\""; }?>>
<input class="button" type="button" value="Draw a field boundary" name="fldButton" <?php if ($_SESSION["SSVAR"]["oltstep"] > 0){ ?> disabled <?php } ?> onClick="javascript:enableDrawBoundary();">
<input class="button" type="button" value="Get watersheds" name="wsfldbButton" <?php if ($_SESSION["SSVAR"]["fldstep"] < 1){ ?> disabled <?php } ?> onClick="javascript:doWatershedFld();">
</td>
</tr>
<tr>
<td <?php if (($_SESSION["SSVAR"]["fldstep"] > 1) or ($_SESSION["SSVAR"]["oltstep"]> 2)) {echo " colspan = \"2\""; }?>>
<?php if (($_SESSION["SSVAR"]["fldstep"] > 0) or ($_SESSION["SSVAR"]["oltstep"]> 1)) { ?>
<input type="checkbox" name="scenariolst[]" value="nass2016" checked > NASS 2016
<input type="checkbox" name="scenariolst[]" value="fallow"> Fallow
<input type="checkbox" name="scenariolst[]" value="peregrass"> Perennial Grass
<input type="checkbox" name="scenariolst[]" value="trees"> Tree
<input class="button" type="button" value="Run APEX Model" name="runAPFldButton" onClick="javascript:runAPEX();">
<?php } ?>
</td>
</tr>
</table>
</div>
<!-- End of contol container: ctlctnr -->
<br>
<!-- Start of results for watershed div -->
<div id="resulttable" style="display:<?php echo $idsp_fldtb;?>">
<!-- Start of results for watershed div -->
<?php
if ($_SESSION["SSVAR"]["oltstep"] > 2)
{
// Get the number of subareas
$totalsubno = count($TBQSNPArray["s1"]["1"]);
echo("<p align=center>Annual Average Surface Runoff (mm)</p>");
echo("<table style=\"width:100%\">");
// Create the table head
echo("<tr><td style=\"width:10%\">Subarea</td>");
for ($subid = 0; $subid <$totalsubno;$subid++){
$subno = $subid+1;
echo("<td style=\"width:5%\">" . $subno . "</td>");
}
echo("</tr>");
// One row for one scenario
$scenariolst = $_SESSION["SSVAR"]["runscenario"];
$numofscen2 = count($scenariolst)/2;
for ($sid = 0; $sid<$numofscen2; $sid++)
{
$sid2 = $sid+1;
$scenkey = "s". (string)$sid2;
$scennamefull = $scenariolst[$scenkey. "_full"];
$scenname = $scenariolst[$scenkey];
echo("<tr><td style=\"width:10%\">". $scennamefull ."</td>");
for ($subid = 0; $subid <$totalsubno;$subid++){
$subno = $subid+1;
$subqsnparray = $TBQSNPArray[$scenkey]["1"];
$oltrunoff = number_format($subqsnparray[$subno][0][0], 1, '.', '');
echo("<td style=\"width:5%\">" . $oltrunoff . "</td>");
}
echo("</tr>");
}
echo("</table>");
echo("<p align=center>Annual Average Soil Erosion (ton/ha)</p>");
echo("<table style=\"width:100%\">");
// Create the table head
echo("<tr><td style=\"width:10%\">Subarea</td>");
for ($subid = 0; $subid <$totalsubno;$subid++){
$subno = $subid+1;
echo("<td style=\"width:5%\">" . $subno . "</td>");
}
echo("</tr>");
// One row for one scenario
$scenariolst = $_SESSION["SSVAR"]["runscenario"];
$numofscen2 = count($scenariolst)/2;
for ($sid = 0; $sid<$numofscen2; $sid++)
{
$sid2 = $sid+1;
$scenkey = "s". (string)$sid2;
$scennamefull = $scenariolst[$scenkey. "_full"];
$scenname = $scenariolst[$scenkey];
echo("<tr><td style=\"width:10%\">". $scennamefull ."</td>");
for ($subid = 0; $subid <$totalsubno;$subid++){
$subno = $subid+1;
$subqsnparray = $TBQSNPArray[$scenkey]["1"];
$olterosion = number_format($subqsnparray[$subno][0][1], 1, '.', '');
echo("<td style=\"width:5%\">" . $olterosion . "</td>");
}
echo("</tr>");
}
echo("</table>");
echo("<p align=center>Annual Average Total Nitrogen (kg/ha)</p>");
echo("<table style=\"width:100%\">");
// Create the table head
echo("<tr><td style=\"width:10%\">Subarea</td>");
for ($subid = 0; $subid <$totalsubno;$subid++){
$subno = $subid+1;
echo("<td style=\"width:5%\">" . $subno . "</td>");
}
echo("</tr>");
// One row for one scenario
$scenariolst = $_SESSION["SSVAR"]["runscenario"];
$numofscen2 = count($scenariolst)/2;
for ($sid = 0; $sid<$numofscen2; $sid++)
{
$sid2 = $sid+1;
$scenkey = "s". (string)$sid2;
$scennamefull = $scenariolst[$scenkey. "_full"];
$scenname = $scenariolst[$scenkey];
echo("<tr><td style=\"width:10%\">". $scennamefull ."</td>");
for ($subid = 0; $subid <$totalsubno;$subid++){
$subno = $subid+1;
$subqsnparray = $TBQSNPArray[$scenkey]["1"];
$olttn = number_format($subqsnparray[$subno][0][2], 1, '.', '');
echo("<td style=\"width:5%\">" . $olttn . "</td>");
}
echo("</tr>");
}
echo("</table>");
echo("<p align=center>Annual Average Total Phosphorus (kg/ha)</p>");
echo("<table style=\"width:100%\">");
// Create the table head
echo("<tr><td style=\"width:10%\">Subarea</td>");
for ($subid = 0; $subid <$totalsubno;$subid++){
$subno = $subid+1;
echo("<td style=\"width:5%\">" . $subno . "</td>");
}
echo("</tr>");
// One row for one scenario
$scenariolst = $_SESSION["SSVAR"]["runscenario"];
$numofscen2 = count($scenariolst)/2;
for ($sid = 0; $sid<$numofscen2; $sid++)
{
$sid2 = $sid+1;
$scenkey = "s". (string)$sid2;
$scennamefull = $scenariolst[$scenkey. "_full"];
$scenname = $scenariolst[$scenkey];
echo("<tr><td style=\"width:10%\">". $scennamefull ."</td>");
for ($subid = 0; $subid <$totalsubno;$subid++){
$subno = $subid+1;
$subqsnparray = $TBQSNPArray[$scenkey]["1"];
$olttp = number_format($subqsnparray[$subno][0][3], 1, '.', '');
echo("<td style=\"width:5%\">" . $olttp . "</td>");
}
echo("</tr>");
}
echo("</table>");
}
?>
</div>
<!-- end of results for watershed div -->
<!-- Start of results for field div -->
<?php
if ($_SESSION["SSVAR"]["fldstep"] > 1)
{
echo("<p align=center>Area Weighted Average Annual Values for the field</p>");
echo("<table>");
// Create head
echo("<tr>");
echo("<td style=\"width:10%\">Scenario</td>");
echo("<td style=\"width:10%\">Surface runoff (mm)</td>");
echo("<td style=\"width:10%\">Soil Erosion (ton/ha)</td>");
echo("<td style=\"width:10%\">Total Nitrogen (kg/ha)</td>");
echo("<td style=\"width:10%\">Total Phosphorus (kg/ha)</td>");
echo("</tr>");
// Fill cells with values for each scenario
$scenariolst = $_SESSION["SSVAR"]["runscenario"];
$numofscen2 = count($scenariolst)/2;
for ($sid = 0; $sid<$numofscen2; $sid++)
{
$sid2 = $sid+1;
$scenkey = "s". (string)$sid2;
$scennamefull = $scenariolst[$scenkey. "_full"];
$scenname = $scenariolst[$scenkey];
echo("<tr><td style=\"width:10%\">". $scennamefull ."</td>");
$fldrunoff = number_format($TBQSNPArray[$scenname][0], 1, '.', '');
echo("<td style=\"width:5%\">" . $fldrunoff . "</td>");
$flderosion = number_format($TBQSNPArray[$scenname][1], 2, '.', '');
echo("<td style=\"width:5%\">" . $flderosion . "</td>");
$fldtn = number_format($TBQSNPArray[$scenname][2], 2, '.', '');
echo("<td style=\"width:5%\">" . $fldtn . "</td>");
$fldtp = number_format($TBQSNPArray[$scenname][3], 2, '.', '');
echo("<td style=\"width:5%\">" . $fldtp . "</td>");
}
echo("</table>");
}
?>
<!-- end of results for field div -->
</form> <!-- end mapserv form -->
<br>
<br>
</body>
</html>