summaryrefslogtreecommitdiff
path: root/src/gipfel.cxx
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2007-08-09 20:25:59 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2007-08-09 20:25:59 +0200
commitdadd1edab19c6f87c3e8cca7e9fbcce554dd4cb0 (patch)
tree4fe8bb0c52f47ec6f9483f89e2cb950b65df59b4 /src/gipfel.cxx
parent88dfe447316eac9ac10423761a3695545313a6cd (diff)
add export mode position, export to stdout
Diffstat (limited to 'src/gipfel.cxx')
-rw-r--r--src/gipfel.cxx40
1 files changed, 30 insertions, 10 deletions
diff --git a/src/gipfel.cxx b/src/gipfel.cxx
index db579de..295adf6 100644
--- a/src/gipfel.cxx
+++ b/src/gipfel.cxx
@@ -59,7 +59,7 @@ static int stitch(GipfelWidget::sample_mode_t m , int b_16,
int stitch_w, int stitch_h,
double from, double to, int type, const char *path, int argc, char **argv);
-static int export_hills(const char *file, double visibility);
+static int export_hills(const char *export_mode, double visibility);
void set_values() {
double k0 = 0.0, k1 = 0.0, x0 = 0.0;
@@ -263,7 +263,7 @@ void usage() {
fprintf(stderr,
"usage: gipfel [-v <viewpoint>] [-d <file>]\n"
" [-s] [-j <file>] [-t <dir] [-w <width>] [-h <height>]\n"
- " [-e <file>]\n"
+ " [-e hills] -e [position]\n"
" [<image(s)>]\n"
" -v <viewpoint> Set point from which the picture was taken.\n"
" This must be a string that unambiguously \n"
@@ -279,7 +279,8 @@ void usage() {
" -h <height> Height of result image.\n"
" -j <file> JPEG output file for Stitch mode.\n"
" -t <dir> Output directory for TIFF images in Stitch mode.\n"
- " -e <file> Export positions on image to file <file>.\n"
+ " -e position Export position of image to stdout.\n"
+ " -e hills Export hill positions on image to stdout.\n"
" <image(s)> JPEG file(s) to use.\n");
}
@@ -420,7 +421,7 @@ int main(int argc, char** argv) {
double dist_k0 = 0.0, dist_k1 = 0.0, dist_x0 = 0.0;
double visibility = 0.07;
char *outpath = "/tmp";
- char *export_file = NULL;
+ char *export_mode = NULL;
err = 0;
while ((c = getopt(argc, argv, ":?d:v:sw:h:j:t:u:br:4e:V:")) != EOF) {
@@ -433,7 +434,12 @@ int main(int argc, char** argv) {
data_file = optarg;
break;
case 'e':
- export_file = optarg;
+ if (strcmp(optarg, "position") && strcmp(optarg, "hills")) {
+ fprintf(stderr, "Unknown export mode %s.\n", optarg);
+ err++;
+ } else {
+ export_mode = optarg;
+ }
break;
case 'v':
view_point = optarg;
@@ -520,8 +526,8 @@ int main(int argc, char** argv) {
stitch_w, stitch_h, stitch_from, stitch_to,
type, outpath, my_argc, my_argv);
- } else if (export_file) {
- return export_hills(export_file, visibility);
+ } else if (export_mode) {
+ return export_hills(export_mode, visibility);
}
Fl::get_system_colors();
@@ -633,17 +639,31 @@ stitch(GipfelWidget::sample_mode_t m, int b_16,
}
static int
-export_hills(const char *file, double visibility) {
+export_hills(const char *export_mode, double visibility) {
int ret = 1;
- if (img_file) {
+ if (!img_file) {
+ fprintf(stderr, "export: No image file given.\n");
+ return 1;
+ }
+
+ if (strcmp(export_mode, "hills") == 0) {
gipf = new GipfelWidget(0,0,800,600);
gipf->load_image(img_file);
gipf->load_data(data_file);
gipf->set_height_dist_ratio(visibility);
- ret = gipf->export_hills(file);
+ ret = gipf->export_hills(stdout);
delete gipf;
gipf = NULL;
+ } else {
+ ImageMetaData md;
+ if (md.load_image(img_file) == 0) {
+ printf(",,%s,,%f,%f,%d\n", img_file,
+ md.get_longitude(),
+ md.get_latitude(),
+ (int) rint(md.get_height()));
+ ret = 0;
+ }
}
return ret;