Mercurial > gemma
diff pkg/models/gauge.go @ 1900:6a67cd819e93
To prepare stretch import made some model data types re-usable.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 18 Jan 2019 15:04:53 +0100 |
parents | 49e047c2106e |
children |
line wrap: on
line diff
--- a/pkg/models/gauge.go Fri Jan 18 14:58:34 2019 +0100 +++ b/pkg/models/gauge.go Fri Jan 18 15:04:53 2019 +0100 @@ -14,9 +14,6 @@ package models import ( - "errors" - "fmt" - "strconv" "time" "gemma.intevation.de/gemma/pkg/common" @@ -36,41 +33,3 @@ Gauge Isrs LatestDateIssue time.Time } - -// Isrs represents the gauge identification data structure -type Isrs struct { - CountryCode string - LoCode string - FairwaySection string - Orc string - Hectometre int -} - -// IsrsFromString converts string representation of isrs code to type Isrs -func IsrsFromString(isrsCode string) (*Isrs, error) { - if len(isrsCode) < 20 { - return nil, errors.New("ISRS code too short") - } - hm, err := strconv.Atoi(isrsCode[15:20]) - if err != nil { - return nil, err - } - isrs := Isrs{ - CountryCode: isrsCode[0:2], - LoCode: isrsCode[2:5], - FairwaySection: isrsCode[5:10], - Orc: isrsCode[10:15], - Hectometre: hm, - } - return &isrs, nil -} - -// String creates a isrs code string from Isrs -func (isrs *Isrs) String() string { - return fmt.Sprintf("%s%s%s%s%05d", - isrs.CountryCode, - isrs.LoCode, - isrs.FairwaySection, - isrs.Orc, - isrs.Hectometre) -}