Patrick Brosi před 4 roky
rodič
revize
c8ced79249
72 změnil soubory, kde provedl 334 přidání a 0 odebrání
  1. 0 0
      .gitignore
  2. 0 0
      .ycm_extra_conf.py
  3. 0 0
      CMakeLists.txt
  4. 0 0
      cmake/GetGitRevisionDescription.cmake
  5. 0 0
      cmake/GetGitRevisionDescription.cmake.in
  6. 0 0
      cmake/MacPlistMacros.cmake
  7. 0 0
      cmake/cpplint.cmake
  8. 0 0
      src/CMakeLists.txt
  9. 0 0
      src/osmfixer/CMakeLists.txt
  10. 0 0
      src/osmfixer/FixerMain.cpp
  11. 0 0
      src/osmfixer/_config.h.in
  12. 0 0
      src/osmfixer/index/StatIdx.cpp
  13. 0 0
      src/osmfixer/index/StatIdx.h
  14. 0 0
      src/osmfixer/server/StatServer.cpp
  15. 0 0
      src/osmfixer/server/StatServer.h
  16. 0 0
      src/util/CMakeLists.txt
  17. 0 0
      src/util/Misc.h
  18. 0 0
      src/util/Nullable.h
  19. 0 0
      src/util/String.h
  20. 0 0
      src/util/geo/BezierCurve.h
  21. 0 0
      src/util/geo/BezierCurve.tpp
  22. 0 0
      src/util/geo/Box.h
  23. 0 0
      src/util/geo/Geo.h
  24. 0 0
      src/util/geo/GeoGraph.h
  25. 0 0
      src/util/geo/Grid.h
  26. 0 0
      src/util/geo/Grid.tpp
  27. 0 0
      src/util/geo/Line.h
  28. 0 0
      src/util/geo/Point.h
  29. 0 0
      src/util/geo/PolyLine.h
  30. 0 0
      src/util/geo/PolyLine.tpp
  31. 0 0
      src/util/geo/Polygon.h
  32. 0 0
      src/util/geo/output/GeoGraphJsonOutput.h
  33. 0 0
      src/util/geo/output/GeoGraphJsonOutput.tpp
  34. 0 0
      src/util/geo/output/GeoJsonOutput.cpp
  35. 0 0
      src/util/geo/output/GeoJsonOutput.h
  36. 0 0
      src/util/geo/output/GeoJsonOutput.tpp
  37. 0 0
      src/util/graph/Algorithm.h
  38. 0 0
      src/util/graph/Algorithm.tpp
  39. 0 0
      src/util/graph/Dijkstra.cpp
  40. 0 0
      src/util/graph/Dijkstra.h
  41. 0 0
      src/util/graph/Dijkstra.tpp
  42. 0 0
      src/util/graph/DirGraph.h
  43. 0 0
      src/util/graph/DirGraph.tpp
  44. 0 0
      src/util/graph/DirNode.h
  45. 0 0
      src/util/graph/DirNode.tpp
  46. 0 0
      src/util/graph/EDijkstra.cpp
  47. 0 0
      src/util/graph/EDijkstra.h
  48. 0 0
      src/util/graph/EDijkstra.tpp
  49. 0 0
      src/util/graph/Edge.h
  50. 0 0
      src/util/graph/Edge.tpp
  51. 0 0
      src/util/graph/Graph.h
  52. 0 0
      src/util/graph/Graph.tpp
  53. 0 0
      src/util/graph/Node.h
  54. 0 0
      src/util/graph/ShortestPath.h
  55. 0 0
      src/util/graph/ShortestPath.tpp
  56. 0 0
      src/util/graph/UndirGraph.h
  57. 0 0
      src/util/graph/UndirGraph.tpp
  58. 0 0
      src/util/graph/UndirNode.h
  59. 0 0
      src/util/graph/UndirNode.tpp
  60. 0 0
      src/util/http/Server.cpp
  61. 0 0
      src/util/http/Server.h
  62. 0 0
      src/util/json/Writer.cpp
  63. 0 0
      src/util/json/Writer.h
  64. 0 0
      src/util/log/Log.h
  65. 0 0
      src/util/tests/CMakeLists.txt
  66. 0 0
      src/util/tests/TestMain.cpp
  67. 0 0
      src/util/tests/lest.h
  68. 0 0
      src/util/xml/XmlWriter.cpp
  69. 0 0
      src/util/xml/XmlWriter.h
  70. 102 0
      web/index.html
  71. 11 0
      web/leaflet-heat.js
  72. 221 0
      web/script.js

+ 0 - 0
.gitignore


