From 364fadcbea5f37799bb42e663106e3a007746984 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 20:45:53 +0100 Subject: strip copyright --- src/Hill.cxx | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'src/Hill.cxx') diff --git a/src/Hill.cxx b/src/Hill.cxx index 277cefe..5ec35ee 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -1,21 +1,3 @@ -// -// Copyright 2005 by Johannes Hofmann -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// #include #include -- cgit v1.2.3 From 6c50749f40e50a4b6a260a262b40035bfe83fd76 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 20:49:30 +0100 Subject: add simplified copyright --- src/Hill.cxx | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Hill.cxx') diff --git a/src/Hill.cxx b/src/Hill.cxx index 5ec35ee..14b8f81 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -1,3 +1,8 @@ +// +// Copyright 2006 Johannes Hofmann +// +// This software may be used and distributed according to the terms +// of the GNU General Public License, incorporated herein by reference. #include #include -- cgit v1.2.3 From f8fb82ba705f6314d502b8efc8f03ecd16b8bed8 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 30 Oct 2006 22:27:04 +0100 Subject: more reindent --- src/Hill.cxx | 396 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 198 insertions(+), 198 deletions(-) (limited to 'src/Hill.cxx') diff --git a/src/Hill.cxx b/src/Hill.cxx index 14b8f81..d5ce1f6 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -14,284 +14,284 @@ static double pi_d, deg2rad; Hill::Hill(const char *n, double p, double l, double h) { - name = strdup(n); - phi = p; - lam = l; - height = h; - alph = 0.0; - x = 0; - y = 0; - flags = 0; + name = strdup(n); + phi = p; + lam = l; + height = h; + alph = 0.0; + x = 0; + y = 0; + flags = 0; } Hill::Hill(const Hill& h) { - name = strdup(h.name); - phi = h.phi; - lam = h.lam; - height = h.height; - alph = h.alph; - a_view = h.a_view; - a_view = h.a_view; - dist = h.dist; - x = h.x; - y = h.y; - label_x = h.label_x; - label_y = h.label_y; - flags = h.flags; + name = strdup(h.name); + phi = h.phi; + lam = h.lam; + height = h.height; + alph = h.alph; + a_view = h.a_view; + a_view = h.a_view; + dist = h.dist; + x = h.x; + y = h.y; + label_x = h.label_x; + label_y = h.label_y; + flags = h.flags; } Hill::Hill(int x_tmp, int y_tmp) { - name = NULL; - phi = 0.0; - lam = 0.0; - height = 0.0; - alph = 0.0; - x = x_tmp; - y = y_tmp; + name = NULL; + phi = 0.0; + lam = 0.0; + height = 0.0; + alph = 0.0; + x = x_tmp; + y = y_tmp; } Hill::~Hill() { - if (name) { - free(name); - } + if (name) { + free(name); + } } Hills::Hills() { - num = 0; - cap = 100; - m = (Hill **) malloc(cap * sizeof(Hill *)); + num = 0; + cap = 100; + m = (Hill **) malloc(cap * sizeof(Hill *)); - pi_d = asin(1.0) * 2.0; - deg2rad = pi_d / 180.0; + pi_d = asin(1.0) * 2.0; + 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 *)); + 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; + pi_d = asin(1.0) * 2.0; + deg2rad = pi_d / 180.0; } int Hills::load(const char *file) { - FILE *fp; - char buf[4000]; - char *vals[10]; - char **ap, *bp; - double phi, lam, height; - Hill *m; - int n; - - fp = fopen(file, "r"); - if (!fp) { - perror("fopen"); - return 1; - } - - while (fgets(buf, sizeof(buf), fp)) { - bp = buf; - memset(vals, 0, sizeof(vals)); - n = 0; - for (ap = vals; (*ap = strsep(&bp, ",")) != NULL;) { - n++; - if (++ap >= &vals[10]) { - break; - } - } - - // standard format including name and description - if (n == 6 && vals[1] && vals [3] && vals[4] && vals[5]) { - phi = atof(vals[3]) * deg2rad; - lam = atof(vals[4]) * deg2rad; - height = atof(vals[5]); - - m = new Hill(vals[1], phi, lam, height); - - add(m); - // track point format - } else if (n == 3 && vals[0] && vals[1] && vals[2]) { - phi = atof(vals[0]) * deg2rad; - lam = atof(vals[1]) * deg2rad; - height = atof(vals[2]); - - m = new Hill("", phi, lam, height); - - add(m); - } - } - - fclose(fp); - - return 0; + FILE *fp; + char buf[4000]; + char *vals[10]; + char **ap, *bp; + double phi, lam, height; + Hill *m; + int n; + + fp = fopen(file, "r"); + if (!fp) { + perror("fopen"); + return 1; + } + + while (fgets(buf, sizeof(buf), fp)) { + bp = buf; + memset(vals, 0, sizeof(vals)); + n = 0; + for (ap = vals; (*ap = strsep(&bp, ",")) != NULL;) { + n++; + if (++ap >= &vals[10]) { + break; + } + } + + // standard format including name and description + if (n == 6 && vals[1] && vals [3] && vals[4] && vals[5]) { + phi = atof(vals[3]) * deg2rad; + lam = atof(vals[4]) * deg2rad; + height = atof(vals[5]); + + m = new Hill(vals[1], phi, lam, height); + + add(m); + // track point format + } else if (n == 3 && vals[0] && vals[1] && vals[2]) { + phi = atof(vals[0]) * deg2rad; + lam = atof(vals[1]) * deg2rad; + height = atof(vals[2]); + + m = new Hill("", phi, lam, height); + + add(m); + } + } + + fclose(fp); + + return 0; } void Hills::mark_duplicates(double dist) { - Hill *m, *n; - int i, j; - - sort_phi(); - - for(i=0; iflags & Hill::TRACK_POINT) { - continue; - } - - if (m) { - j = i + 1; - n = get(j); - while (n && fabs(n->phi - m->phi) <= dist) { - if (! n->flags & Hill::DUPLICATE) { - if (fabs(n->lam - m->lam) <= dist && - fabs(n->height - m->height) <= 50.0 ) { - n->flags |= Hill::DUPLICATE; - } - } - j = j + 1; - n = get(j); - } - } - } + Hill *m, *n; + int i, j; + + sort_phi(); + + for(i=0; iflags & Hill::TRACK_POINT) { + continue; + } + + if (m) { + j = i + 1; + n = get(j); + while (n && fabs(n->phi - m->phi) <= dist) { + if (! n->flags & Hill::DUPLICATE) { + if (fabs(n->lam - m->lam) <= dist && + fabs(n->height - m->height) <= 50.0 ) { + n->flags |= Hill::DUPLICATE; + } + } + j = j + 1; + n = get(j); + } + } + } } Hills::~Hills() { - if (m) { - free(m); - } + if (m) { + free(m); + } } void Hills::add(Hill *m1) { - if (num >= cap) { - cap = cap?cap * 2:100; - m = (Hill **) realloc(m, cap * sizeof(Hill *)); - } + if (num >= cap) { + cap = cap?cap * 2:100; + m = (Hill **) realloc(m, cap * sizeof(Hill *)); + } - m[num++] = m1; + m[num++] = m1; } void Hills::add(Hills *h) { - for(int i=0; iget_num(); i++) { - add(h->get(i)); - } + for(int i=0; iget_num(); i++) { + add(h->get(i)); + } } static int comp_mountains(const void *n1, const void *n2) { - Hill *m1 = *(Hill **)n1; - Hill *m2 = *(Hill **)n2; - - if (m1 && m2) { - if (m1->alph < m2->alph) { - return 1; - } else if (m1->alph > m2->alph) { - return -1; - } else { - return 0; - } - } else { - return 0; - } + Hill *m1 = *(Hill **)n1; + Hill *m2 = *(Hill **)n2; + + if (m1 && m2) { + if (m1->alph < m2->alph) { + return 1; + } else if (m1->alph > m2->alph) { + return -1; + } else { + return 0; + } + } else { + return 0; + } } static int comp_mountains_phi(const void *n1, const void *n2) { - Hill *m1 = *(Hill **)n1; - Hill *m2 = *(Hill **)n2; - - if (m1 && m2) { - if (m1->phi < m2->phi) { - return 1; - } else if (m1->phi > m2->phi) { - return -1; - } else { - return 0; - } - } else { - return 0; - } + Hill *m1 = *(Hill **)n1; + Hill *m2 = *(Hill **)n2; + + if (m1 && m2) { + if (m1->phi < m2->phi) { + return 1; + } else if (m1->phi > m2->phi) { + return -1; + } else { + return 0; + } + } else { + return 0; + } } static int comp_mountains_name(const void *n1, const void *n2) { - Hill *m1 = *(Hill **)n1; - Hill *m2 = *(Hill **)n2; - - if (m1 && m2) { - return strcasecmp(m1->name, m2->name); - } else { - return 0; - } + Hill *m1 = *(Hill **)n1; + Hill *m2 = *(Hill **)n2; + + if (m1 && m2) { + return strcasecmp(m1->name, m2->name); + } else { + return 0; + } } void Hills::sort() { - if (!m) { - return; - } + if (!m) { + return; + } - qsort(m, num, sizeof(Hill *), comp_mountains); + qsort(m, num, sizeof(Hill *), comp_mountains); } void Hills::sort_phi() { - if (!m) { - return; - } + if (!m) { + return; + } - qsort(m, num, sizeof(Hill *), comp_mountains_phi); + qsort(m, num, sizeof(Hill *), comp_mountains_phi); } void Hills::sort_name() { - if (!m) { - return; - } + if (!m) { + return; + } - qsort(m, num, sizeof(Hill *), comp_mountains_name); + qsort(m, num, sizeof(Hill *), comp_mountains_name); } void Hills::clear() { - if (m) { - free(m); - m = NULL; - } - cap = 0; - num = 0; + if (m) { + free(m); + m = NULL; + } + cap = 0; + num = 0; } void Hills::clobber() { - int i; - - for(i=0; i= num) { - return NULL; - } else { - return m[n]; - } + if (n < 0 || n >= num) { + return NULL; + } else { + return m[n]; + } } -- cgit v1.2.3