Files
dmc/app/lib/ui/widgets/mission_map.dart
T
Constantin LeueandClaude Sonnet 5 b93bbab23b Add fillet flight path geometry and Alt/Speed wheels
- RouteGeometry (lib/domain/mission/route_geometry.dart): physically
  grounded flight path - straight segments + tangential arcs at each
  course change, sized from the drone's minimum turn radius (doc 3.7/4.6),
  replacing a naive spline that would suggest unrealistic turn radii.
  Marks a vertex "bad" (turn angle >= 160°, tangent length exceeding 90%
  of either adjacent leg, or exceeding the waypoint's catch radius) and a
  leg "bad" when the required climb/descent rate exceeds the drone's
  max climb/descent rate. Pure Dart, no Flutter dependency, so it stays
  usable if the mission domain is ever split into its own package (4.22).
  Wind-based turn-radius correction from the prototype isn't ported yet -
  the wind system (doc 3.8) doesn't exist in the Flutter app.
- MissionMap now draws each RouteSegment as its own Polyline, colored red
  when bad instead of a single plain white line; waypoint markers turn red
  too when their vertex is bad.
- ValueWheel: vertical drag-to-adjust tape control (HTML prototype's
  #altWheel/#spdWheel), custom-painted tick marks, blue center indicator,
  gradient fade at top/bottom. Wired into PlanScreen on both screen edges
  with Alt/Speed readouts.
- curAlt/curSpeed now live in PlanScreen state instead of fixed constants:
  dropping a new waypoint uses whatever the wheels are currently set to;
  entering editing mode on an existing waypoint loads its values into the
  wheels; adjusting a wheel while editing writes live into that waypoint
  (provider gained setAltitude/setSpeed to match the existing
  moveWaypoint/toggleAction pattern).

Added dedicated unit tests for the geometry (empty list, straight line,
feasible 90° turn producing a line-arc-line segment sequence, an
infeasible near-180° turn, and an infeasible descent rate) rather than
relying on eyeballing it on the emulator - this is exactly the kind of
ported-math correctness that's hard to verify visually but easy to get
subtly wrong. All 11 tests (previous 6 + these 5) and flutter analyze
pass. Also manually verified the wheels on the Pixel_10a emulator: drag
changes the value and the on-screen readout in real time.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-27 23:13:24 +02:00

85 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../domain/mission/route_geometry.dart';
/// Vollbild-OSM-Karte, entspricht dem Leaflet-`#map` im HTML-Demonstrator:
/// randlos, ohne Zoom-Buttons (Pinch-to-Zoom/Pan reicht), Standard-OSM-Tiles.
class MissionMap extends StatelessWidget {
const MissionMap({
super.key,
this.mapController,
this.waypointMarkers = const [],
this.routeSegments = const [],
this.rubberBandLine,
this.onMapReady,
});
final MapController? mapController;
/// Kreis-Marker fuer die Wegpunkte der aktuellen Mission (Doku 3.7).
final List<CircleMarker> waypointMarkers;
/// Geraden + Kreisbogen-Segmente des Flugpfads (Doku 3.7/4.6); rot
/// markierte Segmente ueberschreiten Steig-/Sinkrate oder Kurvenradius.
final List<RouteSegment> routeSegments;
/// Gestrichelte Vorschaulinie vom letzten Wegpunkt zur aktuellen
/// Kartenmitte, waehrend noch kein neuer Punkt bestaetigt wurde.
final List<LatLng>? rubberBandLine;
final VoidCallback? onMapReady;
// Default-Zentrum/Zoom uebernommen aus dem HTML-Demonstrator
// (Drone Mission Control.html: L.map(...).setView([52.3676, 4.9041], 16)).
static const _initialCenter = LatLng(52.3676, 4.9041);
static const _initialZoom = 16.0;
@override
Widget build(BuildContext context) {
return FlutterMap(
mapController: mapController,
options: MapOptions(
initialCenter: _initialCenter,
initialZoom: _initialZoom,
minZoom: 3,
maxZoom: 19,
onMapReady: onMapReady,
),
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'de.dmc.dmc_app',
maxZoom: 19,
),
PolylineLayer(
polylines: [
for (final segment in routeSegments)
Polyline(
points: segment.points,
strokeWidth: 3,
color: segment.bad ? const Color(0xFFE2574A) : Colors.white,
),
if (rubberBandLine != null)
Polyline(
points: rubberBandLine!,
strokeWidth: 2,
color: Colors.white.withValues(alpha: 0.55),
pattern: StrokePattern.dashed(segments: const [6.0, 6.0]),
),
],
),
CircleLayer(circles: waypointMarkers),
SimpleAttributionWidget(
alignment: Alignment.bottomLeft,
source: const Text('OpenStreetMap contributors'),
onTap: () =>
launchUrl(Uri.parse('https://www.openstreetmap.org/copyright')),
),
],
);
}
}