+ 0 - 0
.ycm_extra_conf.py


+ 0 - 0
CMakeLists.txt


+ 0 - 0
cmake/GetGitRevisionDescription.cmake


+ 0 - 0
cmake/GetGitRevisionDescription.cmake.in


+ 0 - 0
cmake/MacPlistMacros.cmake


+ 0 - 0
cmake/cpplint.cmake


+ 0 - 0
src/CMakeLists.txt


+ 0 - 0
src/osmfixer/CMakeLists.txt


+ 0 - 0
src/osmfixer/FixerMain.cpp


+ 0 - 0
src/osmfixer/_config.h.in


+ 0 - 0
src/osmfixer/index/StatIdx.cpp


+ 0 - 0
src/osmfixer/index/StatIdx.h


+ 0 - 0
src/osmfixer/server/StatServer.cpp


+ 0 - 0
src/osmfixer/server/StatServer.h


+ 0 - 0
src/util/CMakeLists.txt


+ 0 - 0
src/util/Misc.h


+ 0 - 0
src/util/Nullable.h


+ 0 - 0
src/util/String.h


+ 0 - 0
src/util/geo/BezierCurve.h


+ 0 - 0
src/util/geo/BezierCurve.tpp


+ 0 - 0
src/util/geo/Box.h


+ 0 - 0
src/util/geo/Geo.h


+ 0 - 0
src/util/geo/GeoGraph.h


+ 0 - 0
src/util/geo/Grid.h


+ 0 - 0
src/util/geo/Grid.tpp


+ 0 - 0
src/util/geo/Line.h


+ 0 - 0
src/util/geo/Point.h


+ 0 - 0
src/util/geo/PolyLine.h


+ 0 - 0
src/util/geo/PolyLine.tpp


+ 0 - 0
src/util/geo/Polygon.h


+ 0 - 0
src/util/geo/output/GeoGraphJsonOutput.h


+ 0 - 0
src/util/geo/output/GeoGraphJsonOutput.tpp


+ 0 - 0
src/util/geo/output/GeoJsonOutput.cpp


+ 0 - 0
src/util/geo/output/GeoJsonOutput.h


+ 0 - 0
src/util/geo/output/GeoJsonOutput.tpp


+ 0 - 0
src/util/graph/Algorithm.h


+ 0 - 0
src/util/graph/Algorithm.tpp


+ 0 - 0
src/util/graph/Dijkstra.cpp


+ 0 - 0
src/util/graph/Dijkstra.h


+ 0 - 0
src/util/graph/Dijkstra.tpp


+ 0 - 0
src/util/graph/DirGraph.h


+ 0 - 0
src/util/graph/DirGraph.tpp


+ 0 - 0
src/util/graph/DirNode.h


+ 0 - 0
src/util/graph/DirNode.tpp


+ 0 - 0
src/util/graph/EDijkstra.cpp


+ 0 - 0
src/util/graph/EDijkstra.h


+ 0 - 0
src/util/graph/EDijkstra.tpp


+ 0 - 0
src/util/graph/Edge.h


+ 0 - 0
src/util/graph/Edge.tpp


+ 0 - 0
src/util/graph/Graph.h


+ 0 - 0
src/util/graph/Graph.tpp


+ 0 - 0
src/util/graph/Node.h


+ 0 - 0
src/util/graph/ShortestPath.h


+ 0 - 0
src/util/graph/ShortestPath.tpp


+ 0 - 0
src/util/graph/UndirGraph.h


+ 0 - 0
src/util/graph/UndirGraph.tpp


+ 0 - 0
src/util/graph/UndirNode.h


+ 0 - 0
src/util/graph/UndirNode.tpp


+ 0 - 0
src/util/http/Server.cpp


+ 0 - 0
src/util/http/Server.h


+ 0 - 0
src/util/json/Writer.cpp


+ 0 - 0
src/util/json/Writer.h


+ 0 - 0
src/util/log/Log.h


+ 0 - 0
src/util/tests/CMakeLists.txt


+ 0 - 0
src/util/tests/TestMain.cpp


+ 0 - 0
src/util/tests/lest.h


+ 0 - 0
src/util/xml/XmlWriter.cpp


+ 0 - 0
src/util/xml/XmlWriter.h


+ 102 - 0
web/index.html

