simplify managedb

This commit is contained in:
Motiejus Jakštys 2020-05-22 20:20:35 +03:00
parent aa16b89ad9
commit c26db786b0
2 changed files with 33 additions and 56 deletions

View File

@ -1,5 +1,3 @@
SHELL = /bin/bash
GEN = zeimena.pdf st-simplify-300.pdf st-simplify-500.pdf st-simplify-1000.pdf GEN = zeimena.pdf st-simplify-300.pdf st-simplify-500.pdf st-simplify-1000.pdf
mj-referatas.pdf: mj-referatas.tex version.tex bib.bib zeimena-pretty.pdf $(GEN) mj-referatas.pdf: mj-referatas.tex version.tex bib.bib zeimena-pretty.pdf $(GEN)
@ -12,8 +10,7 @@ st-simplify-%.pdf: db/.faux_st-simplify-%
./layer2img.py --table=douglas_$* --size=74x52 --outfile $@ ./layer2img.py --table=douglas_$* --size=74x52 --outfile $@
db/.faux_st-simplify-%: db/.faux_ready st-simplify.sql db/.faux_st-simplify-%: db/.faux_ready st-simplify.sql
. ./managedb ; \ ./managedb -- --echo-all -v ON_ERROR_STOP=1 -v tolerance=$* -f st-simplify.sql
psql --echo-all -v ON_ERROR_STOP=1 -v tolerance=$* -f st-simplify.sql
touch $@ touch $@
db/.faux_ready: zeimena.gpkg managedb db/.faux_ready: zeimena.gpkg managedb

View File

@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
main() {
PATH=$PATH:/usr/lib/postgresql/12/bin PATH=$PATH:/usr/lib/postgresql/12/bin
case ${1:-} in case ${1:-} in
init) init)
@ -22,34 +21,15 @@ main() {
pg_ctl -D db -l db/logfile stop pg_ctl -D db -l db/logfile stop
;; ;;
"" | --) "" | --)
[[ $# == 2 ]] && shift [[ $# -gt 1 ]] && shift
exports exec env \
exec psql "$@" PGHOST=127.0.0.1 \
PGUSER=osm \
PGDATABASE=osm \
psql "$@"
;; ;;
*) *)
>&2 echo "Unknown command: '$*'" >&2 echo "Unknown command: '$*'"
exit 1 exit 1
;; ;;
esac esac
}
exports() {
export PGHOST=127.0.0.1
export PGUSER=osm
export PGDATABASE=osm
}
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
if [[ $# != 0 ]]; then
>&2 echo "Sourcing does not accept arguments: $*"
else
exports
>&2 echo "OK: exported PGUSER, PGHOST and PGDATABASE"
fi
else
set -euo pipefail
export PGHOST=
export PGUSER=
export PGDATABASE=
main "$@"
fi