Skip to content

feat(phase-12f): curved corridor DEM extraction#23

Merged
harsh-pandhe merged 1 commit into
mainfrom
feat/phase-12f-curved-corridor
May 20, 2026
Merged

feat(phase-12f): curved corridor DEM extraction#23
harsh-pandhe merged 1 commit into
mainfrom
feat/phase-12f-curved-corridor

Conversation

@harsh-pandhe
Copy link
Copy Markdown
Owner

Summary

The case studies all showed urban routes exceed the straight-line geodesic — Línea Roja 1.5×, Medellín 1.3×, Cablebús 2.2×. routes.py already built curved 2-D paths (polyline / Catmull-Rom Bezier) but the output was never wired into the DEM sampling path; every case study fell back to the straight extract_profile_from_dem and ate the route-length gap.

API

from ropeway.dem import extract_profile_along_route

profile = extract_profile_along_route(
    'data/dem/foo.tif',
    [(lon0, lat0), (lon_mid, lat_mid), (lon1, lat1)],
    sample_spacing_m=20.0,
    kind='polyline',   # or 'bezier'
)
# returns a standard TerrainProfile keyed on along-route arc length
result = optimize(profile.as_function(), profile.total_length, ...)

Two-waypoint calls collapse to the existing extract_profile_from_dem behaviour.

Test plan

  • tests/test_curved_corridor.py6 new tests: two-waypoint ≡ straight, intermediate waypoint lengthens, Bezier ≥ straight, profile drops into optimizer, tuple/Waypoint interchangeable, fewer-than-2 raises
  • Full suite 195/195 green, no regressions

…long_route

The case studies all showed urban routes exceed the straight-line
geodesic (Linea Roja 1.5x, Medellin 1.3x, Cablebus 2.2x). routes.py
already built curved 2-D paths (polyline / Catmull-Rom Bezier) but the
output was never wired into the DEM sampling path — every case study
fell back to the straight extract_profile_from_dem and ate the
route-length gap.

New extract_profile_along_route(dem, waypoints, *, sample_spacing_m,
kind='polyline'|'bezier'):
  - Accepts raw (lon, lat) tuples OR ropeway.routes.Waypoint instances
  - Builds a Route in local UTM (auto-zone), samples the DEM at each
    arc-length step
  - Returns a standard TerrainProfile whose distance axis is the
    along-route arc length, ready to drop into optimize() unchanged

Two-waypoint calls collapse to the existing straight-line behaviour.

Tests: tests/test_curved_corridor.py — 6 new
  - two-waypoint polyline ≡ extract_profile_from_dem
  - intermediate waypoint lengthens corridor
  - Bezier and polyline both exceed straight line
  - returned profile.as_function() is callable + finite (optimizer
    consumes it that way)
  - tuple and Waypoint inputs interchangeable
  - <2 waypoints raises ValueError

Full suite green (195/195); no regressions.
@harsh-pandhe harsh-pandhe force-pushed the feat/phase-12f-curved-corridor branch from 922c490 to 61a3a05 Compare May 20, 2026 07:48
@harsh-pandhe harsh-pandhe merged commit a90cb27 into main May 20, 2026
2 checks passed
@harsh-pandhe harsh-pandhe deleted the feat/phase-12f-curved-corridor branch May 20, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant