Skip to content

Commit ecf886a

Browse files
authored
fix(flight-planner): display one-based waypoint numbers (#33)
* fix(flight-planner): display one-based waypoint numbers * test(flight-planner): cover displayed waypoint numbering * docs(porting): record waypoint numbering handoff
1 parent 1cbe17b commit ecf886a

6 files changed

Lines changed: 68 additions & 4 deletions

File tree

Controls/FlightPlannerMap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ private static PointFeature BuildMarker(MPoint pt, int seq, Color fill, bool sel
539539
SymbolScale = selected ? 0.8 : 0.6,
540540
});
541541
f.Styles.Add(new LabelStyle {
542-
Text = seq.ToString(),
542+
Text = (seq + 1).ToString(),
543543
ForeColor = Color.Black,
544544
BackColor = new Brush(Color.Transparent),
545545
Font = new Font { Size = 11, Bold = true },

GCSViews/FlightPlannerView.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
CommandParameter="{Binding SelectedWaypoint}" />
7272
</DataGrid.KeyBindings>
7373
<DataGrid.Columns>
74-
<DataGridTextColumn Header="#" Binding="{Binding Seq}" IsReadOnly="True" Width="40" />
74+
<DataGridTextColumn Header="#" Binding="{Binding DisplayNumber}" IsReadOnly="True" Width="40" />
7575
<DataGridTemplateColumn Header="Command" Width="190">
7676
<DataGridTemplateColumn.CellTemplate>
7777
<DataTemplate x:DataType="vm:WpRow">

MissionPlannerTests/Avalonia/MissionPlanner.Tests/FlightPlannerViewportTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@
1010
namespace MissionPlanner.Tests;
1111

1212
public class FlightPlannerViewportTests {
13+
[AvaloniaFact]
14+
public void Waypoint_markers_use_one_based_display_numbers() {
15+
var map = new FlightPlannerMap();
16+
17+
map.SetWaypoints(KyivWaypoints(2), 50, 80, Firmwares.ArduPlane);
18+
19+
WritableLayer waypoints = Assert.IsAssignableFrom<WritableLayer>(
20+
Assert.Single(map.Map.Layers, candidate => candidate.Name == "Waypoints"));
21+
string[] labels = waypoints.GetFeatures().OfType<PointFeature>()
22+
.Select(feature =>
23+
Assert.Single(feature.Styles.OfType<LabelStyle>()).GetLabelText(feature) ?? "")
24+
.OrderBy(label => label, StringComparer.Ordinal)
25+
.ToArray();
26+
Assert.Equal(new[] { "1", "2" }, labels);
27+
}
28+
1329
[AvaloniaFact]
1430
public void Waypoint_redraw_preserves_an_initialized_viewport() {
1531
var map = new FlightPlannerMap();

MissionPlannerTests/Avalonia/MissionPlanner.Tests/WpRowTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@
66
namespace MissionPlanner.Tests;
77

88
public class WpRowTests {
9+
[Fact]
10+
public void Planner_display_number_is_one_based_without_changing_internal_sequence() {
11+
var row = new WpRow { Seq = 0 };
12+
var changes = new List<string>();
13+
row.PropertyChanged += (_, args) => changes.Add(args.PropertyName ?? "");
14+
15+
Assert.Equal(1, row.DisplayNumber);
16+
17+
row.Seq = 4;
18+
19+
Assert.Equal(4, row.Seq);
20+
Assert.Equal(5, row.DisplayNumber);
21+
Assert.Contains(nameof(WpRow.DisplayNumber), changes);
22+
}
23+
924
[Fact]
1025
public void From_then_ToLocationwp_round_trips_fields() {
1126
var src = new Locationwp {

Porting/STATUS.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,35 @@
22

33
Updated: **2026-08-31**.
44

5+
## Flight Planner waypoint display numbering
6+
7+
- Dedicated branch `fix/flight-planner-waypoint-numbering` starts from merged `master`
8+
`1cbe17b87`. Behavior commit `03fca7c64` makes human-facing Planner waypoint numbers
9+
one-based; regression commit `054f9c7f1` covers the row model and map markers.
10+
- Official Mission Planner removes mission item zero (home) before building the Flight Data
11+
waypoint overlay, labels the remaining items with `a + 1`, and numbers Flight Planner row
12+
headers with `a + 1`. The Avalonia Plan grid and map instead exposed zero-based `WpRow.Seq`, so
13+
its first planned point appeared as 0 while Flight Data correctly showed 1.
14+
- `WpRow.Seq` remains zero-based for editing, plugin APIs, mission transfer, `DO_JUMP`, map dragging
15+
and mission files. New read-only `DisplayNumber` returns `Seq + 1` and raises a dependent property
16+
notification whenever rows are renumbered. Only human-facing Plan grid, map-marker and KML labels
17+
use the one-based value.
18+
- Focused `WpRowTests` plus `FlightPlannerViewportTests` pass **18/18**. The Release build succeeds
19+
with **0 warnings / 0 errors**. The complete Avalonia suite rerun executed **1569** tests:
20+
**1568 passed** and only the existing host-sensitive
21+
`VideoSourceResolverTests.NormalizesCommonStreamSources` `/dev/video0` case failed. A serial/TCP
22+
loopback timing test failed once during the first full run, then passed alone and in the complete
23+
rerun; no bridge source or test changes on this branch.
24+
- Behavior, integration and test reviewers approve exact code/test head `054f9c7f1` with no
25+
protocol, file-format, plugin or map-interaction blocker.
26+
- The worktree still contains only the user's five pre-existing modifications in
27+
`Drivers/inf2cat.bat`, `Drivers/uninstall_drivers.bat`, `ExtLibs/Mavlink/regenerate.bat`,
28+
`ExtLibs/Mavlink/updatexmls.bat` and `graphs/updatexmls.bat`; none is staged or included. Claude
29+
remains disabled.
30+
- Manual acceptance: rebuild and relaunch, add at least two Plan points and confirm the grid and map
31+
show 1 and 2; upload/read the mission and confirm Flight Data uses the same numbers while current
32+
mission status may still correctly report sequence 0 when the vehicle is idle.
33+
534
## Flight Data bearing-overlay zoom stability
635

736
- Dedicated branch `fix/flight-data-bearing-overlay-zoom` starts from merged `master`

ViewModels/FlightPlannerViewModel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ public string GenerateMissionKmlAndOpen() {
14851485
} catch (Exception ex) {
14861486
string kml = Services.LocalKmlServer.BuildMissionKml(
14871487
pts.Select(w => new Services.LocalKmlWaypoint(
1488-
$"WP {w.Seq}", w.Lat, w.Lng, w.Alt)));
1488+
$"WP {w.DisplayNumber}", w.Lat, w.Lng, w.Alt)));
14891489
var path = Path.Combine(Path.GetTempPath(), "mission.kml");
14901490
File.WriteAllText(path, kml);
14911491
Services.Dialogs.OpenUrl(path);
@@ -1495,7 +1495,7 @@ public string GenerateMissionKmlAndOpen() {
14951495

14961496
private void PublishLocalKmlMission() => AppState.LocalKml.UpdateMission(
14971497
Waypoints.Select(w => new Services.LocalKmlWaypoint(
1498-
$"WP {w.Seq}", w.Lat, w.Lng, w.Alt)));
1498+
$"WP {w.DisplayNumber}", w.Lat, w.Lng, w.Alt)));
14991499

15001500
[Obsolete]
15011501
private void WriteRadiusParams() {
@@ -3174,6 +3174,10 @@ public WpRow() {
31743174
[ObservableProperty]
31753175
private int _seq;
31763176

3177+
public int DisplayNumber => Seq + 1;
3178+
3179+
partial void OnSeqChanged(int value) => OnPropertyChanged(nameof(DisplayNumber));
3180+
31773181
[ObservableProperty]
31783182
private ushort _command;
31793183

0 commit comments

Comments
 (0)