Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<PackageVersion Include="PdfPig" Version="0.1.16" />
<PackageVersion Include="QuestPDF" Version="2026.9.1" />
<!-- Already shipped by Avalonia.Skia; referenced directly so the map can ask a picture's codec its size before decoding (RasterOverlayCache). Keep on the version Avalonia.Skia resolves. -->
<PackageVersion Include="SkiaSharp" Version="3.119.4" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="4.0.1" />
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+lagekarte-luftbild.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LUFTBILD LADEN on the Lagekarte downloads the visible section's Luftbild and Flurstücksgrenzen from the Bayerische Vermessungsverwaltung (BayernAtlas data, CC BY 4.0) and keeps them in the Einsatz as two Kartenebenen that sync and work offline.
13 changes: 12 additions & 1 deletion docs/datenschutz-und-sicherheit.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ dem Bediener ausgelöst:
Ohne Antippen wird nichts abgefragt, auch nicht erneut. Die Werte bleiben auf
dem Gerät; in den Einsatz gelangen sie nur, wenn sie mit INS ETB als Eintrag
übernommen werden.
7. **Luftbild auf der Lagekarte.** Erst wenn unter EBENEN LUFTBILD LADEN
angetippt wird, lädt Lagebuch bei der Bayerischen Vermessungsverwaltung
(`geoservices.bayern.de`) das Luftbild (DOP40) und die Flurstücksgrenzen des
gerade sichtbaren Kartenausschnitts, höchstens etwa 1,6 × 1,6 km. Dafür geht
dieser Ausschnitt an den Dienst; er sieht dabei die IP-Adresse des Geräts und
den Ausschnitt – also ungefähr, wo auf die Karte geschaut wird, aber keine
Adresse, keine Namen und keine weiteren Einsatzdaten. Ohne Antippen wird nichts
abgefragt. Die Bilder werden als zwei Kartenebenen im Einsatz gespeichert, mit
den übrigen Ebenen synchronisiert und danach ohne Netz aus der Einsatzdatei
gezeichnet. In den PDF-Bericht gelangen sie nicht.

Nicht vorhanden sind: Nutzungsstatistiken, automatisch versandte Absturzberichte, Updateprüfungen,
Werbe- oder Analysebibliotheken sowie Schriftarten oder Kartenkacheln, die während
Expand Down Expand Up @@ -319,7 +329,8 @@ ein Begleitgerät.
Betriebssystem übergibt.
- Nachvollziehbare Änderungshistorie: Korrekturen im ETB überschreiben nichts.
- Keine Telemetrie, keine Protokolldateien. Fremde Dienste nur auf
ausdrückliches Antippen: Kartenpakete von GitHub, Wetter von Bright Sky.
ausdrückliches Antippen: Kartenpakete von GitHub, Wetter von Bright Sky,
Luftbilder von der Bayerischen Vermessungsverwaltung.
- Überprüfbare Installationsdateien: zu jedem Release gehören SHA-256-Prüfsummen
und ein Sigstore-Herkunftsnachweis, siehe
[Downloads prüfen](../README.md#downloads-prüfen).
Expand Down
3 changes: 2 additions & 1 deletion src/LageBuch.App.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ protected override void OnCreate(global::Android.OS.Bundle? savedInstanceState)
alarmMute: new AlarmMute(AndroidAppPaths.AlarmMuteJsonPath(this)),
mapPacks: new RegionPackLibrary(MapPackHttp, AndroidAppPaths.RegionPacksDir(this)),
mapNightMode: new MapNightMode(AndroidAppPaths.MapNightJsonPath(this)),
weather: new BrightSkyClient(MapPackHttp)));
weather: new BrightSkyClient(MapPackHttp),
luftbild: new LdbvImageryClient(MapPackHttp)));

