Initial commit - Trekker V2 source

This commit is contained in:
Cortex committed 2026-06-10 11:03:37 -04:00
commit d71faf19e3
65 files changed
+3615

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
from app.ingest.gpx_parser import parse_gpx
from app.ingest.segmenter import haversine_m
def test_haversine_known_distance():
# ~111.2 km per degree of latitude
d = haversine_m(36.0, -84.0, 37.0, -84.0)
assert 110_000 < d < 112_500
def test_waypoint_driven_segments(fixtures):
route = parse_gpx((fixtures / "gaia.gpx").read_bytes())
# Trailhead (idx 0), Water Crossing (idx 3), Camp (idx 6) -> two segments
assert len(route.segments) == 2
s1, s2 = route.segments
assert s1.start_wpt == "Trailhead" and s1.end_wpt == "Water Crossing"
assert s2.start_wpt == "Water Crossing" and s2.end_wpt == "Camp"
assert s1.start_idx == 0 and s1.end_idx == 3
assert s2.start_idx == 3 and s2.end_idx == 6
# each leg covers 0.003 deg lat ~ 334m
assert 300 < s1.distance_m < 370
assert s1.elevation_gain_m == 30.0
assert s1.duration_s == 900.0
assert s2.elevation_gain_m == 40.0 # 430->420 (-10), 420->445 (+25), 445->460 (+15)
assert s2.elevation_loss_m == 10.0
def test_no_waypoints_single_segment(fixtures):
route = parse_gpx((fixtures / "onx.gpx").read_bytes())
assert len(route.segments) == 1
seg = route.segments[0]
assert seg.start_idx == 0 and seg.end_idx == 2
assert seg.elevation_gain_m == 20.0
assert seg.elevation_loss_m == 5.0
def test_route_stats(fixtures):
route = parse_gpx((fixtures / "gaia.gpx").read_bytes())
assert route.stats.elevation_min_m == 400.0
assert route.stats.elevation_max_m == 460.0
assert route.stats.elevation_gain_m == 70.0
assert route.stats.duration_s == 1800.0