@@ -0,0 +1,102 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>perronkanten | OSM Station Relationships</title>
5
+
6
+	<meta charset="utf-8" />
7
+	<meta name="viewport" content="width=device-width, initial-scale=1.0">
8
+	<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
9
+
10
+    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
11
+    <script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js" integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og==" crossorigin=""></script>
12
+    <script src="leaflet-heat.js"></script>
13
+
14
+    <style>
15
+        body {
16
+            padding: 0;
17
+            margin: 0;
18
+            font-family: sans-serif;
19
+        }
20
+        html, body {
21
+            height: 100%;
22
+            width: 100%;
23
+        }
24
+
25
+        #attr-tbl tr {
26
+            background-color: #c0f7c0;
27
+        }
28
+
29
+        .stat-label {
30
+            white-space: nowrap;
31
+            background: transparent;
32
+        }
33
+
34
+        #attr-tbl .err-10 {
35
+            background-color: #ff0000;
36
+        }
37
+
38
+        #attr-tbl .err-9 {
39
+            background-color: #ff1010;
40
+        }
41
+
42
+        #attr-tbl .err-8 {
43
+            background-color: #f92424;
44
+        }
45
+
46
+
47
+        #attr-tbl .err-7 {
48
+            background-color: #f93838;
49
+        }
50
+
51
+        #attr-tbl .err-6 {
52
+            background-color: #f56262;
53
+        }
54
+
55
+        #attr-tbl .err-5 {
56
+            background-color: #f38484;
57
+        }
58
+
59
+        .attr-err-info {
60
+            margin-top:5px;
61
+            font-size: 13px;
62
+            font-style: italic;
63
+        }
64
+
65
+        .leaflet-popup-content-wrapper {
66
+            border-radius: 5px;
67
+        }
68
+
69
+.leaflet-popup {left: -20px !important;}
70
+
71
+.leaflet-popup-tip-container {
72
+   left: 20px;
73
+}
74
+.leaflet-popup-tip {
75
+   box-shadow: none !important;
76
+}
77
+.leaflet-popup:before 
78
+    {
79
+    content: "";
80
+    position: absolute;
81
+    border: 13px solid transparent;
82
+    border-bottom-color: white;
83
+    bottom: 0px;
84
+    margin-left: -13px;
85
+}
86
+
87
+.attrval {
88
+    font-weight: bold;
89
+}
90
+
91
+    </style>
92
+</head>
93
+<body>
94
+
95
+<div id="map" style="width: 100%;height: 100%;"></div>
96
+<script src="script.js">
97
+</script>
98
+
99
+
100
+
101
+</body>
102
+</html>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 11 - 0
web/leaflet-heat.js


+ 221 - 0
web/script.js

