diff options
Diffstat (limited to 'src/gipfel.cxx')
-rw-r--r-- | src/gipfel.cxx | 90 |
1 files changed, 79 insertions, 11 deletions
diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 16329c5..43f2ed5 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -59,6 +59,9 @@ 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 *export_file, double visibility); +static int export_position(); + void set_values() { double k0 = 0.0, k1 = 0.0, x0 = 0.0; @@ -259,13 +262,15 @@ void fill_menubar(Fl_Menu_Bar* mb) { void usage() { fprintf(stderr, - "usage: gipfel [-v <viewpoint>] [-d <datafile>]\n" - " [-s] [-j <outfile>] [-t <outdir] [-w <width>] [-h <height>]\n" + "usage: gipfel [-v <viewpoint>] [-d <file>]\n" + " [-s] [-j <file>] [-t <dir] [-w <width>] [-h <height>]\n" + " [-e <file>] [-E] [-p]\n" " [<image(s)>]\n" " -v <viewpoint> Set point from which the picture was taken.\n" " This must be a string that unambiguously \n" " matches the name of an entry in the data file.\n" - " -d <datafile> Use <datafile> for GPS data.\n" + " -d <file> Use <file> for GPS data.\n" + " -V <visibility> Set initial visibility.\n" " -u <k0>,<k1> Use distortion correction values k0,k1.\n" " -s Stitch mode.\n" " -4 Create 16bit output (only with TIFF stitching).\n" @@ -273,8 +278,11 @@ void usage() { " -b Use bilinear interpolation for stitching.\n" " -w <width> Width of result image.\n" " -h <height> Height of result image.\n" - " -j <outfile> JPEG output file for Stitch mode.\n" - " -t <outdir> Output directory for TIFF images in Stitch mode.\n" + " -j <file> JPEG output file for Stitch mode.\n" + " -t <dir> Output directory for TIFF images in Stitch mode.\n" + " -p Export position of image to stdout.\n" + " -e <file> Export positions of hills from <file> on image.\n" + " -E Export hills from default data file.\n" " <image(s)> JPEG file(s) to use.\n"); } @@ -409,14 +417,17 @@ int main(int argc, char** argv) { char *view_point = NULL; int err, my_argc; int stitch_flag = 0, stitch_w = 2000, stitch_h = 500; - int jpeg_flag = 0, tiff_flag = 0, distortion_flag = 0; + int jpeg_flag = 0, tiff_flag = 0, distortion_flag = 0, position_flag = 0; + int export_flag = 0; int bicubic_flag = 0, b_16_flag = 0; double stitch_from = 0.0, stitch_to = 380.0; double dist_k0 = 0.0, dist_k1 = 0.0, dist_x0 = 0.0; + double visibility = 0.07; char *outpath = "/tmp"; + char *export_file = NULL; err = 0; - while ((c = getopt(argc, argv, ":?d:v:sw:h:j:t:u:br:4")) != EOF) { + while ((c = getopt(argc, argv, ":?d:v:sw:h:j:t:u:br:4e:V:pE")) != EOF) { switch (c) { case '?': usage(); @@ -425,12 +436,25 @@ int main(int argc, char** argv) { case 'd': data_file = optarg; break; + case 'e': + export_flag++; + export_file = optarg; + break; + case 'E': + export_flag++; + break; case 'v': view_point = optarg; break; + case 'V': + visibility = atof(optarg); + break; case 's': stitch_flag++; break; + case 'p': + position_flag++; + break; case '4': b_16_flag++; break; @@ -480,7 +504,6 @@ int main(int argc, char** argv) { } } - my_argc = argc - optind; my_argv = argv + optind; @@ -503,12 +526,15 @@ int main(int argc, char** argv) { type = STITCH_PREVIEW; } - stitch(bicubic_flag?GipfelWidget::BICUBIC:GipfelWidget::NEAREST, + return stitch(bicubic_flag?GipfelWidget::BICUBIC:GipfelWidget::NEAREST, b_16_flag, stitch_w, stitch_h, stitch_from, stitch_to, type, outpath, my_argc, my_argv); - exit(0); + } else if (export_flag) { + return export_hills(export_file, visibility); + } else if (position_flag) { + return export_position(); } Fl::get_system_colors(); @@ -542,6 +568,8 @@ int main(int argc, char** argv) { scroll->size(gipf->w(), gipf->h()); gipf->load_data(data_file); + gipf->set_height_dist_ratio(visibility); + scroll->end(); set_values(); @@ -575,7 +603,6 @@ stitch(GipfelWidget::sample_mode_t m, int b_16, st->load_image(argv[i]); } - if (type & STITCH_JPEG) { st->set_output(new JPEGOutputImage(path, 90)); @@ -617,3 +644,44 @@ stitch(GipfelWidget::sample_mode_t m, int b_16, return 0; } + +static int +export_hills(const char *export_file, double visibility) { + int ret; + + if (!img_file) { + fprintf(stderr, "export: No image file given.\n"); + return 1; + } + + 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(export_file, stdout); + delete gipf; + gipf = NULL; + + return ret; +} + +static int +export_position() { + ImageMetaData md; + + if (!img_file) { + fprintf(stderr, "export: No image file given.\n"); + return 1; + } + + if (md.load_image(img_file) == 0) { + printf(",%s,,%f,%f,%d\n", img_file, + md.get_latitude(), + md.get_longitude(), + (int) rint(md.get_height())); + + return 0; + } else { + return 1; + } +} |