diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-21 15:30:51 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-21 15:30:51 +0200 |
| commit | 5e3d39cda5250cb55bc8324bcf96b0ab4b36c47f (patch) | |
| tree | f92fe6f938866688b994c99670e1e27863579255 /geo | |
| parent | 0e27097e3d706e0e5bd761bf35fe301fd119d2a9 (diff) | |
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
Diffstat (limited to 'geo')
| -rw-r--r-- | geo/geo.go | 25 |
1 files changed, 25 insertions, 0 deletions
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 +} |
