From 5e3d39cda5250cb55bc8324bcf96b0ab4b36c47f Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Fri, 21 Aug 2026 15:30:51 +0200 Subject: feat: bound climb detection by matched official climbs Detected climbs no longer absorb an official climb's range: official climbs matched to the route by coordinates claim their stored start/end range, and climb detection now runs only in the free regions around them. On ride 263 a single absorbed Cat 2 ascent is split so creating a first-half official climb lets the second half be detected on its own. - ride: add Range, freeRegions, and DetectClimbs(claimed); exclude claimed ranges so a climb never overlaps one - official_climb: MatchClimb now bounds-matches purely by coordinates without needing a detected climb; extract geo.Nearest shared helper - rideanalysis: Analyze builds claimed climbs from matched official climbs and detects only in free regions; render official vs unmatched climbs separately --- geo/geo.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 geo/geo.go (limited to 'geo') diff --git a/geo/geo.go b/geo/geo.go new file mode 100644 index 0000000..0fcff14 --- /dev/null +++ b/geo/geo.go @@ -0,0 +1,25 @@ +package geo + +import ( + "math" + + "github.com/jftuga/geodist" +) + +func DistanceM(a, b geodist.Coord) float64 { + _, distanceKm := geodist.HaversineDistance(a, b) + return distanceKm * 1000 +} + +func Nearest(coords []geodist.Coord, target geodist.Coord) (int, float64) { + bestIndex := 0 + bestDistance := math.Inf(1) + for index := 0; index < len(coords); index++ { + distance := DistanceM(coords[index], target) + if distance < bestDistance { + bestIndex = index + bestDistance = distance + } + } + return bestIndex, bestDistance +} -- cgit v1.3