-
Notifications
You must be signed in to change notification settings - Fork 0
/
gps.go
43 lines (36 loc) · 859 Bytes
/
gps.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
package CoreSQLGPS
import (
"database/sql/driver"
"encoding/json"
"errors"
)
//一组坐标系
type FieldsPoints []FieldsPoint
//sql底层处理器
func (t FieldsPoints) Value() (driver.Value, error) {
return json.Marshal(t)
}
func (t *FieldsPoints) Scan(value interface{}) error {
b, ok := value.([]byte)
if !ok {
return errors.New("type assertion to []byte failed")
}
return json.Unmarshal(b, &t)
}
//坐标设计
type FieldsPoint struct {
//坐标位置
Longitude float64 `db:"longitude" json:"longitude"`
Latitude float64 `db:"latitude" json:"latitude"`
}
//sql底层处理器
func (t FieldsPoint) Value() (driver.Value, error) {
return json.Marshal(t)
}
func (t *FieldsPoint) Scan(value interface{}) error {
b, ok := value.([]byte)
if !ok {
return errors.New("type assertion to []byte failed")
}
return json.Unmarshal(b, &t)
}