@@ -0,0 +1,221 @@
1
+widths = [12, 13, 14, 15, 16, 16, 16, 16];
2
+opas = [0.8, 0.6, 0.5, 0.5, 0.4];
3
+mwidths = [1, 1, 1, 1.5, 2, 3, 5, 6, 6, 4, 3, 2];
4
+
5
+function $(id) { return document.getElementById(id); }
6
+
7
+function marker(stat, z) {
8
+    if (z > 15) {
9
+        return L.circle(
10
+            [stat.lat, stat.lon],
11
+            {
12
+                color: 'black',
13
+                fillColor: stat.suggestion ? 'blue' : stat.attrerrs ? 'red' : '#78f378', 
14
+                radius: mwidths[23 - z],
15
+                fillOpacity : 1,
16
+                weight : 1,
17
+                id : stat.id
18
+            }
19
+        );
20
+    } else {
21
+        return L.polyline(
22
+            [[stat.lat, stat.lon], [stat.lat, stat.lon]],
23
+            {
24
+                color: stat.suggestion ? 'blue' : stat.attrerrs ? 'red' : '#78f378',
25
+                weight: widths[15 - z],
26
+                opacity: opas[15 - z],
27
+                id : stat.id
28
+            }
29
+        );
30
+    }
31
+}
32
+
33
+function poly(group, z) {
34
+    if (group.new) return L.polygon(group.poly, {color: "blue", smoothFactor : 0.4})
35
+    return L.polygon(group.poly, {color: '#85f385', smoothFactor : 1})
36
+}
37
+
38
+function sugArr(sug, z) {
39
+    return [
40
+            L.polyline(sug.arrow, {id : sug.id, color: 'black', smoothFactor : 1, weight: 2, opacity:0.5}),
41
+            L.polyline(sug.arrow, {id : sug.id, color: 'blue', smoothFactor : 1, weight: 1, opacity:0.5})
42
+        ]
43
+    ;
44
+}
45
+
46
+function renderStat(stat, ll) {
47
+    var attrrows = {};
48
+
49
+    var content = document.createElement('div');
50
+    content.setAttribute("id", "nav")
51
+    var attrTbl = document.createElement('table');
52
+     attrTbl.setAttribute("id", "attr-tbl")
53
+    var suggD = document.createElement('table');
54
+    suggD.setAttribute("id", "sugg")
55
+    content.innerHTML = "OSM node <a target='_blank' href='https://www.openstreetmap.org/node/" + stat.osmid + "'>" + stat.osmid + "</a>";
56
+
57
+    content.appendChild(attrTbl);
58
+    content.appendChild(suggD);
59
+
60
+    var tbody = document.createElement('tbody');
61
+    attrTbl.appendChild(tbody);
62
+
63
+    for (var key in stat.attrs) {
64
+        var row = document.createElement('tr');
65
+        var col1 = document.createElement('td');
66
+        var col2 = document.createElement('td');
67
+        tbody.appendChild(row);
68
+        row.appendChild(col1);
69
+        row.appendChild(col2);
70
+        col1.innerHTML = "<a href=\"https://wiki.openstreetmap.org/wiki/Key:" + key + "\" target=\"_blank\">" + key + "</a>";
71
+        for (var i = 0; i <  stat.attrs[key].length; i++) col2.innerHTML += "<span class='attrval'>" + stat.attrs[key][i] + "</span>"+ "<br>";
72
+        attrrows[key] = row;
73
+    }
74
+
75
+    for (var i = 0; i < stat.attrerrs.length; i++) {
76
+        var err = stat.attrerrs[i];
77
+        var row = attrrows[err.attr[0]];
78
+        row.className = "err-" + Math.round(err.conf * 10);
79
+
80
+        var info = document.createElement('div');
81
+
82
+        if (err.other_osmid != stat.osmid) {
83
+            info.innerHTML = "Does not match node <a target=\"_blank\" href=\"https://www.openstreetmap.org/node/" + err.other_osmid + "\">" + err.other_osmid + "</a>";
84
+        } else {
85
+            info.innerHTML = "Does not match '" + err.other_attr[0] + "' = '" + err.other_attr[1];
86
+        }
87
+        info.className = 'attr-err-info';
88
+        row.childNodes[1].appendChild(info);
89
+    }
90
+
91
+    for (var i = 0; i < stat.suggestions.length; i++) {
92
+        var sugg = stat.suggestions[i];
93
+
94
+        var suggDiv = document.createElement('div');
95
+        
96
+        if (sugg.type == 1) {
97
+            suggDiv.innerHTML = "Move node into a new relation (internal id=" + sugg.target_gid + ")";
98
+        } else if (sugg.type == 2) {
99
+            suggDiv.innerHTML = "Move node into existing relation <a href=\"https://www.openstreetmap.org/relation/" + sugg.target_osm_rel_id + "\" target=\"_blank\">" + sugg.target_osm_rel_id + "</a>.";
100
+        } else if (sugg.type == 3) {
101
+            suggDiv.innerHTML = "Move node from existing relation <a href=\"https://www.openstreetmap.org/relation/" + sugg.orig_osm_rel_id + "\" target=\"_blank\">" + sugg.orig_osm_rel_id + "</a> into new relation (internal id=" + sugg.target_gid + ")";
102
+        } else if (sugg.type == 4) {
103
+            suggDiv.innerHTML = "Move node from existing relation <a href=\"https://www.openstreetmap.org/relation/" + sugg.orig_osm_rel_id + "\" target=\"_blank\">" + sugg.orig_osm_rel_id + "</a> into existing relation <a href=\"https://www.openstreetmap.org/relation/" + sugg.target_osm_rel_id + "\" target=\"_blank\">" + sugg.target_osm_rel_id + "</a>.";
104
+        } else if (sugg.type == 5) {
105
+            suggDiv.innerHTML = "Move node out of existing relation <a href=\"https://www.openstreetmap.org/relation/" + sugg.orig_osm_rel_id + "\" target=\"_blank\">" + sugg.orig_osm_rel_id + "</a>!";
106
+        }
107
+
108
+        suggD.appendChild(suggDiv);
109
+    }
110
+
111
+    if (map.getZoom() < 18) map.setView(ll, 18);
112
+
113
+    L.popup({opacity: 0.8})
114
+    .setLatLng(ll)
115
+    .setContent(content.innerHTML)
116
+    .openOn(map);
117
+}
118
+
119
+function openStat(id, ll) {
120
+    var xmlhttp = new XMLHttpRequest();
121
+    xmlhttp.onreadystatechange = function() {
122
+        if (this.readyState == 4 && this.status == 200) {
123
+            var content = JSON.parse(this.responseText);
124
+            renderStat(content, ll);
125
+        }
126
+    };
127
+
128
+    xmlhttp.open("GET", "http://localhost:9090/stat?id=" + id, true);
129
+    xmlhttp.send();
130
+}
131
+
132
+var map = L.map('map', {
133
+  renderer: L.canvas()
134
+}).setView([47.9965, 7.8469], 13);
135
+
136
+L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png', {
137
+    maxZoom: 23,
138
+    attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, &copy; <a href="https://carto.com/attribution">CARTO</a>',
139
+    id: 'mapbox.streets'
140
+}).addTo(map);
141
+
142
+
143
+var layer = L.featureGroup().addTo(map);
144
+var labelLayer = L.featureGroup().addTo(map);
145
+
146
+map.on("moveend", function () {
147
+    render();
148
+});
149
+
150
+function render() {
151
+    var xmlhttp = new XMLHttpRequest();
152
+
153
+    if (map.getZoom() < 11) {
154
+        xmlhttp.onreadystatechange = function() {
155
+            if (this.readyState == 4 && this.status == 200) {
156
+                var content = JSON.parse(this.responseText);
157
+
158
+                layer.clearLayers();
159
+                labelLayer.clearLayers();
160
+
161
+                var blur = 21 - map.getZoom();
162
+                var rad = 21 - map.getZoom();
163
+
164
+                blur = Math.max(5, Math.min(9, blur));
165
+                rad = Math.min(10, rad);
166
+
167
+                layer.addLayer(L.heatLayer(content.ok, {gradient: {0: '#cbf7cb', 0.5: '#78f378', 1: '#29c329'}, minOpacity: 1, blur: blur, radius: rad, maxZoom: 15}));
168
+                layer.addLayer(L.heatLayer(content.sugg, {gradient: {0: '#7f7fbd', 0.5: '#4444b3', 1: '#0606c1'}, minOpacity: 1, blur: blur-3, radius: rad-3, maxZoom: 15}));
169
+                layer.addLayer(L.heatLayer(content.err, {gradient: {0: '#f39191', 0.5: '#ff5656', 1: '#ff0000'}, minOpacity: 1, blur: blur-3, radius: rad-3, maxZoom: 15}));
170
+            }
171
+        };
172
+
173
+        xmlhttp.open("GET", "http://localhost:9090/heatmap?bbox=" + [map.getBounds().getSouthWest().lat, map.getBounds().getSouthWest().lng, map.getBounds().getNorthEast().lat, map.getBounds().getNorthEast().lng].join(","), true);
174
+        xmlhttp.send();
175
+    } else {
176
+        xmlhttp.onreadystatechange = function() {
177
+            if (this.readyState == 4 && this.status == 200) {
178
+                var content = JSON.parse(this.responseText);
179
+
180
+                layer.clearLayers();
181
+                labelLayer.clearLayers();
182
+
183
+                var stations = [];
184
+                var labels = [];
185
+                for (var i = 0; i < content.stats.length; i++) {
186
+                    stat = content.stats[i];
187
+                    stations.push(marker(stat, map.getZoom()));
188
+                }
189
+
190
+                var groups = [];
191
+                for (var i = 0; i < content.groups.length; i++) {
192
+                    group = content.groups[i];
193
+                    groups.push(poly(group, map.getZoom()));
194
+                }
195
+
196
+                var suggs = [];
197
+                for (var i = 0; i < content.suggestions.length; i++) {
198
+                    sugg = content.suggestions[i];
199
+                    var a = sugArr(sugg, map.getZoom());
200
+                    suggs.push(a[0]);                    
201
+                    suggs.push(a[1]);
202
+                }
203
+
204
+                if (map.getZoom() > 15) {
205
+                   labelLayer.addLayer(L.featureGroup(labels));
206
+                   layer.addLayer(L.featureGroup(groups));
207
+                   layer.addLayer(L.featureGroup(suggs).on('click', function(a) { openStat(a.layer.options.id, a.latlng);}));
208
+                }
209
+
210
+
211
+                layer.addLayer(L.featureGroup(stations).on('click', function(a) { 
212
+                    openStat(a.layer.options.id, a.latlng);}));
213
+            }
214
+        };
215
+
216
+        xmlhttp.open("GET", "http://localhost:9090/map?bbox=" + [map.getBounds().getSouthWest().lat, map.getBounds().getSouthWest().lng, map.getBounds().getNorthEast().lat, map.getBounds().getNorthEast().lng].join(","), true);
217
+        xmlhttp.send();
218
+    }
219
+}
220
+
221
+render();