mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
Merge pull request #8701 from openstreetmap/check_china_source
Add warning for some commercial mapservice in China
This commit is contained in:
@@ -1761,10 +1761,12 @@ en:
|
||||
incompatible_source:
|
||||
title: Suspicious Sources
|
||||
tip: "Find features with suspicious source tags"
|
||||
google:
|
||||
feature:
|
||||
message: '{feature} lists Google as a data source'
|
||||
reference: "Google products are proprietary and must not be used as references."
|
||||
feature:
|
||||
message: '{feature} lists "{value}" as a data source'
|
||||
reference:
|
||||
amap: "Amap products are proprietary and must not be used as references."
|
||||
baidu: "Baidu products are proprietary and must not be used as references."
|
||||
google: "Google products are proprietary and must not be used as references."
|
||||
incorrect_name:
|
||||
message: '{feature} has the mistaken name "{name}"'
|
||||
message_language: '{feature} has the mistaken name "{name}" in {language}'
|
||||
|
||||
2
dist/locales/en.min.json
vendored
2
dist/locales/en.min.json
vendored
File diff suppressed because one or more lines are too long
@@ -4,65 +4,73 @@ import { validationIssue, validationIssueFix } from '../core/validation';
|
||||
|
||||
|
||||
export function validationIncompatibleSource() {
|
||||
var type = 'incompatible_source';
|
||||
var invalidSources = [
|
||||
{
|
||||
id:'google', regex:'google', exceptRegex: 'books.google|Google Books|drive.google|googledrive|Google Drive'
|
||||
}
|
||||
];
|
||||
const type = 'incompatible_source';
|
||||
const incompatibleRules = [
|
||||
{
|
||||
id: 'amap',
|
||||
regex: /(amap|autonavi|mapabc|高德)/i
|
||||
},
|
||||
{
|
||||
id: 'baidu',
|
||||
regex: /(baidu|mapbar|百度)/i
|
||||
},
|
||||
{
|
||||
id: 'google',
|
||||
regex: /google/i,
|
||||
exceptRegex: /((books|drive)\.google|google\s?(books|drive|plus))/i
|
||||
}
|
||||
];
|
||||
|
||||
var validation = function checkIncompatibleSource(entity) {
|
||||
|
||||
var entitySources = entity.tags && entity.tags.source && entity.tags.source.split(';');
|
||||
const validation = function checkIncompatibleSource(entity) {
|
||||
const entitySources = entity.tags && entity.tags.source && entity.tags.source.split(';');
|
||||
if (!entitySources) return [];
|
||||
|
||||
if (!entitySources) return [];
|
||||
const entityID = entity.id;
|
||||
|
||||
var issues = [];
|
||||
|
||||
invalidSources.forEach(function(invalidSource) {
|
||||
|
||||
var hasInvalidSource = entitySources.some(function(source) {
|
||||
if (!source.match(new RegExp(invalidSource.regex, 'i'))) return false;
|
||||
if (invalidSource.exceptRegex && source.match(new RegExp(invalidSource.exceptRegex, 'i'))) return false;
|
||||
return true;
|
||||
});
|
||||
|
||||
if (!hasInvalidSource) return;
|
||||
|
||||
issues.push(new validationIssue({
|
||||
type: type,
|
||||
severity: 'warning',
|
||||
message: function(context) {
|
||||
var entity = context.hasEntity(this.entityIds[0]);
|
||||
return entity ? t.html('issues.incompatible_source.' + invalidSource.id + '.feature.message', {
|
||||
feature: utilDisplayLabel(entity, context.graph(), true /* verbose */)
|
||||
}) : '';
|
||||
},
|
||||
reference: getReference(invalidSource.id),
|
||||
entityIds: [entity.id],
|
||||
dynamicFixes: function() {
|
||||
return [
|
||||
new validationIssueFix({
|
||||
title: t.html('issues.fix.remove_proprietary_data.title')
|
||||
})
|
||||
];
|
||||
}
|
||||
}));
|
||||
return entitySources
|
||||
.map(source => {
|
||||
const matchRule = incompatibleRules.find(rule => {
|
||||
if (!rule.regex.test(source)) return false;
|
||||
if (rule.exceptRegex && rule.exceptRegex.test(source)) return false;
|
||||
return true;
|
||||
});
|
||||
|
||||
return issues;
|
||||
if (!matchRule) return null;
|
||||
|
||||
return new validationIssue({
|
||||
type: type,
|
||||
severity: 'warning',
|
||||
message: (context) => {
|
||||
const entity = context.hasEntity(entityID);
|
||||
return entity ? t.html('issues.incompatible_source.feature.message', {
|
||||
feature: utilDisplayLabel(entity, context.graph(), true /* verbose */),
|
||||
value: source
|
||||
}) : '';
|
||||
},
|
||||
reference: getReference(matchRule.id),
|
||||
entityIds: [entityID],
|
||||
hash: source,
|
||||
dynamicFixes: () => {
|
||||
return [
|
||||
new validationIssueFix({ title: t.html('issues.fix.remove_proprietary_data.title') })
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
}).filter(Boolean);
|
||||
|
||||
|
||||
function getReference(id) {
|
||||
return function showReference(selection) {
|
||||
selection.selectAll('.issue-reference')
|
||||
.data([0])
|
||||
.enter()
|
||||
.append('div')
|
||||
.attr('class', 'issue-reference')
|
||||
.html(t.html('issues.incompatible_source.' + id + '.reference'));
|
||||
};
|
||||
}
|
||||
function getReference(id) {
|
||||
return function showReference(selection) {
|
||||
selection.selectAll('.issue-reference')
|
||||
.data([0])
|
||||
.enter()
|
||||
.append('div')
|
||||
.attr('class', 'issue-reference')
|
||||
.html(t.html(`issues.incompatible_source.reference.${id}`));
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
validation.type = type;
|
||||
|
||||
Reference in New Issue
Block a user