Better inferRestriction for no_u_turn

* where from.node === to.node
* where from.way and to.way are oneways joined at a narrow angle
This commit is contained in:
Bryan Housel
2014-09-02 16:43:31 -04:00
parent cf715a5156
commit 43777d5259
4 changed files with 74 additions and 23 deletions
+46 -1
View File
@@ -250,7 +250,7 @@ describe("iD.actions.RestrictTurn", function() {
expect(_.pick(r.memberByRole('to'), 'id', 'type')).to.eql({id: '==', type: 'way'});
});
it('guesses the restriction type based on the turn angle', function() {
it('infers the restriction type based on the turn angle', function() {
// u====*~~~~w
// |
// x
@@ -306,4 +306,49 @@ describe("iD.actions.RestrictTurn", function() {
}, projection, 'r')(graph);
expect(u.entity('r').tags.restriction).to.equal('no_u_turn');
});
it('infers no_u_turn from acute angle made by forward oneways', function() {
// *
// / \
// w2/ \w1
// / \
// u x
var graph = iD.Graph([
iD.Node({id: 'u', loc: [-1, -20]}),
iD.Node({id: '*', loc: [ 0, 0]}),
iD.Node({id: 'x', loc: [ 1, -20]}),
iD.Way({id: 'w1', nodes: ['x', '*'], tags: {oneway: 'yes'}}),
iD.Way({id: 'w2', nodes: ['*', 'u'], tags: {oneway: 'yes'}})
]);
var r = iD.actions.RestrictTurn({
from: {node: 'x', way: 'w1'},
via: {node: '*'},
to: {node: 'u', way: 'w2'}
}, projection, 'r')(graph);
expect(r.entity('r').tags.restriction).to.equal('no_u_turn');
});
it('infers no_u_turn from acute angle made by reverse oneways', function() {
// *
// / \
// w2/ \w1
// / \
// u x
var graph = iD.Graph([
iD.Node({id: 'u', loc: [-1, -20]}),
iD.Node({id: '*', loc: [ 0, 0]}),
iD.Node({id: 'x', loc: [ 1, -20]}),
iD.Way({id: 'w1', nodes: ['*', 'x'], tags: {oneway: '-1'}}),
iD.Way({id: 'w2', nodes: ['u', '*'], tags: {oneway: '-1'}})
]);
var r = iD.actions.RestrictTurn({
from: {node: 'x', way: 'w1'},
via: {node: '*'},
to: {node: 'u', way: 'w2'}
}, projection, 'r')(graph);
expect(r.entity('r').tags.restriction).to.equal('no_u_turn');
});
});