mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
Add additional tests for crossing_ways validation
This commit is contained in:
@@ -64,17 +64,23 @@ describe('iD.validations.crossing_ways', function () {
|
||||
return issues;
|
||||
}
|
||||
|
||||
function verifySingleCrossingIssue(issues) {
|
||||
function verifySingleCrossingIssue(issues, connectionTags) {
|
||||
// each entity must produce an identical issue
|
||||
expect(issues).to.have.lengthOf(2);
|
||||
expect(issues[0].hash).to.eql(issues[1].hash);
|
||||
|
||||
var issue = issues[0];
|
||||
expect(issue.type).to.eql('crossing_ways');
|
||||
expect(issue.entityIds).to.have.lengthOf(2);
|
||||
for (var i in issues) {
|
||||
var issue = issues[i];
|
||||
expect(issue.type).to.eql('crossing_ways');
|
||||
expect(issue.severity).to.eql('warning');
|
||||
expect(issue.entityIds).to.have.lengthOf(2);
|
||||
|
||||
expect(issue.loc).to.have.lengthOf(2);
|
||||
expect(issue.loc[0]).to.eql(1.5);
|
||||
expect(issue.loc[1]).to.eql(1.5);
|
||||
expect(issue.loc).to.have.lengthOf(2);
|
||||
expect(issue.loc[0]).to.eql(1.5);
|
||||
expect(issue.loc[1]).to.eql(1.5);
|
||||
|
||||
expect(issue.data.connectionTags).to.eql(connectionTags);
|
||||
}
|
||||
}
|
||||
|
||||
it('has no errors on init', function() {
|
||||
@@ -82,146 +88,237 @@ describe('iD.validations.crossing_ways', function () {
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('ignores untagged line crossing untagged line', function() {
|
||||
createWaysWithOneCrossingPoint({}, {});
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('ignores road crossing abandoned railway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential' }, { railway: 'abandoned' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('ignores road crossing non-rail railway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential' }, { railway: 'yard' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('ignores road crossing non-water waterway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential' }, { waterway: 'fuel' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('ignores road crossing non-building building', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential' }, { building: 'no' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('ignores road crossing non-routable highway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'services' }, { highway: 'residential' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
// legit crossing cases
|
||||
it('legit crossing between highway and highway', function() {
|
||||
it('ignores road tunnel crossing road', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential', tunnel: 'yes', layer: '-1' }, { highway: 'residential' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('legit crossing between highway and railway', function() {
|
||||
it('ignores road crossing railway bridge', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential' }, { railway: 'rail', bridge: 'yes' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('legit crossing between highway and waterway', function() {
|
||||
it('ignores road bridge crossing waterway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential', bridge: 'yes' }, { waterway: 'river' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('legit crossing between highway and building', function() {
|
||||
it('ignores road crossing building on different layers', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential', layer: '-1' }, { building: 'yes' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('legit crossing between railway and railway', function() {
|
||||
it('ignores railway crossing railway bridge', function() {
|
||||
createWaysWithOneCrossingPoint({ railway: 'rail', bridge: 'yes' }, { railway: 'rail' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('legit crossing between railway bridges on different layers', function() {
|
||||
it('ignores railway bridge crossing railway bridge on different layers', function() {
|
||||
createWaysWithOneCrossingPoint({ railway: 'rail', bridge: 'yes', layer: '2' }, { railway: 'rail', bridge: 'yes' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('legit crossing between railway and waterway', function() {
|
||||
it('ignores railway crossing waterway tunnel', function() {
|
||||
createWaysWithOneCrossingPoint({ railway: 'rail' }, { waterway: 'river', tunnel: 'yes' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('legit crossing between railway and building', function() {
|
||||
it('ignores railway crossing building on different layers', function() {
|
||||
createWaysWithOneCrossingPoint({ railway: 'rail', layer: '-1' }, { building: 'yes' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('legit crossing between waterway and waterway', function() {
|
||||
it('ignores waterway crossing waterway tunnel', function() {
|
||||
createWaysWithOneCrossingPoint({ waterway: 'canal', tunnel: 'yes' }, { waterway: 'river' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('legit crossing between waterway and building', function() {
|
||||
it('ignores waterway crossing building on different layers', function() {
|
||||
createWaysWithOneCrossingPoint({ waterway: 'river', layer: '-1' }, { building: 'yes' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('legit crossing between building and building', function() {
|
||||
it('ignores building crossing building on different layers', function() {
|
||||
createWaysWithOneCrossingPoint({ building: 'yes' }, { building: 'yes', layer: '1' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('legit crossing between indoor corridors on different levels', function() {
|
||||
it('ignores corridor crossing corridor on different levels', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'corridor', level: '0' }, { highway: 'corridor', level: '1' });
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
// warning crossing cases between ways
|
||||
it('one cross point between highway and highway', function() {
|
||||
it('flags road crossing road', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential' }, { highway: 'residential' });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
verifySingleCrossingIssue(validate(), {});
|
||||
});
|
||||
|
||||
it('one cross point between highway and railway', function() {
|
||||
it('flags road crossing footway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential' }, { highway: 'footway' });
|
||||
verifySingleCrossingIssue(validate(), { highway: 'crossing' });
|
||||
});
|
||||
|
||||
it('flags road crossing cycleway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential' }, { highway: 'cycleway' });
|
||||
verifySingleCrossingIssue(validate(), { highway: 'crossing' });
|
||||
});
|
||||
|
||||
it('flags road crossing crosswalk', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential' }, { highway: 'footway', crossing: 'marked' });
|
||||
verifySingleCrossingIssue(validate(), { highway: 'crossing', crossing: 'marked' });
|
||||
});
|
||||
|
||||
it('flags cycleway crossing cycleway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'cycleway' }, { highway: 'cycleway' });
|
||||
verifySingleCrossingIssue(validate(), {});
|
||||
});
|
||||
|
||||
it('flags cycleway crossing footway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'cycleway' }, { highway: 'footway' });
|
||||
verifySingleCrossingIssue(validate(), {});
|
||||
});
|
||||
|
||||
it('flags footway crossing footway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'footway' }, { highway: 'footway' });
|
||||
verifySingleCrossingIssue(validate(), {});
|
||||
});
|
||||
|
||||
it('flags road crossing railway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential' }, { railway: 'rail' });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
verifySingleCrossingIssue(validate(), { railway: 'level_crossing' });
|
||||
});
|
||||
|
||||
it('one cross point between highway and waterway', function() {
|
||||
it('flags footway crossing railway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'footway' }, { railway: 'rail' });
|
||||
verifySingleCrossingIssue(validate(), { railway: 'crossing' });
|
||||
});
|
||||
|
||||
it('flags cycleway crossing railway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'cycleway' }, { railway: 'rail' });
|
||||
verifySingleCrossingIssue(validate(), { railway: 'crossing' });
|
||||
});
|
||||
|
||||
it('flags minor road crossing waterway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential' }, { waterway: 'river' });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
verifySingleCrossingIssue(validate(), { ford: 'yes' });
|
||||
});
|
||||
|
||||
it('one cross point between highway and building', function() {
|
||||
it('flags major road crossing waterway', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'motorway' }, { waterway: 'river' });
|
||||
verifySingleCrossingIssue(validate(), null);
|
||||
});
|
||||
|
||||
it('flags road crossing building', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential' }, { building: 'yes' });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
verifySingleCrossingIssue(validate(), null);
|
||||
});
|
||||
|
||||
it('one cross point between railway and railway', function() {
|
||||
it('flags railway crossing railway', function() {
|
||||
createWaysWithOneCrossingPoint({ railway: 'rail' }, { railway: 'rail' });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
verifySingleCrossingIssue(validate(), {});
|
||||
});
|
||||
|
||||
it('one cross point between railway and waterway', function() {
|
||||
it('flags railway crossing waterway', function() {
|
||||
createWaysWithOneCrossingPoint({ railway: 'rail' }, { waterway: 'river' });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
verifySingleCrossingIssue(validate(), null);
|
||||
});
|
||||
|
||||
it('one cross point between railway bridge and highway bridge', function() {
|
||||
it('flags road bridge crossing road bridge on the same layer', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential', bridge: 'yes' }, { highway: 'tertiary', bridge: 'yes' });
|
||||
verifySingleCrossingIssue(validate(), {});
|
||||
});
|
||||
|
||||
it('flags road bridge crossing aqueduct on the same layer', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential', bridge: 'yes' }, { waterway: 'canal', bridge: 'aqueduct' });
|
||||
verifySingleCrossingIssue(validate(), null);
|
||||
});
|
||||
|
||||
it('flags railway bridge crossing road bridge on the same layer', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'residential', bridge: 'yes' }, { railway: 'rail', bridge: 'yes' });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
verifySingleCrossingIssue(validate(), { railway: 'level_crossing' });
|
||||
});
|
||||
|
||||
it('one cross point between railway and building', function() {
|
||||
it('flags railway crossing building', function() {
|
||||
createWaysWithOneCrossingPoint({ railway: 'rail' }, { building: 'yes' });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
verifySingleCrossingIssue(validate(), null);
|
||||
});
|
||||
|
||||
it('one cross point between waterway and waterway', function() {
|
||||
it('flags waterway crossing waterway', function() {
|
||||
createWaysWithOneCrossingPoint({ waterway: 'canal' }, { waterway: 'canal' });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
verifySingleCrossingIssue(validate(), {});
|
||||
});
|
||||
|
||||
it('one cross point between waterway tunnels', function() {
|
||||
it('flags waterway tunnel crossing waterway tunnel on the same layer', function() {
|
||||
createWaysWithOneCrossingPoint({ waterway: 'canal', tunnel: 'yes' }, { waterway: 'canal', tunnel: 'yes' });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
verifySingleCrossingIssue(validate(), {});
|
||||
});
|
||||
|
||||
it('one cross point between waterway and building', function() {
|
||||
it('flags waterway crossing building', function() {
|
||||
createWaysWithOneCrossingPoint({ waterway: 'river' }, { building: 'yes' });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
verifySingleCrossingIssue(validate(), null);
|
||||
});
|
||||
|
||||
it('one cross point between building and building', function() {
|
||||
it('flags building crossing building', function() {
|
||||
createWaysWithOneCrossingPoint({ building: 'yes' }, { building: 'yes' });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
verifySingleCrossingIssue(validate(), null);
|
||||
});
|
||||
|
||||
it('one cross point between indoor corridors on the same level', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'corridor', level: 0 }, { highway: 'corridor', level: 0 });
|
||||
verifySingleCrossingIssue(validate(), 'w-2');
|
||||
it('flags corridor crossing corridor on the same level', function() {
|
||||
createWaysWithOneCrossingPoint({ highway: 'corridor', level: '0' }, { highway: 'corridor', level: '0' });
|
||||
verifySingleCrossingIssue(validate(), {});
|
||||
});
|
||||
|
||||
it('two cross points between two highways', function() {
|
||||
it('flags road crossing road twice', function() {
|
||||
createWaysWithTwoCrossingPoint();
|
||||
var issues = validate();
|
||||
expect(issues).to.have.lengthOf(4);
|
||||
@@ -272,14 +369,14 @@ describe('iD.validations.crossing_ways', function () {
|
||||
);
|
||||
}
|
||||
|
||||
it('one cross point between highway line and building multipolygon relation', function() {
|
||||
it('flags road line crossing building multipolygon relation', function() {
|
||||
createWayAndRelationWithOneCrossingPoint({ highway: 'residential' }, { building: 'yes', type: 'multipolygon' });
|
||||
verifySingleCrossingIssue(validate(), 'r-1');
|
||||
verifySingleCrossingIssue(validate(), null);
|
||||
});
|
||||
|
||||
it('one cross point between highway line and highway multipolygon relation', function() {
|
||||
it('flags road line crossing footway multipolygon relation', function() {
|
||||
createWayAndRelationWithOneCrossingPoint({ highway: 'residential' }, { highway: 'footway', type: 'multipolygon' });
|
||||
verifySingleCrossingIssue(validate(), 'r-1');
|
||||
verifySingleCrossingIssue(validate(), { highway: 'crossing' });
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user