From bf21744077c02ac6a1663e43e61489ec9fcbd2d4 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 20 May 2013 17:16:36 -0700 Subject: [PATCH] Only draw intersections for {high,water,rail,aero}way lines Fixes #1471 --- js/id/core/node.js | 6 +++++- test/spec/core/node.js | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/js/id/core/node.js b/js/id/core/node.js index 1c97a6d62..5fb261d5f 100644 --- a/js/id/core/node.js +++ b/js/id/core/node.js @@ -28,7 +28,11 @@ _.extend(iD.Node.prototype, { isIntersection: function(resolver) { return resolver.transient(this, 'isIntersection', function() { return resolver.parentWays(this).filter(function(parent) { - return parent.geometry(resolver) === 'line'; + return (parent.tags.highway || + parent.tags.waterway || + parent.tags.railway || + parent.tags.aeroway) && + parent.geometry(resolver) === 'line'; }).length > 1; }); }, diff --git a/test/spec/core/node.js b/test/spec/core/node.js index 71a2c5e95..d5ad90ec1 100644 --- a/test/spec/core/node.js +++ b/test/spec/core/node.js @@ -43,6 +43,24 @@ describe('iD.Node', function () { }); }); + describe("#isIntersection", function () { + it("returns true for a node shared by more than one highway", function () { + var node = iD.Node(), + w1 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}}), + w2 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}}), + graph = iD.Graph([node, w1, w2]); + expect(node.isIntersection(graph)).to.equal(true); + }); + + it("returns true for a node shared by more two non-highways", function () { + var node = iD.Node(), + w1 = iD.Way({nodes: [node.id]}), + w2 = iD.Way({nodes: [node.id]}), + graph = iD.Graph([node, w1, w2]); + expect(node.isIntersection(graph)).to.equal(false); + }); + }); + describe("#asJXON", function () { it('converts a node to jxon', function() { var node = iD.Node({id: 'n-1', loc: [-77, 38], tags: {amenity: 'cafe'}});