use of android.support.media.ExifInterface in project iNaturalistAndroid by inaturalist.
the class ObservationEditor method setCurrentLocation.
private void setCurrentLocation(Location location) {
mCurrentLocation = location;
// Update any external photos taken through the app with the coordinates
for (String filename : mCameraPhotos) {
try {
ExifInterface exif;
double latitude = location.getLatitude();
double longitude = location.getLongitude();
exif = new ExifInterface(filename);
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, GPSEncoder.convert(latitude));
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, GPSEncoder.latitudeRef(latitude));
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, GPSEncoder.convert(longitude));
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, GPSEncoder.longitudeRef(longitude));
exif.saveAttributes();
} catch (IOException e) {
e.printStackTrace();
}
}
mObservation.latitude = location.getLatitude();
mObservation.longitude = location.getLongitude();
if ((mObservation.geoprivacy != null) && ((mObservation.geoprivacy.equals("private") || mObservation.geoprivacy.equals("obscured")))) {
mObservation.private_longitude = mObservation.longitude;
mObservation.private_latitude = mObservation.latitude;
}
mLatitudeView.setText(Double.toString(location.getLatitude()));
mLongitudeView.setText(Double.toString(location.getLongitude()));
findViewById(R.id.coordinates).setVisibility(View.VISIBLE);
if (location.hasAccuracy()) {
mAccuracyView.setText(Float.toString(location.getAccuracy()));
mObservation.positional_accuracy = ((Float) location.getAccuracy()).intValue();
findViewById(R.id.accuracy_prefix).setVisibility(View.VISIBLE);
findViewById(R.id.accuracy).setVisibility(View.VISIBLE);
} else {
findViewById(R.id.accuracy_prefix).setVisibility(View.GONE);
findViewById(R.id.accuracy).setVisibility(View.GONE);
}
if (Intent.ACTION_INSERT.equals(getIntent().getAction())) {
mObservation.latitude_was = mObservation.latitude;
mObservation.longitude_was = mObservation.longitude;
mObservation.positional_accuracy_was = mObservation.positional_accuracy;
}
if (isNetworkAvailable()) {
guessLocation();
} else {
setPlaceGuess(null);
}
}
Aggregations