summaryrefslogtreecommitdiff
path: root/tests/harness/exportdump.cxx
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-26 20:05:20 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2026-10-26 20:05:20 +0100
commit375d87a9b0ec1cf2fffd705adb870c86144d2400 (patch)
tree1e8e05e7cd58686628d0f4622622456613a42e4d /tests/harness/exportdump.cxx
parent45425dd047b791fe63f13a46a3251c529cfffc94 (diff)
Replace the C++ implementation with the Rust port
The Rust port (formerly gipfel-rs) is now the official successor to the FLTK/GSL C++ code base. This squashes the port into a single commit and removes the C++ sources (they remain in the git history below). Layout: crates/gipfel-core headless core: hills, panorama geometry, projections (maxima-generated derivatives), pure-Rust LM fit, gipfel: JPEG comment + EXIF I/O, profiles, stitching crates/gipfel-cli command-line tools (export, info, stitch, profiles) crates/gipfel-app Cosmic DE (libcosmic) GUI, binary name `gipfel` codegen/ maxima scripts + regen.sh for the projection code tests/ golden files + C++ reference harnesses (historical) The original README is kept for now; it will be updated to describe the Rust build. gipfel.dat, AUTHORS, ChangeLog and NEWS are unchanged.
Diffstat (limited to 'tests/harness/exportdump.cxx')
-rw-r--r--tests/harness/exportdump.cxx77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/harness/exportdump.cxx b/tests/harness/exportdump.cxx
new file mode 100644
index 0000000..2c0e736
--- /dev/null
+++ b/tests/harness/exportdump.cxx
@@ -0,0 +1,77 @@
+// Golden dump: export-hills pipeline through the original C++ Panorama +
+// ImageMetaData (mirrors GipfelWidget::load_image + export_hills, no FLTK).
+// Usage: exportdump <img> <gipfel.dat>
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+#include <exiv2/exiv2.hpp>
+
+#include "Panorama.H"
+#include "Hill.H"
+#include "ImageMetaData.H"
+
+int main(int argc, char **argv) {
+ if (argc < 3) {
+ fprintf(stderr, "usage: exportdump <img> <gipfel.dat>\n");
+ return 1;
+ }
+
+ int w = 0, h = 0;
+ {
+ auto im = Exiv2::ImageFactory::open(argv[1]);
+ im->readMetadata();
+ w = im->pixelWidth();
+ h = im->pixelHeight();
+ }
+
+ ImageMetaData md;
+ md.load_image(argv[1]);
+
+ Panorama pan;
+ pan.set_view_long(md.longitude());
+ pan.set_view_lat(md.latitude());
+ pan.set_view_height(md.height());
+ pan.set_projection((ProjectionLSQ::Projection_t) md.projection_type());
+
+ int have = 1;
+ double v;
+ v = md.direction();
+ if (std::isnan(v)) { pan.set_center_angle(0.0); have = 0; } else pan.set_center_angle(v);
+ v = md.nick();
+ if (std::isnan(v)) { pan.set_nick_angle(0.0); have = 0; } else pan.set_nick_angle(v);
+ v = md.tilt();
+ if (std::isnan(v)) { pan.set_tilt_angle(0.0); have = 0; } else pan.set_tilt_angle(v);
+ v = md.focal_length_35mm();
+ if (std::isnan(v) || v == 0.0) { pan.set_scale(35.0 * (double)(w > h ? w : h) / 35.0); have = 0; }
+ else pan.set_scale(v * (double)(w > h ? w : h) / 35.0);
+
+ md.distortion_params(&pan.parms.k0, &pan.parms.k1, &pan.parms.x0);
+ if (std::isnan(pan.parms.k0)) pan.parms.k0 = 0.0;
+ if (std::isnan(pan.parms.k1)) pan.parms.k1 = 0.0;
+ if (std::isnan(pan.parms.x0)) pan.parms.x0 = 0.0;
+
+ if (pan.load_data(argv[2])) return 1;
+ pan.set_height_dist_ratio(0.07);
+
+ if (!have) {
+ fprintf(stderr, "No gipfel info available.\n");
+ return 0;
+ }
+
+ printf("#\n# name\theight\tx\ty\tdistance\tflags\n#\n");
+ Hills *mnts = pan.get_visible_mountains();
+ for (int i = 0; i < mnts->get_num(); i++) {
+ Hill *m = mnts->get(i);
+ int _x = (int) rint(m->x) + w / 2;
+ int _y = (int) rint(m->y) + h / 2;
+
+ if (m->flags & Hill::DUPLIC || m->flags & Hill::HIDDEN)
+ continue;
+ if (_x < 0 || _x > w || _y < 0 || _y > h)
+ continue;
+
+ printf("%s\t%d\t%d\t%d\t%d\n", m->name, (int) rint(m->height), _x, _y,
+ (int) rint(pan.get_real_distance(m)));
+ }
+ return 0;
+}