Persist the ground elevation profile with the mission

The Mini-Altitude-Profile terrain data only ever lived in TerrainNotifier's
in-memory state (one slot, keyed by route). Every app restart, or every
switch away from and back to a mission, forced a full re-fetch of all
AWS Terrarium elevation tiles for the route - the noticeably slow load
the user reported for some missions was this happening on every visit,
not just once.

Adds a nullable terrainProfileJson column to the missions table
(schema v6->v7) and a saveTerrainProfile() repository method, kept
separate from the regular waypoint upsert() so an ordinary autosave never
clobbers an already-cached profile. TerrainNotifier persists a profile
right after a successful fetch (fire-and-forget) and gains restore(),
called from CurrentMissionMetaNotifier whenever a mission is loaded/
started so a previously fetched profile is available immediately -
ensureFor() still validates its routeKey before use, so a stale restored
profile is never shown for a route that has since changed.

Also included in mission export/import (MissionExportData/
ParsedMissionImport) so sharing a mission carries its terrain cache along
instead of forcing the recipient to refetch it.

Sample-count/resolution stays as-is for now (still fixed 30m spacing,
10-2000 samples) - adapting the sampling density to terrain variance
(e.g. coarser sampling over flat ground) is a separate follow-up.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Constantin Leue
2026-08-04 08:10:41 +02:00
co-authored by Claude Sonnet 5
parent 4e94102861
commit 35351140ae
11 changed files with 315 additions and 9 deletions
+13 -3
View File
@@ -9,6 +9,7 @@ import '../../domain/waypoint/flat_waypoint_list.dart';
import '../../domain/wind/wind_math.dart';
import '../providers/active_drone_profile_provider.dart';
import '../providers/current_mission_provider.dart';
import '../providers/mission_meta_provider.dart';
import '../providers/terrain_provider.dart';
import '../providers/wind_provider.dart';
import 'full_value_chart.dart';
@@ -92,7 +93,10 @@ class _WaypointListPanelState extends ConsumerState<WaypointListPanel> {
// werden - sonst passiert das erst beim (dann gar nicht mehr
// stattfindenden) Antippen des Tab-Buttons.
if (_tab == PanelTab.altitude) {
ref.read(terrainProvider.notifier).ensureFor(ref.read(currentMissionProvider));
ref.read(terrainProvider.notifier).ensureFor(
ref.read(currentMissionProvider),
missionId: ref.read(currentMissionMetaProvider).id,
);
}
});
// Laedt/aktualisiert das Gelaendeprofil (Doku 3.9) nur, waehrend der
@@ -102,7 +106,10 @@ class _WaypointListPanelState extends ConsumerState<WaypointListPanel> {
// erneuter Kachel-Download noetig ist.
ref.listenManual(currentMissionProvider, (previous, next) {
if (_tab == PanelTab.altitude) {
ref.read(terrainProvider.notifier).ensureFor(next);
ref.read(terrainProvider.notifier).ensureFor(
next,
missionId: ref.read(currentMissionMetaProvider).id,
);
}
});
}
@@ -272,7 +279,10 @@ class _WaypointListPanelState extends ConsumerState<WaypointListPanel> {
if (tab == PanelTab.list) {
WidgetsBinding.instance.addPostFrameCallback((_) => _scrollToActive());
} else if (tab == PanelTab.altitude) {
ref.read(terrainProvider.notifier).ensureFor(ref.read(currentMissionProvider));
ref.read(terrainProvider.notifier).ensureFor(
ref.read(currentMissionProvider),
missionId: ref.read(currentMissionMetaProvider).id,
);
}
},
child: Container(