Skip to content

Commit

Permalink
embed version info in KML/Z description
Browse files Browse the repository at this point in the history
  • Loading branch information
stronnag committed Feb 26, 2024
1 parent 89127e0 commit 0e1cbd8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
10 changes: 5 additions & 5 deletions cmd/flightlog2kml/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ import (
var GitCommit = "local"
var GitTag = "0.0.0"

func getVersion() string {
func GetVersion() string {
return fmt.Sprintf("%s %s commit:%s", filepath.Base(os.Args[0]), GitTag, GitCommit)
}

func main() {
dump_log := os.Getenv("DUMP_LOG") != ""
files, _ := options.ParseCLI(getVersion)
files, _ := options.ParseCLI(GetVersion)
if len(files) == 0 {
if len(options.Config.Mission) > 0 {
outms := kmlgen.GenKmlName(options.Config.Mission, options.Config.MissionIndex)
kmlgen.GenerateMissionOnly(outms)
kmlgen.GenerateMissionOnly(outms, GetVersion)
show_output(outms)
} else if len(options.Config.Cli) > 0 {
outms := kmlgen.GenKmlName(options.Config.Cli, 0)
kmlgen.GenerateCliOnly(outms)
kmlgen.GenerateCliOnly(outms, GetVersion)
show_output(outms)
} else {
options.Usage()
Expand Down Expand Up @@ -93,7 +93,7 @@ func main() {
}
} else if options.Config.Summary == false {
outfn = kmlgen.GenKmlName(b.Logname, b.Index)
kmlgen.GenerateKML(ls.H, ls.L, outfn, b, ls.M)
kmlgen.GenerateKML(ls.H, ls.L, outfn, b, ls.M, GetVersion)
}
}
for k, v := range ls.M {
Expand Down
19 changes: 13 additions & 6 deletions cmd/mission2kml/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var (
outfile string
)

func getVersion() string {
func GetVersion() string {
return fmt.Sprintf("%s %s commit:%s", filepath.Base(os.Args[0]), GitTag, GitCommit)
}

Expand Down Expand Up @@ -72,7 +72,7 @@ Examples:
flag.PrintDefaults()
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, extra)
fmt.Fprintln(os.Stderr, getVersion())
fmt.Fprintln(os.Stderr, GetVersion())
}

defs := os.Getenv("BBL2KML_OPTS")
Expand Down Expand Up @@ -140,13 +140,20 @@ Examples:
}

func generateKML(mfile string, idx int, dms bool, homep []float64, clifile string) error {
var kname string
var sb strings.Builder
kname := ""
sb.Write([]byte(fmt.Sprintf("Generator: %s", GetVersion())))
if mfile != "" {
sb.Write([]byte(fmt.Sprintf(" mission: %s", filepath.Base(mfile))))
kname = filepath.Base(mfile)
} else {
kname = filepath.Base(clifile)
}
d := kml.Folder(kml.Name(kname)).Add(kml.Description(kname)).Add(kml.Open(true))
if clifile != "" {
sb.Write([]byte(fmt.Sprintf(" cli: %s", filepath.Base(clifile))))
if mfile == "" {
kname = filepath.Base(clifile)
}
}
d := kml.Folder(kml.Name(kname)).Add(kml.Description(sb.String())).Add(kml.Open(true))
k := kml.KML(d)
var err error

Expand Down
15 changes: 9 additions & 6 deletions pkg/kmlgen/kmlbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,19 +479,21 @@ func add_ground_track(rec types.LogRec) kml.Element {
return f
}

func GenerateCliOnly(outfn string) {
func GenerateCliOnly(outfn string, gv func() string) {
kname := filepath.Base(options.Config.Cli)
d := kml.Folder(kml.Name(kname)).Add(kml.Open(true))
desc := fmt.Sprintf("Generator: %s", gv())
d := kml.Folder(kml.Name(kname)).Add(kml.Description(desc)).Add(kml.Open(true))
sfx := Generate_cli_kml(options.Config.Cli)
for _, s := range sfx {
d.Add(s)
}
write_kml(outfn, d)
}

func GenerateMissionOnly(outfn string) {
func GenerateMissionOnly(outfn string, gv func() string) {
kname := filepath.Base(options.Config.Mission)
d := kml.Folder(kml.Name(kname)).Add(kml.Open(true))
desc := fmt.Sprintf("Generator: %s", gv())
d := kml.Folder(kml.Name(kname)).Add(kml.Description(desc)).Add(kml.Open(true))
_, mm, err := mission.Read_Mission_File(options.Config.Mission)
if err == nil {
isviz := true
Expand Down Expand Up @@ -529,7 +531,7 @@ func GenerateMissionOnly(outfn string) {
}

func GenerateKML(hpos types.HomeRec, rec types.LogRec, outfn string,
meta types.FlightMeta, smap types.MapRec) {
meta types.FlightMeta, smap types.MapRec, gv func() string) {

defviz := !(options.Config.Rssi && rec.Items[0].Rssi > 0)
ts0 := rec.Items[0].Utc
Expand All @@ -539,7 +541,8 @@ func GenerateKML(hpos types.HomeRec, rec types.LogRec, outfn string,
Add(generate_shared_styles(0)...).
Add(getPoints(rec, hpos, COL_STYLE_MODE, defviz)...)

d := kml.Folder(kml.Name(meta.LogName())).Add(kml.Open(true))
desc := fmt.Sprintf("Generator: %s", gv())
d := kml.Folder(kml.Name(meta.LogName())).Add(kml.Description(desc)).Add(kml.Open(true))
d.Add(add_ground_track(rec))

if len(options.Config.Mission) > 0 {
Expand Down

0 comments on commit 0e1cbd8

Please sign in to comment.