base.OnCreate(savedInstanceState);
}
Expand Down
5 changes: 3 additions & 2 deletions src/LageBuch.App.Shared/CompositionRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public static MainWindowViewModel CreateMainWindowViewModel(
IRegionPackLibrary? mapPacks = null,
MapNightMode? mapNightMode = null,
IWeatherSource? weather = null,
IDispatchInboxStore? dispatchInbox = null)
IDispatchInboxStore? dispatchInbox = null,
LdbvImageryClient? luftbild = null)
{
// Every cue goes through the device's mute switch (#699); without a file to keep it in,
// the switch still works for this run.
Expand All @@ -51,7 +52,7 @@ public static MainWindowViewModel CreateMainWindowViewModel(
var dispatch = dispatchInbox is null
? null
: new DispatchInboxViewModel(dispatchInbox, masterData, dialogs, clock, ticker, uiDispatcher, work => _ = Task.Run(work));
var home = new HomeViewModel(store, masterData, recent, dialogs, clock, ticker, alarm, hostController, appVersion, uiDispatcher, lastSaveFolder, attachmentCacheRoot, trustStore: trustStore, pdfExporter: pdfExporter, lastPdfExport: lastPdfExport, lastConnection: lastConnection, mailComposer: mailComposer, runInBackground: work => _ = Task.Run(work), lastCrashReport: lastCrashReport, alarmMute: alarmMute, mapPacks: mapPacks, mapNightMode: mapNightMode, weather: weather, dispatch: dispatch);
var home = new HomeViewModel(store, masterData, recent, dialogs, clock, ticker, alarm, hostController, appVersion, uiDispatcher, lastSaveFolder, attachmentCacheRoot, trustStore: trustStore, pdfExporter: pdfExporter, lastPdfExport: lastPdfExport, lastConnection: lastConnection, mailComposer: mailComposer, runInBackground: work => _ = Task.Run(work), lastCrashReport: lastCrashReport, alarmMute: alarmMute, mapPacks: mapPacks, mapNightMode: mapNightMode, weather: weather, dispatch: dispatch, luftbild: luftbild);
var editor = new MasterDataEditorViewModel(masterData, dialogs, masterDataFileService, mapPacks);
return new MainWindowViewModel(home, editor, dialogs, appVersion, alarm, alarmMute, uiDispatcher);
}
Expand Down
55 changes: 53 additions & 2 deletions src/LageBuch.App.Shared/Controls/MapCanvasControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ public sealed class MapCanvasControl : Control
public static readonly StyledProperty<IReadOnlyList<OverlayShape>?> OverlaysProperty =
AvaloniaProperty.Register<MapCanvasControl, IReadOnlyList<OverlayShape>?>(nameof(Overlays));

/// <summary>The pictures of the visible raster Kartenebenen, drawn on the tiles in this order; null draws none.</summary>
public static readonly StyledProperty<IReadOnlyList<RasterImage>?> RasterOverlaysProperty =
AvaloniaProperty.Register<MapCanvasControl, IReadOnlyList<RasterImage>?>(nameof(RasterOverlays));

/// <summary>Invoked with the <see cref="Guid"/> file of a raster picture that would not decode, so its Ebene can say so.</summary>
public static readonly StyledProperty<ICommand?> RasterFailedCommandProperty =
AvaloniaProperty.Register<MapCanvasControl, ICommand?>(nameof(RasterFailedCommand));

/// <summary>The Fließweg from the Einsatzort, start first; null draws none.</summary>
public static readonly StyledProperty<IReadOnlyList<GeoPoint>?> FlowPathProperty =
AvaloniaProperty.Register<MapCanvasControl, IReadOnlyList<GeoPoint>?>(nameof(FlowPath));
Expand All @@ -87,6 +95,7 @@ public sealed class MapCanvasControl : Control

private readonly MapTileCache _tiles = new();
private readonly TerrainTileCache _terrain;
private readonly RasterOverlayCache _rasters;

// Where a drag started, on screen and on the map; null while no drag is under way.
private Point? _dragStart;
Expand All @@ -102,14 +111,15 @@ public sealed class MapCanvasControl : Control

static MapCanvasControl()
{
AffectsRender<MapCanvasControl>(TileSourceProperty, CenterProperty, ZoomProperty, RotationProperty, WaterPointsProperty, SelectedWaterPointProperty, ElevationProperty, TerrainStyleProperty, IsNightProperty, OverlaysProperty, FlowPathProperty);
AffectsRender<MapCanvasControl>(TileSourceProperty, CenterProperty, ZoomProperty, RotationProperty, WaterPointsProperty, SelectedWaterPointProperty, ElevationProperty, TerrainStyleProperty, IsNightProperty, OverlaysProperty, FlowPathProperty, RasterOverlaysProperty);
FocusableProperty.OverrideDefaultValue<MapCanvasControl>(true);
ClipToBoundsProperty.OverrideDefaultValue<MapCanvasControl>(true);
}

public MapCanvasControl()
{
_terrain = new TerrainTileCache(InvalidateVisual);
_rasters = new RasterOverlayCache(InvalidateVisual, OnRasterFailed);
GestureRecognizers.Add(new PinchGestureRecognizer());
AddHandler(PinchEvent, OnPinch);
AddHandler(PinchEndedEvent, OnPinchEnded);
Expand Down Expand Up @@ -184,6 +194,37 @@ public IReadOnlyList<OverlayShape>? Overlays
set => SetValue(OverlaysProperty, value);
}

public IReadOnlyList<RasterImage>? RasterOverlays
{
get => GetValue(RasterOverlaysProperty);
set => SetValue(RasterOverlaysProperty, value);
}

public ICommand? RasterFailedCommand
{
get => GetValue(RasterFailedCommandProperty);
set => SetValue(RasterFailedCommandProperty, value);
}

/// <summary>Whether Luftbild pictures are still being decoded; the map redraws as each is ready.</summary>
public bool IsRasterBusy => _rasters.IsBusy;

/// <summary>
/// The box on the map the control shows, its turned corners included; null before the map has
/// a centre or a size. What LUFTBILD LADEN asks the LDBV for.
/// </summary>
public GeoBox? VisibleBounds()
{
if (Center is null || Bounds.Width <= 0 || Bounds.Height <= 0)
{
return null;
}

Point[] corners = [new(0, 0), new(Bounds.Width, 0), new(0, Bounds.Height), new(Bounds.Width, Bounds.Height)];
var points = corners.Select(ScreenToGeo).OfType<GeoPoint>().ToList();
return GeoBox.TryCreate(points.Min(p => p.Longitude), points.Min(p => p.Latitude), points.Max(p => p.Longitude), points.Max(p => p.Latitude));
}

public bool WheelZoomNeedsControl
{
get => GetValue(WheelZoomNeedsControlProperty);
Expand Down Expand Up @@ -231,14 +272,16 @@ public override void Render(DrawingContext context)
// Missing tiles are painted too, so the whole control stays hit-testable for a drag.
_tiles.Use(TileSource);
_terrain.Use(Elevation, TerrainStyle);
MapDrawing.Draw(context, _tiles, center, Zoom, Bounds.Size, Rotation, WaterPoints, SelectedWaterPoint, _terrain, Overlays, FlowPath);
var rasters = _rasters.Use(RasterOverlays);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
MapDrawing.Draw(context, _tiles, center, Zoom, Bounds.Size, Rotation, WaterPoints, SelectedWaterPoint, _terrain, Overlays, FlowPath, rasters);
}

protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
{
base.OnDetachedFromVisualTree(e);
_tiles.Clear();
_terrain.Clear();
_rasters.Clear();
}

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
Expand Down Expand Up @@ -483,6 +526,14 @@ private void ZoomAt(Point screen, int zoom)
Report(WebMercator.ToGeo(anchorX - dx, anchorY - dy, zoom), zoom);
}

