diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-09-24 08:37:33 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-09-24 08:37:33 +0200 |
| commit | 90614736f2a0c556f31eca5361b3c032f5f309f6 (patch) | |
| tree | 81fda954dc2bff8ae8b0023b502343c455995272 /official_climb/model.go | |
| parent | e3d0beee5be3dd2854b0f4fc10905a4fcdc08f47 (diff) | |
Match official climbs against their recorded sample
An official climb matched on endpoint coordinates alone. On a loop ridden
the other way the route meets the climb's top before its bottom, so pairing
each start with the first end inside its lap window credited a 5.9 km
passage as the 850 m Chemin de la Tour Pey Blanc, and a 49 km one on
another ride.
Climbs now keep the sample of the segment they were created from: the
recorded length and elevation gain of the selected route points, captured
by the ride detail and preview handlers and stored NOT NULL. Matching takes
the whole route and drops any candidate outside ±50% of that sample on
either axis, and attempts are refreshed by upsert and prune so re-analyzing
a ride keeps the recorded-at stamp of the passages that survive.
The backfill leaves the web package: backfill.Run recomputes ride values
then official climb attempts as a single `go run . backfill` command
(climbs-backfill is gone), rideanalysis owns the attempt snapshot, and the
mountain-pass loading margin is shared. Applied to the stored rides it
stamps 78 samples, drops the four bogus attempts and leaves ride 800 with
its three Pont Rout passages.
Diffstat (limited to 'official_climb/model.go')
| -rw-r--r-- | official_climb/model.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/official_climb/model.go b/official_climb/model.go index ae66f46..beecd02 100644 --- a/official_climb/model.go +++ b/official_climb/model.go @@ -7,6 +7,7 @@ import ( "time" "github.com/jftuga/geodist" + "github.com/martinlehoux/biking_home/climb" ) const DefaultMatchRadiusM = 100.0 @@ -16,8 +17,10 @@ type OfficialClimb struct { Name string StartCoord geodist.Coord EndCoord geodist.Coord - CreatedAt time.Time - UpdatedAt time.Time + // Sample is the passage the climb was created from; matching rejects candidates outside its band. + Sample climb.SegmentSample + CreatedAt time.Time + UpdatedAt time.Time } type MatchPolicy struct { @@ -42,6 +45,9 @@ func (climb OfficialClimb) validate() error { if !validCoord(climb.StartCoord) || !validCoord(climb.EndCoord) { return fmt.Errorf("official climb coordinates are invalid") } + if climb.Sample.DistanceM <= 0 || climb.Sample.ElevationGainM <= 0 { + return fmt.Errorf("official climb sample must record a positive distance and elevation gain") + } return nil } |
