Introduces the RadarSource seam and the manifest it speaks, plus the demo frames that make the app runnable with no network and no credentials. MockRadarSource is a real adapter rather than test scaffolding, and that is what makes the rest of milestone 3 testable: the timeline, prefetching, cache eviction and every degraded path can be exercised offline because the demo frames parse the same manifest document the Python worker will publish. Its assets come from tool/generate_mock_frames.py — committed so the app runs from a clone, generated by a script so they can be regenerated instead of hand-edited. Twenty-four 512x512 frames total 108 KB, and the generator is pure standard library so nobody needs Pillow to build the app. The manifest parser rejects three things that would otherwise fail silently and look plausible: - A CRS other than EPSG:3857. The map overlays each PNG on a lat/lng quad, which only lines up if the image is already in Web Mercator; anything else renders visibly skewed with no error to explain why. - A missing attribution. The frames are a derived product of CC BY-SA data, so the credit has to travel with them rather than be remembered at render time. - Legend stops that do not ascend, which would silently mislabel intensities. The legend travels in the manifest rather than living as a constant here, because the worker chose those colours when it rendered the PNGs and a local copy could drift. RadarLegend.colorFor returns null below the lowest stop: "no precipitation" has to be transparent, not the first colour of the ramp, or a dry region renders as drizzle everywhere. Every failure reaches the caller as a single RadarUnavailableException regardless of cause, because the app's response is the same in all of them — hold the last good frame and say how old it is — and branching on cause would only invite divergence. ArpaRadarSource is a stub whose every method throws. It is named by the region config as unavailable and must fail loudly: quietly serving something else would misreport where the data came from. Verified: analyze clean, 95 tests passing, including a check that every frame the manifest lists exists and is a real PNG, and that its bbox matches the region config. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
39 lines
1.4 KiB
Dart
39 lines
1.4 KiB
Dart
import 'dart:typed_data';
|
|
|
|
import 'radar_manifest.dart';
|
|
import 'radar_source.dart';
|
|
|
|
/// Placeholder for direct ARPA Piemonte radar (HDF5 ODIM, 5-minute cadence from
|
|
/// the Bric della Croce and Monte Settepani C-band radars).
|
|
///
|
|
/// **Disabled.** Access requires an authorization from ARPA Piemonte that this
|
|
/// project does not have and has not requested. The class exists so the shape
|
|
/// of the seam is visible and the region config can name the adapter, not
|
|
/// because it is nearly ready.
|
|
///
|
|
/// When authorization arrives, the data is CC BY 4.0 and must be credited as
|
|
/// "Fonte: Arpa Piemonte - www.arpa.piemonte.it".
|
|
///
|
|
/// Every method throws. Constructing it is not an error — the region config may
|
|
/// legitimately list it as unavailable — but using it is, and failing loudly
|
|
/// beats silently serving something else.
|
|
class ArpaRadarSource implements RadarSource {
|
|
const ArpaRadarSource();
|
|
|
|
static const String _reason =
|
|
'the ARPA Piemonte radar adapter is disabled: it needs an authorization '
|
|
'from ARPA that this project does not hold';
|
|
|
|
@override
|
|
Future<RadarManifest> getLatestManifest() async =>
|
|
throw const RadarUnavailableException(_reason);
|
|
|
|
@override
|
|
Future<List<RadarFrame>> getFrames() async =>
|
|
throw const RadarUnavailableException(_reason);
|
|
|
|
@override
|
|
Future<Uint8List> loadFrameBytes(RadarFrame frame) async =>
|
|
throw const RadarUnavailableException(_reason);
|
|
}
|