From 8e19474293108b77a1edddeb27ad15249b353deb Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Mon, 11 Dec 2017 10:48:04 -0500 Subject: [PATCH] Render directional points (e.g. benches, cameras, signs) as vertices --- modules/osm/node.js | 2 +- modules/svg/points.js | 14 +++++++++----- modules/svg/vertices.js | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/osm/node.js b/modules/osm/node.js index 38b882c41..cd3c8a79a 100644 --- a/modules/osm/node.js +++ b/modules/osm/node.js @@ -99,7 +99,7 @@ _extend(osmNode.prototype, { var lookForward = (this.tags['traffic_sign:forward'] || val === 'forward' || val === 'both' || val === 'all'); - if (!lookForward && !lookBackward) return null; + if (!lookForward && !lookBackward) return []; var nodeIds = {}; resolver.parentWays(this).forEach(function(parent) { diff --git a/modules/svg/points.js b/modules/svg/points.js index e48f31163..054a7359e 100644 --- a/modules/svg/points.js +++ b/modules/svg/points.js @@ -22,7 +22,7 @@ export function svgPoints(projection, context) { return function drawPoints(selection, graph, entities, filter) { var wireframe = context.surface().classed('fill-wireframe'), points = wireframe ? [] : _filter(entities, function(e) { - return e.geometry(graph) === 'point'; + return e.geometry(graph) === 'point' && !e.directions(graph, projection).length; }); points.sort(sortY); @@ -41,20 +41,24 @@ export function svgPoints(projection, context) { .attr('class', function(d) { return 'node point ' + d.id; }) .order(); - enter.append('path') + enter + .append('path') .call(markerPath, 'shadow'); - enter.append('ellipse') + enter + .append('ellipse') .attr('cx', 0.5) .attr('cy', 1) .attr('rx', 6.5) .attr('ry', 3) .attr('class', 'stroke'); - enter.append('path') + enter + .append('path') .call(markerPath, 'stroke'); - enter.append('use') + enter + .append('use') .attr('transform', 'translate(-5, -19)') .attr('class', 'icon') .attr('width', '11px') diff --git a/modules/svg/vertices.js b/modules/svg/vertices.js index 80638b7bd..e7fa7a776 100644 --- a/modules/svg/vertices.js +++ b/modules/svg/vertices.js @@ -72,11 +72,12 @@ export function svgVertices(projection, context) { } + // memoize directions results, return false for empty arrays (for use in filter) function getDirections(entity) { if (entity.id in directions) return directions[entity.id]; var angles = entity.directions(graph, projection); - if (angles) directions[entity.id] = angles; + directions[entity.id] = angles.length ? angles : false; return angles; } @@ -211,7 +212,7 @@ export function svgVertices(projection, context) { var entity = entities[i], geometry = entity.geometry(graph); - if (wireframe && geometry === 'point') { + if ((geometry === 'point') && (wireframe || entity.directions(graph, projection).length)) { vertices.push(entity); continue; }