Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
UniRides
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SoftwareEngineering
UniRides
Commits
1109b21a
Commit
1109b21a
authored
6 years ago
by
Yankova, Liliya (UG - Computer Science)
Browse files
Options
Downloads
Patches
Plain Diff
Upload Image Properties file
parent
476979c8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/com/example/liliyayankova/unirides/ImageProperties.java
+134
-0
134 additions, 0 deletions
...a/com/example/liliyayankova/unirides/ImageProperties.java
with
134 additions
and
0 deletions
src/main/java/com/example/liliyayankova/unirides/ImageProperties.java
0 → 100644
+
134
−
0
View file @
1109b21a
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
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment