diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-04-01 13:16:44 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-04-01 13:16:44 +0200 |
commit | 9d8a88c1a46cc95f69e9bc0e50ed1134bef6c715 (patch) | |
tree | fa40a289a4fb129420c4c3099df0471c4236d9b4 | |
parent | c368443056c0eda834f4924ca36c141d8d97f89e (diff) |
fix bug in cylindrical projection
If one peak is "left" and one is "right" of north, cylindrical
projection was not able to compute proper viewing parameters.
This is fixed by adjusting alpha angles of known hills to be increasing
with x.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/Hill.H | 3 | ||||
-rw-r--r-- | src/Hill.cxx | 20 | ||||
-rw-r--r-- | src/ProjectionCylindrical.H | 1 | ||||
-rw-r--r-- | src/ProjectionCylindrical.cxx | 16 | ||||
-rw-r--r-- | src/ProjectionLSQ.H | 2 |
6 files changed, 41 insertions, 3 deletions
@@ -8,6 +8,8 @@ gipfel-0.2.9 * Show height in search dialog to distinguish peaks with equal names. * Added "File->Screen Dump" feature. * Improved label placing. +* Fix long standing bug with panoramic projection if one known peak + is "left" and one is "right" of north. gipfel-0.2.8 * Fix issue with image saving on some platforms (reported by David Mitchell). @@ -45,7 +45,8 @@ class Hills { SORT_ALPHA, SORT_PHI, SORT_NAME, - SORT_LABEL_Y + SORT_LABEL_Y, + SORT_X } SortType; Hills(); diff --git a/src/Hill.cxx b/src/Hill.cxx index f45c197..b053568 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -242,6 +242,23 @@ comp_mountains_label_y(const void *n1, const void *n2) { } } +static int +comp_mountains_x(const void *n1, const void *n2) { + Hill *m1 = *(Hill **)n1; + Hill *m2 = *(Hill **)n2; + + if (m1 && m2) { + if (m2->x < m1->x) + return 1; + else if (m2->x > m1->x) + return -1; + else + return 0; + } else { + return 0; + } +} + void Hills::sort(SortType t) { int (*cmp)(const void *, const void *); @@ -262,6 +279,9 @@ Hills::sort(SortType t) { case SORT_LABEL_Y: cmp = comp_mountains_label_y; break; + case SORT_X: + cmp = comp_mountains_x; + break; default: fprintf(stderr, "ERROR: Unknown sort type %d\n", t); return; diff --git a/src/ProjectionCylindrical.H b/src/ProjectionCylindrical.H index 41bad29..06709c4 100644 --- a/src/ProjectionCylindrical.H +++ b/src/ProjectionCylindrical.H @@ -13,6 +13,7 @@ class ProjectionCylindrical : public ProjectionLSQ { public: virtual double get_view_angle() {return 6.2831853;}; /* 360 deg */ + virtual int comp_params(const Hills *h, ViewParams *parms); #define ARGS double c_view, double c_nick, double c_tilt, double scale, double k0, double k1, double x0, double m_view, double m_nick virtual double mac_x(ARGS); diff --git a/src/ProjectionCylindrical.cxx b/src/ProjectionCylindrical.cxx index d41e5f8..094b494 100644 --- a/src/ProjectionCylindrical.cxx +++ b/src/ProjectionCylindrical.cxx @@ -1,5 +1,5 @@ // -// Copyright 2006 Johannes Hofmann <Johannes.Hofmann@gmx.de> +// Copyright 2006-2009 Johannes Hofmann <Johannes.Hofmann@gmx.de> // // This software may be used and distributed according to the terms // of the GNU General Public License, incorporated herein by reference. @@ -10,3 +10,17 @@ #include "ProjectionCylindrical.H" #include "ProjectionCylindrical_funcs.cxx" + +int +ProjectionCylindrical::comp_params(const Hills *h, ViewParams *parms) { + Hills h_monotone(h); + + h_monotone.sort(Hills::SORT_X); + + // ensure that alpha is increasing with x. + for (int i = 1; i < h_monotone.get_num(); i++) + if (h_monotone.get(i)->alph < h_monotone.get(i - 1)->alph) + h_monotone.get(i)->alph += asin(1.0) * 4.0; // += 2pi + + return ProjectionLSQ::comp_params(&h_monotone, parms); +} diff --git a/src/ProjectionLSQ.H b/src/ProjectionLSQ.H index 626c513..a380b4c 100644 --- a/src/ProjectionLSQ.H +++ b/src/ProjectionLSQ.H @@ -32,7 +32,7 @@ class ProjectionLSQ { void get_coordinates(double a_view, double a_nick, const ViewParams *parms, double *x, double *y); - int comp_params(const Hills *h, ViewParams *parms); + virtual int comp_params(const Hills *h, ViewParams *parms); virtual double get_view_angle(); |