diff --git a/README.md b/README.md index dbe83cf..5f08a23 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ It was first [prototyped](https://osmlab.github.io/latest-changes/) by [@lxbarth ## 2013-2021 A hacked version of this prototype has been created with aims into saving bandwith and rendering time. Furthermore it allows lower zoom levels. It will show changes made in the last 24h, 3 days, 7 days or 30 days. Those enhancements were mainly implemented by [@tyrasd](https://github.com/tyrasd) ## 2022-now -As of July 2022 another updated version has been created, that offers added functionality, i.e. a tag comparison table, a vandalism checker and a filter functionality. +As of July 2022 another [updated version](https://www.openstreetmap.org/user/rene78/diary/399505) has been created, that offers added functionality, i.e. a tag comparison table, a vandalism checker and a filter functionality. [social-media-pic]: img/SocialMedia-Latest-Changes.png "Intro Pic" [screenshot]: img/multi-devices.png "Picture of the App" \ No newline at end of file diff --git a/examples/example.xml b/examples/exampleOverpassAPI.xml similarity index 100% rename from examples/example.xml rename to examples/exampleOverpassAPI.xml diff --git a/index.html b/index.html index 45f94b2..b157bf8 100644 --- a/index.html +++ b/index.html @@ -122,7 +122,7 @@

Explore latest changes on OpenStreetMap

-
Zoom in to view changes
+
Zoom in to download changes
@@ -130,7 +130,6 @@

Explore latest changes on OpenStreetMap

- diff --git a/js/leaflet-osm.js b/js/leaflet-osm.js deleted file mode 100644 index 44e6c36..0000000 --- a/js/leaflet-osm.js +++ /dev/null @@ -1,167 +0,0 @@ -L.OSM = {}; - -L.OSM.DataLayer = L.FeatureGroup.extend({ - options: { - areaTags: ['area', 'building', 'leisure', 'tourism', 'ruins', 'historic', 'landuse', 'military', 'natural', 'sport'], - uninterestingTags: ['source', 'source_ref', 'source:ref', 'history', 'attribution', 'created_by', 'tiger:county', 'tiger:tlid', 'tiger:upload_uuid'], - styles: {} - }, - - initialize: function (xml, options) { - L.Util.setOptions(this, options); - - L.FeatureGroup.prototype.initialize.call(this); - - if (xml) { - this.addData(xml); - } - }, - - addData: function (features) { - if (!(features instanceof Array)) { - features = this.buildFeatures(features); - } - - for (var i = 0; i < features.length; i++) { - var feature = features[i], layer; - - if (feature.type === "node") { - layer = L.circleMarker(feature.latLng, this.options.styles.node); - } else { - var latLngs = new Array(feature.nodes.length); - - for (var j = 0; j < feature.nodes.length; j++) { - latLngs[j] = feature.nodes[j].latLng; - } - - if (this.isWayArea(feature)) { - latLngs.pop(); // Remove last == first. - layer = L.polygon(latLngs, this.options.styles.area); - } else { - layer = L.polyline(latLngs, this.options.styles.way); - } - } - - layer.addTo(this); - layer.feature = feature; - } - }, - - buildFeatures: function (xml) { - var features = [], - nodes = L.OSM.getNodes(xml), - ways = L.OSM.getWays(xml, nodes); - - for (var node_id in nodes) { - var node = nodes[node_id]; - if (this.interestingNode(node, ways)) { - features.push(node); - } - } - - for (var i = 0; i < ways.length; i++) { - var way = ways[i]; - features.push(way); - } - - return features; - }, - - isWayArea: function (way) { - if (way.nodes[0] != way.nodes[way.nodes.length - 1]) { - return false; - } - - for (var key in way.tags) { - if (~this.options.areaTags.indexOf(key)) { - return true; - } - } - - return false; - }, - - interestingNode: function (node, ways) { - var used = false; - - for (var i = 0; i < ways.length; i++) { - if (ways[i].nodes.indexOf(node) >= 0) { - used = true; - break; - } - } - - if (!used) { - return true; - } - - for (var key in node.tags) { - if (this.options.uninterestingTags.indexOf(key) < 0) { - return true; - } - } - - return false; - } -}); - -L.Util.extend(L.OSM, { - getNodes: function (xml) { - var result = {}; - - var nodes = xml.getElementsByTagName("node"); - for (var i = 0; i < nodes.length; i++) { - var node = nodes[i], id = node.getAttribute("id"); - result[id] = { - id: id, - type: 'node', - latLng: L.latLng(node.getAttribute("lat"), - node.getAttribute("lon"), true), - timestamp: node.getAttribute('timestamp'), - changeset: node.getAttribute('changeset'), - user: node.getAttribute('user'), - tags: this.getTags(node) - }; - } - - return result; - }, - - getWays: function (xml, nodes) { - var result = []; - - var ways = xml.getElementsByTagName("way"); - for (var i = 0; i < ways.length; i++) { - var way = ways[i], nds = way.getElementsByTagName("nd"); - - var way_object = { - id: way.getAttribute("id"), - type: "way", - nodes: new Array(nds.length), - timestamp: way.getAttribute('timestamp'), - changeset: way.getAttribute('changeset'), - user: way.getAttribute('user'), - tags: this.getTags(way) - }; - - for (var j = 0; j < nds.length; j++) { - way_object.nodes[j] = nodes[nds[j].getAttribute("ref")]; - } - - result.push(way_object); - } - - return result; - }, - - getTags: function (xml) { - var result = {}; - - var tags = xml.getElementsByTagName("tag"); - for (var j = 0; j < tags.length; j++) { - result[tags[j].getAttribute("k")] = tags[j].getAttribute("v"); - } - - return result; - } -}); diff --git a/js/site.js b/js/site.js index ee6016a..eb340b8 100644 --- a/js/site.js +++ b/js/site.js @@ -169,7 +169,7 @@ function updateMap() { mapHtml.classList.add("faded"); infoText.classList.remove("hide"); button.disabled = "disabled"; - button.title = "Zoom in to view changes"; + button.title = "Zoom in to download changes"; return false; } } @@ -232,7 +232,7 @@ function run() { //Either do an API call to Overpass or use a locally saved xml file for debugging purposes let xmlDataLocation; - if (debugMode) xmlDataLocation = "./examples/example.xml"; //Load example xml for debugging purposes. Works offline + if (debugMode) xmlDataLocation = "./examples/exampleOverpassAPI.xml"; //Load example xml for debugging purposes. Works offline else xmlDataLocation = overpass_server + 'interpreter?data=' + overpass_query; //API call to overpass xhr = d3.xml(xmlDataLocation @@ -386,7 +386,7 @@ function run() { let count = 3; let direction = 1; // 1 for counting up, -1 for counting down const interval = setInterval(function () { - if (count === 8) { + if (count === 10) { direction = -1; // Change direction to count down } else if (count === 3) { direction = 1; // Change direction to count up @@ -396,7 +396,7 @@ function run() { // Set the weight property dynamically l.setStyle({ - color: '#008dff', + color: '#008DFF',//Highlight twin geometry in blue opacity: 1, weight: count }); @@ -668,10 +668,6 @@ function run() { //Case 4: Tags similar --> Don't display this key-value pair else cssClass = "'unchanged'"; - // else continue; - // Better option: Add a class "unchanged", hide them and add a button to show similar tags - // Table height needs to update see https://leafletjs.com/reference.html#divoverlay-contentupdate - // table rows can be animated https://stackoverflow.com/a/37376274/5263954 tableHtml += ` @@ -714,7 +710,7 @@ function run() { else { //Fetch data from OSM database. If there are more than 100 changesets to query make multiple API requests with a hundred CS each. while (changesetIds.length > 0) { - console.log('executed'); + // console.log('executed'); queue.defer(d3.xml, 'https://api.openstreetmap.org/api/0.6/changesets?changesets=' + changesetIds.splice(0, 100).join(','));//limit queried changesets to 100 } }