Add activity type and a click-to-open track profile panel
Track properties gain activity_type (FIT: sport enum from the session/sport message, Garmin's own table; GPX: <trk><type> passed through as-is) alongside the existing distance/elevation/duration. Clicking a track line now opens a bottom panel with a chart per metric the track actually has (elevation always; speed/cadence/heart rate only when present — FIT's record fields or GPX's device extensions). TrackStats.build_profile computes cumulative distance the same way for both formats so they're directly comparable. One pointermove listener drives a synchronized crosshair across every chart, a single tooltip listing all series, and a map marker at the hovered point's position — hovering the chart shows where on the track that moment was.
This commit is contained in:
1 parent
cd4eef342b
commit
105651f005
14 files changed
+655
-42
No files matched your search
@@ -32,4 +32,26 @@ class TrackStatsTest < Minitest::Test
|
||||
stats = Maptool::TrackStats.compute([[17.0, 48.0]])
|
||||
assert_equal 0.0, stats["distance_meters"]
|
||||
end
|
||||
|
||||
def test_build_profile_has_cumulative_distance_elevation_and_extras
|
||||
points = [[17.0, 48.0, 100], [17.001, 48.0, 150]]
|
||||
extras = [{ heart_rate_bpm: 120 }, { heart_rate_bpm: 130, cadence_rpm: 80 }]
|
||||
|
||||
profile = Maptool::TrackStats.build_profile(points, extras: extras)
|
||||
|
||||
assert_equal 2, profile.size
|
||||
assert_equal 0.0, profile[0]["distance_meters"]
|
||||
assert_equal 100, profile[0]["elevation_meters"]
|
||||
assert_equal 120, profile[0]["heart_rate_bpm"]
|
||||
assert_nil profile[0]["cadence_rpm"]
|
||||
assert_operator profile[1]["distance_meters"], :>, 0
|
||||
assert_equal 80, profile[1]["cadence_rpm"]
|
||||
assert_equal [17.001, 48.0], [profile[1]["lon"], profile[1]["lat"]]
|
||||
end
|
||||
|
||||
def test_build_profile_extras_default_to_nil_when_shorter_than_coordinates
|
||||
profile = Maptool::TrackStats.build_profile([[17.0, 48.0], [17.001, 48.0]], extras: [])
|
||||
assert_nil profile[0]["heart_rate_bpm"]
|
||||
assert_nil profile[1]["speed_mps"]
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user