From a233b87890f90a480a32f59e23a86849dee348a4 Mon Sep 17 00:00:00 2001 From: Wille Marcel Date: Mon, 19 Mar 2018 11:01:44 -0300 Subject: [PATCH 1/4] remove primary from motorway_trunk_geometry_changed --- comparators/motorway_trunk_geometry_changed.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/comparators/motorway_trunk_geometry_changed.js b/comparators/motorway_trunk_geometry_changed.js index e5e1f86..31a5d2e 100644 --- a/comparators/motorway_trunk_geometry_changed.js +++ b/comparators/motorway_trunk_geometry_changed.js @@ -1,14 +1,7 @@ 'use strict'; var deepEquals = require('deep-equals'); -var MAJOR_ROAD_TYPES = [ - 'motorway', - 'trunk', - 'motorway_link', - 'trunk_link', - 'primary', - 'primary_link' -]; +var MAJOR_ROAD_TYPES = ['motorway', 'trunk', 'motorway_link', 'trunk_link']; function getHighwayType(feature) { return feature.properties.highway; From 3c564783a0d625137d50dd03e199d185a5d16948 Mon Sep 17 00:00:00 2001 From: Wille Marcel Date: Wed, 10 Oct 2018 10:28:17 -0300 Subject: [PATCH 2/4] flag objects that receives a new ref tag --- comparators/added_ref_tag.js | 15 +++ index.js | 1 + tests/fixtures/added_ref_tag.json | 159 ++++++++++++++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 comparators/added_ref_tag.js create mode 100644 tests/fixtures/added_ref_tag.json diff --git a/comparators/added_ref_tag.js b/comparators/added_ref_tag.js new file mode 100644 index 0000000..689b996 --- /dev/null +++ b/comparators/added_ref_tag.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = addedPlace; + +function addedPlace(newVersion, oldVersion) { + if (newVersion.deleted) { + return false; + } + if (oldVersion) { + if ('ref' in newVersion.properties && !('ref' in oldVersion.properties)) { + return {'result:added_ref_tag': true}; + } + } + return false; +} diff --git a/index.js b/index.js index b3061ff..fbf1a79 100755 --- a/index.js +++ b/index.js @@ -28,6 +28,7 @@ module.exports = { require('./comparators/dragged_highway_waterway') ), added_place: wrapsync(require('./comparators/added_place')), + added_ref_tag: wrapsync(require('./comparators/added_ref_tag')), modified_place_wikidata: wrapsync( require('./comparators/modified_place_wikidata') ), diff --git a/tests/fixtures/added_ref_tag.json b/tests/fixtures/added_ref_tag.json new file mode 100644 index 0000000..fcfca69 --- /dev/null +++ b/tests/fixtures/added_ref_tag.json @@ -0,0 +1,159 @@ +{ + "compareFunction": "added_ref_tag", + "fixtures": [ + { + "description": "New object with ref tag", + "newVersion": { + "type": "Feature", + "properties": { + "highway": "primary", + "ref": "BR-001" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "oldVersion": null, + "expectedResult": false + }, + { + "description": "Existing object receives ref tag", + "newVersion": { + "type": "Feature", + "properties": { + "highway": "primary", + "ref": "BR-001" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "oldVersion": { + "type": "Feature", + "properties": { + "highway": "primary" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "expectedResult": { + "result:added_ref_tag": true + } + }, + { + "description": "Changes in existing object with ref tag", + "newVersion": { + "type": "Feature", + "properties": { + "highway": "secondary", + "ref": "BR-001" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "oldVersion": { + "type": "Feature", + "properties": { + "highway": "primary", + "ref": "BR-001" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "expectedResult": false + } + ] +} From 90adeb1193e9df950c17ea925f1fa6e8a966c7e4 Mon Sep 17 00:00:00 2001 From: Wille Marcel Date: Wed, 17 Oct 2018 10:10:46 -0300 Subject: [PATCH 3/4] improve added_ref_tag comparator --- comparators/added_ref_tag.js | 8 +- tests/fixtures/added_ref_tag.json | 130 ++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 1 deletion(-) diff --git a/comparators/added_ref_tag.js b/comparators/added_ref_tag.js index 689b996..1533d9d 100644 --- a/comparators/added_ref_tag.js +++ b/comparators/added_ref_tag.js @@ -7,7 +7,13 @@ function addedPlace(newVersion, oldVersion) { return false; } if (oldVersion) { - if ('ref' in newVersion.properties && !('ref' in oldVersion.properties)) { + if ( + 'ref' in newVersion.properties && + !('ref' in oldVersion.properties) && + ('highway' in newVersion.properties || + ('route' in newVersion.properties && + newVersion.properties.route === 'road')) + ) { return {'result:added_ref_tag': true}; } } diff --git a/tests/fixtures/added_ref_tag.json b/tests/fixtures/added_ref_tag.json index fcfca69..c199c7c 100644 --- a/tests/fixtures/added_ref_tag.json +++ b/tests/fixtures/added_ref_tag.json @@ -34,6 +34,136 @@ "oldVersion": null, "expectedResult": false }, + { + "description": "Building receives ref tag", + "newVersion": { + "type": "Feature", + "properties": { + "building": "yes", + "ref": "BR-001" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ], + [ + 83.33335071802139, + 17.7251960851791 + ] + ] + } + }, + "oldVersion": { + "type": "Feature", + "properties": { + "building": "yes" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ], + [ + 83.33335071802139, + 17.7251960851791 + ] + ] + } + }, + "expectedResult": false + }, + { + "description": "Route receives ref tag", + "newVersion": { + "type": "Feature", + "properties": { + "type": "route", + "route": "road", + "ref": "BR-001" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "oldVersion": { + "type": "Feature", + "properties": { + "route": "road", + "type": "route" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "expectedResult": { + "result:added_ref_tag": true + } + }, { "description": "Existing object receives ref tag", "newVersion": { From 9ecad8b674a1d46d50c74e9b5ebc17d5d2d49b1d Mon Sep 17 00:00:00 2001 From: Wille Marcel Date: Wed, 17 Oct 2018 10:11:21 -0300 Subject: [PATCH 4/4] add deleted_ref_tag comparator --- comparators/deleted_ref_tag.js | 21 ++ index.js | 1 + tests/fixtures/deleted_ref_tag.json | 288 ++++++++++++++++++++++++++++ 3 files changed, 310 insertions(+) create mode 100644 comparators/deleted_ref_tag.js create mode 100644 tests/fixtures/deleted_ref_tag.json diff --git a/comparators/deleted_ref_tag.js b/comparators/deleted_ref_tag.js new file mode 100644 index 0000000..7450564 --- /dev/null +++ b/comparators/deleted_ref_tag.js @@ -0,0 +1,21 @@ +'use strict'; + +module.exports = addedPlace; + +function addedPlace(newVersion, oldVersion) { + if (newVersion.deleted || !oldVersion) { + return false; + } + if (oldVersion) { + if ( + 'ref' in oldVersion.properties && + !('ref' in newVersion.properties) && + ('highway' in newVersion.properties || + ('route' in newVersion.properties && + newVersion.properties.route === 'road')) + ) { + return {'result:deleted_ref_tag': true}; + } + } + return false; +} diff --git a/index.js b/index.js index fbf1a79..5e9cf96 100755 --- a/index.js +++ b/index.js @@ -29,6 +29,7 @@ module.exports = { ), added_place: wrapsync(require('./comparators/added_place')), added_ref_tag: wrapsync(require('./comparators/added_ref_tag')), + deleted_ref_tag: wrapsync(require('./comparators/deleted_ref_tag')), modified_place_wikidata: wrapsync( require('./comparators/modified_place_wikidata') ), diff --git a/tests/fixtures/deleted_ref_tag.json b/tests/fixtures/deleted_ref_tag.json new file mode 100644 index 0000000..05b73af --- /dev/null +++ b/tests/fixtures/deleted_ref_tag.json @@ -0,0 +1,288 @@ +{ + "compareFunction": "deleted_ref_tag", + "fixtures": [ + { + "description": "New object without ref tag", + "newVersion": { + "type": "Feature", + "properties": { + "highway": "primary" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "oldVersion": null, + "expectedResult": false + }, + { + "description": "Object loses ref tag", + "newVersion": { + "type": "Feature", + "properties": { + "highway": "primary" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "oldVersion": { + "type": "Feature", + "properties": { + "highway": "primary", + "ref": "BR-001" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "expectedResult": { + "result:deleted_ref_tag": true + } + }, + { + "description": "Building loses ref tag", + "newVersion": { + "type": "Feature", + "properties": { + "building": "yes" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ], + [ + 83.33335071802139, + 17.7251960851791 + ] + ] + } + }, + "oldVersion": { + "type": "Feature", + "properties": { + "building": "yes", + "ref": "BR-010" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ], + [ + 83.33335071802139, + 17.7251960851791 + ] + ] + } + }, + "expectedResult": false + }, + { + "description": "Route loses ref tag", + "newVersion": { + "type": "Feature", + "properties": { + "type": "route", + "route": "road" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "oldVersion": { + "type": "Feature", + "properties": { + "route": "road", + "type": "route", + "ref": "BA-001" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "expectedResult": { + "result:deleted_ref_tag": true + } + }, + { + "description": "Changes in existing object with ref tag", + "newVersion": { + "type": "Feature", + "properties": { + "highway": "secondary", + "ref": "BR-001" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "oldVersion": { + "type": "Feature", + "properties": { + "highway": "primary", + "ref": "BR-001" + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [ + 83.33335071802139, + 17.7251960851791 + ], + [ + 83.33353847265244, + 17.725829693891324 + ], + [ + 83.33366185426712, + 17.726299789230563 + ], + [ + 83.33373963832855, + 17.726568049605337 + ] + ] + } + }, + "expectedResult": false + } + ] +}