Skip to content
Snippets Groups Projects
Commit 1109b21a authored by Yankova, Liliya (UG - Computer Science)'s avatar Yankova, Liliya (UG - Computer Science)
Browse files

Upload Image Properties file

parent 476979c8
No related branches found
No related tags found
No related merge requests found
package com.example.liliyayankova.unirides;
import android.media.ExifInterface;
import android.net.Uri;
import android.util.Log;
class ImageProperties {
/** Path to the image we want to display... */
private Uri imagePath;
public ImageProperties( Uri imageUri)
{
imagePath = imageUri;
}
/**
* Method for getting the orientation of the image to be displayed on the main scree.
* We use the ExifInterface class that gives access to the EXIF metadata of an image.
*
* @return The orientation of the image
*/
public int getCameraPhotoOrientation()
{
int rotate = 0;
try {
ExifInterface exif = new ExifInterface(imagePath.getPath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
float longitude = convertToDegree(exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE));
float latitude = convertToDegree(exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE));
//this is in a degree minute seconds format a
Log.i("Image Address", longitude + " ," + latitude);
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
}
} catch (Exception e) {
e.printStackTrace();
}
//tells you how much rotation you need
Log.v("ROTATION:", "Rotate Value: " + rotate);
return rotate;
}
/**
* Method for returning the longitude of the image to be displayed.
* @return
*/
public Float getCameraAddressLong()
{
String longitude = null;
try {
// context.getContentResolver().notifyChange(imageUri, null);
// File imageFile = new File(imagePath);
//reading the tags from the JPEG file
ExifInterface exif = new ExifInterface(imagePath.getPath());
longitude = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);
//this is in a degree minute seconds format a
Log.i("Image Address", convertToDegree(longitude) +"as double");
} catch (Exception e) {
e.printStackTrace();
}
//tells you how much rotation you need
return convertToDegree(longitude);
}
/**
* Method for returning the latitude of the image to be displayed.
* @return
*/
public Float getCameraAddressLat()
{
String latitude = null;
try {
// context.getContentResolver().notifyChange(imageUri, null);
// File imageFile = new File(imagePath);
//reading the tags from the JPEG file
ExifInterface exif = new ExifInterface(imagePath.getPath());
latitude = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE);
//this is in a degree minute seconds format a
Log.i("Image Address", convertToDegree(latitude) +"as double");
} catch (Exception e) {
e.printStackTrace();
}
//tells you how much rotation you need
return convertToDegree(latitude);
}
private Float convertToDegree(String stringDMS){
Float result = null;
String[] DMS = stringDMS.split(",", 3);
String[] stringD = DMS[0].split("/", 2);
Double D0 = new Double(stringD[0]);
Double D1 = new Double(stringD[1]);
Double FloatD = D0/D1;
String[] stringM = DMS[1].split("/", 2);
Double M0 = new Double(stringM[0]);
Double M1 = new Double(stringM[1]);
Double FloatM = M0/M1;
String[] stringS = DMS[2].split("/", 2);
Double S0 = new Double(stringS[0]);
Double S1 = new Double(stringS[1]);
Double FloatS = S0/S1;
result = new Float(FloatD + (FloatM/60) + (FloatS/3600));
return result;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment