-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
135 lines (129 loc) · 3.49 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package main
import (
"gopkg.in/urfave/cli.v1"
"os"
"sort"
log "github.com/Sirupsen/logrus"
"io/ioutil"
"github.com/and-hom/gpx-cli/v2"
)
func main() {
log.SetOutput(ioutil.Discard)
for _, arg := range os.Args {
if arg == "--verbose" {
log.SetOutput(os.Stderr)
}
}
app := cli.NewApp()
app.Name = "Gpx Helper"
app.Usage = "Simple command line interface to GPX"
app.EnableBashCompletion = true
app.Commands = []cli.Command{
{
Name: "concat",
Aliases: []string{"c"},
Usage: "concatenate GPX tracks",
Action: concat,
Flags: []cli.Flag{
cli.StringFlag{
Name: "order-by",
Usage: "Sort order for points in new track - by input files order or by point timestamp",
},
cli.StringFlag{
Name: "out",
Usage: "Target file. Use '-' to print to stdout",
},
cli.BoolFlag{
Name: "preserve-segments",
Usage: "Preserve source track segments (by-default no)",
},
},
},
{
Name: "length",
Aliases: []string{"len", "l"},
Usage: "Calculate track length",
Action: trklen,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "2d",
Usage: "Do not use altitude in calculations",
},
},
},
{
Name: "simplify",
Usage: "Remove track artifacts when navigator does not change position but writes track",
Action: trksimpl,
Flags: []cli.Flag{
cli.UintFlag{
Name:"min-points",
Usage:"Minimum count of near-placed points to delete",
},
cli.UintFlag{
Name: "max-dist",
Usage:"Maximum distance between any points in cluster to remove",
},
cli.BoolFlag{
Name:"interactive",
Usage:"Ask for every cluster remove action [NOT IMPLEMENTED YET]",
},
cli.StringFlag{
Name: "out",
Usage: "Target file. Use '-' to print to stdout",
},
},
},
{
Name: "cut",
Usage: "Remove parts from track according to query",
Action: trkcut,
Flags: []cli.Flag{
cli.StringFlag{
Name: "query",
Usage: "Target file. Use '-' to print to stdout",
},
cli.StringFlag{
Name: "out",
Usage: "Target file. Use '-' to print to stdout",
},
},
},
{
Name: "filter",
Usage: "Concat data, calculate features, apply model and remove some track parts",
Action: v2.Filter,
Flags: []cli.Flag{
cli.StringFlag{
Name: v2.FILTER_MODE_FLAG,
Usage: "Use one of n,t,s,ts - data concatenation model. " +
"\n\tn - to concat all poinst from all files to single segment " +
"(track sort by first point timestamp). " +
"\n\tt - preserve tracks, but concat segments inside each track. " +
"\n\ts - preserve segments but put it into one track order by first point timestamp." +
"\n\tts or st - preserve tracks and segments" +
"\nAll data will be processed only inside the unit - track and segment!",
},
cli.StringFlag{
Name: v2.FILTER_MODEL_FLAG,
Usage: "Select the processing model. Available are:" +
"\nnone - by default. Do not remove anything" +
"\nsimplify1 - remove track artifacts when navigator does not change position but writes track",
},
cli.StringFlag{
Name: v2.FILTER_MODEL_PARAMS_FLAG,
Usage: "model dependent-params",
},
},
},
}
app.Flags = []cli.Flag{
cli.BoolFlag{
Name:"verbose",
Usage:"Switch logging on",
},
}
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
app.Run(os.Args)
}