From c712d598ea39dc4f90a733dc06c44617eb30bcbb Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 10 Aug 2007 17:56:37 +0200 Subject: implement automatic gipfelweb generation --- .hgignore | 1 - examples/Makefile | 31 +++++++++++++++++++------------ examples/gipfel2html | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/GipfelWidget.cxx | 22 ++++++++++++++-------- src/gipfel.cxx | 4 ++-- 5 files changed, 82 insertions(+), 23 deletions(-) create mode 100755 examples/gipfel2html diff --git a/.hgignore b/.hgignore index 971fa2d..a1a68ae 100644 --- a/.hgignore +++ b/.hgignore @@ -23,4 +23,3 @@ stamp-h1 missing tags gipfel - diff --git a/examples/Makefile b/examples/Makefile index cfea1a6..762fd9e 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,14 +1,15 @@ -images := $(wildcard *.jpg) -slides := $(addprefix gipfelweb/slides/, $(images)) -thumbs := $(addprefix gipfelweb/thumbs/, $(images)) -html := $(addprefix gipfelweb/, $(addsuffix .html, $(basename $(images)))) - +images := $(wildcard *.jpg) +slides := $(addprefix gipfelweb/slides/, $(images)) +thumbs := $(addprefix gipfelweb/thumbs/, $(images)) +positions := $(addprefix gipfelweb/gipfel/, $(addsuffix .pos, $(basename $(images)))) +dumps := $(addprefix gipfelweb/gipfel/, $(addsuffix .gipf, $(basename $(images)))) +html := $(addprefix gipfelweb/, $(addsuffix .html, $(basename $(images)))) all: echo "make gipfelweb - create a HTML based we of gipfel oriented" echo "images in the current directory." -gipfelweb: dirs $(slides) $(thumbs) $(html) +gipfelweb: dirs $(slides) $(thumbs) $(dumps) $(html) clean: rm -rf gipfelweb @@ -16,16 +17,22 @@ clean: dirs: mkdir -p gipfelweb/slides mkdir -p gipfelweb/thumbs + mkdir -p gipfelweb/gipfel gipfelweb/slides/%.jpg: %.jpg - anytopnm $< | pamscale -xyfit 200000 600 | convert -unsharp 0.5x0.5 - - | pnmtojpeg -quality=85 > $@ + convert -resize '10000x600>' -unsharp 0.5x0.5 -quality 90 $< $@ gipfelweb/thumbs/%.jpg: %.jpg - anytopnm $< | pamscale -xyfit 200000 200 | pnmtojpeg -quality=80 > $@ + convert -resize '1000x150>' -quality 80 $< $@ + +gipfelweb/gipfel/%.pos: %.jpg + gipfel -e position $< > $@ -gipfelweb/%.html: %.jpg index.gipfel - echo tbd +gipfelweb/gipfel/%.gipf: gipfelweb/slides/%.jpg gipfelweb/gipfel/index.gipfel + gipfel -v 0.03 -d gipfelweb/gipfel/index.gipfel -e hills $< > $@ -index.gipfel: $(images) - echo tbd +gipfelweb/gipfel/index.gipfel: $(positions) + cat $(positions) > gipfelweb/gipfel/index.gipfel +gipfelweb/%.html: gipfelweb/slides/%.jpg gipfelweb/gipfel/%.gipf $(thumbs) + gipfel2html $* > $@ diff --git a/examples/gipfel2html b/examples/gipfel2html new file mode 100755 index 0000000..1016b94 --- /dev/null +++ b/examples/gipfel2html @@ -0,0 +1,47 @@ +#!/bin/sh + +cat << EOF + + +" +echo "" +echo "
" + +i=0 +grep -v "^#" gipfelweb/gipfel/${1}.gipf | \ +while read name height x y dist flags dummy; do + if [ "${flags}" = "HIDDEN" ]; then + continue + fi + + echo "
  • ${name} (${height}m)
  • " + + i=$((${i} + 1)) +done + +cat << EOF + +
    + + +EOF diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 20d4a42..15a3cc6 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -677,22 +677,28 @@ GipfelWidget::handle(int event) { int GipfelWidget::export_hills(FILE *fp) { Hills *mnts; - Hill *m; - fprintf(fp, "#\n# name\theight\tx\ty\tdistance\n#\n"); + fprintf(fp, "#\n# name\theight\tx\ty\tdistance\tflags\n#\n"); mnts = pan->get_visible_mountains(); for (int i=0; iget_num(); i++) { - m = mnts->get(i); + Hill *m = mnts->get(i); + char *flags; + int _x = (int) rint(m->x) + w() / 2; + int _y = (int) rint(m->y) + h() / 2; - if (m->x < 0 || m->x > w() || m->y < 0 || m->y > h()) { + if (_x < 0 || _x > w() || _y < 0 || _y > h()) { continue; } - fprintf(fp, "%s\t%d\t%d\t%d\t%d\n", - m->name, (int) rint(m->height), - (int) rint( m->x), (int) rint(m->y), - (int) rint(pan->get_real_distance(m))); + if (m->flags & Hill::HIDDEN) { + flags = "HIDDEN"; + } else { + flags = ""; + } + fprintf(fp, "%s\t%d\t%d\t%d\t%d\t%s\n", + m->name, (int) rint(m->height), _x, _y, + (int) rint(pan->get_real_distance(m)), flags); } return 0; diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 295adf6..ba757e2 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -658,9 +658,9 @@ export_hills(const char *export_mode, double visibility) { } else { ImageMetaData md; if (md.load_image(img_file) == 0) { - printf(",,%s,,%f,%f,%d\n", img_file, - md.get_longitude(), + printf(",%s,,%f,%f,%d\n", img_file, md.get_latitude(), + md.get_longitude(), (int) rint(md.get_height())); ret = 0; } -- cgit v1.2.3