From 80f2e72cd4818a4c0a5b5d4afb93dc23f04208e2 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Sat, 1 Aug 2026 22:40:08 +0200 Subject: feat: Download mountain passes from centcols into SQLite --- main.go | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index cacbe98..f072210 100644 --- a/main.go +++ b/main.go @@ -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") -- cgit v1.2.3