Initial commit: FieldLogger MAUI app with Maglink BLE support
Added Maglink RTK GNSS receiver integration with correct BLE UUIDs and device name filtering (ML-* prefix). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
53
FieldLogger/ViewModels/MapViewModel.cs
Normal file
53
FieldLogger/ViewModels/MapViewModel.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using FieldLogger.Models;
|
||||
using FieldLogger.Services;
|
||||
using FieldLogger.Services.Data;
|
||||
|
||||
namespace FieldLogger.ViewModels;
|
||||
|
||||
[QueryProperty(nameof(JobId), "jobId")]
|
||||
public sealed partial class MapViewModel : ObservableObject
|
||||
{
|
||||
private readonly AppDatabase _database;
|
||||
private readonly SettingsService _settings;
|
||||
|
||||
/// <summary>Job to display; 0 means "use the active job".</summary>
|
||||
[ObservableProperty]
|
||||
private int _jobId;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _jobName = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _statusText = "";
|
||||
|
||||
public SettingsService Settings => _settings;
|
||||
|
||||
public MapViewModel(AppDatabase database, SettingsService settings)
|
||||
{
|
||||
_database = database;
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
/// <summary>Loads the points to plot (only points with a valid GNSS position).</summary>
|
||||
public async Task<List<LoggedPoint>> LoadPointsAsync()
|
||||
{
|
||||
var jobId = JobId > 0 ? JobId : _settings.ActiveJobId;
|
||||
if (jobId is null)
|
||||
{
|
||||
JobName = "";
|
||||
StatusText = "No job selected. Create or activate a job to see its points.";
|
||||
return new List<LoggedPoint>();
|
||||
}
|
||||
|
||||
var job = await _database.GetJobAsync(jobId.Value);
|
||||
JobName = job?.Name ?? "";
|
||||
|
||||
var all = await _database.GetPointsAsync(jobId.Value);
|
||||
var plottable = all.Where(p => p.GpsValid).ToList();
|
||||
StatusText = plottable.Count == all.Count
|
||||
? $"{JobName}: {all.Count} points"
|
||||
: $"{JobName}: {plottable.Count} of {all.Count} points have GPS positions";
|
||||
return plottable;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user