-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_separate_tiles.sh
executable file
·33 lines (26 loc) · 1.18 KB
/
generate_separate_tiles.sh
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
#!/bin/bash
# same as genrate_tiles, but creates a separate .mbtiles file
# for each constitnuency type, instead of separating by layers
set -ex
# Download constituency shapes from whos-on-first
if [ ! -f ./data/whosonfirst-data-constituency-us-latest.db ]; then
echo "Downloading data"
wget -O ./data/whosonfirst-data-constituency-us-latest.db.bz2 https://data.geocode.earth/wof/dist/sqlite/whosonfirst-data-constituency-us-latest.db.bz2
bunzip2 ./data/whosonfirst-data-constituency-us-latest.db.bz2
fi
# Extract GeoJSON from db
echo "Extracting whosonfirst us-constituency data"
sqlite3 ./data/whosonfirst-data-constituency-us-latest.db "select body from geojson" > ./data/constituencies.geojson
# Update geojson records with layer info
echo "Split into files for each constituent type"
node split_files.js
# Generate mbtiles
# -zg (zoom guess: optimized for best zoom levels to render)
# -pS (only simplify polygons at low zoom levels)
# -P (parallel process input file)
# -f (force: allow override of existing file)
# -o (output file)
for file in data/constituencies-*; do
base=$(basename "$file" | sed 's/\.[^.]*$//')
tippecanoe -zg -pS -P -f -o "./tiles/$base.mbtiles" "$file"
done