From 65e04acb2fc9f70936a8dfd680b3e41ae761319e Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Thu, 4 Apr 2019 08:32:03 -0700 Subject: [PATCH] Flag features that mention Google in the "source" tag (close #6135) --- data/core.yaml | 9 ++++++ dist/locales/en.json | 13 +++++++++ modules/ui/entity_issues.js | 2 +- modules/validations/incompatible_source.js | 33 ++++++++++++++++++++++ modules/validations/index.js | 1 + 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 modules/validations/incompatible_source.js diff --git a/data/core.yaml b/data/core.yaml index 027b8a8c6..5e98b9c13 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -1294,6 +1294,13 @@ en: title: Generic Names message: '{feature} has the generic name "{name}"' tip: "Names should be the actual, on-the-ground names of features." + incompatible_source: + title: Incompatible Data Sources + google: + feature: + message: '{feature} lists Google as a data source' + tip: "Google products are proprietary and must not be used as references." + tip: "Source data must be licensed in a manner compatible with OpenStreetMap." many_deletions: title: Many Deletions points-lines-areas: @@ -1362,6 +1369,8 @@ en: annotation: Removed a generic name. remove_private_info: annotation: Removed private information. + remove_proprietary_data: + title: Remove any proprietary data remove_tag: title: Remove the tag annotation: Removed tag. diff --git a/dist/locales/en.json b/dist/locales/en.json index 1effc790d..62b0a0af5 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -1588,6 +1588,16 @@ "message": "{feature} has the generic name \"{name}\"", "tip": "Names should be the actual, on-the-ground names of features." }, + "incompatible_source": { + "title": "Incompatible Data Sources", + "google": { + "feature": { + "message": "{feature} lists Google as a data source" + }, + "tip": "Google products are proprietary and must not be used as references." + }, + "tip": "Source data must be licensed in a manner compatible with OpenStreetMap." + }, "many_deletions": { "title": "Many Deletions", "points-lines-areas": { @@ -1682,6 +1692,9 @@ "remove_private_info": { "annotation": "Removed private information." }, + "remove_proprietary_data": { + "title": "Remove any proprietary data" + }, "remove_tag": { "title": "Remove the tag", "annotation": "Removed tag." diff --git a/modules/ui/entity_issues.js b/modules/ui/entity_issues.js index ef53ea2e9..b20a84e0d 100644 --- a/modules/ui/entity_issues.js +++ b/modules/ui/entity_issues.js @@ -131,7 +131,7 @@ export function uiEntityIssues(context) { var fixLists = items.selectAll('.issue-fix-list'); var fixes = fixLists.selectAll('.issue-fix-item') - .data(function(d) { return d.fixes; }) + .data(function(d) { return d.fixes ? d.fixes : []; }) .enter() .append('li') .attr('class', function(d) { diff --git a/modules/validations/incompatible_source.js b/modules/validations/incompatible_source.js new file mode 100644 index 000000000..612ac4d5c --- /dev/null +++ b/modules/validations/incompatible_source.js @@ -0,0 +1,33 @@ +import { t } from '../util/locale'; +import { utilDisplayLabel } from '../util'; +import { validationIssue, validationIssueFix } from '../core/validator'; + + +export function validationIncompatibleSource() { + var type = 'incompatible_source'; + + var validation = function(entity, context) { + + if (entity.tags && entity.tags.source && entity.tags.source.toLowerCase().match(/google/)) { + return [new validationIssue({ + type: type, + severity: 'warning', + message: t('issues.incompatible_source.google.feature.message', { + feature: utilDisplayLabel(entity, context), + }), + tooltip: t('issues.incompatible_source.google.tip'), + entities: [entity], + fixes: [ + new validationIssueFix({ + title: t('issues.fix.remove_proprietary_data.title') + }) + ] + })]; + } + return []; + }; + + validation.type = type; + + return validation; +} diff --git a/modules/validations/index.js b/modules/validations/index.js index b38ff0d97..3b462ebeb 100644 --- a/modules/validations/index.js +++ b/modules/validations/index.js @@ -2,6 +2,7 @@ export { validationAlmostJunction } from './almost_junction'; export { validationCrossingWays } from './crossing_ways'; export { validationDisconnectedWay } from './disconnected_way'; export { validationGenericName } from './generic_name'; +export { validationIncompatibleSource } from './incompatible_source'; export { validationManyDeletions } from './many_deletions'; export { validationMaprules } from './maprules'; export { validationMissingRole } from './missing_role';