summaryrefslogtreecommitdiff
path: root/crates/gipfel-cli
diff options
context:
space:
mode:
Diffstat (limited to 'crates/gipfel-cli')
-rw-r--r--crates/gipfel-cli/examples/overlay.rs30
-rw-r--r--crates/gipfel-cli/src/main.rs15
2 files changed, 41 insertions, 4 deletions
diff --git a/crates/gipfel-cli/examples/overlay.rs b/crates/gipfel-cli/examples/overlay.rs
new file mode 100644
index 0000000..3ce8745
--- /dev/null
+++ b/crates/gipfel-cli/examples/overlay.rs
@@ -0,0 +1,30 @@
+// Dev helper: project hills for a given viewpoint and print image coords.
+// usage: overlay <lat> <lon> <height> <az> <pitch> <roll> <focal35> <w> <h>
+use gipfel_core::panorama::Panorama;
+
+fn main() {
+ let a: Vec<String> = std::env::args().collect();
+ let n: Vec<f64> = a[1..].iter().map(|s| s.parse().unwrap()).collect();
+ let (lat, lon, height, az, pitch, roll, focal, w, h) =
+ (n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7], n[8]);
+ let mut p = Panorama::new();
+ p.load_data("gipfel.dat").unwrap();
+ p.set_view_lat(lat);
+ p.set_view_long(lon);
+ p.set_view_height(height);
+ p.set_scale(focal * w.max(h) / 36.0);
+ p.set_center_angle(az);
+ p.set_pitch_angle(pitch);
+ p.set_roll_angle(roll);
+ p.max_view_angle = 60_f64.to_radians();
+ p.update_visible_mountains(None);
+ println!("# az={az} pitch={pitch} scale={}", focal * w.max(h) / 36.0);
+ for &i in &p.visible {
+ let hill = &p.hills[i];
+ let d = p.get_real_distance(i) / 1000.0;
+ if hill.x.abs() < w / 2.0 && hill.y.abs() < h / 2.0 && hill.height > 1500.0 {
+ // convert center-relative coords to full image coords
+ println!("{:.0} {:.0} {} {:.0}m {:.1}km", hill.x + w / 2.0, hill.y + h / 2.0, hill.name, hill.height, d);
+ }
+ }
+}
diff --git a/crates/gipfel-cli/src/main.rs b/crates/gipfel-cli/src/main.rs
index f0690a8..06b1447 100644
--- a/crates/gipfel-cli/src/main.rs
+++ b/crates/gipfel-cli/src/main.rs
@@ -12,7 +12,7 @@ fn usage() {
\n\
commands:\n\
\x20 export-position <img> print position CSV line\n\
- \x20 export-hills <img> [-d <data>] [-e <hills>] export hill positions\n\
+ \x20 export-hills <img> [-d <data>] [-e <hills>] [-V <r>] export hill positions\n\
\x20 info <img> show parsed metadata\n\
\x20 stitch [-t out.tif [-4]] [-j out.jpg] [-w N]\n\
\x20 [-h N] [-r from,to] [-b] img... cylindrical panorama\n\
@@ -45,7 +45,7 @@ fn fmt_f(v: f64) -> String {
}
}
-fn export_hills(img: &str, data: &str, export_file: Option<&str>) -> i32 {
+fn export_hills(img: &str, data: &str, export_file: Option<&str>, vis: f64) -> i32 {
let Some((w, h)) = image_dimensions(img) else {
eprintln!("could not read image {}", img);
return 1;
@@ -61,7 +61,7 @@ fn export_hills(img: &str, data: &str, export_file: Option<&str>) -> i32 {
eprintln!("Could not load datafile {}: {}", data, e);
return 1;
}
- pan.set_height_dist_ratio(0.07); // C default "visibility"
+ pan.set_height_dist_ratio(vis); // "visibility" threshold, C default 0.07
if !have_info {
eprintln!("No gipfel info available for {}.", img);
@@ -328,9 +328,16 @@ fn main() {
let img = &args[2];
let mut data = "gipfel.dat".to_string();
let mut export_file: Option<String> = None;
+ let mut vis = 0.07;
let mut i = 3;
while i < args.len() {
match args[i].as_str() {
+ "-V" => {
+ if i + 1 < args.len() {
+ vis = args[i + 1].trim().parse().unwrap_or(0.07);
+ i += 1;
+ }
+ }
"-d" => {
if i + 1 < args.len() {
data = args[i + 1].clone();
@@ -347,7 +354,7 @@ fn main() {
}
i += 1;
}
- export_hills(img, &data, export_file.as_deref())
+ export_hills(img, &data, export_file.as_deref(), vis)
}
}
"info" => {