mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Make sure exif is added if exists and not addet if null or 0.0 (#4082)
* Make sure exif is added if exists and not addet if null or 0.0 * Move boolean to bottom to cover both cases
This commit is contained in:
parent
c19858069b
commit
3aa7a13ec5
1 changed files with 20 additions and 12 deletions
|
|
@ -34,21 +34,29 @@ class ImageCoordinates internal constructor(exif: ExifInterface?) {
|
|||
//If image has no EXIF data and user has enabled GPS setting, get user's location
|
||||
//Always return null as a temporary fix for #1599
|
||||
if (exif != null) {
|
||||
val latitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE)
|
||||
val latitudeRef = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF)
|
||||
val longitude = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE)
|
||||
val longitudeRef = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF)
|
||||
if (latitude != null && longitude != null && latitudeRef != null && longitudeRef != null) {
|
||||
val latAndLong = exif.latLong
|
||||
if (latAndLong != null) {
|
||||
decLatitude = latAndLong[0]
|
||||
decLongitude = latAndLong[1]
|
||||
} else {
|
||||
val latitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE)
|
||||
val latitudeRef = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF)
|
||||
val longitude = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE)
|
||||
val longitudeRef = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF)
|
||||
if (latitude != null && longitude != null && latitudeRef != null && longitudeRef != null) {
|
||||
decLatitude =
|
||||
if (ExifInterface.LATITUDE_NORTH == latitudeRef) convertToDegree(latitude)
|
||||
else 0 - convertToDegree(latitude)
|
||||
decLongitude =
|
||||
if (ExifInterface.LONGITUDE_EAST == longitudeRef) convertToDegree(longitude)
|
||||
else 0 - convertToDegree(longitude)
|
||||
}
|
||||
}
|
||||
if (!(decLatitude == 0.0 && decLongitude == 0.0)) {
|
||||
decimalCoords = "$decLatitude|$decLongitude"
|
||||
//If image has EXIF data, extract image coords
|
||||
imageCoordsExists = true
|
||||
Timber.d("EXIF data has location info")
|
||||
decLatitude =
|
||||
if (ExifInterface.LATITUDE_NORTH == latitudeRef) convertToDegree(latitude)
|
||||
else 0 - convertToDegree(latitude)
|
||||
decLongitude =
|
||||
if (ExifInterface.LONGITUDE_EAST == longitudeRef) convertToDegree(longitude)
|
||||
else 0 - convertToDegree(longitude)
|
||||
decimalCoords = "$decLatitude|$decLongitude"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue