diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2005-09-12 16:57:26 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2005-09-12 16:57:26 +0200 |
commit | 7d3e18176141b7116ed0444568b2caf73e21a50b (patch) | |
tree | ff93fd8e89d8a9377b45d401563483e82e682ce9 | |
parent | 55989ca2fcb462442aa8a3029fdc10030dd04ac9 (diff) |
add support for gps-track format
-rw-r--r-- | src/Hill.cxx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Hill.cxx b/src/Hill.cxx index 59cdfca..9c39779 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -85,6 +85,7 @@ Hills::load(const char *file) { char **ap, *bp; double phi, lam, height; Hill *m; + int n; fp = fopen(file, "r"); if (!fp) { @@ -95,13 +96,16 @@ Hills::load(const char *file) { 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; } } - if (vals[1] && vals[3] && vals[4] && vals[5]) { + // 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]); @@ -109,6 +113,15 @@ Hills::load(const char *file) { 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); } } |