-
Notifications
You must be signed in to change notification settings - Fork 8
/
sotm_presentation.sql
157 lines (137 loc) · 7.43 KB
/
sotm_presentation.sql
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
select
--w_version,
sum(subquery.navigable_geometry_count) navigable_geometry_count ,
sum(subquery.navigable_geometry_lenght) navigable_geometry_lenght,
sum(subquery.tn_user_count) tn_user_count ,
sum(subquery.tn_user_length) tn_user_length ,
sum(subquery.name_count) name_count,
sum(subquery.tn_name_count) tn_name_count,
sum(subquery.name_lenght_meters) name_lenght_meters,
sum(subquery.tn_name_lenght_km) tn_name_lenght_km,
sum(subquery.oneway_count)oneway_count ,
sum(subquery.tn_oneway_count)tn_oneway_count ,
sum(subquery.oneway_lenght_meters)oneway_lenght_meters ,
sum(subquery.tn_oneway_lenght_km)tn_oneway_lenght_km ,
sum(subquery.sighpost_count)sighpost_count ,
sum(subquery.tn_sighpost_count)tn_sighpost_count
from
(
SELECT
w.version w_version,
-- Road Geometry START
(CASE WHEN w.tags->'highway' is not null THEN 1
ELSE 0
END )navigable_geometry_count -- THis will count the name occurences.
,
(CASE WHEN w.tags->'highway' is not null THEN (st_length(linestring::geography)/1000)
ELSE 0
END )navigable_geometry_lenght -- THis will count the name occurences.
,
-- Road Geometry END
-- Road Name START
(CASE WHEN w.tags->'name' is not null THEN 1
ELSE 0
END )name_count -- THis will count the name occurences.
,
(CASE WHEN w.tags->'name' is not null and
(user_id = '2855302' or user_id = '2944689' or user_id = '2929338' or user_id = '2959379' or user_id = '3277198' or user_id = '4355402' or user_id = '4433679' or user_id = '4437318' or user_id = '4930407' or user_id = '4973384' or user_id = '4667454' or user_id = '4827180' or user_id = '4667606' or user_id = '4827272' or user_id = '4870032' or user_id = '4827171' or user_id = '4940486' or user_id = '5188736' or user_id = '5270261' or user_id = '5351387' or user_id = '5245700' or user_id = '5074211' or user_id = '4832980' or user_id = '4972028' or user_id = '5607966' or user_id = '5663000' or user_id = '5478253' )
THEN 1
ELSE 0
END ) tn_name_count
,
(CASE WHEN w.tags->'name' is not null THEN (st_length(linestring::geography)/1000)
ELSE 0
END ) name_lenght_meters -- THis will count the name lenght.
,
(CASE WHEN w.tags->'name' is not null and
(user_id = '2855302' or user_id = '2944689' or user_id = '2929338' or user_id = '2959379' or user_id = '3277198' or user_id = '4355402' or user_id = '4433679' or user_id = '4437318' or user_id = '4930407' or user_id = '4973384' or user_id = '4667454' or user_id = '4827180' or user_id = '4667606' or user_id = '4827272' or user_id = '4870032' or user_id = '4827171' or user_id = '4940486' or user_id = '5188736' or user_id = '5270261' or user_id = '5351387' or user_id = '5245700' or user_id = '5074211' or user_id = '4832980' or user_id = '4972028' or user_id = '5607966' or user_id = '5663000' or user_id = '5478253' )
THEN (st_length(linestring::geography)/1000)
ELSE 0
END ) tn_name_lenght_km
,
-- Road Name END
-- Road Oneway START
(CASE WHEN w.tags->'oneway' = 'yes' THEN 1
ELSE 0
END ) oneway_count -- THis will count the oneway
,
(CASE WHEN w.tags->'oneway' = 'yes' and
(user_id = '2855302' or user_id = '2944689' or user_id = '2929338' or user_id = '2959379' or user_id = '3277198' or user_id = '4355402' or user_id = '4433679' or user_id = '4437318' or user_id = '4930407' or user_id = '4973384' or user_id = '4667454' or user_id = '4827180' or user_id = '4667606' or user_id = '4827272' or user_id = '4870032' or user_id = '4827171' or user_id = '4940486' or user_id = '5188736' or user_id = '5270261' or user_id = '5351387' or user_id = '5245700' or user_id = '5074211' or user_id = '4832980' or user_id = '4972028' or user_id = '5607966' or user_id = '5663000' or user_id = '5478253' )
THEN 1
ELSE 0
END ) tn_oneway_count
,
(CASE WHEN w.tags->'oneway' = 'yes' and
(user_id = '2855302' or user_id = '2944689' or user_id = '2929338' or user_id = '2959379' or user_id = '3277198' or user_id = '4355402' or user_id = '4433679' or user_id = '4437318' or user_id = '4930407' or user_id = '4973384' or user_id = '4667454' or user_id = '4827180' or user_id = '4667606' or user_id = '4827272' or user_id = '4870032' or user_id = '4827171' or user_id = '4940486' or user_id = '5188736' or user_id = '5270261' or user_id = '5351387' or user_id = '5245700' or user_id = '5074211' or user_id = '4832980' or user_id = '4972028' or user_id = '5607966' or user_id = '5663000' or user_id = '5478253' )
THEN (st_length(linestring::geography)/1000)
ELSE 0
END ) tn_oneway_lenght_km
,
(CASE WHEN w.tags->'oneway' = 'yes' THEN (st_length(linestring::geography)/1000)
ELSE 0
END ) oneway_lenght_meters -- This will measure the oneway lenght.
-- Road Oneway END
-- Road Signpost START
,
(CASE WHEN w.tags->'destination' is not null THEN 1
ELSE 0
END ) sighpost_count -- THis will count the oneway
,
(CASE WHEN w.tags->'destination' is not null and
(user_id = '2855302' or user_id = '2944689' or user_id = '2929338' or user_id = '2959379' or user_id = '3277198' or user_id = '4355402' or user_id = '4433679' or user_id = '4437318' or user_id = '4930407' or user_id = '4973384' or user_id = '4667454' or user_id = '4827180' or user_id = '4667606' or user_id = '4827272' or user_id = '4870032' or user_id = '4827171' or user_id = '4940486' or user_id = '5188736' or user_id = '5270261' or user_id = '5351387' or user_id = '5245700' or user_id = '5074211' or user_id = '4832980' or user_id = '4972028' or user_id = '5607966' or user_id = '5663000' or user_id = '5478253' )
THEN (st_length(linestring::geography)/1000)
ELSE 0
END ) tn_sighpost_count
,
(CASE WHEN w.tags->'destination' = 'yes' THEN (st_length(linestring::geography)/1000)
ELSE 0
END ) signpost_lenght_meters -- This will measure the oneway lenght.
,
(CASE WHEN
user_id = '2855302' or user_id = '2944689' or user_id = '2929338' or user_id = '2959379' or user_id = '3277198' or user_id = '4355402' or user_id = '4433679' or user_id = '4437318' or user_id = '4930407' or user_id = '4973384' or user_id = '4667454' or user_id = '4827180' or user_id = '4667606' or user_id = '4827272' or user_id = '4870032' or user_id = '4827171' or user_id = '4940486' or user_id = '5188736' or user_id = '5270261' or user_id = '5351387' or user_id = '5245700' or user_id = '5074211' or user_id = '4832980' or user_id = '4972028' or user_id = '5607966' or user_id = '5663000' or user_id = '5478253'
THEN (st_length(linestring::geography)/1000)
ELSE 0
END ) tn_user_length
,
(CASE WHEN
user_id = '2855302'
or user_id = '2944689'
or user_id = '2929338'
or user_id = '2959379'
or user_id = '3277198'
or user_id = '4355402'
or user_id = '4433679'
or user_id = '4437318'
or user_id = '4930407'
or user_id = '4973384'
or user_id = '4667454'
or user_id = '4827180'
or user_id = '4667606'
or user_id = '4827272'
or user_id = '4870032'
or user_id = '4827171'
or user_id = '4940486'
or user_id = '5188736'
or user_id = '5270261'
or user_id = '5351387'
or user_id = '5245700'
or user_id = '5074211'
or user_id = '4832980'
or user_id = '4972028'
or user_id = '5607966'
or user_id = '5663000'
or user_id = '5478253'
THEN 1
ELSE 0
END ) tn_user_count
,
*
from ways w
where w.tstamp > '2016-01-01'
and w.tags->'highway' is not null
--and user_id = '2959379'
--limit 5000
) subquery
--group by w_version
--order by w_version asc
--Separate query to extract linestring for each of the following map features :