-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
215 lines (182 loc) · 5.67 KB
/
Makefile
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
209
210
211
212
213
214
215
GAZETTEERS := \
gazetteers/afghan-provinces.json \
gazetteers/algerian-provinces.json \
gazetteers/azerbaijani-districts.json \
gazetteers/beninese-departments.json \
gazetteers/bolivian-departments.json \
gazetteers/burkinabe-regions.json \
gazetteers/cities.json \
gazetteers/continents.json \
gazetteers/countries.json \
gazetteers/djiboutian-regions.json \
gazetteers/egyptian-governorates.json \
gazetteers/english-counties.json \
gazetteers/ethiopian-regions.json \
gazetteers/french-regions.json \
gazetteers/gambian-regions.json \
gazetteers/geographic-regions.json \
gazetteers/georgian-regions.json \
gazetteers/greek-regions.json \
gazetteers/guinean-regions.json \
gazetteers/historical.json \
gazetteers/indian-states.json \
gazetteers/indonesian-provinces.json \
gazetteers/iranian-provinces.json \
gazetteers/iraqi-governorates.json \
gazetteers/israeli-districts.json \
gazetteers/italian-regions.json \
gazetteers/jordanian-governorates.json \
gazetteers/kyrgyz-regions.json \
gazetteers/kuwaiti-governorates.json \
gazetteers/laotian-provinces.json \
gazetteers/lebanese-governorates.json \
gazetteers/libyan-districts.json \
gazetteers/malaysian-states.json \
gazetteers/myanma-states.json \
gazetteers/nigerian-states.json \
gazetteers/nigerien-regions.json \
gazetteers/omani-governorates.json \
gazetteers/other-regions.json \
gazetteers/pakistani-provinces.json \
gazetteers/philippine-regions.json \
gazetteers/romanian-counties.json \
gazetteers/russian-federal-subjects.json \
gazetteers/saudi-arabian-provinces.json \
gazetteers/spanish-communities.json \
gazetteers/subregions.json \
gazetteers/sudanese-states.json \
gazetteers/syrian-governorates.json \
gazetteers/tajikistani-regions.json \
gazetteers/thai-provinces.json \
gazetteers/turkish-provinces.json \
gazetteers/turkmen-regions.json \
gazetteers/ukrainian-oblasts.json \
gazetteers/us-states.json \
gazetteers/uzbek-regions.json \
gazetteers/vietnamese-provinces.json \
gazetteers/yemeni-governorates.json
NM := ./node_modules/.bin/
ne/%.zip:
mkdir -p ne
curl -s -L $(shell node js/natural-earth-url.js $@) > $@
ne/%.shp: ne/%.zip
unzip -q -d ne $< $*.shp
ne/%.shx: ne/%.zip
unzip -q -d ne $< $*.shx
ne/%.dbf: ne/%.zip
unzip -q -d ne $< $*.dbf
ne/%.prj: ne/%.zip
unzip -q -d ne $< $*.prj
ne/%.json: ne/%.shp ne/%.shx ne/%.dbf ne/%.prj
ogr2ogr -f GeoJSON \
-t_srs EPSG:4326 \
-lco COORDINATE_PRECISION=6 \
$@ $<
# Prioritize lower resolutions over higher resolutions at each
# resolution, and prioritize map units over countries. This avoids
# weird hulls due to distant colonies or far offshore islands.
geometries/admin-0.json: \
jq/admin-0.jq \
ne/ne_10m_admin_0_countries.json \
ne/ne_10m_admin_0_map_units.json \
ne/ne_50m_admin_0_countries.json \
ne/ne_50m_admin_0_map_units.json \
ne/ne_110m_admin_0_countries.json \
ne/ne_110m_admin_0_map_units.json
mkdir -p geometries
jq -s -f $^ > $@
geometries/scale-rank-0.json: \
jq/scale-rank-0.jq \
ne/ne_10m_geography_regions_polys.json
mkdir -p geometries
jq -f $^ > $@
geometries/scale-ranks-1-5.json: \
jq/scale-ranks-1-5.jq \
ne/ne_10m_geography_regions_polys.json
mkdir -p geometries
jq -f $^ > $@
geometries/urban-areas.json: \
jq/urban-areas.jq \
ne/ne_10m_urban_areas_landscan.json
mkdir -p geometries
jq -f $^ > $@
geometries/10m-admin-0.json: \
jq/admin-0.jq \
ne/ne_10m_admin_0_countries.json \
ne/ne_10m_admin_0_map_units.json
jq -s -f $^ > $@
geometries/western-russia.json: \
jq/western-russia.jq \
ne/ne_10m_admin_0_scale_rank.json
mkdir -p geometries
jq -f $^ \
| $(NM)/geojson-clipping union \
| jq '{"Western Russia":{geometry}}' > $@
geometries/admin-0-and-western-russia.json: \
geometries/10m-admin-0.json \
geometries/western-russia.json
jq -s '.[0] * .[1]' $^ > $@
geometries/subregions.json: \
place-ids/subregions.json \
geometries/admin-0-and-western-russia.json
jq -r keys[] $< | ./sh/places.sh $^ | jq -s add > $@
geometries/cities.json: \
place-ids/cities.json \
geometries/urban-areas.json
jq -r keys[] $< | ./sh/places.sh $^ | jq -s add > $@
geometries/continents.json: \
place-ids/continents.json \
geometries/scale-rank-0.json
jq -r keys[] $< | ./sh/places.sh $^ | jq -s add > $@
geometries/geographic-regions.json: \
place-ids/geographic-regions.json \
geometries/scale-ranks-1-5.json
jq -r keys[] $< | ./sh/places.sh $^ | jq -s add > $@
geometries/countries.json: \
jq/countries.jq \
geometries/admin-0.json
jq -f $^ > $@
geometries/us-territories.json: \
jq/us-territories.jq \
geometries/admin-0.json
jq -f $^ > $@
geometries/us-states.json: \
geometries/us-admin-1.json \
geometries/us-territories.json
jq -s '.[0] * .[1]' $^ > $@
geometries/romanian-counties.json: place-ids/romanian-counties.json
geometries/historical.json: place-ids/historical.json
geometries/other-regions.json: place-ids/other-regions.json
geometries/romanian-counties.json geometries/historical.json geometries/other-regions.json:
mkdir -p geometries
cat $< > $@
geometries/%-admin-1.json: \
jq/%-admin-1.jq \
ne/ne_10m_admin_1_states_provinces.json
mkdir -p geometries
jq -f $^ > $@
.SECONDEXPANSION:
geometries/%.json: \
place-ids/%.json \
geometries/$$(firstword $$(subst -, ,$$*))-admin-1.json
jq -r keys[] $< | ./sh/places.sh $^ | jq -s add > $@
gazetteers/%.json: geometries/%.json
mkdir -p gazetteers
node js/build-gazetteer.js $< $* > $@
.PHONY: all stage deploy check clean superclean
all: $(GAZETTEERS)
stage: all
./sh/stage.sh
deploy: all
./sh/deploy.sh
check: $(GAZETTEERS)
curl -L -s https://data.perio.do/d.json \
| jq -r -f jq/periodo-place-ids.jq \
| sort | uniq \
| node js/check-gazetteers.js $^
clean:
rm -rf \
geometries \
gazetteers
superclean: clean
rm -rf ne