Only draw intersections for {high,water,rail,aero}way lines

Fixes #1471
This commit is contained in:
John Firebaugh
2013-05-20 17:16:36 -07:00
parent bd2c7ba756
commit bf21744077
2 changed files with 23 additions and 1 deletions

View File

@@ -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;
});
},

View File

@@ -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'}});