Mercurial > gemma
changeset 602:10f898bbe50f
Sounding results: Accept if XYZ files are compressed with GZIP or BZIP2
having filename extensions ".gz" or ".bz2".
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 10 Sep 2018 11:04:28 +0200 |
parents | e3d8b732bc97 |
children | 3d33c53db1e3 |
files | cmd/soundingresults/main.go |
diffstat | 1 files changed, 17 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/cmd/soundingresults/main.go Mon Sep 10 10:47:01 2018 +0200 +++ b/cmd/soundingresults/main.go Mon Sep 10 11:04:28 2018 +0200 @@ -87,6 +87,23 @@ base := filepath.Base(fname) + compressed := strings.ToLower(filepath.Ext(base)) + for _, ext := range []string{".gz", ".bz2"} { + if ext == compressed { + base = base[:len(base)-len(ext)] + break + } + } + + // Cut .txt + base = base[:len(base)-len(filepath.Ext(base))] + + if !strings.HasSuffix(strings.ToUpper(base), "_WGS84") { + return meta{}, fmt.Errorf("%s is not in WGS84", base) + } + + base = base[:len(base)-len("_WGS84")] + log.Printf("base: %s\n", base) idx := strings.IndexRune(base, '_') @@ -103,14 +120,6 @@ rest := base[idx+1:] - rest = rest[:len(rest)-len(filepath.Ext(rest))] - - if !strings.HasSuffix(strings.ToUpper(rest), "_WGS84") { - return meta{}, fmt.Errorf("%s is not in WGS84", base) - } - - rest = rest[:len(rest)-len("_WGS84")] - if idx = strings.LastIndex(rest, "_"); idx == -1 { return meta{}, fmt.Errorf("%s has no depth reference", base) }