stud/contours/Makefile.2008

50 lines
1.3 KiB
Makefile
Raw Normal View History

2020-12-15 23:49:25 +02:00
#krekenava
2020-12-16 08:45:54 +02:00
BOUNDS = xmin=493674 ymin=6146103 xmax=518869 ymax=6171741
#BOUNDS = xmin=504440 ymin=6154741 xmax=507410 ymax=6158941
OUTSIZE = $(shell awk $(addprefix -v ,$(BOUNDS)) 'BEGIN{print ymax-ymin" "xmax-xmin}' /dev/null)
2020-12-16 07:23:35 +02:00
XYZ = $(patsubst %.zip,%.xyz,$(wildcard 6*.zip))
2020-12-11 10:44:26 +02:00
SORT = sort -n -k2 -k1 -t,
.PHONY: all
all: smooth_2_5.gpkg smooth_5.gpkg
smooth_%.gpkg: db/smooth_%
2020-12-16 08:45:54 +02:00
ogr2ogr $@ "PG:host=127.0.0.1 user=osm dbname=osm password=osm" $(basename $@)
2020-12-11 10:44:26 +02:00
db/smooth_%: db/contour_% chaikin.sql
./managedb -- --echo-all \
-v ON_ERROR_STOP=1 \
-v src=$(notdir $(basename $<)) \
-v tbl=$(notdir $(basename $@)) \
-f chaikin.sql
touch $@
db/contour_%: contour_%.gpkg db/.ready
./managedb -- -c "DROP TABLE IF EXISTS $(basename $<)"
2020-12-16 08:45:54 +02:00
ogr2ogr -f PostgreSQL "PG:host=127.0.0.1 user=osm dbname=osm password=osm" $<
2020-12-11 10:44:26 +02:00
touch $@
contour_%.gpkg: all.tif
gdal_contour -nln $(basename $@) -i $(subst _,.,$*) -a z $^ $@
2020-12-16 08:45:54 +02:00
all.tif: all.vrt all.xyz
gdal_grid $< $@ \
-a nearest \
-ot Float32 -co COMPRESS=DEFLATE -co PREDICTOR=2 \
-outsize $(OUTSIZE)
2020-12-11 10:44:26 +02:00
2020-12-16 08:02:45 +02:00
.INTERMEDIATE: all.xyz
all.xyz: $(XYZ)
2020-12-11 10:44:26 +02:00
$(SORT) -m $^ > $@
.INTERMEDIATE: $(XYZ)
%.xyz: %.zip
unzip -qq -c $< $@ | \
2020-12-16 00:12:25 +02:00
./clip-2009.awk $(addprefix -v ,$(BOUNDS)) | \
2020-12-11 10:44:26 +02:00
$(SORT) > $@
db/.ready: managedb
2020-12-15 23:58:02 +02:00
mkdir -p db
2020-12-15 23:49:25 +02:00
./managedb start
2020-12-11 10:44:26 +02:00
touch $@