Merge branch 'master' into validation

# Conflicts:
#	data/core.yaml
#	dist/locales/en.json
#	modules/ui/commit_warnings.js
#	modules/ui/entity_editor.js
#	modules/util/index.js
#	modules/util/util.js
#	modules/validations/index.js
#	modules/validations/many_deletions.js
#	modules/validations/missing_tag.js
This commit is contained in:
Quincy Morgan
2019-01-14 10:13:56 -05:00
119 changed files with 4618 additions and 635 deletions
+2 -2
View File
@@ -14,8 +14,8 @@ export function validationDeprecatedTag() {
var validation = function(changes) {
var issues = [];
for (var i = 0; i < changes.created.length; i++) {
var change = changes.created[i],
deprecatedTags = change.deprecatedTags();
var change = changes.created[i];
var deprecatedTags = change.deprecatedTags();
if (!_isEmpty(deprecatedTags)) {
var tags = utilTagText({ tags: deprecatedTags });
+51
View File
@@ -0,0 +1,51 @@
import { t } from '../util/locale';
import { discardNames } from '../../node_modules/name-suggestion-index/config/filters.json';
export function validationGenericName() {
function isGenericName(entity) {
var name = entity.tags.name;
if (!name) return false;
var i, re;
// test if the name is just the tag value (e.g. "park")
var keys = ['amenity', 'leisure', 'shop', 'man_made', 'tourism'];
for (i = 0; i < keys.length; i++) {
var val = entity.tags[keys[i]];
if (val && val.replace(/\_/g, ' ').toLowerCase() === name.toLowerCase()) {
return name;
}
}
// test if the name is a generic name (e.g. "pizzaria")
for (i = 0; i < discardNames.length; i++) {
re = new RegExp(discardNames[i], 'i');
if (re.test(name)) {
return name;
}
}
return false;
}
return function validation(changes) {
var warnings = [];
for (var i = 0; i < changes.created.length; i++) {
var change = changes.created[i];
var generic = isGenericName(change);
if (generic) {
warnings.push({
id: 'generic_name',
message: t('validations.generic_name'),
tooltip: t('validations.generic_name_tooltip', { name: generic }),
entity: change
});
}
}
return warnings;
};
}
+1
View File
@@ -3,6 +3,7 @@ export { validationDisconnectedHighway } from './disconnected_highway';
export { validationHighwayCrossingOtherWays } from './crossing_ways';
export { validationHighwayAlmostJunction } from './highway_almost_junction';
export { ValidationIssueType, ValidationIssueSeverity } from './validation_issue';
export { validationGenericName } from './generic_name.js';
export { validationManyDeletions } from './many_deletions';
export { validationMapCSSChecks } from './mapcss_checks';
export { validationMissingTag } from './missing_tag';
+5 -5
View File
@@ -10,13 +10,13 @@ export function validationManyDeletions() {
var validation = function(changes, graph) {
var issues = [];
var nodes=0, ways=0, areas=0, relations=0;
var nodes = 0, ways = 0, areas = 0, relations = 0;
changes.deleted.forEach(function(c) {
if (c.type === 'node') {nodes++;}
else if (c.type === 'way' && c.geometry(graph) === 'line') {ways++;}
else if (c.type === 'way' && c.geometry(graph) === 'area') {areas++;}
else if (c.type === 'relation') {relations++;}
if (c.type === 'node') { nodes++; }
else if (c.type === 'way' && c.geometry(graph) === 'line') { ways++; }
else if (c.type === 'way' && c.geometry(graph) === 'area') { areas++; }
else if (c.type === 'relation') { relations++; }
});
if (changes.deleted.length > threshold) {
issues.push(new validationIssue({
+2
View File
@@ -21,5 +21,7 @@ export function validationMapCSSChecks() {
return issues;
};
return validation;
}
+4 -4
View File
@@ -20,12 +20,12 @@ export function validationMissingTag(context) {
}
var validation = function(changes, graph) {
var types = ['point', 'line', 'area', 'relation'],
issues = [];
var types = ['point', 'line', 'area', 'relation'];
var issues = [];
for (var i = 0; i < changes.created.length; i++) {
var change = changes.created[i],
geometry = change.geometry(graph);
var change = changes.created[i];
var geometry = change.geometry(graph);
if (types.indexOf(geometry) !== -1 && !hasTags(change, graph)) {
var entityLabel = utilDisplayLabel(change, context);
+3 -3
View File
@@ -32,9 +32,9 @@ export function validationTagSuggestsArea() {
var validation = function(changes, graph) {
var issues = [];
for (var i = 0; i < changes.created.length; i++) {
var change = changes.created[i],
geometry = change.geometry(graph),
suggestion = (geometry === 'line' ? tagSuggestsArea(change.tags) : undefined);
var change = changes.created[i];
var geometry = change.geometry(graph);
var suggestion = (geometry === 'line' ? tagSuggestsArea(change.tags) : undefined);
if (suggestion) {
issues.push(new validationIssue({