From 7851c49e80b59c9c8b8da0975d774488ee0566fc Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 22 Dec 2017 00:26:39 -0500 Subject: [PATCH] Fix nopefilters by testing the original id for the filter --- modules/svg/areas.js | 1 + modules/svg/helpers.js | 3 +++ modules/svg/lines.js | 12 +++++++++--- modules/svg/vertices.js | 7 +++---- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/modules/svg/areas.js b/modules/svg/areas.js index 3fb7c3723..90f35eb57 100644 --- a/modules/svg/areas.js +++ b/modules/svg/areas.js @@ -76,6 +76,7 @@ export function svgAreas(projection, context) { // NOPE var nopes = selection.selectAll('.area.target-nope') + .filter(function(d) { return filter({ id: d.properties.originalID }); }) .data(data.nopes, function key(d) { return d.id; }); // exit diff --git a/modules/svg/helpers.js b/modules/svg/helpers.js index 88f04f578..bbd22f11d 100644 --- a/modules/svg/helpers.js +++ b/modules/svg/helpers.js @@ -245,6 +245,9 @@ export function svgSegmentWay(way, graph, activeID) { features.active.push({ 'type': 'Feature', 'id': way.id + '-nope', // break the ids on purpose + 'properties': { + 'originalID': way.id + }, 'geometry': { 'type': 'MultiLineString', 'coordinates': coordGroups.active diff --git a/modules/svg/lines.js b/modules/svg/lines.js index fbecbed7b..67e433ab8 100644 --- a/modules/svg/lines.js +++ b/modules/svg/lines.js @@ -72,6 +72,7 @@ export function svgLines(projection, context) { // NOPE var nopes = selection.selectAll('.line.target-nope') + .filter(function(d) { return filter({ id: d.properties.originalID }); }) .data(data.nopes, function key(d) { return d.id; }); // exit @@ -101,6 +102,11 @@ export function svgLines(projection, context) { function drawLineGroup(selection, klass, isSelected) { + // Note: Don't add `.selected` class in draw modes + var mode = context.mode(); + var isDrawing = mode && /^draw/.test(mode.id); + var selectedClass = (!isDrawing && isSelected) ? 'selected ' : ''; + var lines = selection .selectAll('path') .filter(filter) @@ -109,13 +115,13 @@ export function svgLines(projection, context) { lines.exit() .remove(); - // Optimization: call simple TagClasses only on enter selection. This + // Optimization: Call expensive TagClasses only on enter selection. This // works because osmEntity.key is defined to include the entity v attribute. lines.enter() .append('path') .attr('class', function(d) { - return 'way line ' + klass + ' ' + d.id + (isSelected ? ' selected' : '') + - (oldMultiPolygonOuters[d.id] ? ' old-multipolygon' : ''); + var oldMPClass = oldMultiPolygonOuters[d.id] ? 'old-multipolygon ' : ''; + return 'way line ' + klass + ' ' + selectedClass + oldMPClass + d.id; }) .call(svgTagClasses()) .merge(lines) diff --git a/modules/svg/vertices.js b/modules/svg/vertices.js index 77aad0a1d..a0584b501 100644 --- a/modules/svg/vertices.js +++ b/modules/svg/vertices.js @@ -196,6 +196,7 @@ export function svgVertices(projection, context) { } else { data.nopes.push({ id: node.id + '-nope', // not a real osmNode, break the id on purpose + originalID: node.id, loc: node.loc }); } @@ -222,6 +223,7 @@ export function svgVertices(projection, context) { // NOPE var nopes = selection.selectAll('.vertex.target-nope') + .filter(function(d) { return filter({ id: d.originalID }); }) .data(data.nopes, function key(d) { return d.id; }); // exit @@ -351,11 +353,8 @@ export function svgVertices(projection, context) { .call(draw, graph, currentVisible(all), sets, filterRendered); // Draw touch targets.. - var filterTargets = function(d) { - return isMoving ? true : filterRendered(d); - }; selection.selectAll('.layer-points .layer-points-targets') - .call(drawTargets, graph, currentVisible(all), filterTargets); + .call(drawTargets, graph, currentVisible(all), filterRendered); function currentVisible(which) {