various fixes: ocean GPS, ~0 GPS, delayed op feedback

This commit is contained in:
Thibault Deckers 2020-12-01 13:56:56 +09:00
parent 4d9df75c46
commit 60e7b2c5d9
4 changed files with 25 additions and 14 deletions

View file

@ -353,10 +353,9 @@ class MetadataHandler(private val context: Context) : MethodCallHandler {
if (locationString != null) {
val matcher = Metadata.VIDEO_LOCATION_PATTERN.matcher(locationString)
if (matcher.find() && matcher.groupCount() >= 2) {
// keep `0.0` as `0.0`, not `0`
val latitude = matcher.group(1)?.toDoubleOrNull() ?: 0.0
val longitude = matcher.group(2)?.toDoubleOrNull() ?: 0.0
if (latitude != 0.0 || longitude != 0.0) {
val latitude = matcher.group(1)?.toDoubleOrNull()
val longitude = matcher.group(2)?.toDoubleOrNull()
if (latitude != null && longitude != null) {
metadataMap[KEY_LATITUDE] = latitude
metadataMap[KEY_LONGITUDE] = longitude
}

View file

@ -375,12 +375,17 @@ class ImageEntry {
: call());
if (addresses != null && addresses.isNotEmpty) {
final address = addresses.first;
final cc = address.countryCode;
final cn = address.countryName;
final aa = address.adminArea;
addressDetails = AddressDetails(
contentId: contentId,
countryCode: address.countryCode,
countryName: address.countryName,
adminArea: address.adminArea,
locality: address.locality,
countryCode: cc,
countryName: cn,
adminArea: aa,
// if country & admin fields are null, it is likely the ocean,
// which is identified by `featureName` but we default to the address line anyway
locality: address.locality ?? (cc == null && cn == null && aa == null ? address.addressLine : null),
);
}
} catch (error, stackTrace) {

View file

@ -34,9 +34,11 @@ class CatalogMetadata {
bool isFlipped;
int rotationDegrees;
final String mimeType, xmpSubjects, xmpTitleDescription;
final double latitude, longitude;
double latitude, longitude;
Address address;
static const double _precisionErrorTolerance = 1e-9;
CatalogMetadata({
this.contentId,
this.mimeType,
@ -48,10 +50,15 @@ class CatalogMetadata {
this.xmpTitleDescription,
double latitude,
double longitude,
})
// Geocoder throws an IllegalArgumentException when a coordinate has a funky values like 1.7056881853375E7
: latitude = latitude == null || latitude < -90.0 || latitude > 90.0 ? null : latitude,
longitude = longitude == null || longitude < -180.0 || longitude > 180.0 ? null : longitude;
}) {
// Geocoder throws an `IllegalArgumentException` when a coordinate has a funky values like `1.7056881853375E7`
// We also exclude zero coordinates, taking into account precision errors (e.g. {5.952380952380953e-11,-2.7777777777777777e-10}),
// but Flutter's `precisionErrorTolerance` (1e-10) is slightly too lenient for this case.
if (latitude != null && longitude != null && (latitude.abs() > _precisionErrorTolerance || longitude.abs() > _precisionErrorTolerance)) {
this.latitude = latitude < -90.0 || latitude > 90.0 ? null : latitude;
this.longitude = longitude < -180.0 || longitude > 180.0 ? null : longitude;
}
}
CatalogMetadata copyWith({
@required int contentId,

View file

@ -56,7 +56,7 @@ mixin FeedbackMixin {
stream: opStream,
builder: (context, snapshot) {
Widget child = SizedBox.shrink();
if (!snapshot.hasError && snapshot.connectionState == ConnectionState.active) {
if (!snapshot.hasError) {
final percent = processed.length.toDouble() / selection.length;
child = CircularPercentIndicator(
percent: percent,