private void OnRasterFailed(Guid fileId)
{
if (RasterFailedCommand?.CanExecute(fileId) == true)
{
RasterFailedCommand.Execute(fileId);
}
}

// A pan or zoom leaves the turn as it is: the rotation is null unless the hand turned the map.
private void Report(GeoPoint center, int zoom, double? rotation = null)
{
Expand Down
54 changes: 42 additions & 12 deletions src/LageBuch.App.Shared/Controls/MapDrawing.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Globalization;
using Avalonia;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Media.Immutable;
using LageBuch.AppLogic.Services.Map;
using LageBuch.Domain.ValueObjects;
Expand Down Expand Up @@ -30,8 +31,10 @@ public static class MapDrawing
/// <paramref name="overlays"/> over the terrain, under the names, and the
/// <paramref name="flowPath"/> over the Kartenebenen. All of it but the terrain, the
/// Kartenebenen and the Fließweg in the colours of the cache's <see cref="MapTileCache.Style"/>.
/// The <paramref name="rasters"/>, the pictures of the Luftbild Ebenen, lie on the tiles and
/// under the terrain, in their own colours by day and by night.
/// </summary>
public static void Draw(DrawingContext context, MapTileCache tiles, GeoPoint center, int zoom, Size size, double rotation = 0, IReadOnlyList<WaterPoint>? waterPoints = null, WaterPoint? selected = null, TerrainTileCache? terrain = null, IReadOnlyList<OverlayShape>? overlays = null, IReadOnlyList<GeoPoint>? flowPath = null)
public static void Draw(DrawingContext context, MapTileCache tiles, GeoPoint center, int zoom, Size size, double rotation = 0, IReadOnlyList<WaterPoint>? waterPoints = null, WaterPoint? selected = null, TerrainTileCache? terrain = null, IReadOnlyList<OverlayShape>? overlays = null, IReadOnlyList<GeoPoint>? flowPath = null, IReadOnlyList<(Bitmap Image, GeoBox Bounds)>? rasters = null)
{
ArgumentNullException.ThrowIfNull(context);
ArgumentNullException.ThrowIfNull(tiles);
Expand All @@ -45,21 +48,29 @@ public static void Draw(DrawingContext context, MapTileCache tiles, GeoPoint cen
context.FillRectangle(style.Background, new Rect(size));
var marks = waterPoints is null ? [] : WaterPointMarkers.LayOut(waterPoints, center, zoom, size, selected, rotation);
var labels = new List<(MapLabel Label, Point At)>();
if (tiles.Source is { } source)
var turn = Turn(size, rotation);
IReadOnlyList<IMapTileSource> layers = tiles.Source switch
{
// Several packs are drawn one over the other. Each pack's tiles are cut to its area when
// it is built, so outside it a pack draws nothing that could cover its neighbour's streets.
IReadOnlyList<IMapTileSource> layers = source is CombinedMapTileSource combined ? combined.Layers : [source];
var turn = Turn(size, rotation);
foreach (var layer in layers)
{
DrawLayer(context, tiles, layer, center, zoom, size, turn, labels);
}
CombinedMapTileSource combined => combined.Layers,
{ } single => [single],
_ => [],
};
foreach (var layer in layers)
{
DrawLayer(context, tiles, layer, center, zoom, size, turn, labels);
}

if (terrain is not null && zoom >= TerrainSampler.MinZoom)
{
DrawTerrain(context, terrain, center, zoom, size, turn, rotation);
}
// A Luftbild covers the streets, but not their names, which are laid over everything below.
if (rasters is { Count: > 0 })
{
DrawRasters(context, rasters, center, zoom, size, turn);
}

if (layers.Count > 0 && terrain is not null && zoom >= TerrainSampler.MinZoom)
{
DrawTerrain(context, terrain, center, zoom, size, turn, rotation);
}

// Kartenebenen lie on the map and its terrain but under its names and the water points, so
Expand Down Expand Up @@ -202,6 +213,25 @@ private static void DrawLayer(DrawingContext context, MapTileCache tiles, IMapTi
}
}

// Each picture into the rectangle between its corners on the north-up map, turned with it. A
// WMS picture in EPSG:3857 is linear in Web Mercator, so its corners are all it takes to lay it
// exactly where the tiles are.
private static void DrawRasters(DrawingContext context, IReadOnlyList<(Bitmap Image, GeoBox Bounds)> rasters, GeoPoint center, int zoom, Size size, Matrix turn)
{
var (centerX, centerY) = WebMercator.ToWorldPixel(center, zoom);
var left = centerX - (size.Width / 2);
var top = centerY - (size.Height / 2);
using (context.PushTransform(turn))
{
foreach (var (image, bounds) in rasters)
{
var (westX, northY) = WebMercator.ToWorldPixel(new GeoPoint(bounds.North, bounds.West), zoom);
var (eastX, southY) = WebMercator.ToWorldPixel(new GeoPoint(bounds.South, bounds.East), zoom);
context.DrawImage(image, new Rect(westX - left, northY - top, eastX - westX, southY - northY));
}
}
}

// Brown like a topographic map's contours; the relative layer's lines in grey, its Einsatzort line black.
private static readonly IPen ContourPen = new ImmutablePen(new ImmutableSolidColorBrush(Color.FromArgb(0xD9, 0x9A, 0x6B, 0x3F)), 0.7);
private static readonly IPen ZaehllinienPen = new ImmutablePen(new ImmutableSolidColorBrush(Color.FromRgb(0x7A, 0x4A, 0x1F)), 1.4);
Expand Down
Loading