forked from go-spatial/tegola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeature.go
42 lines (38 loc) · 815 Bytes
/
feature.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
package provider
import (
"strconv"
"github.com/go-spatial/geom"
)
type Feature struct {
ID uint64
Geometry geom.Geometry
SRID uint64
Tags map[string]interface{}
}
// ConvertFeatureID attempts to convert an interface value to an uint64
func ConvertFeatureID(v interface{}) (uint64, error) {
switch aval := v.(type) {
case float64:
return uint64(aval), nil
case int64:
return uint64(aval), nil
case uint64:
return aval, nil
case uint:
return uint64(aval), nil
case int8:
return uint64(aval), nil
case uint8:
return uint64(aval), nil
case uint16:
return uint64(aval), nil
case int32:
return uint64(aval), nil
case uint32:
return uint64(aval), nil
case string:
return strconv.ParseUint(aval, 10, 64)
default:
return 0, ErrUnableToConvertFeatureID{val: v}
}
}