summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-26 17:52:24 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-26 17:52:24 +0100
commiteb72978eb28008f677145dbeb1b3090ed47a5b19 (patch)
tree159f52e636a20c2320d64e9a67a84c07fb2af8eb
parent4459b8bfd97f2373ce55b37e905b419f2c0e8920 (diff)
validate lsq results
-rw-r--r--src/Panorama.cxx4
-rw-r--r--src/ProjectionLSQ.cxx24
2 files changed, 20 insertions, 8 deletions
diff --git a/src/Panorama.cxx b/src/Panorama.cxx
index b0d0228..ad0fdf4 100644
--- a/src/Panorama.cxx
+++ b/src/Panorama.cxx
@@ -130,7 +130,9 @@ Panorama::comp_params(Hills *h) {
int ret;
ret = proj->comp_params(h, &parms);
- update_visible_mountains();
+ if (ret == 0)
+ update_visible_mountains();
+
return ret;
}
diff --git a/src/ProjectionLSQ.cxx b/src/ProjectionLSQ.cxx
index 364c740..45fd76b 100644
--- a/src/ProjectionLSQ.cxx
+++ b/src/ProjectionLSQ.cxx
@@ -37,6 +37,7 @@ ProjectionLSQ::comp_params(const Hills *h, ViewParams *parms) {
const Hill *m1, *m2;
double scale_tmp;
int distortion_correct = 0;
+ ViewParams new_parms;
if (h->get_num() < 2) {
fprintf(stderr, "Please position at least 2 hills\n");
@@ -60,17 +61,26 @@ ProjectionLSQ::comp_params(const Hills *h, ViewParams *parms) {
return 1;
}
- parms->a_center = m1->alph;
- parms->scale = scale_tmp;
- parms->a_nick = 0.0;
- parms->a_tilt = 0.0;
+ new_parms.a_center = m1->alph;
+ new_parms.scale = scale_tmp;
+ new_parms.a_nick = 0.0;
+ new_parms.a_tilt = 0.0;
+ new_parms.k0 = parms->k0;
+ new_parms.k1 = parms->k1;
+ new_parms.x0 = parms->x0;
- lsq(h, parms, 0);
+ lsq(h, &new_parms, 0);
- if (distortion_correct) {
- lsq(h, parms, 1);
+ if (distortion_correct)
+ lsq(h, &new_parms, 1);
+
+ if (isnan(new_parms.scale) || new_parms.scale < 50.0) {
+ fprintf(stderr, "Could not determine reasonable view parameters\n");
+ return 1;
}
+ *parms = new_parms;
+
return 0;
}