forked from osmlab/osm-deep-history
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathosm_out.php
181 lines (161 loc) · 4.55 KB
/
osm_out.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
<?
function color($prev, $curr) {
if($prev == "----" and $curr == "----") {
return "notpresent";
} else if($prev == "----" and $curr != "----") {
return "new";
} else if($prev != "----" and $curr != "----") {
if($prev == $curr) {
return "unchanged";
} else {
return "changed";
}
} else if($prev != "----" and $curr == "----") {
return "removed";
}
}
function userAgreed($uid) {
if($uid >= 286582) {
return 'agreed';
} else if(findInFile('users_disagreed.txt', $uid)) {
return 'disagreed';
} else if(findInFile('users_agreed.txt', $uid)) {
return 'agreed';
} else {
return 'nodecision';
}
}
function changesetAgreed($changsetId) {
if(findInFile('anon_changesets_agreed.txt', $changesetId)) {
return 'agreed';
} else {
return 'nodecision';
}
}
function findInFile($file, $needle) {
$data = file($file);
$top = sizeof($data) - 1;
$bot = 0;
while($top >= $bot) {
$p = floor(($top + $bot) / 2);
if((int) $data[$p] < $needle) $bot = $p + 1;
else if((int) $data[$p] > $needle) $top = $p - 1;
else return TRUE;
}
return FALSE;
}
function refLine($ways, $ref) {
$ret = "<tr>";
$previousVal = "----";
$i = 0;
$ret .= "<td style='background:#ccc;'><img src='node.png'/><a href='node.php?id=$ref'>$ref</a></td>";
foreach ($ways as $way) {
$refs = $way['refs'];
if(!array_key_exists($ref, $refs)) {
$currentVal = "----";
} else {
$currentVal = $ref[$ref];
}
$class = color($previousVal, $currentVal);
$ret .= "<td class='$class'> </td>";
$previousVal = $currentVal;
}
$ret .= "</tr>\n";
return $ret;
}
function memberLine($relations, $type, $ref) {
$ret = "<tr>";
$previousVal = "----";
$i = 0;
$ret .= "<td style='background:#ccc;'><img src='$type.png'/><a href='$type.php?id=$ref'>$ref</a></td>";
foreach ($relations as $relation) {
$members = $relation['members'];
if(!array_key_exists("$type,$ref", $members)) {
$currentVal = "----";
$class = color($previousVal, $currentVal);
$ret .= "<td class='$class'> </td>";
} else {
$currentVal = $members["$type,$ref"];
$class = color($previousVal, $currentVal);
if($currentVal == "") {
$ret .= "<td class='$class empty'>(empty)</td>";
} else {
$ret .= "<td class='$class'>$currentVal</td>";
}
}
$previousVal = $currentVal;
}
$ret .= "</tr>\n";
return $ret;
}
function tagLine($ways, $key, $title) {
$ret = "<tr>";
$previousVal = "----";
$i = 0;
$ret .= "<td style='background:#ccc;'><img src='tag.png'/>$title</td>";
foreach ($ways as $way) {
$tags = $way['tags'];
if(!array_key_exists($key, $tags)) {
$currentVal = "----";
$class = color($previousVal, $currentVal);
$ret .= "<td class='$class'> </td>";
} else {
$currentVal = $way['tags'][$key];
$shortVal = $currentVal;
$class = color($previousVal, $currentVal);
if(strlen($currentVal) > 20) {
$shortVal = substr($currentVal, 0, 20) . "…";
$displayVal = str_replace(' ', '␣', $currentVal);
$shortVal = str_replace(' ', '␣', $shortVal);
$ret .= "<td class='$class'><abbr title='$displayVal'>$shortVal</abbr></td>";
} else {
$displayVal = str_replace(' ', '␣', $currentVal);
$ret .= "<td class='$class'>$displayVal</td>";
}
}
$previousVal = $currentVal;
}
$ret .= "</tr>\n";
return $ret;
}
function timeLine($ways) {
$ret = "<tr>";
$ret .= "<td style='background:#ccc;'>Time</td>";
foreach ($ways as $way) {
$currentVal = $way['time'];
$ret .= "<td style='background:#ccc;'>$currentVal</td>";
}
$ret .= "</tr>\n";
return $ret;
}
function wayLine($ways, $val, $useColor=true, $title, $link=Null) {
$ret = "<tr>";
$previousVal = "----";
$ret .= "<td style='background:#ccc;'>$title</td>";
foreach ($ways as $way) {
$currentVal = $way[$val];
$class = color($previousVal, $currentVal);
if($link)
$ret .= "<td class='$class'><a href='$link$currentVal'>$currentVal</a></td>";
else
$ret .= "<td class='$class'>$currentVal</td>";
$previousVal = $currentVal;
}
$ret .= "</tr>\n";
return $ret;
}
function licenseLine($ways) {
$ret = "<tr>";
$ret .= "<td style='background:#ccc;'>Status</td>";
foreach ($ways as $way) {
if($way['uid']) {
$class = userAgreed($way['uid']);
} else {
$class = changesetAgreed($way['changeset']);
}
$ret .= "<td class='$class empty'>$class</td>";
}
$ret .= "</tr>\n";
return $ret;
}
?>