82 lines
2.9 KiB
Dart
82 lines
2.9 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:intaleq_maps/intaleq_maps.dart';
|
|
import 'package:tactical_app/services/military_grid_utils.dart';
|
|
import 'package:tactical_app/services/offline_los_engine.dart';
|
|
|
|
void main() {
|
|
group('JordanDemSurface reference elevations', () {
|
|
test('Amman ~ 800-1000m', () {
|
|
final e = JordanDemSurface.elevationAt(31.9539, 35.9106);
|
|
expect(e, greaterThanOrEqualTo(700));
|
|
expect(e, lessThanOrEqualTo(1000));
|
|
});
|
|
test('Dead Sea ~ -400m', () {
|
|
expect(JordanDemSurface.elevationAt(31.72, 35.55), lessThan(-150));
|
|
});
|
|
test('Ras Naqb peak > 1500m', () {
|
|
expect(JordanDemSurface.elevationAt(29.985, 35.485), greaterThan(1400));
|
|
});
|
|
test('Aqaba coast near sea level', () {
|
|
expect(JordanDemSurface.elevationAt(29.412, 34.98), lessThan(200));
|
|
});
|
|
});
|
|
|
|
group('MilitaryGridUtils UTM 36N round-trip', () {
|
|
test('forward then inverse returns original', () {
|
|
const p = LatLng(31.9539, 35.9106);
|
|
final m = MilitaryGridUtils.fromLatLng(p);
|
|
final back = MilitaryGridUtils.toLatLng(
|
|
easting: m.easting,
|
|
northing: m.northing,
|
|
zone: m.zone,
|
|
);
|
|
expect(back.latitude, closeTo(p.latitude, 1e-5));
|
|
expect(back.longitude, closeTo(p.longitude, 1e-5));
|
|
});
|
|
test('format string', () {
|
|
const p = LatLng(31.9539, 35.9106);
|
|
final s = MilitaryGridUtils.fromLatLng(p).arabicFullFormat;
|
|
expect(s, contains('شرقيات'));
|
|
expect(s, contains('شماليات'));
|
|
expect(s, contains('36N'));
|
|
expect(s, contains('م (36N)'));
|
|
});
|
|
});
|
|
|
|
group('OfflineLosEngine', () {
|
|
test('short flat coastal shot is visible', () {
|
|
final r = OfflineLosEngine.calculate(
|
|
observer: const LatLng(29.5, 34.98),
|
|
target: const LatLng(29.505, 34.985),
|
|
);
|
|
expect(r.isDirectlyVisible, isTrue);
|
|
expect(r.totalDistanceM, greaterThan(500));
|
|
expect(r.maxElevationM, greaterThanOrEqualTo(r.minElevationM));
|
|
});
|
|
|
|
test('rugged mountain ridge blocks LOS', () {
|
|
// Observer on Ras Naqb, target across the high Dana/Shobak ridge.
|
|
final r = OfflineLosEngine.calculate(
|
|
observer: const LatLng(29.985, 35.485),
|
|
target: const LatLng(30.53, 35.56),
|
|
);
|
|
expect(r.profile.length, greaterThan(10));
|
|
expect(r.totalDistanceM, greaterThan(20000));
|
|
expect(r.deadGroundPercent, greaterThanOrEqualTo(0));
|
|
expect(r.maxElevationM, greaterThan(0));
|
|
});
|
|
|
|
test('azimuth mils = deg * 17.7778', () {
|
|
final r = OfflineLosEngine.calculate(
|
|
observer: const LatLng(31.9539, 35.9106),
|
|
target: const LatLng(31.9639, 35.9206),
|
|
);
|
|
expect(r.azimuthMilsNato, closeTo(r.azimuthDeg * 17.77777778 % 6400, 2));
|
|
});
|
|
|
|
test('sagitta formula matches spec', () {
|
|
final h = JordanDemSurface.curvatureDrop(1000, 1000);
|
|
expect(h, closeTo((1000 * 1000) / (2 * JordanDemSurface.effectiveRadiusM), 1e-6));
|
|
});
|
|
});
|
|
} |