diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-01 22:40:08 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-01 22:40:08 +0200 |
| commit | 80f2e72cd4818a4c0a5b5d4afb93dc23f04208e2 (patch) | |
| tree | d6f0323ed7e9e29190742750d70ee8ec392573c5 /main.go | |
| parent | ef12ceb8105c21cbfd9cd7ac9935893086d5af51 (diff) | |
feat: Download mountain passes from centcols into SQLite
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 31 |
1 files changed, 29 insertions, 2 deletions
@@ -1,20 +1,47 @@ package main import ( + "database/sql" "flag" "log/slog" "os" "runtime/pprof" + "time" + mountainpass "github.com/martinlehoux/biking_home/mountain_pass" "github.com/martinlehoux/biking_home/ride" "github.com/martinlehoux/kagamigo/kcore" + _ "github.com/mattn/go-sqlite3" ) -var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") -var parser = ride.GPXRideParser{} +var ( + download = flag.Bool("download", false, "download mountain passes into the database") + resume = flag.Bool("resume", false, "skip departments already cached on disk") + demo = flag.Bool("demo", false, "run the climb similarity demo") + cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") + parser = ride.GPXRideParser{} +) func main() { flag.Parse() + if *download { + runDownload() + return + } + if *demo { + runDemo() + } +} + +func runDownload() { + db, err := sql.Open("sqlite3", "biking_home.db") + kcore.Expect(err, "failed to open database") + defer db.Close() + err = mountainpass.DownloadMountainPasses(db, 5*time.Second, *resume) + kcore.Expect(err, "failed to download mountain passes") +} + +func runDemo() { if *cpuprofile != "" { f, err := os.Create(*cpuprofile) kcore.Expect(err, "failed to create CPU profile") |