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:
Quincy Morgan
2019-02-05 12:16:46 -05:00
parent a80aaf65db
commit 7dd337383a
3 changed files with 46 additions and 19 deletions
+4 -1
View File
@@ -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.
+5 -1
View File
@@ -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."
+37 -17
View File
@@ -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
}));
}