-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathtest.py
133 lines (118 loc) · 6.74 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 11 14:59:36 2019
@author: jhm
"""
from OSMParser.testing import _test_nodes, TestEntity
def test_simple3Way2LaneTCrossing():
nodes = [TestEntity(1,None,lon=1, lat=1, nodes=0),
TestEntity(2,None,lon=1, lat=2, nodes=0),
TestEntity(3,None,lon=2, lat=2, nodes=0),
TestEntity(4,None,lon=0, lat=2, nodes=0)]
ways = [TestEntity(1,{"highway":"residential","lanes":"2","turn:lanes:forward":"through"}, nodes=[1,2]),
TestEntity(2,{"highway":"residential","lanes":"2","turn:lanes:forward":"through"}, nodes=[2,3]),
TestEntity(3,{"highway":"residential","lanes":"2","turn:lanes:forward":"through"}, nodes=[2,4])]
_test_nodes(nodes, ways)
def test_simple3WayoneWayLaneTCrossing():
nodes = [TestEntity(1,None,lon=1, lat=1, nodes=0),
TestEntity(2,None,lon=1, lat=2, nodes=0),
TestEntity(3,None,lon=2, lat=2, nodes=0),
TestEntity(4,None,lon=0, lat=2, nodes=0)]
ways = [TestEntity(1,{"highway":"residential","lanes":"2","oneway":"yes"}, nodes=[1,2]),
TestEntity(2,{"highway":"residential","lanes":"2","turn:lanes:forward":"through"}, nodes=[2,3]),
TestEntity(3,{"highway":"residential","lanes":"2","turn:lanes:forward":"through"}, nodes=[2,4])]
_test_nodes(nodes, ways)
def test_simple3WayoneWayLaneTCrossingOpposite():
nodes = [TestEntity(1,None,lon=1, lat=1, nodes=0),
TestEntity(2,None,lon=1, lat=2, nodes=0),
TestEntity(3,None,lon=2, lat=2, nodes=0),
TestEntity(4,None,lon=0, lat=2, nodes=0)]
ways = [TestEntity(1,{"highway":"residential","lanes":"2","oneway":"yes"}, nodes=[2,1]),
TestEntity(2,{"highway":"residential","lanes":"2","turn:lanes:forward":"through"}, nodes=[2,3]),
TestEntity(3,{"highway":"residential","lanes":"2","turn:lanes:forward":"through"}, nodes=[2,4])]
_test_nodes(nodes, ways)
def test_merge2to3():
nodes = [TestEntity(1,None,lon=1, lat=1, nodes=0),
TestEntity(2,None,lon=1, lat=2, nodes=0),
TestEntity(3,None,lon=2, lat=2, nodes=0)]
ways = [TestEntity(1,{"highway":"residential","lanes":"3","lanes:forward":"2"}, nodes=[1,2]),
TestEntity(2,{"highway":"residential","lanes":"4","lanes:forward":"3"}, nodes=[2,3])]
_test_nodes(nodes, ways)
def test_merge3to2():
nodes = [TestEntity(1,None,lon=1, lat=1, nodes=0),
TestEntity(2,None,lon=1, lat=2, nodes=0),
TestEntity(3,None,lon=2, lat=2, nodes=0)]
ways = [TestEntity(1,{"highway":"residential","lanes":"4","lanes:forward":"3"}, nodes=[1,2]),
TestEntity(2,{"highway":"residential","lanes":"3","lanes:forward":"2"}, nodes=[2,3])]
_test_nodes(nodes, ways)
def test_simple3WayoneWayLaneTCrossing2():
nodes = [TestEntity(1,None,lon=1, lat=1, nodes=0),
TestEntity(2,None,lon=1, lat=1.001, nodes=0),
TestEntity(3,None,lon=1.001, lat=1.001, nodes=0),
TestEntity(4,None,lon=0.99, lat=1.001, nodes=0)]
ways = [TestEntity(1,{"highway":"residential","lanes":"2","oneway":"yes"}, nodes=[1,2]),
TestEntity(2,{"highway":"residential","lanes":"2","turn:lanes:forward":"through"}, nodes=[2,3]),
TestEntity(3,{"highway":"residential","lanes":"2","turn:lanes:forward":"through"}, nodes=[2,4])]
_test_nodes(nodes, ways)
def test_3WayTCrossing2():
nodes = [TestEntity(1,None,lon=1, lat=1, nodes=0),
TestEntity(2,None,lon=1, lat=1.001, nodes=0),
TestEntity(3,None,lon=1.001, lat=1.001, nodes=0),
TestEntity(4,None,lon=0.999, lat=1.001, nodes=0)]
ways = [TestEntity(1,{"highway":"residential","lanes":"3", "lanes:forward":"2", "lanes:backward":"1","oneway":"no"}, nodes=[1,2]),
TestEntity(2,{"highway":"residential","lanes":"3", "lanes:forward":"2", "lanes:backward":"1","oneway":"no"}, nodes=[2,3]),
TestEntity(3,{"highway":"residential","lanes":"3", "lanes:forward":"2", "lanes:backward":"1","oneway":"no"}, nodes=[2,4])]
_test_nodes(nodes, ways)
def test_2WayTCrossing():
nodes = [TestEntity(1,None,lon=1, lat=1, nodes=0),
TestEntity(2,None,lon=1, lat=1.001, nodes=0),
TestEntity(3,None,lon=1.001, lat=1.001, nodes=0)
]
ways = [TestEntity(1,{"highway":"residential","lanes":"5", "lanes:forward":"3", "lanes:backward":"2","oneway":"no"}, nodes=[1,2]),
TestEntity(2,{"highway":"residential","lanes":"5", "lanes:forward":"2", "lanes:backward":"3","oneway":"no"}, nodes=[3,2])
]
_test_nodes(nodes, ways)
def test_2WayTCrossing2():
nodes = [TestEntity(1,None,lon=1, lat=1, nodes=0),
TestEntity(2,None,lon=1, lat=1.001, nodes=0),
TestEntity(3,None,lon=1.001, lat=1.001, nodes=0)
]
ways = [TestEntity(1,{"highway":"residential","lanes":"5", "lanes:forward":"3", "lanes:backward":"2","oneway":"no"}, nodes=[1,2]),
TestEntity(2,{"highway":"residential","lanes":"5", "lanes:forward":"3", "lanes:backward":"2","oneway":"no"}, nodes=[2,3])
]
_test_nodes(nodes, ways)
def test_2WayTCrossing3():
nodes = [TestEntity(1,None,lon=1, lat=1, nodes=0),
TestEntity(2,None,lon=1, lat=1.001, nodes=0),
TestEntity(3,None,lon=1.001, lat=1.001, nodes=0)
]
ways = [TestEntity(1,{"highway":"residential","lanes":"5", "lanes:forward":"2", "lanes:backward":"3","oneway":"no"}, nodes=[2,1]),
TestEntity(2,{"highway":"residential","lanes":"5", "lanes:forward":"3", "lanes:backward":"2","oneway":"no"}, nodes=[2,3])
]
_test_nodes(nodes, ways)
def test_2WayTCrossing4():
nodes = [TestEntity(1,None,lon=1, lat=1, nodes=0),
TestEntity(2,None,lon=1, lat=1.001, nodes=0),
TestEntity(3,None,lon=1.001, lat=1.001, nodes=0)
]
ways = [TestEntity(1,{"highway":"residential","lanes":"5", "lanes:forward":"2", "lanes:backward":"3","oneway":"no"}, nodes=[1,2]),
TestEntity(2,{"highway":"residential","lanes":"5", "lanes:forward":"3", "lanes:backward":"2","oneway":"no"}, nodes=[3,2])
]
_test_nodes(nodes, ways)
def testSimpleRoad():
nodes = [TestEntity(1,None,lon=1, lat=1, nodes=0),
TestEntity(2,None,lon=1, lat=1.001, nodes=0),
TestEntity(3,None,lon=1.001, lat=1.002, nodes=0),
TestEntity(4,None,lon=1.001, lat=1.003, nodes=0)
]
ways = [TestEntity(1,{"highway":"residential","lanes":"5", "lanes:forward":"3", "lanes:backward":"2","oneway":"no"}, nodes=[1,2,3,4])]
_test_nodes(nodes, ways)
test_2WayTCrossing2()
test_2WayTCrossing4()
test_2WayTCrossing2()
test_2WayTCrossing3()
test_3WayTCrossing2()
test_simple3WayoneWayLaneTCrossing2()
test_merge3to2()
test_simple3WayoneWayLaneTCrossing()