Skip to content
This repository was archived by the owner on Mar 15, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions comparators/added_ref_tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'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) &&
('highway' in newVersion.properties ||
('route' in newVersion.properties &&
newVersion.properties.route === 'road'))
) {
return {'result:added_ref_tag': true};
}
}
return false;
}
21 changes: 21 additions & 0 deletions comparators/deleted_ref_tag.js
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ module.exports = {
require('./comparators/dragged_highway_waterway')
),
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')
),
Expand Down
289 changes: 289 additions & 0 deletions tests/fixtures/added_ref_tag.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
{
"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": "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": {
"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
}
]
}
Loading