mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-22 03:36:37 +02:00
Don't count vertices toward many deletions warnings
Lower threshold for triggering many deletions warnings
This commit is contained in:
+4
-1
@@ -1222,7 +1222,10 @@ en:
|
||||
message: '{feature} has the generic name "{name}".'
|
||||
tip: Names should be the official, on-the-ground titles of features.
|
||||
many_deletions:
|
||||
message: "Deleting {n} features: {p} nodes, {l} lines, {a} areas, and {r} relations."
|
||||
points-lines-areas:
|
||||
message: "Deleting {n} features: {p} points, {l} lines, and {a} areas."
|
||||
points-lines-areas-relations:
|
||||
message: "Deleting {n} features: {p} points, {l} lines, {a} areas, and {r} relations."
|
||||
tip: Only redundant or nonexistent features should be deleted.
|
||||
missing_tag:
|
||||
message: "{feature} has no descriptive tags."
|
||||
|
||||
Vendored
+6
-1
@@ -1494,7 +1494,12 @@
|
||||
"tip": "Names should be the official, on-the-ground titles of features."
|
||||
},
|
||||
"many_deletions": {
|
||||
"message": "Deleting {n} features: {p} nodes, {l} lines, {a} areas, and {r} relations.",
|
||||
"points-lines-areas": {
|
||||
"message": "Deleting {n} features: {p} points, {l} lines, and {a} areas."
|
||||
},
|
||||
"points-lines-areas-relations": {
|
||||
"message": "Deleting {n} features: {p} points, {l} lines, {a} areas, and {r} relations."
|
||||
},
|
||||
"tip": "Only redundant or nonexistent features should be deleted."
|
||||
},
|
||||
"missing_tag": {
|
||||
|
||||
@@ -5,30 +5,50 @@ import {
|
||||
|
||||
export function validationManyDeletions() {
|
||||
|
||||
var threshold = 100;
|
||||
var totalOtherGeomThreshold = 50;
|
||||
|
||||
// relations are less common so use a lower threshold
|
||||
var relationThreshold = 10;
|
||||
|
||||
var type = 'many_deletions';
|
||||
|
||||
var validation = function(changes, context) {
|
||||
var issues = [];
|
||||
var nodes = 0, ways = 0, areas = 0, relations = 0;
|
||||
var graph = context.graph();
|
||||
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++; }
|
||||
var points = 0, lines = 0, areas = 0, relations = 0;
|
||||
var base = context.history().base();
|
||||
var geometry;
|
||||
changes.deleted.forEach(function(entity) {
|
||||
if (entity.type === 'node' && entity.geometry(base) === 'point') {
|
||||
points++;
|
||||
} else if (entity.type === 'way') {
|
||||
geometry = entity.geometry(base);
|
||||
if (geometry === 'line') {
|
||||
lines++;
|
||||
} else if (geometry === 'area') {
|
||||
areas++;
|
||||
}
|
||||
} else if (entity.type === 'relation') {
|
||||
relations++;
|
||||
}
|
||||
});
|
||||
if (changes.deleted.length > threshold) {
|
||||
if (points + lines + areas >= totalOtherGeomThreshold ||
|
||||
relations >= relationThreshold) {
|
||||
|
||||
var totalFeatures = points + lines + areas + relations;
|
||||
|
||||
var messageType = 'points-lines-areas';
|
||||
if (relations > 0) {
|
||||
messageType += '-relations';
|
||||
}
|
||||
issues.push(new validationIssue({
|
||||
type: type,
|
||||
severity: 'warning',
|
||||
message: t(
|
||||
'issues.many_deletions.message',
|
||||
{ n: changes.deleted.length, p: nodes, l: ways, a:areas, r: relations }
|
||||
'issues.many_deletions.'+messageType+'.message',
|
||||
{ n: totalFeatures, p: points, l: lines, a:areas, r: relations }
|
||||
),
|
||||
tooltip: t('issues.many_deletions.tip'),
|
||||
hash: [nodes, ways, areas, relations].join()
|
||||
hash: [points, lines, areas, relations].join()
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user