Skip to content
This repository was archived by the owner on May 27, 2020. It is now read-only.

Commit 6b474a0

Browse files
committed
debug mode added
1 parent c5aace7 commit 6b474a0

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

main.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
var target gpx.Wpt
1616
var dist *float64
17+
var debug *bool
1718
var wg sync.WaitGroup
1819
var globMinDist = math.MaxFloat64
1920
var globAbsFileName string
@@ -41,11 +42,15 @@ func scan(file string) {
4142
}
4243
}
4344

44-
if minDist <= *dist {
45+
if *debug {
4546
fmt.Printf("%8.0f m, %s\n", minDist, absFileName)
46-
} else if globMinDist > minDist {
47-
globMinDist = minDist
48-
globAbsFileName = absFileName
47+
} else {
48+
if minDist <= *dist {
49+
fmt.Printf("%8.0f m, %s\n", minDist, absFileName)
50+
} else if globMinDist > minDist {
51+
globMinDist = minDist
52+
globAbsFileName = absFileName
53+
}
4954
}
5055
}
5156

@@ -55,6 +60,7 @@ func main() {
5560
lon := flag.Float64("lon", 0, "longitude of target (East to West)")
5661
dist = flag.Float64("dist", 1000, "distance between target and waypoint in meters")
5762
root := flag.String("path", ".", "path containing the gpx files (from the executable)")
63+
debug = flag.Bool("debug", false, "debug mode (print out all file distances)")
5864

5965
flag.Parse()
6066

@@ -92,10 +98,11 @@ func main() {
9298

9399
wg.Wait()
94100

95-
fmt.Println("\nNearest out of dist was:")
96-
97-
if globMinDist != math.MaxFloat64 {
98-
fmt.Printf("%8.0f m, %s", globMinDist, globAbsFileName)
101+
if *debug {
102+
fmt.Println("\nNearest out of dist was:")
103+
if globMinDist != math.MaxFloat64 {
104+
fmt.Printf("%8.0f m, %s", globMinDist, globAbsFileName)
105+
}
99106
}
100107

101108
}

0 commit comments

Comments
 (0)