Skip to content

Commit

Permalink
bump version to 0.21.3 and fix #169
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrupczak3 committed Sep 25, 2024
1 parent 651b619 commit 03c0e06
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 22 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.openathena"
minSdk 28
targetSdk 34
versionCode 43
versionName "0.21.2"
versionCode 44
versionName "0.21.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.debug
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/openathena/CoordTranslator.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import mil.nga.grid.features.Point;

import java.util.Arrays;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -199,7 +200,7 @@ protected static double[] parseLatLon(String latLonStr) throws ParseException {
}

// Sanitize input
latLonStr = latLonStr.trim().toUpperCase().replaceAll("[()]", "");
latLonStr = latLonStr.trim().toUpperCase(Locale.ENGLISH).replaceAll("[()]", "");
latLonStr = latLonStr.replaceAll("[Dd]egrees","°");
latLonStr = latLonStr.replaceAll("[Dd]eg","°");

Expand Down Expand Up @@ -238,7 +239,7 @@ protected static double[] parseLatLon(String latLonStr) throws ParseException {
// Helper method to convert degrees, minutes, seconds values to decimal
public static double dmsToDecimal(String dms) throws ParseException {
dms = dms.trim();
dms = dms.toUpperCase();
dms = dms.toUpperCase(Locale.ENGLISH);
dms = dms.replaceAll("[()]","");
dms = dms.replaceAll("[Dd]egrees","°");
dms = dms.replaceAll("[Dd]eg","°");
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/openathena/DemCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import java.io.File;
import java.util.List;
import java.util.ArrayList;
import java.util.Locale;

import android.content.Context;
import android.net.Uri;
import android.util.Log;
Expand Down Expand Up @@ -117,7 +119,7 @@ public void refreshCache()
selectedItem = -1;

// list all DEM files in the demDir in app cache folder
File[] files = demDir.listFiles((dir,name) -> name.toLowerCase().endsWith(".tiff") || name.toLowerCase().endsWith(".dt2") || name.toLowerCase().endsWith(".dt3"));
File[] files = demDir.listFiles((dir,name) -> name.toLowerCase(Locale.ENGLISH).endsWith(".tiff") || name.toLowerCase(Locale.ENGLISH).endsWith(".dt2") || name.toLowerCase(Locale.ENGLISH).endsWith(".dt3"));
if (files != null) {

Log.d(TAG,"DemCache: found "+files.length+" files to look at");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.net.Uri;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;

public class DroneParametersFromJSON {
private static final String TAG = "DroneParametersFromJSON";
Expand Down Expand Up @@ -178,7 +179,7 @@ public JSONArray getMatchingDrones(String make, String model) {
throw new IllegalArgumentException("ERROR: attempted to find getMatchingDrones for empty or null String!");
}

String makeModel = make.toLowerCase() + model.toUpperCase();
String makeModel = make.toLowerCase(Locale.ENGLISH) + model.toUpperCase(Locale.ENGLISH);
JSONArray matchingDrones = new JSONArray();
try {
for (int i = 0; i < droneArray.length(); i++) {
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/openathena/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;

// Libraries from the U.S. National Geospatial Intelligence Agency https://www.nga.mil
Expand Down Expand Up @@ -674,8 +675,8 @@ public void calculateImage(View view, boolean shouldISendCoT)
String model = exif.getAttribute(ExifInterface.TAG_MODEL);
if (model == null) model = "";
if (IS_EXTENDED_COT_MODE_ACTIVE) {
openAthenaCalculationInfo.put("make", make.toLowerCase());
openAthenaCalculationInfo.put("model", model.toUpperCase());
openAthenaCalculationInfo.put("make", make.toLowerCase(Locale.ENGLISH));
openAthenaCalculationInfo.put("model", model.toUpperCase(Locale.ENGLISH));
openAthenaCalculationInfo.put("isCameraModelRecognized", Boolean.toString(MetadataExtractor.isDroneModelRecognized(exif)));
openAthenaCalculationInfo.put("lensType", MetadataExtractor.getLensType(exif));
}
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/openathena/ManageDemsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import android.widget.ImageButton;
import android.widget.ProgressBar;

import java.util.Locale;

// Parent Abstract class with common functionality
public class ManageDemsActivity extends DemManagementActivity
{
Expand Down Expand Up @@ -153,8 +155,8 @@ private void onClickLookup()

// remove any () or degrees or leading/trailing whitespace
latLonStr = latLonStr.trim();
latLonStr = latLonStr.toUpperCase();
latLonStr = latLonStr.toUpperCase().replaceAll("[()]", "");
latLonStr = latLonStr.toUpperCase(Locale.ENGLISH);
latLonStr = latLonStr.toUpperCase(Locale.ENGLISH).replaceAll("[()]", "");
latLonStr = latLonStr.replaceAll("[Dd]egrees","°");
latLonStr = latLonStr.replaceAll("[Dd]eg","°");

Expand Down Expand Up @@ -245,4 +247,3 @@ protected void onDestroy()
public void calculateImage(View view, boolean shouldISendCoT) { return; } // not used in this activity

} // ManageDemsActivity

17 changes: 9 additions & 8 deletions app/src/main/java/com/openathena/MetadataExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.util.LinkedHashMap;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public class MetadataExtractor {
Expand Down Expand Up @@ -218,8 +219,8 @@ public static double[] getMetadataValues(ExifInterface exif) throws XMPException
Log.e(TAG, "ERROR: getMetadataValues failed, ExifInterface was null");
throw new IllegalArgumentException("ERROR: getMetadataValues failed, exif was null");
}
String make = exif.getAttribute(ExifInterface.TAG_MAKE).toUpperCase();
String model = exif.getAttribute(ExifInterface.TAG_MODEL).toUpperCase();
String make = exif.getAttribute(ExifInterface.TAG_MAKE).toUpperCase(Locale.ENGLISH);
String model = exif.getAttribute(ExifInterface.TAG_MODEL).toUpperCase(Locale.ENGLISH);
if (make == null || make.equals("")) {
return null;
}
Expand Down Expand Up @@ -341,7 +342,7 @@ public static double[] handleDJI(ExifInterface exif) throws XMPException, Missin

// DJI altitude is usually orthometric (EGM96 AMSL), but will be ellipsoidal (WGS84 hae) if special RTK device is used (rare)
String make = exif.getAttribute(ExifInterface.TAG_MAKE);
if (!make.toLowerCase().contains("autel") /* I'm not sure if autel uses EGM96 AMSL or WGS84 hae for new firmware */ && !xmp_str.toLowerCase().contains("rtkflag")) {
if (!make.toLowerCase(Locale.ENGLISH).contains("autel") /* I'm not sure if autel uses EGM96 AMSL or WGS84 hae for new firmware */ && !xmp_str.toLowerCase(Locale.ENGLISH).contains("rtkflag")) {
// convert the height from EGM96 AMSL to WGS84 hae if made by dji and rtk device not present
Log.i(TAG, "Converting from orthometric to ellipsoidal vertical datum for image metadata");
z = z - offsetProvider.getEGM96OffsetAtLatLon(y,x);
Expand Down Expand Up @@ -439,7 +440,7 @@ public static double[] handleAUTEL(ExifInterface exif) throws XMPException, Miss
String rdf_about = xmp_str.substring(aboutIndex + 10, aboutIndex + 24); // not perfect, should be fine though
Log.d(TAG, "rdf_about: " + rdf_about);

if (!rdf_about.toLowerCase().contains("autel")) {
if (!rdf_about.toLowerCase(Locale.ENGLISH).contains("autel")) {
isNewMetadataFormat = true;
} else {
isNewMetadataFormat = false;
Expand Down Expand Up @@ -555,8 +556,8 @@ public static double[] handlePARROT(ExifInterface exif) throws XMPException, Mis
// From Parrot Docs, regarding EGM96 AMSL vs WGS84 hae:
// Location altitude of where the photo was taken in meters expressed as a fraction (e.g. “4971569/65536”) On ANAFI 4K/Thermal/USA, this is the drone location with reference to the EGM96 geoid (AMSL); on ANAFI Ai with firmware < 7.4, this is the drone location with with reference to the WGS84 ellipsoid; on ANAFI Ai with firmware >= 7.4, this is the front camera location with reference to the WGS84 ellipsoid
// https://developer.parrot.com/docs/groundsdk-tools/photo-metadata.html
String model = exif.getAttribute(ExifInterface.TAG_MODEL).toUpperCase();
if (!model.toLowerCase().contains("anafiai")) {
String model = exif.getAttribute(ExifInterface.TAG_MODEL).toUpperCase(Locale.ENGLISH);
if (!model.toLowerCase(Locale.ENGLISH).contains("anafiai")) {
// convert from EGM96 AMSL to WGS84 hae (if necessary)
z = z - offsetProvider.getEGM96OffsetAtLatLon(y,x);
}
Expand Down Expand Up @@ -649,9 +650,9 @@ public static Float[] exifGetYXZ(ExifInterface exif) throws MissingDataException
throw new MissingDataException(parent.getString(R.string.missing_data_exception_altitude_error_msg), MissingDataException.dataSources.EXIF, MissingDataException.missingValues.ALTITUDE);
}

latDir = latDir.toUpperCase();
latDir = latDir.toUpperCase(Locale.ENGLISH);
String[] latArr = latRaw.split(",", 3);
lonDir = lonDir.toUpperCase();
lonDir = lonDir.toUpperCase(Locale.ENGLISH);
String[] lonArr = lonRaw.split(",", 3);

float y = 0.0f;
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/openathena/NewElevationMapActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;

public class NewElevationMapActivity extends DemManagementActivity
{
Expand Down Expand Up @@ -188,8 +189,8 @@ private void onClickDownload()
}

// remove any () or degrees
latlon = latlon.toUpperCase();
latlon = latlon.toUpperCase().replaceAll("[()]", "");
latlon = latlon.toUpperCase(Locale.ENGLISH);
latlon = latlon.toUpperCase(Locale.ENGLISH).replaceAll("[()]", "");
latlon = latlon.replaceAll("[Dd]egrees","°");
latlon = latlon.replaceAll("[Dd]eg","°");
// TODO remove degrees unit label from other languages as well
Expand Down Expand Up @@ -292,7 +293,7 @@ public void run() {
}
}).start();
} // copyFileToCache

@Override
protected void downloadNewDEM(double lat, double lon, double meters_diameter) {
DemDownloader aDownloader = new DemDownloader(getApplicationContext(),lat,lon,meters_diameter);
Expand Down

0 comments on commit 03c0e06

Please sign in to comment.