-
Notifications
You must be signed in to change notification settings - Fork 3
/
run
executable file
·188 lines (171 loc) · 24 KB
/
run
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
#!/bin/bash
rm -rvf world
install() {
npm install -g d3-dsv d3-geo-projection ndjson-cli shapefile topojson@3
}
world_shp() {
mkdir -p build
curl -z build/ne_$1_admin_0_countries.zip -o build/ne_$1_admin_0_countries.zip https://naciscdn.org/naturalearth/$1/cultural/ne_$1_admin_0_countries.zip
# curl -z build/ne_$1_admin_0_countries.zip -o build/ne_$1_admin_0_countries.zip "http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip?version=2.0.0"
unzip -od build build/ne_$1_admin_0_countries.zip
chmod a-x build/ne_$1_admin_0_countries.*
}
worldfix() {
world_shp $1
mkdir -p world
shp2json --encoding utf-8 build/ne_$1_admin_0_countries.shp > build/ne_$1_admin_0_countries.geojson
ndjson-split 'd.features' < build/ne_$1_admin_0_countries.geojson \
| ndjson-map 'Object.keys(d.properties).forEach(function(PROP) {
var prop = PROP.toLowerCase();
if (prop !== PROP) {
d.properties[prop] = d.properties[PROP];
delete d.properties[PROP];
}
}), d' \
| ndjson-map 'c = {"Norway":"578","N. Cyprus":"-1","Kosovo":"-2","Somaliland":"-3"}, i = d.properties.iso_n3, d.id = i === "-99" ? c[d.properties.name] : i, d' \
| ndjson-map 'JSON.parse(JSON.stringify(d)
// "fix Surinam / Fr. Guyane"
//.replace(/\[-54.524\d+,2.311\d+\],\[-54.271\d+,2.738\d+\],\[-54.184\d+,3.194\d+\],\[-54.011\d+,3.622\d+\],\[-54.399\d+,4.212\d+\]/,"[-54.524754197799716,2.3118488631237852],[-54.2697051662232,2.7323916691150463],[-54.181726040246275,3.1897797713304215],[-54.00693050801901,3.6200377465925584],[-54.399542202356514,4.212611395683467]")
// "fix Sudan’s partition tripoints"
//.replace(/\[33.9609\d+,9.58384\d+\]/g,"[33.9609,9.58384]")
//.replace(/\[33\.97\d+,8\.68\d+\],\[33\.96\d+,9\.58\d+\],/g,"")
//.replace(/(\[23\.80\d+,8\.66\d+\]),(\[24\.567\d+,8\.229\d+\])/,"$1,[23.88698,8.61973],$2")
// "fix Tanzania / DRC"
//.replace(/\[29.620\d+,-6.520\d+]/,"[29.62,-6.52]")
// "anchor points for Puntland, in Ethiopia and Somalia"
//.replace(/(\[46\.9\d+,7\.9\d+\],\[47\.7\d+,8\.0\d+\])/,"$1,[47.4, 7.6]")
//.replace(/(\[44\.9\d+,5\.\d+\]),(\[47\.7\d+,8\.0\d+\])/,"$1,[47.4, 7.6],$2")
//.replace(/(\[50\.07\d+,8\.08\d+\])/,"$1,[49.81, 7.6]")
// "fix Egypt/Gaza"
.replace(/(\[33\.77\d+,30\.96\d+\])/g,"$1,[34.20,31.28]")
.replace(/\[34\.55\d+,31\.5\d+\]/g,"[34.65,31.40]")
.replace(/\[34\.26\d+,31\.2[12]\d+\]/g,"[34.34,31.03]")
// "fix tripoint Egypt/Israel/Jordan"
.replace(/\[34\.9226\d+,29\.5013[23]\d+\]/g,"[34.9226,29.50133]")
)' \
| ndjson-map 'd.properties.fill = ["#ff0000","#ff4d00","#ff9900","#ffe600","#ccff00","#80ff00","#33ff00","#00ff19","#00ff66","#00ffb3","#00ffff","#00b2ff","#0066ff","#001aff","#3300ff","#8000ff","#cc00ff","#ff00e6","#ff0099","#ff004d"][Math.random()*20|0],d' \
| ndjson-map '
// "fix Sudan+CAF tripoint"
[d].forEach(d => {
// SDN: remove C ; CAF: add B before C
const B = [23.886979580860668,8.619729712933065], C = [24.567, 8.229];
if (d.properties.adm0_a3 === "SDN") {
const remove = C;
var geom = d.geometry.coordinates[0].slice(0,-1).filter(p => {
return !(Math.abs(p[0]-remove[0]) < 0.001 && Math.abs(p[1]-remove[1]) < 0.001);
});
geom.push(geom[0]);
d.geometry.coordinates[0] = geom;
}
if (d.properties.adm0_a3 === "CAF") {
var geom = d.geometry.coordinates[0].slice(0,-1);
let f = -1;
const find = C;
geom.forEach((p,i) => {
if (Math.abs(p[0]-find[0]) < 0.001 && Math.abs(p[1]-find[1]) < 0.001) f = i;
});
geom = [...geom.slice(0,f), B, ...geom.slice(f,Infinity)];
geom.push(geom[0]);
d.geometry.coordinates[0] = geom;
}
}), d' \
| ndjson-map '
// "fix Sudan+ETH tripoint"
[d].forEach(d => {
// SDN: remove C ; ETH: add B after C
const B = [33.963392794971185,9.464285229420625], C = [33.975,8.68456];
if (d.properties.adm0_a3 === "SDN") {
const remove = C;
var geom = d.geometry.coordinates[0].slice(0,-1).filter(p => {
return !(Math.abs(p[0]-remove[0]) < 0.001 && Math.abs(p[1]-remove[1]) < 0.001);
});
geom.push(geom[0]);
d.geometry.coordinates[0] = geom;
}
if (d.properties.adm0_a3 === "ETH") {
var geom = d.geometry.coordinates[0].slice(0,-1);
let f = -1;
const find = C;
geom.forEach((p,i) => {
if (Math.abs(p[0]-find[0]) < 0.001 && Math.abs(p[1]-find[1]) < 0.001) f = i;
});
geom = [...geom.slice(0,f+1), B, ...geom.slice(f+1,Infinity)];
geom.push(geom[0]);
d.geometry.coordinates[0] = geom;
}
}), d' \
| ndjson-map '
// "add Gaza to PSX"
((d.properties.adm0_a3 !== "PSX") ? null : (d.geometry.type = "MultiPolygon", d.geometry.coordinates = [d.geometry.coordinates, /* Gaza */ [[[34.20,31.28], [34.48810713068136,31.60553884533732], [34.65,31.40], [34.34,31.03], [34.20,31.28]]] ]), d)' \
| ndjson-map '
// "use the UN delimited border between MAR and SAH"
((d.properties.iso_a3 !== "MAR") ? null : (d.geometry = { "type": "Polygon", "coordinates": [ [[-5.92999426921989,35.75998810479399],[-5.193863491222032,35.75518219659085],[-4.591006232105144,35.330711981745594],[-3.640056525070065,35.399855048152006],[-2.604305792644084,35.179093329401155],[-2.169913702798624,35.16839630791668],[-1.792985805661715,34.527918606091305],[-1.7334545556614671,33.91971283623212],[-1.388049282222596,32.86401500094138],[-1.1245511539663084,32.65152151135713],[-1.30789913573787,32.2628889023061],[-2.616604783529567,32.09434621838619],[-3.068980271812648,31.724497992473218],[-3.647497931320146,31.637294012980675],[-3.6904410465547244,30.896951605751156],[-4.859646165374471,30.501187649043846],[-5.242129278982787,30.00044302013559],[-6.060632290053774,29.731699734001694],[-7.059227667661958,29.5792284205246],[-8.674116176782974,28.84128896739658],[-8.665589565454809,27.656425889592356],[-10.893601467684789,27.6552867806561],[-13.121613369914769,27.65414767171984],[-12.618836635783111,28.03818553314869],[-11.688919236690765,28.148643907172527],[-10.900956997104402,28.83214223888092],[-10.399592251008642,29.09858592377782],[-9.564811163765683,29.93357371674989],[-9.814718390329176,31.17773550060906],[-9.434793260119363,32.038096421836485],[-9.300692918321886,32.564679266890664],[-8.657476365585012,33.240245266242425],[-7.6541784326382185,33.69706492770251],[-6.912544114601417,34.110476386037476],[-6.2443420068514115,35.145865383437524],[-5.92999426921989,35.75998810479399]]
] }), d)' \
| ndjson-map '
((d.properties.adm0_a3 !== "SAH") ? null : (d.geometry = { "type": "Polygon", "coordinates": [
[[-8.665589565454809,27.656425889592356],[-8.665124477564191,27.589479071558227],[-8.684399786809053,27.395744126896005],[-8.6872936670174,25.881056219988906],[-11.96941891117116,25.933352769468268],[-11.937224493853321,23.374594224536168],[-12.874221564169575,23.284832261645178],[-13.118754441774712,22.771220201096256],[-12.929101935263532,21.327070624267563],[-16.845193650773993,21.33332347257488],[-17.06342322434257,20.999752102130827],[-17.02042843267577,21.422310288981578],[-16.973247849993243,21.885744533774982],[-16.589136928767687,22.158234361250095],[-16.261921759495635,22.679339504481277],[-16.3264139469959,23.017768459560898],[-15.982610642958036,23.723358466074046],[-15.426003790742186,24.35913361256104],[-15.089331834360735,24.520260728447],[-14.824645148161665,25.103532619725343],[-14.800925665739726,25.63626496022232],[-14.439939947964831,26.254418443297652],[-13.773804897506466,26.618892320252314],[-13.13994177901435,27.640147813420526],[-13.121613369914769,27.65414767171984],[-10.893601467684789,27.6552867806561],[-8.665589565454809,27.656425889592356]]
] }), d)' \
| ndjson-map '
// "add three South Kuril islands"
((d.properties.adm0_a3 !== "RUS") ? null : (d.geometry.coordinates.push([[[146.2,44.52],[148.44,44.9],[149.15,45.64],[147.52,45.39],[146.2,44.52]].reverse()]), d.geometry.coordinates.push([[[149.63,45.85],[149.85,45.64],[151.12,46.31],[150.42,46.4],[149.63,45.85]].reverse()]),d.geometry.coordinates.push([[[155.74,50.76],[154.33,49.09],[156.66,50.54],[155.74,50.76]].reverse()]),d.geometry.coordinates.push([[[151.56,46.98],[151.87,46.7],[152.66,47.1],[152.4,47.33],[151.56,46.98]].reverse()])), d)' \
| ndjson-map '/* delete d.properties, */ d' \
> build/ne_$1_admin_0_countries.ndjson
nd2topo $1
}
world() {
world_shp $1
mkdir -p world
shp2json --encoding utf-8 build/ne_$1_admin_0_countries.shp > build/ne_$1_admin_0_countries.geojson
ndjson-split 'd.features' < build/ne_$1_admin_0_countries.geojson \
| ndjson-map 'Object.keys(d.properties).forEach(function(PROP) {
var prop = PROP.toLowerCase();
if (prop !== PROP) {
d.properties[prop] = d.properties[PROP];
delete d.properties[PROP];
}
}), d' \
| ndjson-map 'c = {"Norway":"578","N. Cyprus":"-1","Kosovo":"-2","Somaliland":"-3"}, i = d.properties.iso_n3, d.id = i === "-99" ? c[d.properties.name] : i, d' \
| ndjson-map '
// "use the UN delimited border between MAR and SAH"
// see https://beta.observablehq.com/d/baf776ff54a9a6b9
((d.properties.iso_a3 !== "MAR") ? null : (d.geometry.coordinates[0] =
[[-5.397363281249994,35.9298828125],[-5.27783203125,35.902734374999994],[-5.337646484375,35.85654296875],[-5.337646484375,35.74521484375],[-5.252685546875,35.61474609375],[-5.105371093749994,35.4677734375],[-4.837207031249989,35.281298828124996],[-4.628320312499994,35.206396484375],[-4.329980468749994,35.161474609375],[-3.982421875,35.243408203125],[-3.7879882812499943,35.244921874999996],[-3.6932617187499943,35.27998046875],[-3.5906249999999886,35.228320312499996],[-3.394726562499983,35.211816406249994],[-3.206005859374983,35.239111328125],[-3.0630859374999773,35.317236328125],[-2.9722167968749886,35.407275390624996],[-2.957958984374983,35.363085937499996],[-2.95361328125,35.31513671875],[-2.925976562499983,35.287109375],[-2.8695312499999943,35.172656249999996],[-2.8399414062499773,35.127832031249994],[-2.731396484374983,35.135205078125],[-2.6368164062499773,35.112695312499994],[-2.4237304687499943,35.123486328125],[-2.2196289062499943,35.10419921875],[-2.1907714843749773,35.02978515625],[-2.131787109374983,34.970849609374994],[-1.9208984375,34.835546875],[-1.795605468749983,34.751904296875],[-1.792187499999983,34.723193359374996],[-1.8324218749999943,34.654638671875],[-1.8496582031249886,34.607324218749994],[-1.816601562499983,34.557080078125],[-1.739453124999983,34.49609375],[-1.7333007812499943,34.467041015625],[-1.7518554687499943,34.433251953124994],[-1.7917968749999886,34.367919921875],[-1.7069335937499943,34.176074218749996],[-1.6926757812499886,33.990283203124996],[-1.7146972656249773,33.858203124999996],[-1.714111328125,33.7818359375],[-1.7029785156249773,33.716845703124996],[-1.6312499999999943,33.566748046875],[-1.67919921875,33.318652343749996],[-1.6250976562499773,33.183349609375],[-1.550732421874983,33.073583984375],[-1.510009765625,32.87763671875],[-1.4499999999999886,32.784814453124994],[-1.3521484374999773,32.703369140625],[-1.29638671875,32.675683593749994],[-1.188232421875,32.60849609375],[-1.111035156249983,32.552294921874996],[-1.0655273437499773,32.468310546874996],[-1.16259765625,32.399169921875],[-1.2403320312499773,32.33759765625],[-1.2621093749999943,32.271142578124994],[-1.2259277343749773,32.16455078125],[-1.2259277343749773,32.107226562499996],[-1.275341796874983,32.089013671874994],[-1.47705078125,32.094873046874994],[-1.6351562499999943,32.099560546875],[-1.8169921874999773,32.104785156249996],[-2.0728027343749886,32.115039062499996],[-2.2312499999999886,32.121337890625],[-2.4483886718749943,32.12998046875],[-2.5232421874999886,32.12568359375],[-2.722607421874983,32.095751953124996],[-2.8634277343749943,32.07470703125],[-2.88720703125,32.06884765625],[-2.930859374999983,32.042529296874996],[-2.961132812499983,31.96396484375],[-2.988232421874983,31.874218749999997],[-3.0173828124999886,31.834277343749996],[-3.4397949218749773,31.704541015624997],[-3.6045898437499773,31.686767578125],[-3.7002441406249886,31.700097656249994],[-3.7681640624999773,31.68955078125],[-3.8267578124999773,31.661914062499996],[-3.8466796875,31.619873046875],[-3.849560546874983,31.56640625],[-3.837109374999983,31.512353515624994],[-3.7964355468749886,31.437109375],[-3.7891601562499773,31.36181640625],[-3.815136718749983,31.308837890625],[-3.8213867187499773,31.25546875],[-3.8333984374999943,31.197802734374996],[-3.8118164062499886,31.1666015625],[-3.77099609375,31.161816406249997],[-3.730175781249983,31.135400390624994],[-3.6725097656249943,31.111376953124996],[-3.62451171875,31.065771484375],[-3.626904296874983,31.000927734374997],[-3.6667968749999886,30.964013671874994],[-3.7020019531249773,30.944482421874994],[-3.860058593749983,30.92724609375],[-3.9853515625,30.913525390624997],[-4.148779296874977,30.8095703125],[-4.322851562499977,30.698876953124994],[-4.529150390624977,30.625537109374996],[-4.61962890625,30.604785156249996],[-4.778515624999983,30.552392578124994],[-4.96826171875,30.465380859374996],[-5.061914062499994,30.326416015625],[-5.180126953124983,30.166162109374994],[-5.293652343749983,30.058642578124996],[-5.448779296874989,29.956933593749994],[-5.593310546874989,29.91796875],[-5.774999999999977,29.869042968749994],[-6.004296874999994,29.831249999999997],[-6.16650390625,29.8189453125],[-6.214794921874983,29.810693359374994],[-6.357617187499983,29.808300781249997],[-6.427636718749994,29.816113281249997],[-6.479736328125,29.820361328124996],[-6.500878906249994,29.809130859374996],[-6.507910156249977,29.7837890625],[-6.510693359374983,29.726025390624997],[-6.520556640624989,29.659863281249997],[-6.565673828125,29.603857421875],[-6.597753906249977,29.578955078125],[-6.635351562499977,29.568798828124997],[-6.755126953125,29.583837890625],[-6.855566406249977,29.601611328124996],[-7.094921874999983,29.625195312499997],[-7.142431640624977,29.619580078124997],[-7.160205078124989,29.612646484375],[-7.234912109374989,29.574902343749997],[-7.349755859374994,29.4947265625],[-7.427685546874983,29.424999999999997],[-7.485742187499994,29.392236328124994],[-7.624609374999977,29.375195312499997],[-7.685156249999977,29.349511718749994],[-7.94384765625,29.174755859374997],[-7.998925781249994,29.132421875],[-8.265185546874989,28.980517578124996],[-8.340478515624994,28.93017578125],[-8.399316406249994,28.880175781249996],[-8.558349609375,28.767871093749996],[-8.659912109375,28.718603515625],[-8.678417968749983,28.689404296874997],[-8.683349609375,28.620751953124994],[-8.683349609375,28.46923828125],[-8.683349609375,28.323681640624997],[-8.683349609375,28.112011718749997],[-8.683349609375,27.900390625],[-8.683349609375,27.656445312499997],[-10.929663085937491,27.656079101562497],[-13.175976562499983,27.655712890624997],[-13.040722656249983,27.769824218749996],[-12.948925781249983,27.91416015625],[-12.793652343749983,27.978417968749994],[-12.468896484374994,28.009423828124994],[-11.986083984375,28.129296874999994],[-11.552685546874983,28.310107421874996],[-11.43017578125,28.382031249999997],[-11.299072265625,28.526074218749997],[-11.080957031249994,28.713769531249994],[-10.673828125,28.939208984375],[-10.486474609374994,29.06494140625],[-10.200585937499994,29.38037109375],[-10.010498046875,29.641406249999996],[-9.852636718749977,29.809228515624994],[-9.743457031249989,29.958203124999997],[-9.667089843749977,30.109277343749994],[-9.623828124999989,30.35263671875],[-9.652929687499977,30.447558593749996],[-9.773144531249983,30.603125],[-9.853906249999994,30.644580078124996],[-9.87548828125,30.717919921874994],[-9.832421874999994,30.847265625],[-9.833349609374977,31.069628906249996],[-9.808691406249977,31.424609374999996],[-9.674951171874994,31.710986328124996],[-9.347460937499989,32.086376953125],[-9.286572265624983,32.240576171875],[-9.249121093749977,32.48583984375],[-9.245849609375,32.5724609375],[-8.836230468749989,32.920458984374996],[-8.596289062499977,33.187158203124994],[-8.512841796874994,33.25244140625],[-8.301171874999994,33.374365234375],[-7.562353515624977,33.640283203124994],[-7.144677734374994,33.830322265625],[-6.900976562499977,33.969042968749996],[-6.755761718749994,34.13291015625],[-6.353124999999977,34.77607421875],[-5.957568359374989,35.68115234375],[-5.9248046875,35.785791015624994],[-5.747949218749994,35.815966796874996],[-5.622851562499989,35.828906249999996],[-5.522265624999989,35.86201171875],[-5.397363281249994,35.9298828125]]
), d)' \
| ndjson-map '
((d.properties.adm0_a3 !== "SAH") ? null : (d.geometry.coordinates[0] =
[[-8.683349609375,27.656445312499997],[-8.683349609375,27.490234375],[-8.683349609375,27.285937499999996],[-8.68310546875,27.119287109374994],[-8.682861328125,26.921337890624997],[-8.6826171875,26.72314453125],[-8.682324218749983,26.497705078124994],[-8.68212890625,26.273193359375],[-8.68212890625,26.10947265625],[-8.682226562499977,25.995507812499994],[-8.885644531249994,25.995507812499994],[-9.071923828124994,25.995507812499994],[-9.258203124999994,25.995507812499994],[-9.444531249999983,25.995507812499994],[-9.630859375,25.995507812499994],[-9.817187499999989,25.99545898437499],[-10.003515624999977,25.99545898437499],[-10.189794921874977,25.99545898437499],[-10.376123046874994,25.99545898437499],[-10.562451171874983,25.99545898437499],[-10.748779296875,25.99545898437499],[-10.935107421874989,25.99545898437499],[-11.121386718749989,25.99545898437499],[-11.307714843749977,25.995410156250003],[-11.494042968749994,25.995410156250003],[-11.680371093749983,25.995410156250003],[-11.866650390624983,25.995410156250003],[-12.016308593749983,25.995410156250003],[-12.016308593749983,25.87631835937499],[-12.016308593749983,25.740136718749994],[-12.016308593749983,25.60400390625],[-12.016308593749983,25.46787109374999],[-12.016308593749983,25.331689453124994],[-12.016308593749983,25.195556640625],[-12.016308593749983,25.059375000000003],[-12.016308593749983,24.923242187499994],[-12.016308593749983,24.787109375],[-12.016308593749983,24.65097656249999],[-12.016308593749983,24.514794921874994],[-12.016308593749983,24.378662109375],[-12.016308593749983,24.242480468750003],[-12.016308593749983,24.106347656249994],[-12.016308593749983,23.97021484375],[-12.016308593749983,23.834033203125003],[-12.016308593749983,23.697900390624994],[-12.016308593749983,23.576464843750003],[-12.0234375,23.467578125000003],[-12.083349609374977,23.435449218749994],[-12.226171874999977,23.377490234375003],[-12.372900390624977,23.318017578124994],[-12.559374999999989,23.290820312500003],[-12.620410156249989,23.27133789062499],[-12.739599609374977,23.19272460937499],[-12.89599609375,23.089550781249997],[-13.031494140625,23.000244140625],[-13.120898437499989,22.884082031250003],[-13.153271484374983,22.820507812499997],[-13.16650390625,22.753222656250003],[-13.155957031249983,22.68930664062499],[-13.107324218749994,22.560742187499997],[-13.094335937499977,22.495996093749994],[-13.086767578124977,22.383251953124997],[-13.078466796874977,22.260449218749997],[-13.069580078125,22.128173828125],[-13.060644531249977,21.995751953124994],[-13.051220703124983,21.854785156250003],[-13.041748046875,21.713818359374997],[-13.0322265625,21.572070312500003],[-13.025097656249983,21.466796875],[-13.016210937499977,21.333935546874997],[-13.167431640624983,21.333789062500003],[-13.396728515625,21.333544921875003],[-13.626025390624989,21.333251953125],[-13.855371093749994,21.332958984374997],[-14.084667968749983,21.332714843749997],[-14.31396484375,21.332421874999994],[-14.543261718749989,21.33212890624999],[-14.772607421874994,21.33188476562499],[-15.001904296874983,21.331591796875003],[-15.231201171875,21.331298828125],[-15.460546874999977,21.3310546875],[-15.689794921874977,21.330761718749997],[-15.919140624999983,21.330468749999994],[-16.1484375,21.330224609374994],[-16.37773437499999,21.32993164062499],[-16.607031249999977,21.329638671875003],[-16.836328124999994,21.329394531250003],[-16.964550781249983,21.329248046874994],[-17.00590820312499,21.14243164062499],[-17.042382812499994,21.008007812499997],[-17.06396484375,20.898828124999994],[-17.048046874999983,20.80615234375],[-17.098779296874994,20.856884765624997],[-17.009619140624977,21.377099609374994],[-17.003076171874994,21.420703125000003],[-16.930859374999983,21.89999999999999],[-16.79326171874999,22.159716796875003],[-16.683984374999994,22.274365234374997],[-16.514404296875,22.33349609375],[-16.358740234374977,22.594531250000003],[-16.304296874999977,22.83481445312499],[-16.201855468749983,22.945361328125003],[-16.16972656249999,23.031933593749997],[-16.21025390624999,23.097900390625],[-16.113671874999994,23.2275390625],[-15.996728515624994,23.425488281249997],[-15.942626953125,23.552636718749994],[-15.805957031249989,23.74951171875],[-15.789257812499983,23.792871093749994],[-15.801660156249994,23.842236328124997],[-15.855175781249983,23.800341796875003],[-15.912548828124983,23.727587890625003],[-15.980712890625,23.670312499999994],[-15.952832031249983,23.74082031249999],[-15.899316406249994,23.844433593749997],[-15.777783203124983,23.952929687500003],[-15.586328124999994,24.07275390625],[-15.188623046874994,24.478808593750003],[-15.038867187499989,24.548828125],[-14.904296875,24.719775390625003],[-14.856054687499977,24.87158203125],[-14.842919921874994,25.220117187499994],[-14.794921875,25.40415039062499],[-14.70703125,25.54770507812499],[-14.602294921875,25.808544921874997],[-14.522753906249989,25.925244140624997],[-14.470556640624977,26.163037109374997],[-14.413867187499989,26.253710937499996],[-14.312451171874983,26.296728515625],[-14.168359374999994,26.415429687499994],[-13.952099609374983,26.48876953125],[-13.695898437499977,26.642919921875],[-13.575781249999977,26.735107421875],[-13.495751953124994,26.87265625],[-13.409814453124994,27.146630859374994],[-13.256152343749989,27.434619140624996],[-13.177392578124994,27.65185546875],[-13.175976562499983,27.655712890624997],[-10.929663085937491,27.656079101562497],[-8.683349609375,27.656445312499997]]
), d)' \
> build/ne_$1_admin_0_countries.ndjson
nd2topo $1
}
nd2topo() {
# precision = 4 is 1 digit better than the topojson transform.scale() element
# build the countries GeoJSON with all data fields
geostitch -n < build/ne_$1_admin_0_countries.ndjson \
| ndjson-reduce | ndjson-map '{type: "FeatureCollection", features: d}' \
> build/$1_countries.geojson
node bin/geoformat --precision 4 < build/$1_countries.geojson > world/$1_countries.geojson
# build the merged land GeoJSON
geo2topo -n countries=<( geostitch -n < build/ne_$1_admin_0_countries.ndjson) \
| topomerge land=countries \
| topo2geo land=build/$1_land.geojson
node bin/geoformat --precision 4 < build/$1_land.geojson > world/$1_land.geojson
# build the TopoJSON (optimized: no data fields except id)
geo2topo -q 1e5 -n countries=<( ndjson-map 'delete d.properties, d' < build/ne_$1_admin_0_countries.ndjson | geostitch -n) \
| topomerge land=countries \
> world/$1.json
# geo2topo -n countries=<( ndjson-map 'delete d.properties, d' < build/ne_$1_admin_0_countries.ndjson | geostitch -n) \
# | topomerge land=countries \
# > world/$1_not_quantized.json
# build the TSV
ndjson-map 'Object.assign({id: d.id}, d.properties)' < build/ne_$1_admin_0_countries.ndjson \
| ndjson-sort 'a.iso_a3.localeCompare(b.iso_a3)' \
| json2tsv -n \
> world/$1.tsv
}
createindex() {
(echo -n "define(function() { return ([{ file: 'world/110m.json', format: 'topojson' }, { file: 'world/110m.tsv', format: 'tsv' }, { file: 'world/110m_land.geojson', format: 'geojson' }, { file: 'world/110m_countries.geojson', format: 'geojson' }, { file: 'world/50m.json', format: 'topojson' }, { file: 'world/50m.tsv', format: 'tsv' }, { file: 'world/50m_land.geojson', format: 'geojson' }, { file: 'world/50m_countries.geojson', format: 'geojson' }]); })") > index.js
}
worldfix 110m
world 50m
createindex