forked from TerriaJS/aremi-natmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
old2new_init.jq
76 lines (68 loc) · 1.82 KB
/
old2new_init.jq
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
#
# This little filter is for the 'jq' command line tool, and turns pre-refactor
# init_*.json files into the post-refactor style JSON.
#
# It's a work in progress, and only really deals with the AREMI specific data,
# but may be useful as a base for extension.
#
# To do the conversion, run something like the following command line:
#
# cat public/init_aremi.json | jq -f old2new_init.jq | grep -v '"legendUrl": null,' > output.json
#
{
corsDomains : [
"data.gov.au",
"ga.gov.au",
"corsproxy.com",
"programs.communications.gov.au"
],
camera: {
"west": 105,
"south": -45,
"east": 155,
"north": -5
},
services: [],
catalog: [
# for each major catalog
.Layer[] | {
name: .name,
type: "group",
items: [
# for each category
.Layer[] | {
name: .name,
type: "group",
items: [
# for each layer in this category
.Layer[] | {
name: .Title,
layers: .Name,
description: .description,
# can't figure out a way of only printing legendUrl only when one
# is present, so we just grep out '"legendUrl": null,' in post
legendUrl: .legendUrl,
# this is what we want to do but isn't valid syntax
#(if (.legendUrl | length) > 0 then
# legendUrl: .legendUrl,
#end)
dataCustodian: .dataCustodian,
url: .base_url,
type: (if .type == "WMS" then
"wms"
else
.type
end),
rectangle: .BoundingBox | [
.west,
.south,
.east,
.north
]
}
]
}
]
}
]
}