various fixes: ocean GPS, ~0 GPS, delayed op feedback
This commit is contained in:
parent
4d9df75c46
commit
60e7b2c5d9
4 changed files with 25 additions and 14 deletions
|
@ -353,10 +353,9 @@ class MetadataHandler(private val context: Context) : MethodCallHandler {
|
||||||
if (locationString != null) {
|
if (locationString != null) {
|
||||||
val matcher = Metadata.VIDEO_LOCATION_PATTERN.matcher(locationString)
|
val matcher = Metadata.VIDEO_LOCATION_PATTERN.matcher(locationString)
|
||||||
if (matcher.find() && matcher.groupCount() >= 2) {
|
if (matcher.find() && matcher.groupCount() >= 2) {
|
||||||
// keep `0.0` as `0.0`, not `0`
|
val latitude = matcher.group(1)?.toDoubleOrNull()
|
||||||
val latitude = matcher.group(1)?.toDoubleOrNull() ?: 0.0
|
val longitude = matcher.group(2)?.toDoubleOrNull()
|
||||||
val longitude = matcher.group(2)?.toDoubleOrNull() ?: 0.0
|
if (latitude != null && longitude != null) {
|
||||||
if (latitude != 0.0 || longitude != 0.0) {
|
|
||||||
metadataMap[KEY_LATITUDE] = latitude
|
metadataMap[KEY_LATITUDE] = latitude
|
||||||
metadataMap[KEY_LONGITUDE] = longitude
|
metadataMap[KEY_LONGITUDE] = longitude
|
||||||
}
|
}
|
||||||
|
|
|
@ -375,12 +375,17 @@ class ImageEntry {
|
||||||
: call());
|
: call());
|
||||||
if (addresses != null && addresses.isNotEmpty) {
|
if (addresses != null && addresses.isNotEmpty) {
|
||||||
final address = addresses.first;
|
final address = addresses.first;
|
||||||
|
final cc = address.countryCode;
|
||||||
|
final cn = address.countryName;
|
||||||
|
final aa = address.adminArea;
|
||||||
addressDetails = AddressDetails(
|
addressDetails = AddressDetails(
|
||||||
contentId: contentId,
|
contentId: contentId,
|
||||||
countryCode: address.countryCode,
|
countryCode: cc,
|
||||||
countryName: address.countryName,
|
countryName: cn,
|
||||||
adminArea: address.adminArea,
|
adminArea: aa,
|
||||||
locality: address.locality,
|
// 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) {
|
} catch (error, stackTrace) {
|
||||||
|
|
|
@ -34,9 +34,11 @@ class CatalogMetadata {
|
||||||
bool isFlipped;
|
bool isFlipped;
|
||||||
int rotationDegrees;
|
int rotationDegrees;
|
||||||
final String mimeType, xmpSubjects, xmpTitleDescription;
|
final String mimeType, xmpSubjects, xmpTitleDescription;
|
||||||
final double latitude, longitude;
|
double latitude, longitude;
|
||||||
Address address;
|
Address address;
|
||||||
|
|
||||||
|
static const double _precisionErrorTolerance = 1e-9;
|
||||||
|
|
||||||
CatalogMetadata({
|
CatalogMetadata({
|
||||||
this.contentId,
|
this.contentId,
|
||||||
this.mimeType,
|
this.mimeType,
|
||||||
|
@ -48,10 +50,15 @@ class CatalogMetadata {
|
||||||
this.xmpTitleDescription,
|
this.xmpTitleDescription,
|
||||||
double latitude,
|
double latitude,
|
||||||
double longitude,
|
double longitude,
|
||||||
})
|
}) {
|
||||||
// Geocoder throws an IllegalArgumentException when a coordinate has a funky values like 1.7056881853375E7
|
// 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,
|
// We also exclude zero coordinates, taking into account precision errors (e.g. {5.952380952380953e-11,-2.7777777777777777e-10}),
|
||||||
longitude = longitude == null || longitude < -180.0 || longitude > 180.0 ? null : longitude;
|
// 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({
|
CatalogMetadata copyWith({
|
||||||
@required int contentId,
|
@required int contentId,
|
||||||
|
|
|
@ -56,7 +56,7 @@ mixin FeedbackMixin {
|
||||||
stream: opStream,
|
stream: opStream,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
Widget child = SizedBox.shrink();
|
Widget child = SizedBox.shrink();
|
||||||
if (!snapshot.hasError && snapshot.connectionState == ConnectionState.active) {
|
if (!snapshot.hasError) {
|
||||||
final percent = processed.length.toDouble() / selection.length;
|
final percent = processed.length.toDouble() / selection.length;
|
||||||
child = CircularPercentIndicator(
|
child = CircularPercentIndicator(
|
||||||
percent: percent,
|
percent: percent,
|
||||||
|
|
Loading…
Reference in a new issue