diff --git a/data/core.yaml b/data/core.yaml index 48056c2df..984b2f74e 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -1398,9 +1398,7 @@ en: tip: "Find features that are tagged as lines and should possibly be tagged as areas" reference: "Areas must have connected endpoints." unknown_road: - title: Unknown Roads message: "{feature} has no classification" - tip: "Find roads that are missing a proper road classification" reference: "Roads without a specific type may not appear in maps or routing." unsquare_way: title: Unsquare Buildings diff --git a/dist/locales/en.json b/dist/locales/en.json index d3c809a91..cbab926e2 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -1730,9 +1730,7 @@ "reference": "Areas must have connected endpoints." }, "unknown_road": { - "title": "Unknown Roads", "message": "{feature} has no classification", - "tip": "Find roads that are missing a proper road classification", "reference": "Roads without a specific type may not appear in maps or routing." }, "unsquare_way": { diff --git a/modules/validations/index.js b/modules/validations/index.js index 6a481507e..60d9acd36 100644 --- a/modules/validations/index.js +++ b/modules/validations/index.js @@ -10,5 +10,4 @@ export { validationOldMultipolygon } from './old_multipolygon'; export { validationOutdatedTags } from './outdated_tags'; export { validationPrivateData } from './private_data'; export { validationTagSuggestsArea } from './tag_suggests_area'; -export { validationUnknownRoad } from './unknown_road'; export { validationUnsquareWay } from './unsquare_way'; diff --git a/modules/validations/missing_tag.js b/modules/validations/missing_tag.js index 1230a2fee..8a953aee5 100644 --- a/modules/validations/missing_tag.js +++ b/modules/validations/missing_tag.js @@ -1,4 +1,4 @@ -import { operationDelete } from '../operations/index'; +import { operationDelete } from '../operations/delete'; import { osmIsInterestingTag } from '../osm/tags'; import { t } from '../util/locale'; import { utilDisplayLabel } from '../util'; @@ -26,6 +26,15 @@ export function validationMissingTag() { } + function isUnknownRoad(entity) { + return entity.type === 'way' && entity.tags.highway === 'road'; + } + + function isUntypedRelation(entity) { + return entity.type === 'relation' && !entity.tags.type; + } + + var validation = function checkMissingTag(entity, context) { var graph = context.graph(); @@ -41,21 +50,23 @@ export function validationMissingTag() { missingTagType = 'any'; } else if (!hasDescriptiveTags(entity)) { missingTagType = 'descriptive'; - } else if (entity.type === 'relation' && !entity.tags.type) { + } else if (isUntypedRelation(entity)) { missingTagType = 'specific'; messageObj.tag = 'type'; + } else if (isUnknownRoad(entity)) { + missingTagType = 'unknown_road'; } - if (!missingTagType) { - return []; - } + if (!missingTagType) return []; messageObj.feature = utilDisplayLabel(entity, context); + var selectFixType = missingTagType === 'unknown_road' ? 'select_road_type' : 'select_preset'; + var fixes = [ new validationIssueFix({ icon: 'iD-icon-search', - title: t('issues.fix.select_preset.title'), + title: t('issues.fix.' + selectFixType + '.title'), onClick: function() { context.ui().sidebar.showPresetList(); } @@ -86,10 +97,15 @@ export function validationMissingTag() { ); } + var messageID = missingTagType === 'unknown_road' ? 'unknown_road' : 'missing_tag.' + missingTagType; + var referenceID = missingTagType === 'unknown_road' ? 'unknown_road' : 'missing_tag'; + + var severity = (canDelete && missingTagType !== 'unknown_road') ? 'error' : 'warning'; + return [new validationIssue({ type: type, - severity: canDelete ? 'error' : 'warning', - message: t('issues.missing_tag.' + missingTagType + '.message', messageObj), + severity: severity, + message: t('issues.' + messageID + '.message', messageObj), reference: showReference, entities: [entity], fixes: fixes @@ -102,7 +118,7 @@ export function validationMissingTag() { .enter() .append('div') .attr('class', 'issue-reference') - .text(t('issues.missing_tag.reference')); + .text(t('issues.' + referenceID + '.reference')); } }; diff --git a/modules/validations/unknown_road.js b/modules/validations/unknown_road.js deleted file mode 100644 index 7bd8d0fe5..000000000 --- a/modules/validations/unknown_road.js +++ /dev/null @@ -1,64 +0,0 @@ -import { t } from '../util/locale'; -import { operationDelete } from '../operations/index'; -import { utilDisplayLabel } from '../util'; -import { validationIssue, validationIssueFix } from '../core/validation'; - - -export function validationUnknownRoad() { - var type = 'unknown_road'; - - var validation = function checkUnknownRoad(entity, context) { - if (entity.type !== 'way' || entity.tags.highway !== 'road') return []; - - var fixes = [ - new validationIssueFix({ - icon: 'iD-icon-search', - title: t('issues.fix.select_road_type.title'), - onClick: function() { - context.ui().sidebar.showPresetList(); - } - }) - ]; - - if (!operationDelete([entity.id], context).disabled()) { - fixes.push( - new validationIssueFix({ - icon: 'iD-operation-delete', - title: t('issues.fix.delete_feature.title'), - onClick: function() { - var id = this.issue.entities[0].id; - var operation = operationDelete([id], context); - if (!operation.disabled()) { - operation(); - } - } - }) - ); - } - - return [new validationIssue({ - type: type, - severity: 'warning', - message: t('issues.unknown_road.message', { - feature: utilDisplayLabel(entity, context), - }), - reference: showReference, - entities: [entity], - fixes: fixes - })]; - - - function showReference(selection) { - selection.selectAll('.issue-reference') - .data([0]) - .enter() - .append('div') - .attr('class', 'issue-reference') - .text(t('issues.unknown_road.reference')); - } - }; - - validation.type = type; - - return validation; -} diff --git a/test/index.html b/test/index.html index 827d7cea7..6587d173f 100644 --- a/test/index.html +++ b/test/index.html @@ -163,7 +163,6 @@ -