mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-21 19:26:41 +02:00
Add quick fix for connecting the endpoints of a line where tags suggest area if it won't create self-intersection
This commit is contained in:
+4
-1
@@ -1234,7 +1234,7 @@ en:
|
||||
message: "{multipolygon} has misplaced tags."
|
||||
tip: Multipolygons should be tagged on their relation, not their outer way.
|
||||
tag_suggests_area:
|
||||
message: 'Feature is a line, but the tag "{tag}" suggests it should be an area.'
|
||||
message: '{feature} should be an area based on the tags: {tags}'
|
||||
tip: Areas must have connected endpoints.
|
||||
fix:
|
||||
add_connection_vertex:
|
||||
@@ -1247,6 +1247,9 @@ en:
|
||||
title: Continue this feature
|
||||
delete_feature:
|
||||
title: Delete this feature
|
||||
connect_endpoints:
|
||||
title: Connect the ends
|
||||
undo_redo: Connected the endpoints of a way.
|
||||
move_tags:
|
||||
title: Move the tags
|
||||
undo_redo: Moved tags.
|
||||
|
||||
Vendored
+5
-1
@@ -1511,7 +1511,7 @@
|
||||
"tip": "Multipolygons should be tagged on their relation, not their outer way."
|
||||
},
|
||||
"tag_suggests_area": {
|
||||
"message": "Feature is a line, but the tag \"{tag}\" suggests it should be an area.",
|
||||
"message": "{feature} should be an area based on the tags: {tags}",
|
||||
"tip": "Areas must have connected endpoints."
|
||||
},
|
||||
"fix": {
|
||||
@@ -1529,6 +1529,10 @@
|
||||
"delete_feature": {
|
||||
"title": "Delete this feature"
|
||||
},
|
||||
"connect_endpoints": {
|
||||
"title": "Connect the ends",
|
||||
"undo_redo": "Connected the endpoints of a way."
|
||||
},
|
||||
"move_tags": {
|
||||
"title": "Move the tags",
|
||||
"undo_redo": "Moved tags."
|
||||
|
||||
@@ -2,6 +2,7 @@ import _isEmpty from 'lodash-es/isEmpty';
|
||||
import _clone from 'lodash-es/clone';
|
||||
import { t } from '../util/locale';
|
||||
import {
|
||||
utilDisplayLabel,
|
||||
utilTagText
|
||||
} from '../util';
|
||||
import {
|
||||
@@ -9,8 +10,10 @@ import {
|
||||
validationIssueFix
|
||||
} from '../core/validator';
|
||||
import {
|
||||
actionAddVertex,
|
||||
actionChangeTags
|
||||
} from '../actions';
|
||||
import { geoHasSelfIntersections } from '../geo';
|
||||
|
||||
|
||||
// https://github.com/openstreetmap/josm/blob/mirror/src/org/
|
||||
@@ -47,28 +50,45 @@ export function validationTagSuggestsArea() {
|
||||
|
||||
if (suggestingTags) {
|
||||
var tagText = utilTagText({ tags: suggestingTags });
|
||||
var fixes = [];
|
||||
var nodes = _clone(graph.childNodes(entity));
|
||||
nodes.push(nodes[0]);
|
||||
if (!geoHasSelfIntersections(nodes, nodes[0].id)) {
|
||||
fixes.push(new validationIssueFix({
|
||||
title: t('issues.fix.connect_endpoints.title'),
|
||||
onClick: function() {
|
||||
var way = this.issue.entities[0];
|
||||
var nodeId = way.nodes[0];
|
||||
var index = way.nodes.length;
|
||||
context.perform(
|
||||
actionAddVertex(way.id, nodeId, index),
|
||||
t('issues.fix.connect_endpoints.undo_redo')
|
||||
);
|
||||
}
|
||||
}));
|
||||
}
|
||||
fixes.push(new validationIssueFix({
|
||||
title: t('issues.fix.remove_tags.title'),
|
||||
onClick: function() {
|
||||
var entity = this.issue.entities[0];
|
||||
var tags = _clone(entity.tags);
|
||||
for (var key in suggestingTags) {
|
||||
delete tags[key];
|
||||
}
|
||||
context.perform(
|
||||
actionChangeTags(entity.id, tags),
|
||||
t('issues.fix.remove_tags.undo_redo')
|
||||
);
|
||||
}
|
||||
}));
|
||||
var featureLabel = utilDisplayLabel(entity, context);
|
||||
issues.push(new validationIssue({
|
||||
type: type,
|
||||
severity: 'warning',
|
||||
message: t('issues.tag_suggests_area.message', { tag: tagText }),
|
||||
message: t('issues.tag_suggests_area.message', { feature: featureLabel, tags: tagText }),
|
||||
tooltip: t('issues.tag_suggests_area.tip'),
|
||||
entities: [entity],
|
||||
fixes: [
|
||||
new validationIssueFix({
|
||||
title: t('issues.fix.remove_tags.title'),
|
||||
onClick: function() {
|
||||
var entity = this.issue.entities[0];
|
||||
var tags = _clone(entity.tags);
|
||||
for (var key in suggestingTags) {
|
||||
delete tags[key];
|
||||
}
|
||||
context.perform(
|
||||
actionChangeTags(entity.id, tags),
|
||||
t('issues.fix.remove_tags.undo_redo')
|
||||
);
|
||||
}
|
||||
})
|
||||
]
|
||||
fixes: fixes
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user