From 680fdb6b54f69c75052d539f366920402397f5ad Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Mon, 23 Dec 2019 18:32:26 +0000 Subject: [PATCH] Allow Osmose errors to use category for UI strings Some error types don't require unique strings and can share common strings among the category. This makes that possible as well as adding support for some other types of error for demonstrative purposes. --- css/65_data.css | 14 +++++++--- data/core.yaml | 35 ++++++++++++++++++++++++- data/qa_errors.json | 43 ++++++++++++++++++++++++++++-- dist/locales/en.json | 49 +++++++++++++++++++++++++++++++++-- modules/services/osmose.js | 10 +++---- modules/svg/osmose.js | 2 +- modules/ui/osmose_details.js | 29 +++++++++------------ modules/ui/osmose_header.js | 19 +++++++++----- scripts/build_data.js | 3 ++- svg/fontawesome/far-clone.svg | 1 + 10 files changed, 165 insertions(+), 40 deletions(-) create mode 100644 svg/fontawesome/far-clone.svg diff --git a/css/65_data.css b/css/65_data.css index 39c1c1603..9dfc509c0 100644 --- a/css/65_data.css +++ b/css/65_data.css @@ -155,12 +155,18 @@ /* Osmose Errors ------------------------------------------------------- */ -.osmose { - color: #FFFFFF; + +.osmose.category-0 { + color: #BDBDBD; } -.osmose.category-structure { - color: #F9C700; +.osmose.category-1040, +.osmose.category-1050, +.osmose.category-1070, +.osmose.category-1080, +.osmose.category-1150, +.osmose.category-1280 { + color: #DCB000; } /* Custom Map Data (geojson, gpx, kml, vector tile) */ diff --git a/data/core.yaml b/data/core.yaml index b5b4c0af9..24507a75a 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -830,9 +830,42 @@ en: osmose: title: Osmose error_types: + 0: + title: 'Building Intersection' + description: '{0} and {1} intersect.' + 0-3: + title: 'Suspiciously Small Building' + description: '{0} is a suspisciously small building.' + 0-4: + title: 'Gap Between Buildings' + description: 'A gap exists between {0} and {1} which looks suspiciously small.' + 1040-1: + title: 'Invalid Polygon' + description: '{0} intersects itself.' + 1050-1: + title: 'Reversed Roundabout' + description: '{0} looks like a roundabout mapped in the wrong direction for this location.' + 1050-1050: + title: 'Reversed Mini-Roundabout' + description: '{0} looks like a mini-roundabout with the incorrect "direction" tag for this location.' + 1070: + title: 'Highway intersecting water' + description: '{1} intersects with {0}, but there is no junction node, bridge, or tunnel.' 1070-1: title: 'Highway intersecting building' - description: '{1} intersects with {0}.' + 1070-8: + title: 'Highway intersecting highway' + 1070-10: + title: 'Waterway intersecting waterway' + 1080-1: + title: 'Orphan Nodes Cluster' + description: 'A culster of nodes with no tags is present.' + 1150: + title: 'Overlapping Similar Areas' + description: '{0} and {1} overlap.' + 1280-1: + title: 'Incorrect Speed Camera' + description: 'Speed camera should be on the highway or part of an "enforcement" relation.' improveOSM: title: ImproveOSM Detection geometry_types: diff --git a/data/qa_errors.json b/data/qa_errors.json index aad4b3328..50e930cf6 100644 --- a/data/qa_errors.json +++ b/data/qa_errors.json @@ -34,10 +34,49 @@ } }, "osmose": { + "items": ["0", "1040", "1050", "1070", "1080", "1150", "1280"], "errorTypes": { + "0-1": { + "icon": "maki-home" + }, + "0-2": { + "icon": "maki-home" + }, + "1040-1": { + "icon": "maki-square-stroked" + }, + "1050-1": { + "icon": "maki-circle-stroked" + }, + "1050-1050": { + "icon": "maki-circle-stroked" + }, + "1150-1": { + "icon": "far-clone" + }, + "1150-2": { + "icon": "far-clone" + }, + "1150-3": { + "icon": "far-clone" + }, "1070-1": { - "icon": "maki-home", - "category": "structure" + "icon": "maki-home" + }, + "1070-4": { + "icon": "maki-dam" + }, + "1070-5": { + "icon": "maki-dam" + }, + "1070-8": { + "icon": "maki-cross" + }, + "1070-10": { + "icon": "maki-cross" + }, + "1280-1": { + "icon": "maki-attraction" } } } diff --git a/dist/locales/en.json b/dist/locales/en.json index a38ff70e6..df3cdc818 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -1034,9 +1034,54 @@ "osmose": { "title": "Osmose", "error_types": { + "0": { + "title": "Building Intersection", + "description": "{0} and {1} intersect." + }, + "1070": { + "title": "Highway intersecting water", + "description": "{1} intersects with {0}, but there is no junction node, bridge, or tunnel." + }, + "1150": { + "title": "Overlapping Similar Areas", + "description": "{0} and {1} overlap." + }, + "0-3": { + "title": "Suspiciously Small Building", + "description": "{0} is a suspisciously small building." + }, + "0-4": { + "title": "Gap Between Buildings", + "description": "A gap exists between {0} and {1} which looks suspiciously small." + }, + "1040-1": { + "title": "Invalid Polygon", + "description": "{0} intersects itself." + }, + "1050-1": { + "title": "Reversed Roundabout", + "description": "{0} looks like a roundabout mapped in the wrong direction for this location." + }, + "1050-1050": { + "title": "Reversed Mini-Roundabout", + "description": "{0} looks like a mini-roundabout with the incorrect \"direction\" tag for this location." + }, "1070-1": { - "title": "Highway intersecting building", - "description": "{1} intersects with {0}." + "title": "Highway intersecting building" + }, + "1070-8": { + "title": "Highway intersecting highway" + }, + "1070-10": { + "title": "Waterway intersecting waterway" + }, + "1080-1": { + "title": "Orphan Nodes Cluster", + "description": "A culster of nodes with no tags is present." + }, + "1280-1": { + "title": "Incorrect Speed Camera", + "description": "Speed camera should be on the highway or part of an \"enforcement\" relation." } } }, diff --git a/modules/services/osmose.js b/modules/services/osmose.js index af7aedd54..28e2bfc32 100644 --- a/modules/services/osmose.js +++ b/modules/services/osmose.js @@ -94,7 +94,8 @@ export default { var options = { full: 'true', // Returns element IDs level: '1,2,3', - zoom: '19' + zoom: '19', + item: services.osmose.items.join() // only interested in certain errors }; // determine the needed tiles to cover the view @@ -110,7 +111,7 @@ export default { if (_erCache.loadedTile[tile.id] || _erCache.inflightTile[tile.id]) return; var rect = tile.extent.rectangle(); // E, N, W, S - var params = Object.assign({}, options, { bbox: [rect[0], rect[1], rect[2], rect[3]].join() }); + var params = Object.assign({}, options, { bbox: rect.join() }); var url = _osmoseUrlRoot + 'issues?' + utilQsString(params); @@ -133,7 +134,7 @@ export default { var type = [issue.item, issue.classs].join('-'); // Filter out unsupported error types (some are too specific or advanced) - if (services.osmose.errorTypes[type]) { + if (type in services.osmose.errorTypes) { loc = preventCoincident(loc, true); var d = new qaError({ @@ -144,8 +145,7 @@ export default { // Extra details needed for this service identifier: issue.id, // this is used to post changes to the error elems: elems, - object_id: elems.length ? elems[0].substring(1) : '', - object_type: elems.length ? elems[0].substring(0,1) : '' + item: issue.item // category of the issue for styling }); // Variables used in the description diff --git a/modules/svg/osmose.js b/modules/svg/osmose.js index 1126087d6..bc25d9612 100644 --- a/modules/svg/osmose.js +++ b/modules/svg/osmose.js @@ -120,7 +120,7 @@ export function svgOsmose(projection, context, dispatch) { d.service, 'error_id-' + d.id, 'error_type-' + d.error_type, - 'category-' + d.category + 'category-' + d.item ].join(' '); }); diff --git a/modules/ui/osmose_details.js b/modules/ui/osmose_details.js index 9490eb25c..22353e7f4 100644 --- a/modules/ui/osmose_details.js +++ b/modules/ui/osmose_details.js @@ -18,19 +18,18 @@ export function uiOsmoseDetails(context) { if (!d) return unknown; - if (d.desc) return d.desc; + // Some errors fall back to their category for strings + var i, et; + var keys = [d.error_type, d.item]; + for (i = 0; i < 2; i++) { + et = dataEn.QA.osmose.error_types[keys[i]]; - var errorType = d.error_type; - var et = dataEn.QA.osmose.error_types[errorType]; - - var detail; - if (et && et.description) { - detail = t('QA.osmose.error_types.' + errorType + '.description', d.replacements); - } else { - detail = unknown; + if (et && et.description) { + return t('QA.osmose.error_types.' + keys[i] + '.description', d.replacements); + } } - return detail; + return unknown; } @@ -64,14 +63,10 @@ export function uiOsmoseDetails(context) { .html(errorDetail); // If there are entity links in the error message.. - var relatedEntities = _error.elems; descriptionEnter.selectAll('.error_entity_link, .error_object_link') .each(function() { var link = d3_select(this); - var isObjectLink = link.classed('error_object_link'); - var entityID = isObjectLink ? - (_error.object_type + _error.object_id) - : this.textContent; + var entityID = this.textContent; var entity = context.hasEntity(entityID); // Add click handler @@ -107,7 +102,7 @@ export function uiOsmoseDetails(context) { if (entity) { var name = utilDisplayName(entity); // try to use common name - if (!name && !isObjectLink) { + if (!name) { var preset = context.presets().match(entity, context.graph()); name = preset && !preset.isFallback() && preset.name(); // fallback to preset name } @@ -119,7 +114,7 @@ export function uiOsmoseDetails(context) { }); // Don't hide entities related to this error - #5880 - context.features().forceVisible(relatedEntities); + context.features().forceVisible(_error.elems); context.map().pan([0,0]); // trigger a redraw } diff --git a/modules/ui/osmose_header.js b/modules/ui/osmose_header.js index 21995cbcb..b66d31980 100644 --- a/modules/ui/osmose_header.js +++ b/modules/ui/osmose_header.js @@ -10,14 +10,19 @@ export function uiOsmoseHeader() { var unknown = t('inspector.unknown'); if (!d) return unknown; - var errorType = d.error_type; - var et = dataEn.QA.osmose.error_types[errorType]; - if (et && et.title) { - return t('QA.osmose.error_types.' + errorType + '.title'); - } else { - return unknown; + // Some errors fall back to their category for strings + var i, et; + var keys = [d.error_type, d.item]; + for (i = 0; i < 2; i++) { + et = dataEn.QA.osmose.error_types[keys[i]]; + + if (et && et.title) { + return t('QA.osmose.error_types.' + keys[i] + '.title'); + } } + + return unknown; } @@ -52,7 +57,7 @@ export function uiOsmoseHeader() { d.service, 'error_id-' + d.id, 'error_type-' + d.error_type, - 'category-' + d.category + 'category-' + d.item ].join(' '); }); diff --git a/scripts/build_data.js b/scripts/build_data.js index 1dfbee72f..a5c7c2ef7 100644 --- a/scripts/build_data.js +++ b/scripts/build_data.js @@ -69,7 +69,8 @@ function buildData() { 'fas-lock': {}, 'fas-long-arrow-alt-right': {}, 'fas-th-list': {}, - 'fas-user-cog': {} + 'fas-user-cog': {}, + 'far-clone': {} }; // The Noun Project icons used diff --git a/svg/fontawesome/far-clone.svg b/svg/fontawesome/far-clone.svg new file mode 100644 index 000000000..c3e65e21e --- /dev/null +++ b/svg/fontawesome/far-clone.svg @@ -0,0 +1 @@ + \ No newline at end of file