From 0e7a63f5c51bfad4a1a0e853baaf1d2577b1a1bb Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Thu, 9 May 2019 12:04:18 -0400 Subject: [PATCH] Add quick fix to unsquare way validation to tag a way as having unsquare corners (close #6332) --- data/core.yaml | 3 +++ dist/locales/en.json | 4 ++++ modules/actions/orthogonalize.js | 8 ++++++++ modules/validations/unsquare_way.js | 20 +++++++++++++++++++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/data/core.yaml b/data/core.yaml index 3e026e817..2341e12c4 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -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: diff --git a/dist/locales/en.json b/dist/locales/en.json index a759f67b0..978fcc3df 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -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" }, diff --git a/modules/actions/orthogonalize.js b/modules/actions/orthogonalize.js index 5abccafee..b03ce5713 100644 --- a/modules/actions/orthogonalize.js +++ b/modules/actions/orthogonalize.js @@ -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(); diff --git a/modules/validations/unsquare_way.js b/modules/validations/unsquare_way.js index 368d4ca3b..139af01cb 100644 --- a/modules/validations/unsquare_way.js +++ b/modules/validations/unsquare_way.js @@ -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') + ); + } }) ] })];