forked from andrewharvey/osm-deep-history
-
Notifications
You must be signed in to change notification settings - Fork 0
/
way.php
122 lines (110 loc) · 3.2 KB
/
way.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
<?php
include_once('osm_out.php');
if(!is_numeric($_GET['id'])) {
exit;
}
$id = $_GET['id'];
$output = get_contents("way",$id);
$xml = simplexml_load_string($output);
$ways = array();
$tag_keys = array();
$way_refs = array();
foreach ($xml->way as $way_xml) {
$version = (integer) $way_xml->attributes()->version;
$way['version'] = $version;
$way['changeset'] = (integer) $way_xml->attributes()->changeset;
$way['user'] = (string) $way_xml->attributes()->user;
$way['uid'] = (integer) $way_xml->attributes()->uid;
$way['time'] = (string) $way_xml->attributes()->timestamp;
$tags = array();
foreach ($way_xml->tag as $tag_xml) {
$k = (string) $tag_xml->attributes()->k;
$v = (string) $tag_xml->attributes()->v;
$tags[$k] = $v;
$tag_keys[$k] = true;
}
$way['tags'] = $tags;
$refs = array();
foreach ($way_xml->nd as $nd_xml) {
$ref = (string) $nd_xml->attributes()->ref;
$refs[$ref] = true;
$way_refs[$ref] = true;
}
$way['refs'] = $refs;
$ways[$version] = $way;
}
?>
<head>
<title>Deep Diff of Way #<? echo $id ?></title>
<link rel='stylesheet' type='text/css' media='screen,print' href='style.css'/>
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1");
</script>
<script>
$(function() {
$(".collapse").click(function() {
var o = this;
var p = $(this);
while (!$(p).is("table")) {
p = $(p).parent();
}
$(".collapse",p).each(function(i) {
if (this == o) {
$("tr",p).find("td:eq(" + (i+1) + ")").css("display","none");
}
});
$(this).parent().css("display","none");
$(p).siblings(".reset_collapse").html("<p><a href='#' class='show_all_collapsed'>Show All</a></p>").find(".show_all_collapsed").click(function(){
$("th,td",p).css("display","");
$(this).parent().remove();
return false;
});
return false;
});
});
</script>
</head>
<body>
<h3>Way ID <? echo $id ?></h3>
<hr />
<div>
<table>
<tr>
<td> </td>
<?
foreach($ways as $n) {
print "<td>Ver {$n['version']} [<a href='#' class='collapse'>x</a>]</td>";
}
?>
</tr>
<tr>
<td style='background:#aaa;' colspan='<? echo count($ways) + 1 ?>'>Primitive Info</td>
</tr>
<? echo timeLine($ways) ?>
<? echo wayLine($ways, 'changeset', true, "Changeset#", "http://osm.org/browse/changeset/") ?>
<? echo wayLine($ways, 'user', true, "User", "http://osm.org/user/") ?>
<tr>
<td style='background:#aaa;' colspan='<? echo count($ways) + 1 ?>'>License Status <small>(Last updated: <? echo date ("d-M-Y H:i", filemtime("users_agreed.txt")) ?>)</small></td>
</tr>
<? echo licenseLine($ways) ?>
<tr>
<td style='background:#aaa;' colspan='<? echo count($ways) + 1 ?>'>Tags</td>
</tr>
<?
foreach (array_keys($tag_keys) as $key) {
print tagLine($ways, $key, $key);
}
?>
<tr>
<td style='background:#aaa;' colspan='<? echo count($ways) + 1 ?>'>Nodes</td>
</tr>
<?
foreach (array_keys($way_refs) as $ref) {
print refLine($ways, $ref);
}
?>
</table>
<div class="reset_collapse"><!-- --></div>
</div>
</body>