2024-05-15 13:35:01 +02:00
|
|
|
import 'package:collection/collection.dart';
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Compare two lists by their content ignoring their elements order.
|
|
|
|
///
|
|
|
|
bool equalContent(List<dynamic> list1, List<dynamic> list2) {
|
|
|
|
return const DeepCollectionEquality.unordered().equals(list1, list2);
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Convert decimal coordinate to degrees minutes seconds (DMS).
|
|
|
|
///
|
2024-05-09 21:55:17 +02:00
|
|
|
String convertDecimalToDMS(double decimalValue) {
|
|
|
|
bool isNegative = decimalValue < 0;
|
|
|
|
double absoluteValue = decimalValue.abs();
|
|
|
|
|
|
|
|
int degrees = absoluteValue.toInt();
|
|
|
|
double minutesDecimal = (absoluteValue - degrees) * 60;
|
|
|
|
int minutes = minutesDecimal.toInt();
|
|
|
|
double secondsDecimal = (minutesDecimal - minutes) * 60;
|
|
|
|
double seconds = double.parse(secondsDecimal.toStringAsFixed(2));
|
|
|
|
|
|
|
|
String direction = isNegative
|
|
|
|
? (decimalValue < 0 ? 'W' : 'S')
|
|
|
|
: (decimalValue >= 0 ? (degrees != 0 ? 'N' : 'E') : '');
|
|
|
|
|
|
|
|
// return formatted string
|
|
|
|
return '${degrees.abs()}° ${minutes.abs()}\' ${seconds.abs()}" $direction';
|
2024-05-15 13:35:01 +02:00
|
|
|
}
|