mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
@@ -6,6 +6,7 @@ import 'package:latlong2/latlong.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import '../../../models/contact.dart';
|
||||
import '../../../models/sar_marker.dart';
|
||||
import '../../../utils/location_formats.dart';
|
||||
import 'compass_math.dart';
|
||||
|
||||
/// Header component for the compass dialog showing compass rose,
|
||||
@@ -563,21 +564,7 @@ class _LocationFormatToggle extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LocationFormatToggleState extends State<_LocationFormatToggle> {
|
||||
bool _showDMS = false;
|
||||
|
||||
String _formatDMS(double degrees, bool isLatitude) {
|
||||
final direction = isLatitude
|
||||
? (degrees >= 0 ? 'N' : 'S')
|
||||
: (degrees >= 0 ? 'E' : 'W');
|
||||
|
||||
final absolute = degrees.abs();
|
||||
final deg = absolute.floor();
|
||||
final minDecimal = (absolute - deg) * 60;
|
||||
final min = minDecimal.floor();
|
||||
final sec = (minDecimal - min) * 60;
|
||||
|
||||
return '$deg°${min.toString().padLeft(2, '0')}\'${sec.toStringAsFixed(2).padLeft(5, '0')}"$direction';
|
||||
}
|
||||
CoordinateDisplayFormat _format = CoordinateDisplayFormat.decimal;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -589,20 +576,24 @@ class _LocationFormatToggleState extends State<_LocationFormatToggle> {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final String displayText;
|
||||
|
||||
if (_showDMS) {
|
||||
displayText =
|
||||
'${_formatDMS(position.latitude, true)} ${_formatDMS(position.longitude, false)}';
|
||||
} else {
|
||||
if (_format == CoordinateDisplayFormat.decimal) {
|
||||
displayText = l10n.latLonFormat(
|
||||
position.latitude.toStringAsFixed(5),
|
||||
position.longitude.toStringAsFixed(5),
|
||||
);
|
||||
} else {
|
||||
displayText = formatCoordinates(
|
||||
position.latitude,
|
||||
position.longitude,
|
||||
_format,
|
||||
);
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_showDMS = !_showDMS;
|
||||
_format = CoordinateDisplayFormat.values[
|
||||
(_format.index + 1) % CoordinateDisplayFormat.values.length];
|
||||
});
|
||||
},
|
||||
behavior: HitTestBehavior.opaque,
|
||||
|
||||
@@ -4,6 +4,7 @@ import '../models/contact.dart';
|
||||
import '../models/sar_marker.dart';
|
||||
import '../models/sar_template.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../utils/location_formats.dart';
|
||||
|
||||
class MapMarkers {
|
||||
static List<Marker> createTeamMemberMarkers(
|
||||
@@ -253,7 +254,11 @@ class MapMarkers {
|
||||
if (contact.displayLocation != null) ...[
|
||||
_InfoRow(
|
||||
'Location',
|
||||
'${contact.displayLocation!.latitude.toStringAsFixed(6)}, ${contact.displayLocation!.longitude.toStringAsFixed(6)}',
|
||||
formatCoordinates(
|
||||
contact.displayLocation!.latitude,
|
||||
contact.displayLocation!.longitude,
|
||||
CoordinateDisplayFormat.utm,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (contact.telemetry?.batteryMilliVolts != null)
|
||||
@@ -313,7 +318,11 @@ class MapMarkers {
|
||||
children: [
|
||||
_InfoRow(
|
||||
'Location',
|
||||
'${marker.location.latitude.toStringAsFixed(6)}, ${marker.location.longitude.toStringAsFixed(6)}',
|
||||
formatCoordinates(
|
||||
marker.location.latitude,
|
||||
marker.location.longitude,
|
||||
CoordinateDisplayFormat.utm,
|
||||
),
|
||||
),
|
||||
_InfoRow('Reported', marker.timeAgo),
|
||||
if (marker.senderName != null)
|
||||
|
||||
Reference in New Issue
Block a user