summaryrefslogtreecommitdiff
path: root/src/Hill.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Hill.cxx')
-rw-r--r--src/Hill.cxx33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/Hill.cxx b/src/Hill.cxx
index 08d834f..4057524 100644
--- a/src/Hill.cxx
+++ b/src/Hill.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Hill.cxx,v 1.16 2005/06/22 19:47:20 hofmann Exp $"
+// "$Id: Hill.cxx,v 1.17 2005/06/22 20:40:35 hofmann Exp $"
//
// Hill routines.
//
@@ -67,6 +67,16 @@ Hills::Hills() {
deg2rad = pi_d / 180.0;
}
+Hills::Hills(const Hills *h) {
+ num = h->num;
+ cap = h->cap;
+ m = (Hill **) malloc(cap * sizeof(Hill *));
+ memcpy(m, h->m, cap * sizeof(Hill *));
+
+ pi_d = asin(1.0) * 2.0;
+ deg2rad = pi_d / 180.0;
+}
+
int
Hills::load(const char *file) {
FILE *fp;
@@ -184,6 +194,18 @@ comp_mountains_phi(const void *n1, const void *n2) {
}
}
+static int
+comp_mountains_name(const void *n1, const void *n2) {
+ Hill *m1 = *(Hill **)n1;
+ Hill *m2 = *(Hill **)n2;
+
+ if (m1 && m2) {
+ return strcmp(m1->name, m2->name);
+ } else {
+ return 0;
+ }
+}
+
void
Hills::sort() {
if (!m) {
@@ -203,6 +225,15 @@ Hills::sort_phi() {
}
void
+Hills::sort_name() {
+ if (!m) {
+ return;
+ }
+
+ qsort(m, num, sizeof(Hill *), comp_mountains_name);
+}
+
+void
Hills::clear() {
if (m) {
free(m);