From 2c264dbb85f64221f20cf93ebdd724dab881b998 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 15 Aug 2005 11:43:23 +0100 Subject: fix save/restore of projection type --- src/GipfelWidget.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 5570399..d2fe69c 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -68,7 +68,7 @@ GipfelWidget::GipfelWidget(int X,int Y,int W, int H): Fl_Widget(X, Y, W, H) { fl_register_images(); } -#define GIPFEL_FORMAT "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, scale %lf" +#define GIPFEL_FORMAT "gipfel: longitude %lf, latitude %lf, height %lf, direction %lf, nick %lf, tilt %lf, scale %lfi, projection type %d" int GipfelWidget::load_image(char *file) { @@ -78,6 +78,7 @@ GipfelWidget::load_image(char *file) { char buf[1024]; double lo, la, he, dir, ni, ti, sc; int status; + Projection_t pt = PROJECTION_TANGENTIAL; Fl_Image *new_img; new_img = new Fl_JPEG_Image(file); @@ -115,7 +116,7 @@ GipfelWidget::load_image(char *file) { if (p) { while (fgets(buf, sizeof(buf), p) != NULL) { - if (sscanf(buf, GIPFEL_FORMAT, &lo, &la, &he, &dir, &ni, &ti, &sc) == 7) { + if (sscanf(buf, GIPFEL_FORMAT, &lo, &la, &he, &dir, &ni, &ti, &sc, &pt) >= 7) { set_view_long(lo); set_view_lat(la); set_view_height(he); @@ -123,6 +124,7 @@ GipfelWidget::load_image(char *file) { set_nick_angle(ni); set_tilt_angle(ti); set_scale(sc); + set_projection(pt); break; } @@ -164,7 +166,8 @@ GipfelWidget::save_image(char *file) { get_center_angle(), get_nick_angle(), get_tilt_angle(), - get_scale()); + get_scale(), + (int) get_projection()); // try to save gipfel data in JPEG comment section args[0] = "wrjpgcom"; -- cgit v1.2.3 From 8d7e0aaa20dff413fdc9747b842015664dae6cac Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 15 Aug 2005 12:01:08 +0100 Subject: add check to avoid saving to input image file --- src/GipfelWidget.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index d2fe69c..44134f8 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -147,12 +148,26 @@ GipfelWidget::save_image(char *file) { char buf[1024]; int status; size_t n; + struct stat in_stat, out_stat; if (img_file == NULL) { fprintf(stderr, "Nothing to save\n"); return 1; } + if (stat(img_file, &in_stat) != 0) { + perror("stat"); + return 1; + } + + if (stat(file, &out_stat) == 0) { + if (in_stat.st_ino == out_stat.st_ino) { + fprintf(stderr, "Input image %s and output image %s are the same file\n", + img_file, file); + return 1; + } + } + out = fopen(file, "w"); if (out == NULL) { perror("fopen"); -- cgit v1.2.3