-
Notifications
You must be signed in to change notification settings - Fork 0
/
collections.rb
152 lines (140 loc) · 4.59 KB
/
collections.rb
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
require './etl'
source = 'https://data.seattle.gov/resource/dk8m-pdjf?'+
'$limit=100&'+
'$order=date_case_created+DESC&'+
'$where=longitude+IS+NOT+NULL+AND+'+
'latitude+IS+NOT+NULL'
ETL.register('/seattle-code-violation-cases', source) do |collection|
features = collection.map do |item|
title = "[#{item['case_type']} - #{item['case_group']}] #{item['status']} @ #{item['address']}"
{
'id' => item['case_number'],
'type' => 'Feature',
'geometry' => {
'type' => 'Point',
'coordinates' => [
item['longitude'].to_f,
item['latitude'].to_f
]
},
'properties' => item.merge('title' => title)
}
end
{'type' => 'FeatureCollection', 'features' => features}
end
source = 'https://data.seattle.gov/resource/mags-97de?'+
'$limit=100&'+
'$order=application_date+DESC&'+
'$where=longitude+IS+NOT+NULL+AND+'+
'latitude+IS+NOT+NULL+AND+'+
'application_permit_number+IS+NOT+NULL'
ETL.register('/seattle-building-permits', source) do |collection|
features = collection.map do |item|
title = "[#{item['permit_type']} - #{item['category']}] #{item['status']} @ #{item['address']}"
{
'id' => item['application_permit_number'],
'type' => 'Feature',
'geometry' => {
'type' => 'Point',
'coordinates' => [
item['longitude'].to_f,
item['latitude'].to_f
]
},
'properties' => item.merge('title' => title)
}
end
{'type' => 'FeatureCollection', 'features' => features}
end
source = 'https://data.seattle.gov/resource/kzjm-xkqj?'+
'$limit=100&'+
'$order=datetime+DESC&'+
'$where=longitude+IS+NOT+NULL+AND+'+
'latitude+IS+NOT+NULL+AND+'+
'incident_number+IS+NOT+NULL+AND+'+
'datetime+IS+NOT+NULL'
ETL.register('/seattle-911-fire-calls', source) do |collection|
features = collection.map do |item|
title = "[911 Fire Call] #{item['type']} @ #{item['address']}"
{
'id' => item['incident_number'],
'type' => 'Feature',
'geometry' => {
'type' => 'Point',
'coordinates' => [
item['longitude'].to_f,
item['latitude'].to_f
]
},
'properties' => item.merge('title' => title, 'datetime' => Time.at(item['datetime']).iso8601)
}
end
{'type' => 'FeatureCollection', 'features' => features}
end
source = 'http://data.cityofnewyork.us/resource/jrsc-cabt?'+
'$limit=100&$order=created_date+DESC&'+
'$where=longitude+IS+NOT+NULL+AND+'+
'incident_address+IS+NOT+NULL+AND+'+
'descriptor+IS+NOT+NULL'
ETL.register('/nyc-311-restaurant-data', source) do |collection|
features = collection.map do |item|
title = "[#{item['incident_address']}] #{item['descriptor']}"
{
'id' => item['unique_key'],
'type' => 'Feature',
'geometry' => {
'type' => 'Point',
'coordinates' => [
item['location']['longitude'].to_f,
item['location']['latitude'].to_f
]
},
'properties' => item.merge('title' => title)
}
end
{'type' => 'FeatureCollection', 'features' => features}
end
source = 'https://data.cityofchicago.org/resource/r5kz-chrr?'+
'$limit=100&'+
'$order=date_issued+DESC&'+
'$where=longitude+IS+NOT+NULL'
ETL.register('/chi-new-biz-licenses', source) do |collection|
features = collection.map do |item|
title = "[#{item['license_description']}] #{item['legal_name']}"
{
'id' => item['id'],
'type' => 'Feature',
'geometry' => {
'type' => 'Point',
'coordinates' => [
item['location']['longitude'].to_f,
item['location']['latitude'].to_f
]
},
'properties' => item.merge('title' => title)
}
end
{'type' => 'FeatureCollection', 'features' => features}
end
source = 'https://data.sfgov.org/resource/vw6y-z8j6?'+
'$limit=100&'+
'$order=opened+DESC&'+
'$where=opened+IS+NOT+NULL'
ETL.register('/sf-311-cases', source) do |collection|
features = collection.map do |item|
title = "[#{item['request_type']}] #{item['request_details']}"
{
'id' => item['case_id'],
'type' => 'Feature',
'geometry' => {
'type' => 'Point',
'coordinates' => [
item['point']['longitude'].to_f,
item['point']['latitude'].to_f
]
},
'properties' => item.merge('title' => title)
}
end
{'type' => 'FeatureCollection', 'features' => features}
end