summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--src/Hill.H3
-rw-r--r--src/Hill.cxx20
-rw-r--r--src/ProjectionCylindrical.H1
-rw-r--r--src/ProjectionCylindrical.cxx16
-rw-r--r--src/ProjectionLSQ.H2
6 files changed, 41 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 072cba6..57d3cd5 100644
--- a/NEWS
+++ b/NEWS
@@ -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).
diff --git a/src/Hill.H b/src/Hill.H
index ac4917a..d408dc7 100644
--- a/src/Hill.H
+++ b/src/Hill.H
@@ -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();