-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
62 lines (51 loc) · 1.4 KB
/
main.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
54
55
56
57
58
59
60
61
62
package main
import (
"flag"
"go/build"
_ "image/jpeg"
_ "image/png"
"log"
"os"
"path/filepath"
"github.com/asgaines/glocplot/img"
"github.com/asgaines/glocplot/locations"
"github.com/asgaines/glocplot/plot"
)
func main() {
gopath := os.Getenv("GOPATH")
if gopath == "" {
gopath = build.Default.GOPATH
}
var locationF string
var imageF string
var outputImageF string
var size uint
var showLines bool
flag.StringVar(&locationF, "location", "", "Path to file with location history")
flag.StringVar(&imageF, "image", filepath.Join(gopath, "src/github.com/asgaines/glocplot/assets/images/Earth.png"), "Path to map image")
flag.StringVar(&outputImageF, "output", "glocplot_result.png", "Image output filename")
flag.UintVar(&size, "size", 1, "Size of each point and width of line")
flag.BoolVar(&showLines, "lines", true, "Show lines between points for continuity")
flag.Parse()
if locationF == "" {
flag.PrintDefaults()
log.Fatal("Please provide path to location history file")
}
data, err := locations.Load(locationF)
if err != nil {
log.Fatal(err)
}
dimg, err := img.Load(imageF)
if err != nil {
log.Fatal(err)
}
err = plot.Locations(dimg, &data.Locations, size, showLines)
if err != nil {
log.Fatal(err)
}
err = img.Write(outputImageF, dimg)
if err != nil {
log.Fatal(err)
}
log.Printf("Successfully plotted %d locations to %s", len(data.Locations), outputImageF)
}