-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencodingtypes.go
47 lines (41 loc) · 1.27 KB
/
encodingtypes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package core
import (
"errors"
)
// EncodingType holds the information on a EncodingType
type EncodingType struct {
Code int
Value string
}
// List of supported EncodingTypes, do not change!!
var (
EncodingUnknown = EncodingType{0, "unknown"}
EncodingGeoJSON = EncodingType{1, "application/vnd.geo+json"}
EncodingPDF = EncodingType{2, "application/pdf"}
EncodingSensorML = EncodingType{3, "http://www.opengis.net/doc/IS/SensorML/2.0"}
)
// EncodingValues is a list of names mapped to their EncodingValue
var EncodingValues = []EncodingType{
EncodingUnknown,
EncodingGeoJSON,
EncodingPDF,
EncodingSensorML,
}
//GetSupportedEncodings returns a list of supported encodings
func GetSupportedEncodings() string {
var supportedEncodings string
for _, k := range EncodingValues {
supportedEncodings += k.Value + ", "
}
return supportedEncodings
}
// CreateEncodingType returns the int representation for a given encoding, returns an error when encoding is not supported
func CreateEncodingType(encoding string) (EncodingType, error) {
for _, k := range EncodingValues {
if k.Value == encoding {
return k, nil
}
}
supportedEncodings := GetSupportedEncodings()
return EncodingUnknown, errors.New("Encoding not supported. Supported encodings:" + supportedEncodings)
}