Skip to content

feat(phase-4-plus): project save/load persists Tower offset + Phase 7+/12d state#26

Open
harsh-pandhe wants to merge 1 commit into
mainfrom
feat/phase-4-plus-persistence
Open

feat(phase-4-plus): project save/load persists Tower offset + Phase 7+/12d state#26
harsh-pandhe wants to merge 1 commit into
mainfrom
feat/phase-4-plus-persistence

Conversation

@harsh-pandhe
Copy link
Copy Markdown
Owner

Summary

Until now, ropeway.project.save_project() persisted only Tower.distance and Tower.height. A save+load round trip silently lost:

  • Tower.is_station (Phase 7+ pinned-station flag)
  • Tower.offset (Phase 12c lateral offset)
  • no_tower_zones (Phase 7+)
  • forced_flyover_zones (Phase 12d)
  • intermediate_stations (Phase 7+ pinned waypoints)

So a Streamlit user saving an urban-gondola study and re-opening it got the centreline back without the constraints that made it feasible.

Changes (additive + backward-compatible)

  • Schema: new extras_json TEXT NOT NULL DEFAULT '{}' column. Older DBs without it auto-migrate via ALTER TABLE ADD COLUMN inside _connect() (idempotent via try/except OperationalError).
  • Tower JSON now carries is_station + offset.
  • extras_json holds the three corridor-constraint lists (no_tower_zones, intermediate_stations, forced_flyover_zones) with stable, hand-readable shapes.
  • ProjectRecord gains the three new fields (default empty lists).
  • ProjectRecord.to_alignment(profile_fn, surface_fn=...) rebuilds an Alignment that includes every persisted constraint, so the round-tripped alignment evaluates identically to the saved one.
  • save_project gets a new optional intermediate_stations kwarg (the only constraint Alignment doesn't already carry directly).

Backward compatibility

Rows written by pre-4+ code deserialise to empty zone/station lists; Tower.offset defaults to 0.0. Existing test_project.py passes unchanged.

Test plan

  • tests/test_project_persistence_plus.py7 new tests: tower offset, no-tower zones, forced flyover zones, intermediate stations, full to_alignment rebuild, legacy-format DB row loads, delete-project semantics
  • Full suite 206 → 216 passing, zero regressions

…+/12d state

Until now, ropeway.project.save_project() persisted only Tower.distance
and Tower.height. A save+load round trip lost:
  - Tower.is_station (Phase 7+ pinned-station flag)
  - Tower.offset (Phase 12c lateral offset)
  - no_tower_zones (Phase 7+)
  - forced_flyover_zones (Phase 12d)
  - intermediate_stations (Phase 7+ pinned waypoints)

So a Streamlit user saving an urban-gondola study and re-opening it
got the centreline back without the constraints that made it feasible.

Changes (additive + backward-compatible):
  - Schema: new extras_json TEXT NOT NULL DEFAULT '{}' column. Older
    DBs without it auto-migrate via ALTER TABLE ADD COLUMN inside
    _connect() (idempotent via try/except OperationalError).
  - Tower JSON now carries is_station + offset.
  - extras_json holds the three corridor-constraint lists
    (no_tower_zones, intermediate_stations, forced_flyover_zones)
    with stable, hand-readable shapes.
  - ProjectRecord gains the three new fields (default empty lists).
  - ProjectRecord.to_alignment(profile_fn, surface_fn=...) rebuilds an
    Alignment that includes every persisted constraint, so the
    round-tripped alignment evaluates identically to the saved one.
  - save_project gets a new optional intermediate_stations kwarg
    (the only constraint Alignment doesn't already carry directly).

Backward compatibility: rows written by the pre-4+ code (no
extras_json column populated) deserialise to empty zone/station lists
and Tower.offset defaults to 0.0. Existing tests pass unchanged.

Tests: tests/test_project_persistence_plus.py — 7 new
  - tower offset round-trips
  - no_tower_zones round-trip (kind enum, distances, name)
  - forced_flyover_zones round-trip (min_cable_elev_m, name)
  - intermediate_stations round-trip
  - to_alignment() rebuilds all persisted constraints
  - legacy-format DB row (no extras_json) loads without error
  - delete_project return-value semantics

Full suite 206 -> 216, zero regressions in test_project.py.
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