Repository navigation
Expand file tree
/
Copy pathdata.json
More file actions
208 lines (190 loc) · 9.15 KB
/
Copy pathdata.json
File metadata and controls
208 lines (190 loc) · 9.15 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
---
---
{
"conformsTo": "https://project-open-data.cio.gov/v1.1/schema",
"dataset": [{%- for dataset in site.datasets -%}
{%- capture temp -%}
{% assign schema = dataset.schema | default: site.schema %}
{% assign dataset_fields = site.data.schemas[schema].dataset_fields %}
{% assign resource_fields = site.data.schemas[schema].resource_fields %}
{% assign licenses = site.data.licenses %}
{% assign f_title = dataset_fields | where: "datajson", "title" | first %}
{% assign title = dataset[f_title[field_name]] %}
{% assign identifier = dataset.url | remove_first: "/datasets/" | remove: "/" %}
{% assign f_publisher_name = dataset_fields | where: "datajson", "publisher.name" | first %}
{% assign publisher_name = dataset[f_publisher_name[field_name]] %}
{% assign f_license = dataset_fields | where: "datajson", "license" | first %}
{% assign license_name = dataset[f_license[field_name]] %}
{% assign license_model = licenses.items | find: "name", license_name %}
{% assign license_url = license_model.url %}
{% assign f_description = dataset_fields | where: "datajson", "description" | first %}
{% assign description = dataset[f_description[field_name]] %}
{% assign f_category = dataset_fields | where: "datajson", "category" | first %}
{% assign category = dataset[f_category[field_name]] %}
{% assign f_contact_point_fn = dataset_fields | where: "datajson", "contactPoint.fn" | first %}
{% assign contact_point_fn = dataset[f_contact_point_fn[field_name]] %}
{% assign f_contact_point_email = dataset_fields | where: "datajson", "contactPoint.hasEmail" | first %}
{% assign contact_point_email = dataset[f_contact_point_email[field_name]] %}
{% assign f_modified = dataset_fields | where: "datajson", "modified" | first %}
{% assign modified = dataset[f_modified[field_name]] %}
{% assign f_dist_title = resource_fields | where: "datajson", "distribution.title" | first %}
{% assign f_dist_download_url = resource_fields | where: "datajson", "distribution.downloadURL" | first %}
{% assign f_dist_format = resource_fields | where: "datajson", "distribution.format" | first %}
{%- endcapture -%}
{%- if contact_point_email contains '@' and contact_point_email != '' and contact_point_email != null -%}
{% assign is_email = true %}
{%- else -%}
{% assign is_email = false %}
{%- endif -%}
{%- if publisher_name == "City of Philadelphia" -%}
{%- if contact_point_fn == '' or contact_point_fn == null -%}
{% assign contact_point_fn = "City of Philadelphia Open Data Program" -%}
{%- endif -%}
{%- unless is_email -%}
{% assign contact_point_email = "maps@phila.gov" -%}
{%- endunless -%}
{%- else -%}
{%- if contact_point_fn == '' or contact_point_fn == null -%}
{% assign contact_point_fn = "OpenDataPhilly" -%}
{%- endif -%}
{%- unless is_email -%}
{% assign contact_point_email = "info@opendataphilly.org" -%}
{%- endunless -%}
{%- endif -%}
{%- if title -%}
{
"title": {{ title | jsonify }},
"identifier": {{ identifier | jsonify }},
"accessLevel": "public",
"publisher": {
"@type": "org:Organization",
"name": {{publisher_name | jsonify}}
},
{%- if description -%}
"description": {{ description | jsonify }},
{% endif %}
"modified": {{ modified | jsonify }},
"keyword":[
{%- for cat in dataset.categories -%}
{%- assign cat_split = cat | split: " / " -%}
{%- if cat_split.size > 1 -%}
{%- for cs in cat_split -%}
{{ cs | downcase | jsonify }}
{%- unless forloop.last -%},{%- endunless -%}
{%- endfor -%}
{%- else -%}
{{ cat | downcase | jsonify }}
{%- endif -%}
{%- unless forloop.last -%},{%- endunless -%}
{%- endfor -%}
{%- for tag in dataset.tags -%}
{%- if category and forloop.first -%},{%- endif -%}
{{ tag | jsonify }}{%- unless forloop.last -%},{%- endunless -%}
{%- endfor -%}
],
"contactPoint": {
"fn": {{ contact_point_fn | jsonify }},
"hasEmail": {{ contact_point_email | prepend: "mailto:" | jsonify }}
},
"license": {{ license_url | jsonify }},
{% if publisher_name == "City of Philadelphia" %}
"spatial":"Philadelphia, Pennsylvania",
{% endif %}
{% if dataset.resources %}
"distribution": [
{%- for distribution in dataset.resources -%}
{%- capture temp -%}
{% assign dist_title = distribution[f_dist_title[field_name]] -%}
{% assign dist_download_url = distribution[f_dist_download_url[field_name]] -%}
{% assign dist_format = distribution[f_dist_format[field_name]] -%}
{%- endcapture -%}
{%- assign access_flag = false -%}
{%- if dist_format -%}
{%- case dist_format | upcase -%}
{%- when "HTML", "APP", "APPLICATION" -%}
{% assign media_type = "text/html" -%}
{% assign access_flag = true -%}
{%- when "HTTP", "API" -%}
{% assign media_type = "application/http" -%}
{% assign access_flag = true -%}
{%- when "CSV" -%}
{% assign media_type = "text/csv" -%}
{%- when "XML" -%}
{% assign media_type = "application/xml" -%}
{%- when "RSS" -%}
{% assign media_type = "application/rss+xml" -%}
{%- when "KML" -%}
{% assign media_type = "application/vnd.google-earth.kml+xml" -%}
{%- when "KMZ" -%}
{% assign media_type = "application/vnd.google-earth.kmz" -%}
{%- when "JSON" -%}
{% assign media_type = "application/json" -%}
{%- when "GEOJSON" -%}
{% assign media_type = "application/geo+json" -%}
{%- when "GPKG","GEOPACKAGE" -%}
{% assign media_type = "application/geopackage+sqlite3" -%}
{%- when "PARQUET", "GEOPARQUET" -%}
{% assign media_type = "application/vnd.apache.parquet" -%}
{%- when "GTFS-RT" -%}
{% assign media_type = "application/octet-stream" -%}
{%- when "JPEG", "JPG" -%}
{% assign media_type = "image/jpeg" -%}
{%- when "TIFF", "TIF" -%}
{% assign media_type = "image/tiff" -%}
{%- when "PNG" -%}
{% assign media_type = "image/png" -%}
{%- when "IMG", "IMAGINE", "HFA" -%}
{% assign media_type = "application/x-erdas-hfa" -%}
{%- when "ECW" -%}
{% assign media_type = "application/x-raster-ecw" -%}
{%- when "SID","MRSID" -%}
{% assign media_type = "application/x-raster-mrsid" -%}
{%- when "LAS" -%}
{% assign media_type = "application/vnd.las" -%}
{%- when "SHP", "GDB", "ZIP", "GTFS" -%}
{% assign media_type = "application/zip" -%}
{%- when "PDF" -%}
{% assign media_type = "application/pdf" -%}
{%- when "XSLX" -%}
{% assign media_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" -%}
{%- when "DOCX" -%}
{% assign media_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document" -%}
{%- when "TXT" -%}
{% assign media_type = "text/plain" -%}
{%- else -%}
{% assign media_type = "application/octet-stream" -%}
{%- endcase -%}
{%- else -%}
{% assign media_type = "text/html" -%}
{% assign access_flag = true -%}
{%- endif # close dist_format conditional -%}
{% comment %}
PASDA references require a subsequent click to download
{% endcomment %}
{%- if dist_download_url contains "pasda" -%}
{% assign access_flag = true -%}
{%- endif -%}
{
{%- assign dist_download_url = dist_download_url | replace: " ", "%20" -%}
{%- assign dist_download_url = dist_download_url | replace: "|", "%7C" -%}
{%- assign dist_download_url = dist_download_url | replace: "*", "%2A" -%}
{%- assign dist_download_url = dist_download_url | replace: "<", "%3C" -%}
{%- assign dist_download_url = dist_download_url | replace: ">", "%3E" -%}
"title": {{ dist_title | jsonify }},
{%- if access_flag %}
"accessURL": {{ dist_download_url | jsonify }},
{%- else %}
"downloadURL": {{ dist_download_url | jsonify }},
{%- endif %}
"mediaType": {{media_type | jsonify}},
"format": {{ dist_format | upcase | jsonify }}
}
{% unless forloop.last -%},{%- endunless %}
{% endfor # close distribution loop %}
]
{% endif # close dataset.resources conditional %}
}{% unless forloop.last %},{% endunless %}
{% endif # close title conditional %}
{% endfor # close dataset loop %}
]
}