feat(phase-4-plus): project save/load persists Tower offset + Phase 7+/12d state#26
Open
harsh-pandhe wants to merge 1 commit into
Open
feat(phase-4-plus): project save/load persists Tower offset + Phase 7+/12d state#26harsh-pandhe wants to merge 1 commit into
harsh-pandhe wants to merge 1 commit into
Conversation
…+/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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Until now,
ropeway.project.save_project()persisted onlyTower.distanceandTower.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)
extras_json TEXT NOT NULL DEFAULT '{}'column. Older DBs without it auto-migrate viaALTER TABLE ADD COLUMNinside_connect()(idempotent via try/exceptOperationalError).is_station+offset.no_tower_zones,intermediate_stations,forced_flyover_zones) with stable, hand-readable shapes.intermediate_stationskwarg (the only constraintAlignmentdoesn't already carry directly).Backward compatibility
Rows written by pre-4+ code deserialise to empty zone/station lists;
Tower.offsetdefaults to 0.0. Existingtest_project.pypasses unchanged.Test plan
tests/test_project_persistence_plus.py— 7 new tests: tower offset, no-tower zones, forced flyover zones, intermediate stations, fullto_alignmentrebuild, legacy-format DB row loads, delete-project semantics