-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloadingData.php
executable file
·107 lines (98 loc) · 5.92 KB
/
loadingData.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
<?php
include_once('JTree.php');
//create a new tree object
$jt = new JTree();
/* $categories = array();
$categories[] = array('id' => 1, 'weather_condition' => 'weather', 'parent_id' => 9999);
$categories[] = array('id' => 2, 'weather_condition' => 'Earthquakes', 'parent_id' => 1);
$categories[] = array('id' => 3, 'weather_condition' => 'Major', 'parent_id' => 2);
$categories[] = array('id' => 4, 'weather_condition' => 'Minor', 'parent_id' => 2);
$categories[] = array('id' => 5, 'weather_condition' => 'Fires', 'parent_id' => 9);
$categories[] = array('id' => 6, 'weather_condition' => 'Rain', 'parent_id' => 1);
$categories[] = array('id' => 7, 'weather_condition' => 'Flooding', 'parent_id' => 6);
$categories[] = array('id' => 8, 'weather_condition' => 'Washout', 'parent_id' => 6);
$categories[] = array('id' => 9, 'weather_condition' => 'Hurricanes', 'parent_id' => 1); */
$categories = array();
$categories[] = array('id' => 'X7', 'Name' => 'Flood water level', 'parent_id' => 9999);
$categories[] = array('id' => 'X8', 'Name' => 'Meteorological Factors', 'parent_id' => 'X7');
$categories[] = array('id' => 'X9', 'Name' => 'Geological Factors', 'parent_id' => 'X7');
$categories[] = array('id' => 'X10', 'Name' => 'River Discharge', 'parent_id' => 'X7');
$categories[] = array('id' => 'X11', 'Name' => 'Topography', 'parent_id' => 'X7');
$categories[] = array('id' => 'X12', 'Name' => 'Human activities', 'parent_id' => 'X7');
$categories[] = array('id' => 'X22', 'Name' => 'Onset rainfall', 'parent_id' => 'X8');
$categories[] = array('id' => 'X23', 'Name' => 'Prolonged rainfall', 'parent_id' => 'X8');
$categories[] = array('id' => 'X19', 'Name' => 'Soil type', 'parent_id' => 'X9');
$categories[] = array('id' => 'X20', 'Name' => 'Saturation limit of the soil type', 'parent_id' => 'X9');
$categories[] = array('id' => 'X21', 'Name' => 'Soil infiltration rate', 'parent_id' => 'X9');
$categories[] = array('id' => 'X14', 'Name' => 'River depth', 'parent_id' => 'X10');
$categories[] = array('id' => 'X15', 'Name' => 'River width', 'parent_id' => 'X10');
$categories[] = array('id' => 'X16', 'Name' => 'Velocity', 'parent_id' => 'X10');
$categories[] = array('id' => 'X25', 'Name' => 'Slope', 'parent_id' => 'X11');
$categories[] = array('id' => 'X26', 'Name' => 'Aspect', 'parent_id' => 'X11');
$categories[] = array('id' => 'X27', 'Name' => 'Unplanned infrastructure', 'parent_id' => 'X12');
$categories[] = array('id' => 'X28', 'Name' => 'Embankment failure', 'parent_id' => 'X12');
$categories[] = array('id' => 'X29', 'Name' => 'Deforestation', 'parent_id' => 'X12');
$categories[] = array('id' => 'X30', 'Name' => 'Settlement on the flood prone areas', 'parent_id' => 'X12');
$categories[] = array('id' => 'X31', 'Name' => 'Decrease watershed areas', 'parent_id' => 'X12');
$categories[] = array('id' => 'X17', 'Name' => 'Slope', 'parent_id' => 'X16');
$categories[] = array('id' => 'X18', 'Name' => 'Siltation', 'parent_id' => 'X16');
// $categories[] = array('id' => 'X7', 'Name' => 'Hurricanes', 'parent_id' => 1);
//iterate building the tree
foreach($categories as $category) {
$uid = $jt->createNode($category['Name'],$category['id'], $category['parent_id']);
}
function gettree(){
$jt = new JTree();
$categories = array();
$categories[] = array('id' => 'X7', 'Name' => 'Flood water level', 'parent_id' => 9999);
$categories[] = array('id' => 'X8', 'Name' => 'Meteorological Factors', 'parent_id' => 'X7');
$categories[] = array('id' => 'X9', 'Name' => 'Geological Factors', 'parent_id' => 'X7');
$categories[] = array('id' => 'X10', 'Name' => 'River Discharge', 'parent_id' => 'X7');
$categories[] = array('id' => 'X11', 'Name' => 'Topography', 'parent_id' => 'X7');
$categories[] = array('id' => 'X12', 'Name' => 'Human activities', 'parent_id' => 'X7');
$categories[] = array('id' => 'X22', 'Name' => 'Onset rainfall', 'parent_id' => 'X8');
$categories[] = array('id' => 'X23', 'Name' => 'Prolonged rainfall', 'parent_id' => 'X8');
$categories[] = array('id' => 'X19', 'Name' => 'Soil type', 'parent_id' => 'X9');
$categories[] = array('id' => 'X20', 'Name' => 'Saturation limit of the soil type', 'parent_id' => 'X9');
$categories[] = array('id' => 'X21', 'Name' => 'Soil infiltration rate', 'parent_id' => 'X9');
$categories[] = array('id' => 'X14', 'Name' => 'River depth', 'parent_id' => 'X10');
$categories[] = array('id' => 'X15', 'Name' => 'River width', 'parent_id' => 'X10');
$categories[] = array('id' => 'X16', 'Name' => 'Velocity', 'parent_id' => 'X10');
$categories[] = array('id' => 'X25', 'Name' => 'Slope', 'parent_id' => 'X11');
$categories[] = array('id' => 'X26', 'Name' => 'Aspect', 'parent_id' => 'X11');
$categories[] = array('id' => 'X27', 'Name' => 'Unplanned infrastructure', 'parent_id' => 'X12');
$categories[] = array('id' => 'X28', 'Name' => 'Embankment failure', 'parent_id' => 'X12');
$categories[] = array('id' => 'X29', 'Name' => 'Deforestation', 'parent_id' => 'X12');
$categories[] = array('id' => 'X30', 'Name' => 'Settlement on the flood prone areas', 'parent_id' => 'X12');
$categories[] = array('id' => 'X31', 'Name' => 'Decrease watershed areas', 'parent_id' => 'X12');
$categories[] = array('id' => 'X17', 'Name' => 'Slope', 'parent_id' => 'X16');
$categories[] = array('id' => 'X18', 'Name' => 'Siltation', 'parent_id' => 'X16');
foreach($categories as $category) {
$uid = $jt->createNode($category['Name'],$category['id'], $category['parent_id']);
}
return $jt;
}
/* //update: removed third variable. Use defaults
$it = new JTreeRecursiveIterator($jt, new JTreeIterator($jt->getTree()));
//iterate to create the ul list
foreach($it as $k => $v) {
echo "<br>k:=>$k";
//echo "v:=>$v";
print_r($v);
}
echo"<br>";
echo"Details of Node X8";
echo"<br>";
$jN=$jt->getNode("X8");
print_r($jN->getValue());
echo"<br>";
//print_r($jN->getChildren());
$jChildren=$jN->getChildren();
foreach( $jChildren as $value )
{
$h=$jt->getNode($value);
print_r($h->getUid());
print_r($h->getValue());
echo"<br>";
//echo "Value is $h->getValue() <br />";
} */