From 20ed8b50c98cf6ef01a6da07415227c69e87a9cf Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Sun, 3 Feb 2019 12:54:05 +0000 Subject: [PATCH 1/7] Add generic QA error I've converted the improveOSM errors to use this new generic QA error structure which should allow for more general code to be used in behaviour and UI. Sidebar preview is currently broken, but will be fixed shortly. --- css/65_data.css | 8 ++-- data/qa_errors.json | 39 ++++++++++++++++ modules/behavior/hover.js | 6 +-- modules/behavior/select.js | 10 ++--- modules/osm/index.js | 4 +- modules/osm/qa_error.js | 65 +++++++++++++++++++++++++++ modules/services/improveOSM.js | 76 +++++++++++++++----------------- modules/svg/improveOSM.js | 5 ++- modules/ui/improveOSM_details.js | 4 +- modules/ui/improveOSM_header.js | 13 ++++-- 10 files changed, 168 insertions(+), 62 deletions(-) create mode 100644 data/qa_errors.json create mode 100644 modules/osm/qa_error.js diff --git a/css/65_data.css b/css/65_data.css index 2686d940d..47d1c03a2 100644 --- a/css/65_data.css +++ b/css/65_data.css @@ -131,7 +131,7 @@ /* ImproveOSM Errors ------------------------------------------------------- */ -.iOSM.error_type-ow- { /* missing one way */ +.iOSM.error_type-ow { /* missing one way */ color: #1E90FF; } @@ -148,10 +148,11 @@ color: #FFA500; } -.iOSM.error_type-tr- { /* missing turn restriction */ +.iOSM.error_type-tr { /* missing turn restriction */ color: #EC1C24; } + /* Custom Map Data (geojson, gpx, kml, vector tile) */ .layer-mapdata { pointer-events: none; @@ -210,5 +211,4 @@ stroke: #000; stroke-width: 5px; stroke-miterlimit: 1; -} - +} \ No newline at end of file diff --git a/data/qa_errors.json b/data/qa_errors.json new file mode 100644 index 000000000..689b5da78 --- /dev/null +++ b/data/qa_errors.json @@ -0,0 +1,39 @@ +{ + "services": { + "improveOSM": { + "shortName": "iOSM", + "errorTypes": { + "ow": { + "icon": "", + "category": "routing" + }, + "mr-both": { + "icon": "maki-car", + "category": "geometry" + }, + "mr-parking": { + "icon": "maki-parking", + "category": "geometry" + }, + "mr-path": { + "icon": "maki-shoe", + "category": "geometry" + }, + "mr-road": { + "icon": "maki-car", + "category": "geometry" + }, + "tr": { + "icon": "temaki-junction", + "category": "routing" + } + } + }, + "keepRight": { + "shortName": "kr", + "errorTypes": { + + } + } + } +} \ No newline at end of file diff --git a/modules/behavior/hover.js b/modules/behavior/hover.js index 9645b83e2..04031afc7 100644 --- a/modules/behavior/hover.js +++ b/modules/behavior/hover.js @@ -5,7 +5,7 @@ import { select as d3_select } from 'd3-selection'; -import { osmEntity, osmNote, krError, iOsmError } from '../osm'; +import { osmEntity, osmNote, krError, qaError } from '../osm'; import { utilKeybinding, utilRebind } from '../util'; @@ -113,7 +113,7 @@ export function behaviorHover(context) { selector = '.data' + datum.__featurehash__; } else if ( - datum instanceof iOsmError || + datum instanceof qaError || datum instanceof krError ) { entity = datum; @@ -187,4 +187,4 @@ export function behaviorHover(context) { return utilRebind(behavior, dispatch, 'on'); -} +} \ No newline at end of file diff --git a/modules/behavior/select.js b/modules/behavior/select.js index 8043648d3..e87318b6c 100644 --- a/modules/behavior/select.js +++ b/modules/behavior/select.js @@ -19,8 +19,8 @@ import { import { osmEntity, osmNote, - iOsmError, - krError + krError, + qaError } from '../osm'; @@ -171,11 +171,11 @@ export function behaviorSelect(context) { context .selectedNoteID(datum.id) .enter(modeSelectNote(context, datum.id)); - } else if (datum instanceof iOsmError & !isMultiselect) { // clicked an improveOSM error + } else if (datum instanceof krError & !isMultiselect) { // clicked a krError error context .selectedErrorID(datum.id) .enter(modeSelectError(context, datum.id, datum.source)); - } else if (datum instanceof krError & !isMultiselect) { // clicked a krError error + } else if (datum instanceof qaError & !isMultiselect) { // clicked an external QA error context .selectedErrorID(datum.id) .enter(modeSelectError(context, datum.id, datum.source)); @@ -241,4 +241,4 @@ export function behaviorSelect(context) { return behavior; -} +} \ No newline at end of file diff --git a/modules/osm/index.js b/modules/osm/index.js index d97cb8feb..dd1397daa 100644 --- a/modules/osm/index.js +++ b/modules/osm/index.js @@ -1,11 +1,11 @@ export { osmChangeset } from './changeset'; export { osmEntity } from './entity'; export { krError } from './keepRight'; -export { iOsmError } from './improveOSM'; export { osmNode } from './node'; export { osmNote } from './note'; export { osmRelation } from './relation'; export { osmWay } from './way'; +export { qaError } from './qa_error'; export { osmIntersection, @@ -27,4 +27,4 @@ export { osmOneWayTags, osmPavedTags, osmIsInterestingTag -} from './tags'; +} from './tags'; \ No newline at end of file diff --git a/modules/osm/qa_error.js b/modules/osm/qa_error.js new file mode 100644 index 000000000..b00d6f5b6 --- /dev/null +++ b/modules/osm/qa_error.js @@ -0,0 +1,65 @@ +import _extend from 'lodash-es/extend'; +import { services } from '../../data/qa_errors.json'; + +export function qaError() { + if (!(this instanceof qaError)) { + return (new qaError()).initialize(arguments); + } else if (arguments.length) { + this.initialize(arguments); + } +} + +// Generic handling for services without nice IDs +qaError.id = function() { + return qaError.id.next--; +}; + +qaError.id.next = -1; + +_extend(qaError.prototype, { + type: 'qaError', + + // All errors need a position + loc: [0, 0], + + // These should be passed in, used to retrieve from qa_errors.json + service: '', + error_type: '', + + initialize: function(sources) { + for (var i = 0; i < sources.length; ++i) { + var source = sources[i]; + for (var prop in source) { + if (Object.prototype.hasOwnProperty.call(source, prop)) { + if (source[prop] === undefined) { + delete this[prop]; + } else { + this[prop] = source[prop]; + } + } + } + } + + if (this.service) { + this.source = services[this.service].shortName; + + if (this.error_type) { + var template = services[this.service].errorTypes[this.error_type]; + + this.icon = template.icon; + this.category = template.category; + } + } + + // All errors must have an ID for selection + if (!this.id) { + this.id = qaError.id() + ''; // as string + } + + return this; + }, + + update: function(attrs) { + return qaError(this, attrs); // {v: 1 + (this.v || 0)} + } +}); \ No newline at end of file diff --git a/modules/services/improveOSM.js b/modules/services/improveOSM.js index e170f930d..5623a09db 100644 --- a/modules/services/improveOSM.js +++ b/modules/services/improveOSM.js @@ -9,7 +9,7 @@ import { json as d3_json } from 'd3-request'; import { request as d3_request } from 'd3-request'; import { geoExtent, geoVecAdd } from '../geo'; -import { iOsmError } from '../osm'; +import { qaError } from '../osm'; import { services } from './index'; import { t } from '../util/locale'; import { utilRebind, utilTiler, utilQsString } from '../util'; @@ -210,12 +210,13 @@ export default { // One-ways can land on same segment in opposite direction loc = preventCoincident(loc, false); - var d = new iOsmError({ + var d = new qaError({ + // Info required for every error loc: loc, - comments: null, - error_subtype: '', + service: 'improveOSM', error_type: k, - icon: '', //TODO: Find suitable icon + // Extra details needed for this service + error_key: k, identifier: { // this is used to post changes to the error wayId: feature.wayId, fromNodeId: feature.fromNodeId, @@ -243,27 +244,20 @@ export default { // Tiles at high zoom == missing roads if (data.tiles) { data.tiles.forEach(function(feature) { - // Average of recorded points should land on the missing geometry - var loc = pointAverage(feature.points); + var geoType = feature.type.toLowerCase(); + // Average of recorded points should land on the missing geometry // Missing geometry could happen to land on another error + var loc = pointAverage(feature.points); loc = preventCoincident(loc, false); - - var geoType = feature.type.toLowerCase(); - var geoIcons = { - road: 'maki-car', - parking: 'maki-parking', - both: 'maki-car', - path: 'maki-shoe' - }; - - var d = new iOsmError({ + var d = new qaError({ + // Info required for every error loc: loc, - comments: null, - error_subtype: geoType, - error_type: k, - icon: geoIcons[geoType], + service: 'improveOSM', + error_type: k + '-' + geoType, + // Extra details needed for this service + error_key: k, identifier: { x: feature.x, y: feature.y }, status: feature.status }); @@ -281,10 +275,9 @@ export default { // Entities at high zoom == turn restrictions if (data.entities) { data.entities.forEach(function(feature) { - var loc = feature.point; - // Turn restrictions could be missing at same junction // We also want to bump the error up so node is accessible + var loc = feature.point; loc = preventCoincident([loc.lon, loc.lat], true); // Elements are presented in a strange way @@ -293,24 +286,25 @@ export default { var via_node = ids[3]; var to_way = ids[2].split(':')[1]; - // Travel direction along from_way clarifies the turn restriction - var p1 = feature.segments[0].points[0]; - var p2 = feature.segments[0].points[1]; - - var dir_of_travel = cardinalDirection(relativeBearing(p1, p2)); - - var d = new iOsmError({ + var d = new qaError({ + // Info required for every error loc: loc, - comments: null, - error_subtype: '', + service: 'improveOSM', error_type: k, - icon: 'temaki-junction', + // Extra details needed for this service + error_key: k, identifier: feature.id, object_id: via_node, object_type: 'node', status: feature.status }); + // Travel direction along from_way clarifies the turn restriction + var p1 = feature.segments[0].points[0]; + var p2 = feature.segments[0].points[1]; + + var dir_of_travel = cardinalDirection(relativeBearing(p1, p2)); + // Variables used in the description d.replacements = { num_passed: feature.numberOfPasses, @@ -351,18 +345,18 @@ export default { function sendPayload(err, user) { if (err) { return callback(err, d); } - var type = d.error_type; - var url = _impOsmUrls[type] + '/comment'; + var key = d.error_key; + var url = _impOsmUrls[key] + '/comment'; var payload = { username: user.display_name }; // Each error type has different data for identification - if (type === 'ow') { + if (key === 'ow') { payload.roadSegments = [ d.identifier ]; - } else if (type === 'mr') { + } else if (key === 'mr') { payload.tiles = [ d.identifier ]; - } else if (type === 'tr') { + } else if (key === 'tr') { payload.targetIds = [ d.identifier ]; } @@ -390,7 +384,7 @@ export default { // No pretty identifier, so we just use coordinates if (d.newStatus === 'SOLVED') { var closedID = d.loc[1].toFixed(5) + '/' + d.loc[0].toFixed(5); - _erCache.closed[d.error_type + ':' + closedID] = true; + _erCache.closed[key + ':' + closedID] = true; } return callback(err, d); @@ -417,7 +411,7 @@ export default { // replace a single error in the cache replaceError: function(error) { - if (!(error instanceof iOsmError) || !error.id) return; + if (!(error instanceof qaError) || !error.id) return; _erCache.data[error.id] = error; updateRtree(encodeErrorRtree(error), true); // true = replace @@ -426,7 +420,7 @@ export default { // remove a single error from the cache removeError: function(error) { - if (!(error instanceof iOsmError) || !error.id) return; + if (!(error instanceof qaError) || !error.id) return; delete _erCache.data[error.id]; updateRtree(encodeErrorRtree(error), false); // false = remove diff --git a/modules/svg/improveOSM.js b/modules/svg/improveOSM.js index b9881ff29..f10be4823 100644 --- a/modules/svg/improveOSM.js +++ b/modules/svg/improveOSM.js @@ -119,7 +119,8 @@ export function svgImproveOSM(projection, context, dispatch) { 'qa_error', d.source, 'error_id-' + d.id, - 'error_type-' + d.error_type + '-' + d.error_subtype + 'error_type-' + d.error_type, + 'category-' + d.category ].join(' '); }); @@ -259,4 +260,4 @@ export function svgImproveOSM(projection, context, dispatch) { return drawImproveOSM; -} +} \ No newline at end of file diff --git a/modules/ui/improveOSM_details.js b/modules/ui/improveOSM_details.js index be513ccb0..075ccd0cb 100644 --- a/modules/ui/improveOSM_details.js +++ b/modules/ui/improveOSM_details.js @@ -17,7 +17,7 @@ export function uiImproveOsmDetails(context) { var unknown = t('inspector.unknown'); if (!d) return unknown; - var errorType = d.error_type; + var errorType = d.error_key; var et = dataEn.QA.improveOSM.error_types[errorType]; var detail; @@ -124,4 +124,4 @@ export function uiImproveOsmDetails(context) { return improveOsmDetails; -} +} \ No newline at end of file diff --git a/modules/ui/improveOSM_header.js b/modules/ui/improveOSM_header.js index aa393b22b..381118a81 100644 --- a/modules/ui/improveOSM_header.js +++ b/modules/ui/improveOSM_header.js @@ -10,7 +10,7 @@ export function uiImproveOsmHeader() { var unknown = t('inspector.unknown'); if (!d) return unknown; - var errorType = d.error_type; + var errorType = d.error_key; var et = dataEn.QA.improveOSM.error_types[errorType]; if (et && et.title) { @@ -46,7 +46,14 @@ export function uiImproveOsmHeader() { .attr('height', '30px') .attr('viewbox', '0 0 20 30') .attr('class', function(d) { - return 'preset-icon-28 qa_error ' + d.source + ' error_id-' + d.id + ' error_type-' + d.error_type + '-' + d.error_subtype; + return [ + 'preset-icon-28', + 'qa_error', + d.source, + 'error_id-' + d.id, + 'error_type-' + d.error_type, + 'category-' + d.category + ].join(' '); }); svgEnter @@ -86,4 +93,4 @@ export function uiImproveOsmHeader() { return improveOsmHeader; -} +} \ No newline at end of file From 3ed13e9a4aa871562b8de543527ed8b2c581371d Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Sun, 3 Feb 2019 12:58:09 +0000 Subject: [PATCH 2/7] Convert KeepRight to use generic error type --- modules/behavior/hover.js | 7 ++----- modules/behavior/select.js | 5 ----- modules/osm/index.js | 1 - modules/services/keepRight.js | 17 ++++++++++------- modules/ui/view_on_keepRight.js | 6 +++--- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/modules/behavior/hover.js b/modules/behavior/hover.js index 04031afc7..c62d2bdd1 100644 --- a/modules/behavior/hover.js +++ b/modules/behavior/hover.js @@ -5,7 +5,7 @@ import { select as d3_select } from 'd3-selection'; -import { osmEntity, osmNote, krError, qaError } from '../osm'; +import { osmEntity, osmNote, qaError } from '../osm'; import { utilKeybinding, utilRebind } from '../util'; @@ -112,10 +112,7 @@ export function behaviorHover(context) { entity = datum; selector = '.data' + datum.__featurehash__; - } else if ( - datum instanceof qaError || - datum instanceof krError - ) { + } else if (datum instanceof qaError) { entity = datum; selector = '.' + datum.source + '.error_id-' + datum.id; diff --git a/modules/behavior/select.js b/modules/behavior/select.js index e87318b6c..541535255 100644 --- a/modules/behavior/select.js +++ b/modules/behavior/select.js @@ -19,7 +19,6 @@ import { import { osmEntity, osmNote, - krError, qaError } from '../osm'; @@ -171,10 +170,6 @@ export function behaviorSelect(context) { context .selectedNoteID(datum.id) .enter(modeSelectNote(context, datum.id)); - } else if (datum instanceof krError & !isMultiselect) { // clicked a krError error - context - .selectedErrorID(datum.id) - .enter(modeSelectError(context, datum.id, datum.source)); } else if (datum instanceof qaError & !isMultiselect) { // clicked an external QA error context .selectedErrorID(datum.id) diff --git a/modules/osm/index.js b/modules/osm/index.js index dd1397daa..c8e467001 100644 --- a/modules/osm/index.js +++ b/modules/osm/index.js @@ -1,6 +1,5 @@ export { osmChangeset } from './changeset'; export { osmEntity } from './entity'; -export { krError } from './keepRight'; export { osmNode } from './node'; export { osmNote } from './note'; export { osmRelation } from './relation'; diff --git a/modules/services/keepRight.js b/modules/services/keepRight.js index aa59acbaf..0995cab27 100644 --- a/modules/services/keepRight.js +++ b/modules/services/keepRight.js @@ -9,7 +9,7 @@ import { json as d3_json } from 'd3-request'; import { request as d3_request } from 'd3-request'; import { geoExtent, geoVecAdd } from '../geo'; -import { krError } from '../osm'; +import { qaError } from '../osm'; import { t } from '../util/locale'; import { utilRebind, utilTiler, utilQsString } from '../util'; @@ -71,7 +71,7 @@ function updateRtree(item, replace) { function tokenReplacements(d) { - if (!(d instanceof krError)) return; + if (!(d instanceof qaError)) return; var htmlRegex = new RegExp(/<\/[a-z][\s\S]*>/); var replacements = {}; @@ -375,14 +375,17 @@ export default { coincident = _krCache.rtree.search(bbox).length; } while (coincident); - var d = new krError({ + var d = new qaError({ + // Required values loc: loc, + service: 'keepRight', + error_type: errorType, + // Extra values for this service id: props.error_id, comment: props.comment || null, description: props.description || '', error_id: props.error_id, which_type: whichType, - error_type: errorType, parent_error_type: parentErrorType, severity: whichTemplate.severity || 'error', object_id: props.object_id, @@ -468,7 +471,7 @@ export default { // replace a single error in the cache replaceError: function(error) { - if (!(error instanceof krError) || !error.id) return; + if (!(error instanceof qaError) || !error.id) return; _krCache.data[error.id] = error; updateRtree(encodeErrorRtree(error), true); // true = replace @@ -478,7 +481,7 @@ export default { // remove a single error from the cache removeError: function(error) { - if (!(error instanceof krError) || !error.id) return; + if (!(error instanceof qaError) || !error.id) return; delete _krCache.data[error.id]; updateRtree(encodeErrorRtree(error), false); // false = remove @@ -496,4 +499,4 @@ export default { return Object.keys(_krCache.closed).sort(); } -}; +}; \ No newline at end of file diff --git a/modules/ui/view_on_keepRight.js b/modules/ui/view_on_keepRight.js index d0b28a4cb..8ac4a7931 100644 --- a/modules/ui/view_on_keepRight.js +++ b/modules/ui/view_on_keepRight.js @@ -1,7 +1,7 @@ import { t } from '../util/locale'; import { services } from '../services'; import { svgIcon } from '../svg'; -import { krError } from '../osm'; +import { qaError } from '../osm'; export function uiViewOnKeepRight() { @@ -10,7 +10,7 @@ export function uiViewOnKeepRight() { function viewOnKeepRight(selection) { var url; - if (services.keepRight && (_error instanceof krError)) { + if (services.keepRight && (_error instanceof qaError)) { url = services.keepRight.errorURL(_error); } @@ -42,4 +42,4 @@ export function uiViewOnKeepRight() { }; return viewOnKeepRight; -} +} \ No newline at end of file From 40af841d53e38e87bbf8235605b99b7906b5c46a Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Sun, 3 Feb 2019 12:58:37 +0000 Subject: [PATCH 3/7] Fix sidebar preview for new generic errors --- modules/ui/sidebar.js | 49 +++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/modules/ui/sidebar.js b/modules/ui/sidebar.js index 3192b5315..dfa71f4eb 100644 --- a/modules/ui/sidebar.js +++ b/modules/ui/sidebar.js @@ -9,7 +9,7 @@ import { selectAll as d3_selectAll } from 'd3-selection'; -import { osmEntity, osmNote, iOsmError, krError } from '../osm'; +import { osmEntity, osmNote, qaError } from '../osm'; import { services } from '../services'; import { uiDataEditor, @@ -31,8 +31,7 @@ export function uiSidebar(context) { var _current; var _wasData = false; var _wasNote = false; - var _wasIOsmError = false; - var _wasKRError = false; + var _wasQAError = false; function sidebar(selection) { @@ -140,36 +139,23 @@ export function uiSidebar(context) { selection.selectAll('.sidebar-component') .classed('inspector-hover', true); - } else if (datum instanceof iOsmError) { - _wasIOsmError = true; + } else if (datum instanceof qaError) { + _wasQAError = true; - var improveOSM = services.improveOSM; - if (improveOSM) { - datum = improveOSM.getError(datum.id); + var errService = services[datum.service]; + if (errService) { + // marker may contain stale data - get latest + datum = errService.getError(datum.id); } - d3_selectAll('.iOSM.qa_error') + // Temporary solution while only two services + var errEditor = (datum.source === 'kr') ? keepRightEditor : improveOsmEditor; + + d3_selectAll('.qa_error.' + datum.source) .classed('hover', function(d) { return d.id === datum.id; }); sidebar - .show(improveOsmEditor.error(datum)); - - selection.selectAll('.sidebar-component') - .classed('inspector-hover', true); - - } else if (datum instanceof krError) { - _wasKRError = true; - - var keepRight = services.keepRight; - if (keepRight) { - datum = keepRight.getError(datum.id); // marker may contain stale data - get latest - } - - d3_selectAll('.kr.qa_error') - .classed('hover', function(d) { return d.id === datum.id; }); - - sidebar - .show(keepRightEditor.error(datum)); + .show(errEditor.error(datum)); selection.selectAll('.sidebar-component') .classed('inspector-hover', true); @@ -199,13 +185,12 @@ export function uiSidebar(context) { inspector .state('hide'); - } else if (_wasData || _wasNote || _wasIOsmError || _wasKRError) { + } else if (_wasData || _wasNote || _wasQAError) { _wasNote = false; _wasData = false; - _wasIOsmError = false; - _wasKRError = false; + _wasQAError = false; d3_selectAll('.note').classed('hover', false); - d3_selectAll('.kr_error').classed('hover', false); + d3_selectAll('.qa_error').classed('hover', false); sidebar.hide(); } } @@ -366,4 +351,4 @@ export function uiSidebar(context) { sidebar.toggle = function() {}; return sidebar; -} +} \ No newline at end of file From 450c549ea5378f9bf33523d04414fb979ee88b5e Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Sun, 3 Feb 2019 13:00:34 +0000 Subject: [PATCH 4/7] Remove old error type files --- modules/osm/improveOSM.js | 51 --------------------------------------- modules/osm/keepRight.js | 50 -------------------------------------- 2 files changed, 101 deletions(-) delete mode 100644 modules/osm/improveOSM.js delete mode 100644 modules/osm/keepRight.js diff --git a/modules/osm/improveOSM.js b/modules/osm/improveOSM.js deleted file mode 100644 index fc438ee53..000000000 --- a/modules/osm/improveOSM.js +++ /dev/null @@ -1,51 +0,0 @@ -import _extend from 'lodash-es/extend'; - - -export function iOsmError() { - if (!(this instanceof iOsmError)) { - return (new iOsmError()).initialize(arguments); - } else if (arguments.length) { - this.initialize(arguments); - } -} - -// ImproveOSM has no error IDs unfortunately -// So no way to explicitly refer to each error in their DB -iOsmError.id = function() { - return iOsmError.id.next--; -}; - - -iOsmError.id.next = -1; - - -_extend(iOsmError.prototype, { - - type: 'iOsmError', - source: 'iOSM', - - initialize: function(sources) { - for (var i = 0; i < sources.length; ++i) { - var source = sources[i]; - for (var prop in source) { - if (Object.prototype.hasOwnProperty.call(source, prop)) { - if (source[prop] === undefined) { - delete this[prop]; - } else { - this[prop] = source[prop]; - } - } - } - } - - if (!this.id) { - this.id = iOsmError.id() + ''; // as string - } - - return this; - }, - - update: function(attrs) { - return iOsmError(this, attrs); // {v: 1 + (this.v || 0)} - } -}); diff --git a/modules/osm/keepRight.js b/modules/osm/keepRight.js deleted file mode 100644 index 838382e65..000000000 --- a/modules/osm/keepRight.js +++ /dev/null @@ -1,50 +0,0 @@ -import _extend from 'lodash-es/extend'; - - -export function krError() { - if (!(this instanceof krError)) { - return (new krError()).initialize(arguments); - } else if (arguments.length) { - this.initialize(arguments); - } -} - - -krError.id = function() { - return krError.id.next--; -}; - - -krError.id.next = -1; - - -_extend(krError.prototype, { - - type: 'krError', - source: 'kr', - - initialize: function(sources) { - for (var i = 0; i < sources.length; ++i) { - var source = sources[i]; - for (var prop in source) { - if (Object.prototype.hasOwnProperty.call(source, prop)) { - if (source[prop] === undefined) { - delete this[prop]; - } else { - this[prop] = source[prop]; - } - } - } - } - - if (!this.id) { - this.id = krError.id() + ''; // as string - } - - return this; - }, - - update: function(attrs) { - return krError(this, attrs); // {v: 1 + (this.v || 0)} - } -}); From ddf44377e8472857a631bf788da4aebd546ffb48 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Mon, 4 Feb 2019 17:55:44 +0000 Subject: [PATCH 5/7] Fix errors without templates not working --- modules/osm/qa_error.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/osm/qa_error.js b/modules/osm/qa_error.js index b00d6f5b6..ad1b1858a 100644 --- a/modules/osm/qa_error.js +++ b/modules/osm/qa_error.js @@ -40,14 +40,18 @@ _extend(qaError.prototype, { } } - if (this.service) { - this.source = services[this.service].shortName; + // Extract common error information from data + if (this.service && this.error_type) { + var serviceInfo = services[this.service]; - if (this.error_type) { - var template = services[this.service].errorTypes[this.error_type]; + if (serviceInfo) { + var errInfo = serviceInfo.errorTypes[this.error_type]; - this.icon = template.icon; - this.category = template.category; + this.source = serviceInfo.shortName; + if (errInfo) { + this.icon = errInfo.icon; + this.category = errInfo.category; + } } } From 781558e56be636b2602cb436bb2151aa8ee87820 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Mon, 4 Feb 2019 18:29:46 +0000 Subject: [PATCH 6/7] Remove redundant source property --- css/65_data.css | 76 ++++++++++++++++----------------- data/qa_errors.json | 2 - modules/behavior/hover.js | 2 +- modules/behavior/select.js | 2 +- modules/modes/select_error.js | 15 +++---- modules/osm/qa_error.js | 1 - modules/svg/improveOSM.js | 14 +++--- modules/svg/keepRight.js | 16 +++---- modules/ui/improveOSM_header.js | 2 +- modules/ui/keepRight_header.js | 4 +- modules/ui/sidebar.js | 4 +- 11 files changed, 67 insertions(+), 71 deletions(-) diff --git a/css/65_data.css b/css/65_data.css index 47d1c03a2..2b19ae553 100644 --- a/css/65_data.css +++ b/css/65_data.css @@ -57,98 +57,98 @@ /* Keep Right Errors ------------------------------------------------------- */ -.kr.error_type-20, /* multiple nodes on same spot */ -.kr.error_type-40, /* impossible oneways */ -.kr.error_type-210, /* self intersecting ways */ -.kr.error_type-270, /* unusual motorway connection */ -.kr.error_type-310, /* roundabout issues */ -.kr.error_type-320, /* improper _link */ -.kr.error_type-350 { /* improper bridge tag */ +.keepRight.error_type-20, /* multiple nodes on same spot */ +.keepRight.error_type-40, /* impossible oneways */ +.keepRight.error_type-210, /* self intersecting ways */ +.keepRight.error_type-270, /* unusual motorway connection */ +.keepRight.error_type-310, /* roundabout issues */ +.keepRight.error_type-320, /* improper _link */ +.keepRight.error_type-350 { /* improper bridge tag */ color: #ff9; } -.kr.error_type-50 { /* almost junctions */ +.keepRight.error_type-50 { /* almost junctions */ color: #88f; } -.kr.error_type-60, /* deprecated tags */ -.kr.error_type-70, /* tagging issues */ -.kr.error_type-90, /* motorway without ref */ -.kr.error_type-100, /* place of worship without religion */ -.kr.error_type-110, /* poi without name */ -.kr.error_type-150, /* railway crossing without tag */ -.kr.error_type-220, /* misspelled tag */ -.kr.error_type-380 { /* non-physical sport tag */ +.keepRight.error_type-60, /* deprecated tags */ +.keepRight.error_type-70, /* tagging issues */ +.keepRight.error_type-90, /* motorway without ref */ +.keepRight.error_type-100, /* place of worship without religion */ +.keepRight.error_type-110, /* poi without name */ +.keepRight.error_type-150, /* railway crossing without tag */ +.keepRight.error_type-220, /* misspelled tag */ +.keepRight.error_type-380 { /* non-physical sport tag */ color: #5d0; } -.kr.error_type-130 { /* disconnected ways */ +.keepRight.error_type-130 { /* disconnected ways */ color: #fa3; } -.kr.error_type-170 { /* FIXME tag */ +.keepRight.error_type-170 { /* FIXME tag */ color: #ff0; } -.kr.error_type-190 { /* intersection without junction */ +.keepRight.error_type-190 { /* intersection without junction */ color: #f33; } -.kr.error_type-200 { /* overlapping ways */ +.keepRight.error_type-200 { /* overlapping ways */ color: #fdbf6f; } -.kr.error_type-160, /* railway layer conflict */ -.kr.error_type-230 { /* layer conflict */ +.keepRight.error_type-160, /* railway layer conflict */ +.keepRight.error_type-230 { /* layer conflict */ color: #b60; } -.kr.error_type-280 { /* boundary issues */ +.keepRight.error_type-280 { /* boundary issues */ color: #5f47a0; } -.kr.error_type-180, /* relation without type */ -.kr.error_type-290 { /* turn restriction issues */ +.keepRight.error_type-180, /* relation without type */ +.keepRight.error_type-290 { /* turn restriction issues */ color: #ace; } -.kr.error_type-300, /* missing maxspeed */ -.kr.error_type-390 { /* missing tracktype */ +.keepRight.error_type-300, /* missing maxspeed */ +.keepRight.error_type-390 { /* missing tracktype */ color: #090; } -.kr.error_type-360, /* language unknown */ -.kr.error_type-370, /* doubled places */ -.kr.error_type-410 { /* website issues */ +.keepRight.error_type-360, /* language unknown */ +.keepRight.error_type-370, /* doubled places */ +.keepRight.error_type-410 { /* website issues */ color: #f9b; } -.kr.error_type-120, /* way without nodes */ -.kr.error_type-400 { /* geometry / turn angles */ +.keepRight.error_type-120, /* way without nodes */ +.keepRight.error_type-400 { /* geometry / turn angles */ color: #c35; } /* ImproveOSM Errors ------------------------------------------------------- */ -.iOSM.error_type-ow { /* missing one way */ +.improveOSM.error_type-ow { /* missing one way */ color: #1E90FF; } -.iOSM.error_type-mr-road { /* missing road */ +.improveOSM.error_type-mr-road { /* missing road */ color: #B452CD; } -.iOSM.error_type-mr-path { /* missing path */ +.improveOSM.error_type-mr-path { /* missing path */ color: #A0522D; } -.iOSM.error_type-mr-parking { /* missing parking */ +.improveOSM.error_type-mr-parking { /* missing parking */ color: #EEEE00; } -.iOSM.error_type-mr-both { /* missing road+parking */ +.improveOSM.error_type-mr-both { /* missing road+parking */ color: #FFA500; } -.iOSM.error_type-tr { /* missing turn restriction */ +.improveOSM.error_type-tr { /* missing turn restriction */ color: #EC1C24; } diff --git a/data/qa_errors.json b/data/qa_errors.json index ae29b13bd..d14306dcd 100644 --- a/data/qa_errors.json +++ b/data/qa_errors.json @@ -1,7 +1,6 @@ { "services": { "improveOSM": { - "shortName": "iOSM", "errorTypes": { "ow": { "icon": "fas-long-arrow-alt-right", @@ -30,7 +29,6 @@ } }, "keepRight": { - "shortName": "kr", "errorTypes": { } diff --git a/modules/behavior/hover.js b/modules/behavior/hover.js index c62d2bdd1..40cd68be3 100644 --- a/modules/behavior/hover.js +++ b/modules/behavior/hover.js @@ -114,7 +114,7 @@ export function behaviorHover(context) { } else if (datum instanceof qaError) { entity = datum; - selector = '.' + datum.source + '.error_id-' + datum.id; + selector = '.' + datum.service + '.error_id-' + datum.id; } else if (datum instanceof osmNote) { entity = datum; diff --git a/modules/behavior/select.js b/modules/behavior/select.js index 541535255..7942026db 100644 --- a/modules/behavior/select.js +++ b/modules/behavior/select.js @@ -173,7 +173,7 @@ export function behaviorSelect(context) { } else if (datum instanceof qaError & !isMultiselect) { // clicked an external QA error context .selectedErrorID(datum.id) - .enter(modeSelectError(context, datum.id, datum.source)); + .enter(modeSelectError(context, datum.id, datum.service)); } else { // clicked nothing.. context.selectedNoteID(null); context.selectedErrorID(null); diff --git a/modules/modes/select_error.js b/modules/modes/select_error.js index 4f7645644..0293d79de 100644 --- a/modules/modes/select_error.js +++ b/modules/modes/select_error.js @@ -17,7 +17,7 @@ import { uiImproveOsmEditor, uiKeepRightEditor } from '../ui'; import { utilKeybinding } from '../util'; -export function modeSelectError(context, selectedErrorID, selectedErrorSource) { +export function modeSelectError(context, selectedErrorID, selectedErrorService) { var mode = { id: 'select-error', button: 'browse' @@ -25,10 +25,10 @@ export function modeSelectError(context, selectedErrorID, selectedErrorSource) { var keybinding = utilKeybinding('select-error'); - var errorService, errorEditor; - switch (selectedErrorSource) { - case 'iOSM': - errorService = services.improveOSM; + var errorService = services[selectedErrorService]; + var errorEditor; + switch (selectedErrorService) { + case 'improveOSM': errorEditor = uiImproveOsmEditor(context) .on('change', function() { context.map().pan([0,0]); // trigger a redraw @@ -38,8 +38,7 @@ export function modeSelectError(context, selectedErrorID, selectedErrorSource) { .show(errorEditor.error(error)); }); break; - case 'kr': - errorService = services.keepRight; + case 'keepRight': errorEditor = uiKeepRightEditor(context) .on('change', function() { context.map().pan([0,0]); // trigger a redraw @@ -153,4 +152,4 @@ export function modeSelectError(context, selectedErrorID, selectedErrorSource) { return mode; -} +} \ No newline at end of file diff --git a/modules/osm/qa_error.js b/modules/osm/qa_error.js index ad1b1858a..a5c9fd20d 100644 --- a/modules/osm/qa_error.js +++ b/modules/osm/qa_error.js @@ -47,7 +47,6 @@ _extend(qaError.prototype, { if (serviceInfo) { var errInfo = serviceInfo.errorTypes[this.error_type]; - this.source = serviceInfo.shortName; if (errInfo) { this.icon = errInfo.icon; this.category = errInfo.category; diff --git a/modules/svg/improveOSM.js b/modules/svg/improveOSM.js index f10be4823..33dd71dec 100644 --- a/modules/svg/improveOSM.js +++ b/modules/svg/improveOSM.js @@ -53,9 +53,9 @@ export function svgImproveOSM(projection, context, dispatch) { _improveOsmVisible = false; drawLayer .style('display', 'none'); - drawLayer.selectAll('.qa_error.iOSM') + drawLayer.selectAll('.qa_error.improveOSM') .remove(); - touchLayer.selectAll('.qa_error.iOSM') + touchLayer.selectAll('.qa_error.improveOSM') .remove(); } } @@ -80,7 +80,7 @@ export function svgImproveOSM(projection, context, dispatch) { function layerOff() { throttledRedraw.cancel(); drawLayer.interrupt(); - touchLayer.selectAll('.qa_error.iOSM') + touchLayer.selectAll('.qa_error.improveOSM') .remove(); drawLayer @@ -104,7 +104,7 @@ export function svgImproveOSM(projection, context, dispatch) { var getTransform = svgPointTransform(projection); // Draw markers.. - var markers = drawLayer.selectAll('.qa_error.iOSM') + var markers = drawLayer.selectAll('.qa_error.improveOSM') .data(data, function(d) { return d.id; }); // exit @@ -117,7 +117,7 @@ export function svgImproveOSM(projection, context, dispatch) { .attr('class', function(d) { return [ 'qa_error', - d.source, + d.service, 'error_id-' + d.id, 'error_type-' + d.error_type, 'category-' + d.category @@ -170,7 +170,7 @@ export function svgImproveOSM(projection, context, dispatch) { if (touchLayer.empty()) return; var fillClass = context.getDebug('target') ? 'pink ' : 'nocolor '; - var targets = touchLayer.selectAll('.qa_error.iOSM') + var targets = touchLayer.selectAll('.qa_error.improveOSM') .data(data, function(d) { return d.id; }); // exit @@ -187,7 +187,7 @@ export function svgImproveOSM(projection, context, dispatch) { .merge(targets) .sort(sortY) .attr('class', function(d) { - return 'qa_error ' + d.source + ' target error_id-' + d.id + ' ' + fillClass; + return 'qa_error ' + d.service + ' target error_id-' + d.id + ' ' + fillClass; }) .attr('transform', getTransform); diff --git a/modules/svg/keepRight.js b/modules/svg/keepRight.js index 126ffd320..dffb7bddb 100644 --- a/modules/svg/keepRight.js +++ b/modules/svg/keepRight.js @@ -54,9 +54,9 @@ export function svgKeepRight(projection, context, dispatch) { _keepRightVisible = false; drawLayer .style('display', 'none'); - drawLayer.selectAll('.qa_error.kr') + drawLayer.selectAll('.qa_error.keepRight') .remove(); - touchLayer.selectAll('.qa_error.kr') + touchLayer.selectAll('.qa_error.keepRight') .remove(); } } @@ -81,7 +81,7 @@ export function svgKeepRight(projection, context, dispatch) { function layerOff() { throttledRedraw.cancel(); drawLayer.interrupt(); - touchLayer.selectAll('.qa_error.kr') + touchLayer.selectAll('.qa_error.keepRight') .remove(); drawLayer @@ -105,7 +105,7 @@ export function svgKeepRight(projection, context, dispatch) { var getTransform = svgPointTransform(projection); // Draw markers.. - var markers = drawLayer.selectAll('.qa_error.kr') + var markers = drawLayer.selectAll('.qa_error.keepRight') .data(data, function(d) { return d.id; }); // exit @@ -118,7 +118,7 @@ export function svgKeepRight(projection, context, dispatch) { .attr('class', function(d) { return [ 'qa_error', - d.source, + d.service, 'error_id-' + d.id, 'error_type-' + d.parent_error_type ].join(' '); @@ -157,7 +157,7 @@ export function svgKeepRight(projection, context, dispatch) { if (touchLayer.empty()) return; var fillClass = context.getDebug('target') ? 'pink ' : 'nocolor '; - var targets = touchLayer.selectAll('.qa_error.kr') + var targets = touchLayer.selectAll('.qa_error.keepRight') .data(data, function(d) { return d.id; }); // exit @@ -174,7 +174,7 @@ export function svgKeepRight(projection, context, dispatch) { .merge(targets) .sort(sortY) .attr('class', function(d) { - return 'qa_error ' + d.source + ' target error_id-' + d.id + ' ' + fillClass; + return 'qa_error ' + d.service + ' target error_id-' + d.id + ' ' + fillClass; }) .attr('transform', getTransform); @@ -247,4 +247,4 @@ export function svgKeepRight(projection, context, dispatch) { return drawKeepRight; -} +} \ No newline at end of file diff --git a/modules/ui/improveOSM_header.js b/modules/ui/improveOSM_header.js index 381118a81..c1cd579c4 100644 --- a/modules/ui/improveOSM_header.js +++ b/modules/ui/improveOSM_header.js @@ -49,7 +49,7 @@ export function uiImproveOsmHeader() { return [ 'preset-icon-28', 'qa_error', - d.source, + d.service, 'error_id-' + d.id, 'error_type-' + d.error_type, 'category-' + d.category diff --git a/modules/ui/keepRight_header.js b/modules/ui/keepRight_header.js index 534ecaf73..0e611c74f 100644 --- a/modules/ui/keepRight_header.js +++ b/modules/ui/keepRight_header.js @@ -49,7 +49,7 @@ export function uiKeepRightHeader() { iconEnter .append('div') .attr('class', function(d) { - return 'preset-icon-28 qa_error ' + d.source + ' error_id-' + d.id + ' error_type-' + d.parent_error_type; + return 'preset-icon-28 qa_error ' + d.service + ' error_id-' + d.id + ' error_type-' + d.parent_error_type; }) .call(svgIcon('#iD-icon-bolt', 'qa_error-fill')); @@ -68,4 +68,4 @@ export function uiKeepRightHeader() { return keepRightHeader; -} +} \ No newline at end of file diff --git a/modules/ui/sidebar.js b/modules/ui/sidebar.js index dfa71f4eb..a25df48d2 100644 --- a/modules/ui/sidebar.js +++ b/modules/ui/sidebar.js @@ -149,9 +149,9 @@ export function uiSidebar(context) { } // Temporary solution while only two services - var errEditor = (datum.source === 'kr') ? keepRightEditor : improveOsmEditor; + var errEditor = (datum.service === 'keepRight') ? keepRightEditor : improveOsmEditor; - d3_selectAll('.qa_error.' + datum.source) + d3_selectAll('.qa_error.' + datum.service) .classed('hover', function(d) { return d.id === datum.id; }); sidebar From b55830485df3f530383493925fe4364bfecd0507 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Mon, 4 Feb 2019 22:55:47 +0000 Subject: [PATCH 7/7] Fix use of old variable name --- modules/modes/select_error.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/modes/select_error.js b/modules/modes/select_error.js index 0293d79de..de12b4dd1 100644 --- a/modules/modes/select_error.js +++ b/modules/modes/select_error.js @@ -106,7 +106,7 @@ export function modeSelectError(context, selectedErrorID, selectedErrorService) if (!checkSelectedID()) return; var selection = context.surface() - .selectAll('.error_id-' + selectedErrorID + '.' + selectedErrorSource); + .selectAll('.error_id-' + selectedErrorID + '.' + selectedErrorService); if (selection.empty()) { // Return to browse mode if selected DOM elements have