Add quick fix to unsquare way validation to tag a way as having unsquare corners (close #6332)

This commit is contained in:
Quincy Morgan
2019-05-09 12:04:18 -04:00
parent 5e21cec469
commit 0e7a63f5c5
4 changed files with 34 additions and 1 deletions
+3
View File
@@ -1507,6 +1507,9 @@ en:
tag_as_disconnected:
title: Tag as disconnected
annotation: Tagged very close features as disconnected.
tag_as_unsquare:
title: Tag as physically unsquare
annotation: Tagged a way as having unsquare corners.
tag_this_as_higher:
title: Tag this as higher
tag_this_as_lower:
+4
View File
@@ -1881,6 +1881,10 @@
"title": "Tag as disconnected",
"annotation": "Tagged very close features as disconnected."
},
"tag_as_unsquare": {
"title": "Tag as physically unsquare",
"annotation": "Tagged a way as having unsquare corners."
},
"tag_this_as_higher": {
"title": "Tag this as higher"
},
+8
View File
@@ -21,6 +21,14 @@ export function actionOrthogonalize(wayID, projection, vertexID, ep, degThresh)
var way = graph.entity(wayID);
way = way.removeNode(''); // sanity check - remove any consecutive duplicates
if (way.tags.nosquare) {
var tags = Object.assign({}, way.tags);
// since we're squaring, remove indication that this is physically unsquare
delete tags.nosquare;
way = way.update({tags: tags});
}
graph = graph.replace(way);
var isClosed = way.isClosed();
+19 -1
View File
@@ -1,4 +1,5 @@
import { t } from '../util/locale';
import { actionChangeTags } from '../actions/change_tags';
import { actionOrthogonalize } from '../actions/orthogonalize';
import { geoOrthoCanOrthogonalize } from '../geo';
import { utilDisplayLabel } from '../util';
@@ -24,6 +25,9 @@ export function validationUnsquareWay() {
var graph = context.graph();
if (!isBuilding(entity, graph)) return [];
// don't flag ways marked as physically unsquare
if (entity.tags.nosquare === 'yes') return [];
var isClosed = entity.isClosed();
if (!isClosed) return []; // this building has bigger problems
@@ -72,12 +76,26 @@ export function validationUnsquareWay() {
title: t('issues.fix.square_feature.title'),
autoArgs: autoArgs,
onClick: function() {
var entityId = this.issue.entityIds[0];
// note: use default params for actionOrthogonalize, not relaxed epsilon
context.perform(
actionOrthogonalize(entity.id, context.projection),
actionOrthogonalize(entityId, context.projection),
t('operations.orthogonalize.annotation.area')
);
}
}),
new validationIssueFix({
title: t('issues.fix.tag_as_unsquare.title'),
onClick: function() {
var entityId = this.issue.entityIds[0];
var entity = context.entity(entityId);
var tags = Object.assign({}, entity.tags); // shallow copy
tags.nosquare = 'yes';
context.perform(
actionChangeTags(entityId, tags),
t('issues.fix.tag_as_unsquare.annotation')
);
}
})
]
})];