mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Cleaned up unnecessary code
This commit is contained in:
parent
651fd61189
commit
74dcd9df8f
2 changed files with 8 additions and 39 deletions
|
|
@ -16,7 +16,7 @@ public class GPSExtractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Extract GPS coords of image
|
//Extract GPS coords of image
|
||||||
public String getCoords(boolean xyCoordsReq) {
|
public String getCoords() {
|
||||||
|
|
||||||
ExifInterface exif;
|
ExifInterface exif;
|
||||||
String latitude = "";
|
String latitude = "";
|
||||||
|
|
@ -24,7 +24,6 @@ public class GPSExtractor {
|
||||||
String latitude_ref = "";
|
String latitude_ref = "";
|
||||||
String longitude_ref = "";
|
String longitude_ref = "";
|
||||||
String decimalCoords = "";
|
String decimalCoords = "";
|
||||||
String xyCoords = "";
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
exif = new ExifInterface(filePath);
|
exif = new ExifInterface(filePath);
|
||||||
|
|
@ -43,17 +42,12 @@ public class GPSExtractor {
|
||||||
longitude = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);
|
longitude = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);
|
||||||
longitude_ref = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF);
|
longitude_ref = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF);
|
||||||
|
|
||||||
if (xyCoordsReq == true) {
|
|
||||||
Log.d("Image", "Latitude: " + latitude + " " + latitude_ref);
|
Log.d("Image", "Latitude: " + latitude + " " + latitude_ref);
|
||||||
Log.d("Image", "Longitude: " + longitude + " " + longitude_ref);
|
Log.d("Image", "Longitude: " + longitude + " " + longitude_ref);
|
||||||
xyCoords = getXyCoords(latitude, latitude_ref, longitude, longitude_ref);
|
decimalCoords = getDecimalCoords(latitude, latitude_ref, longitude, longitude_ref);
|
||||||
return xyCoords;
|
return decimalCoords;
|
||||||
} else {
|
|
||||||
Log.d("Image", "Latitude: " + latitude + " " + latitude_ref);
|
|
||||||
Log.d("Image", "Longitude: " + longitude + " " + longitude_ref);
|
|
||||||
decimalCoords = getDecimalCoords(latitude, latitude_ref, longitude, longitude_ref);
|
|
||||||
return decimalCoords;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,31 +83,6 @@ public class GPSExtractor {
|
||||||
return decimalCoords;
|
return decimalCoords;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Converts format of coords into XY values as required by Quadtree for caching
|
|
||||||
private String getXyCoords(String latitude, String latitude_ref, String longitude, String longitude_ref) {
|
|
||||||
|
|
||||||
double decLatitude, decLongitude;
|
|
||||||
|
|
||||||
if(latitude_ref.equals("N")){
|
|
||||||
decLatitude = convertToDegree(latitude);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
decLatitude = 0 - convertToDegree(latitude);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(longitude_ref.equals("E")){
|
|
||||||
decLongitude = convertToDegree(longitude);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
decLongitude = 0 - convertToDegree(longitude);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Have to return Longitude before Latitude for X/Y conversion. Long = X; Lat = Y
|
|
||||||
String xyCoords = String.valueOf(decLongitude) + "|" + String.valueOf(decLatitude);
|
|
||||||
Log.d("Coords", "X and Y are " + xyCoords);
|
|
||||||
return xyCoords;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private double convertToDegree(String stringDMS){
|
private double convertToDegree(String stringDMS){
|
||||||
double result;
|
double result;
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ public class ShareActivity
|
||||||
Log.d("Image", "Calling GPSExtractor");
|
Log.d("Image", "Calling GPSExtractor");
|
||||||
GPSExtractor imageObj = new GPSExtractor(filePath);
|
GPSExtractor imageObj = new GPSExtractor(filePath);
|
||||||
//decimalCoords for MediaWiki API, xyCoords for Quadtree
|
//decimalCoords for MediaWiki API, xyCoords for Quadtree
|
||||||
String decimalCoords = imageObj.getCoords(false);
|
String decimalCoords = imageObj.getCoords();
|
||||||
|
|
||||||
double decLongitude = imageObj.getDecLongitude();
|
double decLongitude = imageObj.getDecLongitude();
|
||||||
double decLatitude = imageObj.getDecLatitude();
|
double decLatitude = imageObj.getDecLatitude();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue