summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2005-08-27 23:02:47 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2005-08-27 23:02:47 +0200
commit42cd862ec6f3d0e4cc0bb84f801877473d32395b (patch)
tree9ab2ac39ca8f28b77a1970d88dcf5ce9b6bc5ed8 /src
parentee9b1ddd14172c18074baa74e276a33ccdd69eca (diff)
save/restore of projection type
Diffstat (limited to 'src')
-rw-r--r--src/GipfelWidget.cxx24
-rw-r--r--src/Hill.cxx1
2 files changed, 21 insertions, 4 deletions
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index 5570399..95f8cde 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <math.h>
@@ -68,7 +69,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 %lf, projection type %d"
int
GipfelWidget::load_image(char *file) {
@@ -78,6 +79,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 +117,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 +125,7 @@ GipfelWidget::load_image(char *file) {
set_nick_angle(ni);
set_tilt_angle(ti);
set_scale(sc);
+ set_projection(pt);
break;
}
@@ -145,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");
@@ -164,7 +181,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";
diff --git a/src/Hill.cxx b/src/Hill.cxx
index 7910986..b78dcd7 100644
--- a/src/Hill.cxx
+++ b/src/Hill.cxx
@@ -102,7 +102,6 @@ Hills::load(const char *file) {
if (vals[1] && vals[3] && vals[4] && vals[5]) {
phi = atof(vals[3]) * deg2rad;
lam = atof(vals[4]) * deg2rad;
-
height = atof(vals[5]);
m = new Hill(vals[1], phi, lam, height);