diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-05 22:59:46 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-05 22:59:46 +0200 |
| commit | 4b90740c41afb43d11e4dd2c0c9ed91654b7ce43 (patch) | |
| tree | b847f7e4411e60693947c857192f49e8b4d01547 | |
| parent | 8f829816e35a41844808d1d338fd02dcc0320981 (diff) | |
refactor: Remove demo CLI
| -rw-r--r-- | README.md | 9 | ||||
| -rw-r--r-- | cli/cli.go | 90 |
2 files changed, 1 insertions, 98 deletions
@@ -31,9 +31,6 @@ go build -o biking_home . # Resume an interrupted download, reusing departments already cached on disk ./biking_home -download -resume -# Run the climb-similarity and difficulty-score demo on the example rides -./biking_home -demo - # Import cached department CSVs (debug_department_06.csv, 13.csv) into the DB ./biking_home -import-cached @@ -46,8 +43,6 @@ go build -o biking_home . # Render an elevation chart with climb highlights and pass markers ./biking_home -chart examples/2023-06-17.AlpesVerdonTour.gpx -# Profile the demo with Go's CPU profiler -./biking_home -demo -cpuprofile /tmp/cpu.prof ``` ## Options / Configuration @@ -60,8 +55,6 @@ go build -o biking_home . | `-extract-osm` | Extract mountain passes from a France OSM PBF | `""` | | `-enrich` | Backfill OSM coordinates onto passes | `false` | | `-chart` | Render an elevation chart (climbs + passes) for a GPX file | `""` | -| `-demo` | Run the climb-similarity demo | `false` | -| `-cpuprofile` | Write a CPU profile to file | `""` | Configuration is stored in `config.yaml`. Start from `config.example.yaml` and set the Strava credentials before launching the server. @@ -87,7 +80,7 @@ Standard apps are rate-limited to 100 calls per 15 minutes and 1,000 per day. - `rides` — SQLite persistence for imported ride metadata - `config` — typed YAML configuration and atomic persistence - `web` — HTTP server, OAuth callback, sync orchestration, and templ pages -- `cli` — legacy mountain-pass, OSM, demo, and chart command handlers +- `cli` — legacy mountain-pass, OSM, and chart command handlers - `chart` — elevation chart rendering - **Notable choices** — the difficulty score follows the Cotacol method: the ride is split into fixed 100 m segments and each scores `distance_km × slope²`, so steep sections weigh exponentially more than long flat ones @@ -5,9 +5,7 @@ import ( "database/sql" "flag" "log/slog" - "os" "path/filepath" - "runtime/pprof" "strings" "time" @@ -27,9 +25,7 @@ var ( fetchOSM = flag.Bool("fetch-osm", false, "download the France OSM PBF (resumable) into france-latest.osm.pbf") extractOSM = flag.String("extract-osm", "", "extract mountain passes from an OSM PBF file into the database") enrich = flag.Bool("enrich", false, "backfill mountain pass coordinates from OSM data") - demo = flag.Bool("demo", false, "run the climb similarity demo") chartFile = flag.String("chart", "", "render a climb/pass chart for a GPX file") - cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") parser = ride.GPXRideParser{} ) @@ -50,8 +46,6 @@ func Run(db *sql.DB, configPath string, appConfig config.Config) { case *enrich: _, err := osmpass.EnrichMountainPasses(db) kcore.Expect(err, "failed to enrich mountain passes") - case *demo: - runDemo(db) case *chartFile != "": runChart(db, *chartFile) default: @@ -83,87 +77,3 @@ func runChart(db *sql.DB, filename string) { chart.Render(r, climbs, crossings, output) slog.Info("Chart written", "file", output) } - -func runDemo(db *sql.DB) { - if *cpuprofile != "" { - f, err := os.Create(*cpuprofile) - kcore.Expect(err, "failed to create CPU profile") - pprof.StartCPUProfile(f) - defer pprof.StopCPUProfile() - } - ride19Jan, _ := ride.ParseFile(parser, "examples/activity_18043356988.gpx") - ride30Mar, _ := ride.ParseFile(parser, "examples/activity_18679866717.gpx") - ride20Apr, _ := ride.ParseFile(parser, "examples/activity_18880605641.gpx") - for _, r := range []*ride.Ride{&ride19Jan, &ride30Mar, &ride20Apr} { - slog.Info("Ride", "difficulty", r.DifficultyScore()) - } - passes, passesErr := mountain_pass.LoadMountainPasses(db) - if passesErr != nil { - slog.Warn("No mountain passes in database, skipping crossings and climb naming", "error", passesErr) - passes = nil - } else { - rides := []struct { - name string - ride ride.Ride - }{ - {"2022-07-21.Pogacar", func() ride.Ride { - r, _ := ride.ParseFile(parser, "examples/2022-07-21.Pogacar.gpx") - return r - }()}, - {"2023-06-17.AlpesVerdonTour", func() ride.Ride { - r, _ := ride.ParseFile(parser, "examples/2023-06-17.AlpesVerdonTour.gpx") - return r - }()}, - {"2024-12-29.MimetArbois", func() ride.Ride { - r, _ := ride.ParseFile(parser, "examples/2024-12-29.MimetArbois.gpx") - return r - }()}, - {"activity_18043356988", ride19Jan}, - {"activity_18679866717", ride30Mar}, - {"activity_18880605641", ride20Apr}, - } - for _, entry := range rides { - crossings := mountain_pass.DetectCrossings(entry.ride, passes, 100, 25) - if len(crossings) > 0 { - slog.Info("Crossings", "ride", entry.name, "count", len(crossings)) - for _, crossing := range crossings { - slog.Info("Crossing", "pass", crossing.String()) - } - } - } - } - - nameClimbs := func(climbs []ride.Climb) { - for i := range climbs { - if matched, ok := mountain_pass.MatchClimb(climbs[i], passes, 300, 50); ok { - climbs[i].Name = matched.Name - } - } - } - verdon, _ := ride.ParseFile(parser, "examples/2023-06-17.AlpesVerdonTour.gpx") - verdonClimbs := verdon.AllClimbs() - nameClimbs(verdonClimbs) - for _, climb := range verdonClimbs { - slog.Info("Climb", "climb", climb, "elevation", climb.Top().ElevationM, "duration", climb.Duration(), "speed", climb.Speed()*3.6) - } - - index := ride.NewFlatRideClimbsIndex(30) - index.Insert(ride19Jan) - index.Insert(ride30Mar) - ride20AprilClimbs := ride20Apr.AllClimbs() - nameClimbs(ride20AprilClimbs) - for _, climb := range ride20AprilClimbs { - slog.Info("Climb", "climb", climb, "duration", climb.Duration(), "speed", climb.Speed()*3.6) - if len(index.Similar(ride20Apr, climb)) > 0 { - for _, similar := range index.Similar(ride20Apr, climb) { - slog.Info("Similar", "climb", similar, "duration", similar.Duration(), "speed", similar.Speed()*3.6) - } - } - } - ride30MarchClimbs := ride30Mar.AllClimbs() - nameClimbs(ride30MarchClimbs) - for _, climb := range ride30MarchClimbs { - slog.Info("Climb", "climb", climb, "duration", climb.Duration(), "speed", climb.Speed()*3.6) - } - ride.PlotScore(&ride30Mar, 61.2, 66.7, "Ride 30 Mar.png") -} |