summaryrefslogtreecommitdiff
path: root/crates/gipfel-core/src
AgeCommit message (Collapse)Author
4 dayscore: reject fits that park markers outside the projection's viewJohannes Hofmann
Investigating the Thaneller report (mark Zugspitze + Saeuling in rectilinear mode, 'jump totally weird' when Saeuling sits east of north): a numeric sweep of the Saeuling marker across north with the real geography shows comp_params is perfectly CONTINUOUS there - it recovers truth exactly at the true position. What is NOT benign: a fit whose solution places a marked peak beyond the projection's own view angle (rectilinear: +/-60 deg). The tangent-compressed solution that matches far-apart markers is exact for the two markers but scatters every other peak, and is_visible() hides the marked ones - exactly 'totally weird'. comp_params now validates every known marker against proj.get_view_angle() after fitting and returns a descriptive error (suggesting cylindrical mode) instead of committing the parameters. Cylindrical's limit is 2pi, so panorama fits are untouched. The web status line shows 'fit failed: <reason>' in that case. Tests: rectilinear fit of markers 150 deg apart is rejected; the same markers fit fine in cylindrical mode; golden fits unaffected.
4 daysweb: refit view parameters when switching projectionJohannes Hofmann
View parameters are projection-specific: a cylindrical scale is linear in azimuth, a rectilinear one tangent-based. Switching projections kept the old parameters, so the display reinterpreted them; the first marker drag then refit in the NEW projection, converging to parameters that are valid there but garbage for the other one - and switching back showed that garbage until yet another refit happened to save it (exactly the reported panorama -> rect -> drag -> back -> crazy -> tiny-drag-fixes-it chain). * web: the projection dropdown now refits to the markers right after switching (no-op without markers), so parameters always match the active projection. * core: the wide-branch initial guess (markers >180 deg apart in the image, chosen by the sign of the pixel difference) is now gated to projections that can show more than a half-plane. Rectilinear (120 deg max view) always uses the shortest arc. * regression test: panorama fit -> rectilinear interlude -> refit recovers the panorama parameters exactly.
8 dayscore: consolidate the three ad-hoc azimuth wraps into wrap_angleJohannes Hofmann
ProjArgs::from_params now normalizes the mountain azimuth centrally, so the two remaining hand-rolled wraps are redundant: * get_coordinates dropped its single-step +/-2pi normalization (a leftover of the C++ original that could not even handle azimuths more than one full turn off); from_params covers it strictly more generally. * is_visible's abs-mod-fold became one wrap_angle call. The explicit is_finite guard stays (wrap_angle's NaN would silently pass the >= view_angle test when max_view_angle is 0). No behavior change: 35 core + 13 golden tests, including the Finding 1 regression test and all north/wide-panorama tests, pass unmodified.
8 daysgrey out distortion controls in panorama mode; make core skip the fitJohannes Hofmann
Confirmed: the cylindrical projection formulas contain no k0/k1/x0 and its distortion derivative trait defaults are NaN, so a level-2 (distortion) fit cannot move anything there. Worse, comp_params zeroed the distortion parameters before the (doomed) calibration - so enabling 'Fit distortion' in panorama mode silently destroyed distortion a rectilinear fit had established. * core: comp_params probes whether the projection actually provides distortion derivatives (NaN trait default = no) and skips both the calibration reset and the level-2 lsq if not. Regression test asserts k0/k1/x0 survive a fit_distortion=true fit in cylindrical mode. * web: the fit-distortion checkbox AND the whole distortion-profiles group now sit in a <fieldset disabled> in cylindrical mode (opacity 0.45), so the dead controls are visibly inert. * dist: rebuilt.
8 dayscore: fix fit for wide panoramas (markers >180 deg apart in image)Johannes Hofmann
The initial guess in comp_params assumed the two markers are less than 180 deg apart: a_center started on the first marker and the scale came from the shortest-arc azimuth difference. In panoramas wider than 180 deg the markers can straddle the seam - e.g. at -170 deg and +170 deg of the view center they are 340 deg apart in the image but only 20 deg on the compass. The start was then off by up to 170 deg in azimuth and a factor of 17 in scale, and the fit never recovered. Fix: derive the image-space azimuth difference from the SIGN OF THE PIXEL DIFFERENCE (the user's marker placement tells us which branch was meant; the magnitude is unique modulo 2pi for panoramas below 360 deg), and start the view center between the markers in that branch. The golden fit tests now compare a_center modulo 2pi: the C harness settles wherever its >2pi input azimuths put it (380 deg), the Rust port normalizes (20 deg) - same physical solution. Tests: fits with markers 340 deg apart, 350 deg apart in reversed marker order, and 200 deg apart (just over the seam). All three fail without the fix (verified), pass with it.
8 dayscore: fix fit when north lies between the two markersJohannes Hofmann
With markers at e.g. 350 deg and 10 deg the raw azimuth difference is 340 deg instead of 20 deg. Two places choked on that: * ProjArgs::from_params fed the raw difference into the projection formulas. The cylindrical projection uses it LINEARLY (x = scale * (m_view - c_view)), so the 350 deg peak was projected 350 degrees of scale to the right of center instead of 10 degrees to the left - no parameter set can satisfy both markers and the panorama-mode fit fails. The rectilinear projection is periodic and unaffected. Fix: represent m_view as c_view + wrapped difference, so every consumer (fit residuals, Jacobian, project_point) sees the shortest arc. get_coordinates already normalized for exactly this reason; the fit path bypassed it. * comp_params derived the initial scale from |d_alph| = 340 deg, an initial scale off by a factor of 17 - this hit rectilinear mode too. Use the wrapped difference. Regression tests: two-marker fits across north for both projections (the cylindrical one fails without the fix), plus a direct check that a 350 deg peak projects to -10 deg * scale.
10 daysMerge branch 'wasm-spike'Johannes Hofmann
# Conflicts: # crates/gipfel-core/src/metadata.rs
10 dayscore: is_visible wraps the azimuth difference and rejects non-finite inputJohannes Hofmann
GipfelFind.lean Finding 1: with |alph - a_center| > 2pi (user enters azimuth 400deg, or a fit leaves a_center unnormalized) the single fold produced a NEGATIVE 'distance' that passed every comparison, making hills behind the camera visible. NaN or infinite azimuths — and a NaN center, which made everything visible — passed as well. Fix at the point of use: wrap with % 2pi before the fold, and bail out on non-finite alph/a_center. Regression test pins the Lean witnesses (out_of_range_center_angle_stays_safe).
11 daysweb: projection switch, external image URLs, zoom buttonsJohannes Hofmann
- ?file= now also accepts absolute http(s) image URLs (CORS applies); README documents all URL parameters - Projection dropdown (rectilinear / cylindrical-panoramic), synced from the gipfel comment on load; cylindrical lifts the lens-FOV visibility limit (unlimited view angle) so 360 deg panoramas show peaks in every direction - force visibility rebuild on every image load (the change detection alone could keep a stale list when the limit value was unchanged) - Google-Maps-style +/- zoom buttons at the lower right of the canvas - save/load roundtrip test for the projection type in the gipfel comment; build stamp in the sidebar footer and ?debug=1 console diagnostics to spot stale cached bundles and inspect the effective visibility state
2026-11-06wasm front end becomes the main gipfel; add desktop installersJohannes Hofmann
- rename crates/wipfel -> crates/gipfel (crate, wasm artifact, dist, scripts, page titles); slogan back to "Photogrammetry for Mountain Images"; crates/wipfel-tauri -> crates/gipfel-desktop - new features in the wasm app: Save image (gipfel JPEG comment, same format as before, via browser download) and lens distortion profiles stored in localStorage in FLTK prefs format with camera auto-match on image load; profile name field, save/load and dropdown - gipfel-core: read GPSImgDirection from EXIF (magnetic -> true) as azimuth fallback; expose parse_prefs/serialize_prefs for the wasm build; ?file=/?az=/?pitch=/?roll=/?focal=/?vis= URL parameters - Tauri v2 wrapper crate building .deb, AppImage and (cross-compiled) Windows NSIS installers; safe stage-and-swap build-release.sh - README: web-centric Installation, concise Build section for the official targets (Web, Windows, Linux); drop native/Android mentions - release site moved dist/wipfel -> dist/gipfel
2026-10-30cli: -V flag; restricted export ignores occlusion; web visibility knobJohannes Hofmann
- gipfel-cli export-hills gains -V <ratio> (the visibility/prominence threshold, C default 0.07); default unchanged - export_hill_rows: restricted mode (-e, curated lists like the gipfelweb photo index) no longer drops FLAG_HIDDEN entries. The occlusion heuristic is for thinning the full peak database; a curated photo list should show every entry inside the field of view. Unrestricted export (golden-pinned) unchanged. - gipfelweb Makefile: V ?= 0.05 knob for the peak view, -V 0 for the photo index; per-image %.opts now appended after the standard flags (they were placed before the subcommand and silently ignored)
2026-10-28core: guard atof prefix slicing against char boundariesJohannes Hofmann
The longest-numeric-prefix fallback sliced s[..i] at every byte index, which panics when i lands inside a multi-byte character (reachable via lossy-decoded Latin-1 database fields, e.g. a trailing degree sign). Skip non-boundary indices; behavior on ASCII numeric fields is unchanged. Includes regression test atof("12.5 deg").
2026-10-28core: fix focal-length-to-scale constant (36 mm film width, not 35)Johannes Hofmann
The 35mm film frame is 36 mm wide, so a lens with 35mm-equivalent focal length f projects with focal length f*w/36 in pixels. The original C++ code divided by 35, making the EXIF-derived initial scale ~2.9% too large (and the fitted focal readout ~2.9% low). - EXIF init and the focal slider/readout now use /36 - the gipfel JPEG comment KEEPS its historical scale*35/w encoding (focal_from_comment flag), so annotated JPEGs written by any older gipfel version still reproduce the identical view, and files saved by this version remain readable by them - new regression test focal_scale_exif_vs_comment; golden tests untouched (they pin the comment path) Verified against real photos: optical shots now agree with EXIF within ~1% (was ~3.6%).
2026-10-28core: guard atof prefix slicing against char boundariesJohannes Hofmann
The longest-numeric-prefix fallback sliced s[..i] at every byte index, which panics when i lands inside a multi-byte character (reachable via lossy-decoded Latin-1 database fields, e.g. a trailing degree sign). Skip non-boundary indices; behavior on ASCII numeric fields is unchanged. Includes regression test atof("12.5 deg").
2026-10-28core: fix focal-length-to-scale constant (36 mm film width, not 35)Johannes Hofmann
The 35mm film frame is 36 mm wide, so a lens with 35mm-equivalent focal length f projects with focal length f*w/36 in pixels. The original C++ code divided by 35, making the EXIF-derived initial scale ~2.9% too large (and the fitted focal readout ~2.9% low). - EXIF init and the focal slider/readout in both apps now use /36 - the gipfel JPEG comment KEEPS its historical scale*35/w encoding (focal_from_comment flag), so annotated JPEGs written by any older gipfel version still reproduce the identical view, and files saved by this version remain readable by them - new regression test focal_scale_exif_vs_comment; golden tests untouched (they pin the comment path)
2026-10-27web: GPX track loadingJohannes Hofmann
- core: track::load_gpx_from_bytes (path wrapper delegates to it; same hardening: size cap, no entity expansion, direct-child <ele>) - sidebar: 'Load GPX Track…' button + hidden .gpx file input; the track swaps in via remove_hills(FLAG_TRACK_POINT) + add_hills, so marker hill indices never shift (track hills always live at the end of the hill list) - rendering: desktop parity — consecutive visible points joined with round-cap strokes, width = scale*track_width/(dist_m*10) clamped to [1,1000] image px, red (blue when hidden by terrain); a Track width slider (50-1000 m, default 200) appears in Display once a track is loaded - track points and duplicates are excluded from guide dots, hover and click hit-testing (they are scenery, not markable peaks)
2026-10-27wasm: experimental browser spikeJohannes Hofmann
Proves the gipfel core can run in the browser via WASM. Enabled by the earlier GSL removal: the core is now pure Rust. gipfel-core gains byte-oriented entry points (no filesystem) alongside the existing path-based ones: - hill::load_from_bytes, Panorama::load_data_from_bytes - metadata: load_image_from_bytes, read_jpeg_comment_from_bytes, write_jpeg_comment_to_bytes, save_image_to_bytes (EXIF via Cursor) New crate gipfel-wasm (experimental, not shipped with the app): - wasm-bindgen surface: version() + fit_demo(db_bytes, jpg_bytes) which runs the whole pipeline in memory: parse hill DB, read gipfel JPEG comment / EXIF, synthesize 5 observations from visible hills, perturb, refit (pure-Rust LM), report JSON with reprojection error - demo/index.html: file pickers + result pane (wasm-pack --target web) - build.sh: adds the wasm target, builds with wasm-pack, prints serve cmd - native test runs the same pipeline against gipfel.dat + test.jpg and asserts sub-pixel reprojection error (passes here) To try on a machine with rustup: cd crates/gipfel-wasm && ./build.sh
2026-10-26Replace the C++ implementation with the Rust portJohannes Hofmann
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.