summaryrefslogtreecommitdiff
path: root/src/Hill.cxx
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-29 14:00:12 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-29 14:00:12 +0200
commitd2eca5bbe81dc4a899c97f1423c392554113f852 (patch)
treec853ff74d7b221cd1b6b610e9e397c2cc681586d /src/Hill.cxx
parentdfb33cc7bd701e7549d28cb496c2dab73c92e2d2 (diff)
fix long standing bug in label positioning code
Diffstat (limited to 'src/Hill.cxx')
-rw-r--r--src/Hill.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Hill.cxx b/src/Hill.cxx
index f4ba112..9056d2f 100644
--- a/src/Hill.cxx
+++ b/src/Hill.cxx
@@ -225,6 +225,17 @@ comp_mountains_name(const void *n1, const void *n2) {
}
}
+static int
+comp_mountains_label_y(const void *n1, const void *n2) {
+ Hill *m1 = *(Hill **)n1;
+ Hill *m2 = *(Hill **)n2;
+
+ if (m1 && m2)
+ return (m2->y + m2->label_y) - (m1->y + m1->label_y);
+ else
+ return 0;
+}
+
void
Hills::sort() {
if (!m)
@@ -250,6 +261,14 @@ Hills::sort_name() {
}
void
+Hills::sort_label_y() {
+ if (!m)
+ return;
+
+ qsort(m, num, sizeof(Hill *), comp_mountains_label_y);
+}
+
+void
Hills::clear() {
if (m) {
free(m);