Fast parent calculation.

This commit is contained in:
Tom MacWright
2013-01-09 14:52:39 -05:00
parent 543a6e169c
commit eedc0fce9d
8 changed files with 79 additions and 25 deletions
+5 -4
View File
@@ -69,18 +69,19 @@ describe('iD.Graph', function() {
var node = iD.Node({id: "n1"}),
way = iD.Way({id: "w1", nodes: ["n1"]}),
graph = iD.Graph({n1: node, w1: way});
expect(graph.parentWays("n1")).to.eql([way]);
expect(graph.parentWays("n2")).to.eql([]);
expect(graph.parentWays(node)).to.eql([way]);
expect(graph.parentWays(way)).to.eql([]);
});
});
describe("#parentRelations", function() {
it("returns an array of relations that contain the given entity id", function () {
var node = iD.Node({id: "n1"}),
nonnode = iD.Node({id: "n2"}),
relation = iD.Relation({id: "r1", members: [{ id: "n1", role: 'from' }]}),
graph = iD.Graph({n1: node, r1: relation});
expect(graph.parentRelations("n1")).to.eql([relation]);
expect(graph.parentRelations("n2")).to.eql([]);
expect(graph.parentRelations(node)).to.eql([relation]);
expect(graph.parentRelations(nonnode)).to.eql([]);
});
});