Skip to content

Commit

Permalink
Fix remaining tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bonkles committed Jul 26, 2021
1 parent cecc533 commit 7ba89ce
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 90 deletions.
2 changes: 1 addition & 1 deletion modules/osm/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ osmNode.prototype = Object.create(osmEntity.prototype);

Object.assign(osmNode.prototype, {
type: 'node',
loc: [9999, 9999],
loc: new Extent([9999, 9999]),

extent: function() {
return new Extent(this.loc);
Expand Down
2 changes: 1 addition & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
'spec/util/session_mutex.js',
'spec/util/util.js',

// 'spec/validations/almost_junction.js',
'spec/validations/almost_junction.js',
'spec/validations/crossing_ways.js',
'spec/validations/disconnected_way.js',
'spec/validations/incompatible_source.js',
Expand Down
69 changes: 36 additions & 33 deletions test/spec/validations/almost_junction.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const { Extent } = require('@id-sdk/extent');


describe('iD.validations.almost_junction', function () {
var context;

Expand All @@ -7,8 +10,8 @@ describe('iD.validations.almost_junction', function () {

function horizontalVertialCloserThanThd() {
// horizontal road
var n1 = iD.osmNode({id: 'n-1', loc: [22.42357, 0]});
var n2 = iD.osmNode({id: 'n-2', loc: [22.42367, 0]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([22.42357, 0])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([22.42367, 0])});
var w1 = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: { highway: 'residential' }});

context.perform(
Expand All @@ -19,8 +22,8 @@ describe('iD.validations.almost_junction', function () {

// vertical road to the west of w1 by 0.00001 longitude degree
// 5th digit after decimal point has a resolution of ~1 meter
var n3 = iD.osmNode({id: 'n-3', loc: [22.42356, 0.001]});
var n4 = iD.osmNode({id: 'n-4', loc: [22.42356, -0.001]});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([22.42356, 0.001])});
var n4 = iD.osmNode({id: 'n-4', loc: new Extent([22.42356, -0.001])});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-3', 'n-4'], tags: { highway: 'residential' }});

context.perform(
Expand All @@ -32,8 +35,8 @@ describe('iD.validations.almost_junction', function () {

function horizontalTiltedCloserThanThd() {
// horizontal road
var n1 = iD.osmNode({id: 'n-1', loc: [22.42357, 0]});
var n2 = iD.osmNode({id: 'n-2', loc: [22.42367, 0]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([22.42357, 0])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([22.42367, 0])});
var w1 = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: { highway: 'residential' }});

context.perform(
Expand All @@ -43,8 +46,8 @@ describe('iD.validations.almost_junction', function () {
);

// tilted road to the west of w1 by 0.00001 longitude degree
var n3 = iD.osmNode({id: 'n-3', loc: [22.423555, 0.001]});
var n4 = iD.osmNode({id: 'n-4', loc: [22.423565, -0.001]});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([22.423555, 0.001])});
var n4 = iD.osmNode({id: 'n-4', loc: new Extent([22.423565, -0.001])});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-3', 'n-4'], tags: { highway: 'residential' }});

context.perform(
Expand All @@ -56,8 +59,8 @@ describe('iD.validations.almost_junction', function () {

function horizontalVertialFurtherThanThd() {
// horizontal road
var n1 = iD.osmNode({id: 'n-1', loc: [22.42357, 0]});
var n2 = iD.osmNode({id: 'n-2', loc: [22.42367, 0]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([22.42357, 0])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([22.42367, 0])});
var w1 = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: { highway: 'residential' }});

context.perform(
Expand All @@ -67,8 +70,8 @@ describe('iD.validations.almost_junction', function () {
);

// vertical road to the west of w1 by 0.00007 longitude degree
var n3 = iD.osmNode({id: 'n-3', loc: [22.42350, 0.001]});
var n4 = iD.osmNode({id: 'n-4', loc: [22.42350, -0.001]});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([22.42350, 0.001])});
var n4 = iD.osmNode({id: 'n-4', loc: new Extent([22.42350, -0.001])});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-3', 'n-4'], tags: { highway: 'residential' }});

context.perform(
Expand All @@ -80,8 +83,8 @@ describe('iD.validations.almost_junction', function () {

function twoHorizontalCloserThanThd() {
// horizontal road
var n1 = iD.osmNode({id: 'n-1', loc: [22.42357, 0]});
var n2 = iD.osmNode({id: 'n-2', loc: [22.42367, 0]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([22.42357, 0])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([22.42367, 0])});
var w1 = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: { highway: 'residential' }});

context.perform(
Expand All @@ -91,8 +94,8 @@ describe('iD.validations.almost_junction', function () {
);

// another horizontal road to the north of w1 by 0.0001 latitude degree
var n3 = iD.osmNode({id: 'n-3', loc: [22.42357, 0.00001]});
var n4 = iD.osmNode({id: 'n-4', loc: [22.42367, 0.00001]});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([22.42357, 0.00001])});
var n4 = iD.osmNode({id: 'n-4', loc: new Extent([22.42367, 0.00001])});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-3', 'n-4'], tags: { highway: 'residential' }});

context.perform(
Expand All @@ -104,8 +107,8 @@ describe('iD.validations.almost_junction', function () {

function horizontalVertialWithNoExit() {
// horizontal road
var n1 = iD.osmNode({id: 'n-1', loc: [22.42357, 0], tags: { noexit: 'yes' }});
var n2 = iD.osmNode({id: 'n-2', loc: [22.42367, 0]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([22.42357, 0]), tags: { noexit: 'yes' }});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([22.42367, 0])});
var w1 = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: { highway: 'residential' }});

context.perform(
Expand All @@ -115,8 +118,8 @@ describe('iD.validations.almost_junction', function () {
);

// vertical road to the west of w1 by 0.00001 longitude degree
var n3 = iD.osmNode({id: 'n-3', loc: [22.42356, 0.001]});
var n4 = iD.osmNode({id: 'n-4', loc: [22.42356, -0.001]});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([22.42356, 0.001])});
var n4 = iD.osmNode({id: 'n-4', loc: new Extent([22.42356, -0.001])});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-3', 'n-4'], tags: { highway: 'residential' }});

context.perform(
Expand All @@ -128,8 +131,8 @@ describe('iD.validations.almost_junction', function () {

function closeEndNodesSmallAngle() {
// Vertical path
var n1 = iD.osmNode({id: 'n-1', loc: [0.0003247, 22.4423866]});
var n2 = iD.osmNode({id: 'n-2', loc: [0.0003060, 22.4432671]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([0.0003247, 22.4423866])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([0.0003060, 22.4432671])});
var w1 = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: { highway: 'path' }});

context.perform(
Expand All @@ -139,8 +142,8 @@ describe('iD.validations.almost_junction', function () {
);

// Angled path with end node within 4.25m and change of angle <9°
var n3 = iD.osmNode({id: 'n-3', loc: [0.0003379, 22.4423861]});
var n4 = iD.osmNode({id: 'n-4', loc: [0.0004354, 22.4421312]});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([0.0003379, 22.4423861])});
var n4 = iD.osmNode({id: 'n-4', loc: new Extent([0.0004354, 22.4421312])});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-3', 'n-4'], tags: { highway: 'path' }});

context.perform(
Expand All @@ -163,8 +166,8 @@ describe('iD.validations.almost_junction', function () {
);

// Horizontal path with end node within 4.25m and change of angle >9°
var n3 = iD.osmNode({id: 'n-3', loc: [0.0000199, 22.4427801]});
var n4 = iD.osmNode({id: 'n-4', loc: [0.0002038, 22.4427801]});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([0.0000199, 22.4427801])});
var n4 = iD.osmNode({id: 'n-4', loc: new Extent([0.0002038, 22.4427801])});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-3', 'n-4'], tags: { highway: 'path' }});

context.perform(
Expand All @@ -178,9 +181,9 @@ describe('iD.validations.almost_junction', function () {
// Square path that ends within 4.25m of itself and change of angle <9°
var n1 = iD.osmNode({id: 'n-1', loc: [0, 22.4427453]});
var n2 = iD.osmNode({id: 'n-2', loc: [0, 22.4429811]});
var n3 = iD.osmNode({id: 'n-3', loc: [0.0001923, 22.4429811]});
var n4 = iD.osmNode({id: 'n-4', loc: [0.0001923, 22.4427523]});
var n5 = iD.osmNode({id: 'n-5', loc: [0.0000134, 22.4427523]});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([0.0001923, 22.4429811])});
var n4 = iD.osmNode({id: 'n-4', loc: new Extent([0.0001923, 22.4427523])});
var n5 = iD.osmNode({id: 'n-5', loc: new Extent([0.0000134, 22.4427523])});
var w1 = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2', 'n-3', 'n-4', 'n-5'], tags: { highway: 'path' }});

context.perform(
Expand All @@ -197,8 +200,8 @@ describe('iD.validations.almost_junction', function () {
// Square path with both endpoints near each other
var n1 = iD.osmNode({id: 'n-1', loc: [0, 22.4427453]});
var n2 = iD.osmNode({id: 'n-2', loc: [0, 22.4429810]});
var n3 = iD.osmNode({id: 'n-3', loc: [0.0000063, 22.4429810]});
var n4 = iD.osmNode({id: 'n-4', loc: [0.0000063, 22.4427483]});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([0.0000063, 22.4429810])});
var n4 = iD.osmNode({id: 'n-4', loc: new Extent([0.0000063, 22.4427483])});
var w1 = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2', 'n-3', 'n-4'], tags: { highway: 'path' }});

context.perform(
Expand All @@ -210,8 +213,8 @@ describe('iD.validations.almost_junction', function () {
);

// Horizontal path with end node within 4.25m and change of angle >9° (to both endpoints)
var n5 = iD.osmNode({id: 'n-5', loc: [0.0000124, 22.4427458]});
var n6 = iD.osmNode({id: 'n-6', loc: [0.0000445, 22.4427449]});
var n5 = iD.osmNode({id: 'n-5', loc: new Extent([0.0000124, 22.4427458])});
var n6 = iD.osmNode({id: 'n-6', loc: new Extent([0.0000445, 22.4427449])});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-5', 'n-6'], tags: { highway: 'path' }});

context.perform(
Expand Down
35 changes: 19 additions & 16 deletions test/spec/validations/crossing_ways.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const { Extent } = require('@id-sdk/extent');


describe('iD.validations.crossing_ways', function () {
var context;

Expand All @@ -6,8 +9,8 @@ describe('iD.validations.crossing_ways', function () {
});

function createWaysWithOneCrossingPoint(tags1, tags2) {
var n1 = iD.osmNode({id: 'n-1', loc: [1,1]});
var n2 = iD.osmNode({id: 'n-2', loc: [2,2]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([1,1])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([2,2])});
var w1 = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: tags1});

context.perform(
Expand All @@ -16,8 +19,8 @@ describe('iD.validations.crossing_ways', function () {
iD.actionAddEntity(w1)
);

var n3 = iD.osmNode({id: 'n-3', loc: [1,2]});
var n4 = iD.osmNode({id: 'n-4', loc: [2,1]});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([1,2])});
var n4 = iD.osmNode({id: 'n-4', loc: new Extent([2,1])});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-3', 'n-4'], tags: tags2});

context.perform(
Expand All @@ -28,8 +31,8 @@ describe('iD.validations.crossing_ways', function () {
}

function createWaysWithTwoCrossingPoint() {
var n1 = iD.osmNode({id: 'n-1', loc: [1,1]});
var n2 = iD.osmNode({id: 'n-2', loc: [3,3]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([1,1])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([3,3])});
var w1 = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: { highway: 'residential' }});

context.perform(
Expand All @@ -38,10 +41,10 @@ describe('iD.validations.crossing_ways', function () {
iD.actionAddEntity(w1)
);

var n3 = iD.osmNode({id: 'n-3', loc: [1,2]});
var n4 = iD.osmNode({id: 'n-4', loc: [2,1]});
var n5 = iD.osmNode({id: 'n-5', loc: [3,2]});
var n6 = iD.osmNode({id: 'n-6', loc: [2,3]});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([1,2])});
var n4 = iD.osmNode({id: 'n-4', loc: new Extent([2,1])});
var n5 = iD.osmNode({id: 'n-5', loc: new Extent([3,2])});
var n6 = iD.osmNode({id: 'n-6', loc: new Extent([2,3])});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-3', 'n-4', 'n-5', 'n-6'], tags: { highway: 'residential' }});

context.perform(
Expand Down Expand Up @@ -350,8 +353,8 @@ describe('iD.validations.crossing_ways', function () {
});

function createWayAndRelationWithOneCrossingPoint(wayTags, relTags) {
var n1 = iD.osmNode({id: 'n-1', loc: [1,1]});
var n2 = iD.osmNode({id: 'n-2', loc: [2,2]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([1,1])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([2,2])});
var w1 = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: wayTags});

context.perform(
Expand All @@ -360,10 +363,10 @@ describe('iD.validations.crossing_ways', function () {
iD.actionAddEntity(w1)
);

var n3 = iD.osmNode({id: 'n-3', loc: [1,2]});
var n4 = iD.osmNode({id: 'n-4', loc: [2,1]});
var n5 = iD.osmNode({id: 'n-5', loc: [3,2]});
var n6 = iD.osmNode({id: 'n-6', loc: [2,3]});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([1,2])});
var n4 = iD.osmNode({id: 'n-4', loc: new Extent([2,1])});
var n5 = iD.osmNode({id: 'n-5', loc: new Extent([3,2])});
var n6 = iD.osmNode({id: 'n-6', loc: new Extent([2,3])});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-3', 'n-4', 'n-5'], tags: {}});
var w3 = iD.osmWay({id: 'w-3', nodes: ['n-5', 'n-6', 'n-3'], tags: {}});
var r1 = iD.osmRelation({id: 'r-1', members: [{id: 'w-2', type: 'way'}, {id: 'w-3', type: 'way'}], tags: relTags});
Expand Down
19 changes: 11 additions & 8 deletions test/spec/validations/disconnected_way.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const { Extent } = require('@id-sdk/extent');


describe('iD.validations.disconnected_way', function () {
var context;

Expand All @@ -6,8 +9,8 @@ describe('iD.validations.disconnected_way', function () {
});

function createWay(tags) {
var n1 = iD.osmNode({id: 'n-1', loc: [4,4]});
var n2 = iD.osmNode({id: 'n-2', loc: [4,5]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([4,4])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([4,5])});
var w = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: tags});

context.perform(
Expand All @@ -18,9 +21,9 @@ describe('iD.validations.disconnected_way', function () {
}

function createConnectingWays(tags1, tags2) {
var n1 = iD.osmNode({id: 'n-1', loc: [4,4]});
var n2 = iD.osmNode({id: 'n-2', loc: [4,5]});
var n3 = iD.osmNode({id: 'n-3', loc: [5,5]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([4,4])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([4,5])});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([5,5])});
var w = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: tags1});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-1', 'n-3'], tags: tags2});

Expand Down Expand Up @@ -75,9 +78,9 @@ describe('iD.validations.disconnected_way', function () {

it('ignores highway with connected entrance vertex', function() {

var n1 = iD.osmNode({id: 'n-1', loc: [4,4], tags: {'entrance': 'yes'}});
var n2 = iD.osmNode({id: 'n-2', loc: [4,5]});
var n3 = iD.osmNode({id: 'n-3', loc: [5,5]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([4,4]), tags: {'entrance': 'yes'}});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([4,5])});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([5,5])});
var w = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2'], tags: {'highway': 'unclassified'}});
var w2 = iD.osmWay({id: 'w-2', nodes: ['n-1', 'n-3']});

Expand Down
9 changes: 6 additions & 3 deletions test/spec/validations/incompatible_source.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const { Extent } = require('@id-sdk/extent');


describe('iD.validations.incompatible_source', function () {
var context;

Expand All @@ -6,9 +9,9 @@ describe('iD.validations.incompatible_source', function () {
});

function createWay(tags) {
var n1 = iD.osmNode({id: 'n-1', loc: [4,4]});
var n2 = iD.osmNode({id: 'n-2', loc: [4,5]});
var n3 = iD.osmNode({id: 'n-3', loc: [5,5]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([4,4])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([4,5])});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([5,5])});
var w = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2', 'n-3'], tags: tags});

context.perform(
Expand Down
17 changes: 10 additions & 7 deletions test/spec/validations/mismatched_geometry.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const { Extent } = require('@id-sdk/extent');


describe('iD.validations.mismatched_geometry', function () {
var context, _savedAreaKeys;

Expand All @@ -12,16 +15,16 @@ describe('iD.validations.mismatched_geometry', function () {


function createPoint(tags) {
var n1 = iD.osmNode({id: 'n-1', loc: [4,4], tags: tags});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([4,4]), tags: tags});
context.perform(
iD.actionAddEntity(n1)
);
}

function createOpenWay(tags) {
var n1 = iD.osmNode({id: 'n-1', loc: [4,4]});
var n2 = iD.osmNode({id: 'n-2', loc: [4,5]});
var n3 = iD.osmNode({id: 'n-3', loc: [5,5]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([4,4])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([4,5])});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([5,5])});
var w = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2', 'n-3'], tags: tags});

context.perform(
Expand All @@ -33,9 +36,9 @@ describe('iD.validations.mismatched_geometry', function () {
}

function createClosedWay(tags) {
var n1 = iD.osmNode({id: 'n-1', loc: [4,4]});
var n2 = iD.osmNode({id: 'n-2', loc: [4,5]});
var n3 = iD.osmNode({id: 'n-3', loc: [5,5]});
var n1 = iD.osmNode({id: 'n-1', loc: new Extent([4,4])});
var n2 = iD.osmNode({id: 'n-2', loc: new Extent([4,5])});
var n3 = iD.osmNode({id: 'n-3', loc: new Extent([5,5])});
var w = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2', 'n-3', 'n-1'], tags: tags});

context.perform(
Expand Down
Loading

0 comments on commit 7ba89ce

Please sign in to comment.