-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathstarbucks.go
49 lines (41 loc) · 849 Bytes
/
starbucks.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
package main
import (
"encoding/json"
"image/color"
"io/ioutil"
"log"
"github.com/mmcloughlin/globe"
)
type CoffeeShop struct {
Lat float64 `json:"latitude"`
Lng float64 `json:"longitude"`
}
func LoadCoffeeShops(filename string) ([]CoffeeShop, error) {
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
shops := []CoffeeShop{}
err = json.Unmarshal(data, &shops)
if err != nil {
return nil, err
}
return shops, nil
}
func main() {
shops, err := LoadCoffeeShops("./starbucks.json")
if err != nil {
log.Fatal(err)
}
green := color.NRGBA{0x00, 0x64, 0x3c, 192}
g := globe.New()
g.DrawGraticule(10.0)
for _, s := range shops {
g.DrawDot(s.Lat, s.Lng, 0.05, globe.Color(green))
}
g.CenterOn(40.645423, -73.903879)
err = g.SavePNG("starbucks.png", 400)
if err != nil {
log.Fatal(err)
}
}