Skip to content

Instantly share code, notes, and snippets.

@typebrook
Last active July 30, 2022 23:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typebrook/67c51de17a50fed3c8857451a58a79be to your computer and use it in GitHub Desktop.
Save typebrook/67c51de17a50fed3c8857451a58a79be to your computer and use it in GitHub Desktop.
Command to generate Cesium terrain tiles with ctb-tile #cesium #tile #makefile
# Check command ctb-tile at
# https://github.com/geo-data/cesium-terrain-builder
# https://github.com/tum-gis/cesium-terrain-builder-docker
,
.ONESHELL:
ZIP_URL = http://dtm.moi.gov.tw/不分幅_全台及澎湖.zip
DOCKER_IMAGE = "tumgis/ctb-quantized-mesh:latest"
data.zip:
<<<"$(ZIP_URL)" perl -lpe 's/([^A-Za-z0-9.\/:])/sprintf("%%%02X", ord($$1))/seg' |\
xargs curl -Lo $@
dem_20m.tif: data.zip
unzip -p $< $@ >$@
dem_20m_EPSG4326.tif: dem_20m.tif
gdalwarp \
-t_srs EPSG:4326 \
-dstnodata None \
-co TILED=YES \
-co COMPRESS=DEFLATE \
-co BIGTIFF=IF_NEEDED \
$< $@
tiles/: dem_20m_EPSG4326.tif
docker image inspect $(DOCKER_IMAGE) >/dev/null || docker pull $(DOCKER_IAMGE)
mkdir -p $@
docker run --rm -it \
--name ctb \
-v `pwd`:"/data" \
$(DOCKER_IMAGE) \
ctb-tile -f Mesh -CN --output-dir /data/$@ /data/$<
docker run --rm -it \
--name ctb \
-v `pwd`:"/data" \
$(DOCKER_IMAGE) \
ctb-tile -f Mesh -CN -l --output-dir /data/$@ /data/$<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment