/
tile_set.go
53 lines (44 loc) · 1.2 KB
/
tile_set.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
48
49
50
51
52
53
package snapmap
import (
"encoding/json"
"fmt"
"net/http"
"strings"
)
type TileSetService struct {
http *http.Client
}
func newTileSetService(http *http.Client) *TileSetService {
return &TileSetService{
http: http,
}
}
type TileSetId struct {
Type string `json:"type"`
Flavor string `json:"flavor"`
Epoch string `json:"epoch"`
}
type TileSetInfo struct {
Id TileSetId `json:"id"`
State string `json:"state"`
StartTime int `json:"startTime"`
LastUpdateTime int `json:"lastUpdateTime"`
PoiTileSetInfo interface{} `json:"poiTileSetInfo"`
}
type Response struct {
RenderConfig struct {
HeatmapGradient interface{} `json:"heatmapGradient"`
HeatNormalizationPeak int `json:"heatNormalizationPeak"`
FuzzNormalizationPeak float32 `json:"fuzzNormalizationPeak"`
HeatPointBaseRadius int `json:"heatPointBaseRadius"`
} `json:"renderConfig"`
TileSetInfos []TileSetInfo `json:"tileSetInfos"`
}
func (t *TileSetService) GetLatest(target *Response) (error) {
response, err := t.http.Post(fmt.Sprintf("%v/getLatestTileSet", SnapmapApiBaseUrl), "application/json", strings.NewReader("{}"))
if err != nil {
return err
}
defer response.Body.Close()
return json.NewDecoder(response.Body).Decode(target)
}