forked from osmlab/osm-deep-history
-
Notifications
You must be signed in to change notification settings - Fork 1
/
node.php
123 lines (108 loc) · 3.43 KB
/
node.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
<?php
include_once('osm_out.php');
if(!is_numeric($_GET['id'])) {
exit;
}
$id = $_GET['id'];
$url = "http://www.openstreetmap.org/api/0.6/node/$id/history";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "curl/deep_history_viewer (http://osm.mapki.com/history/)");
$output = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($http_code != 200) {
print "Error retrieving history: $http_code";
exit;
}
$xml = simplexml_load_string($output);
$nodes = array();
$tag_keys = array();
foreach ($xml->node as $node_xml) {
$version = (integer) $node_xml->attributes()->version;
$node['version'] = $version;
$node['lat'] = (double) $node_xml->attributes()->lat;
$node['lon'] = (double) $node_xml->attributes()->lon;
$node['changeset'] = (integer) $node_xml->attributes()->changeset;
$node['user'] = (string) $node_xml->attributes()->user;
$node['uid'] = (integer) $node_xml->attributes()->uid;
$node['time'] = (string) $node_xml->attributes()->timestamp;
$tags = array();
foreach ($node_xml->tag as $tag_xml) {
$k = (string) $tag_xml->attributes()->k;
$v = (string) $tag_xml->attributes()->v;
$tags[$k] = $v;
$tag_keys[$k] = true;
}
$node['tags'] = $tags;
$nodes[$version] = $node;
}
?>
<head>
<title>Deep Diff of Node #<? 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>Node ID <? echo $id ?></h3>
<hr />
<div>
<table>
<tr>
<td> </td>
<?
foreach($nodes as $n) {
print "<td>Ver {$n['version']} [<a href='#' class='collapse'>x</a>]</td>";
}
?>
</tr>
<tr>
<td style='background:#aaa;' colspan='<? echo count($nodes) + 1 ?>'>Primitive Info</td>
</tr>
<? echo timeLine($nodes) ?>
<? echo wayLine($nodes, 'changeset', true, "Changeset#", "http://osm.org/browse/changeset/") ?>
<? echo wayLine($nodes, 'user', true, "User", "http://osm.org/user/") ?>
<? echo wayLine($nodes, 'lat', true, "Lat") ?>
<? echo wayLine($nodes, 'lon', true, "Lon") ?>
<tr>
<td style='background:#aaa;' colspan='<? echo count($nodes) + 1 ?>'>License Status <small>(Last updated: <? echo date ("d-M-Y H:i", filemtime("users_agreed.txt")) ?>)</small></td>
</tr>
<? echo licenseLine($nodes) ?>
<tr>
<td style='background:#aaa;' colspan='<? echo count($nodes) + 1 ?>'>Tags</td>
</tr>
<?
foreach (array_keys($tag_keys) as $key) {
print tagLine($nodes, $key, $key);
}
?>
</table>
<div class="reset_collapse"><!-- --></div>
</div>
</body>