Skip to content

Commit

Permalink
fix #145 Add warning for drone cameras not in database
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrupczak3 committed Jun 18, 2024
1 parent 470570b commit 80309de
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion app/src/main/java/com/openathena/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public class MainActivity extends AthenaActivity {

public static int dangerousAutelAwarenessCount;

public static int dangerousMissingCameraIntrinsicsCount;

public static EGMOffsetProvider offsetAdapter = new EGM96OffsetAdapter(); // calculates diff between WGS84 reference ellipsoid and EGM96 geoid

public static final double FEET_PER_METER = 3937.0d/1200.0d; // Exact constant for US Survey Foot per Meter
Expand Down Expand Up @@ -179,6 +181,7 @@ protected void onCreate(Bundle savedInstanceState) {
clearText();

dangerousAutelAwarenessCount = athenaApp.getInt("dangerousAutelAwarenessCount");
dangerousMissingCameraIntrinsicsCount = athenaApp.getInt("dangerousMissingCameraIntrinsicsCount");

CharSequence textRestore = athenaApp.getCharSequence("textview");
if (textRestore != null) {
Expand Down Expand Up @@ -276,6 +279,7 @@ protected void onSaveInstanceState(Bundle saveInstanceState) {
@Override
protected void saveStateToSingleton() {
athenaApp.putInt("dangerousAutelAwarenessCount", dangerousAutelAwarenessCount);
athenaApp.putInt("dangerousMissingCameraIntrinsicsCount", dangerousMissingCameraIntrinsicsCount);
if (textView != null) {
athenaApp.putCharSequence("textview", textView.getText());
}
Expand Down Expand Up @@ -860,6 +864,9 @@ public void calculateImage(View view, boolean shouldISendCoT)
}
textViewTargetCoord.setText(Html.fromHtml(targetCoordString, 0, null, null));
isTargetCoordDisplayed = true;
if (!MetadataExtractor.isDroneModelRecognized(exif)) {
displayMissingCameraIntrinsicsAlert();
}
// close file
is.close();
//
Expand Down Expand Up @@ -922,7 +929,7 @@ private void printDEMBounds() {
}

public void displayAutelAlert() {
if (dangerousAutelAwarenessCount < 1) {
if (dangerousAutelAwarenessCount < 1) { // suppress warning if already encountered by user in this session
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage(R.string.autel_accuracy_warning_msg);
builder.setPositiveButton(R.string.i_understand_this_risk, (DialogInterface.OnClickListener) (dialog, which) -> {
Expand All @@ -933,6 +940,18 @@ public void displayAutelAlert() {
}
}

public void displayMissingCameraIntrinsicsAlert() {
if (dangerousMissingCameraIntrinsicsCount < 1) { // suppress warning if already encountered by user in this session
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage("⚠\uFE0F DANGER: Camera internal properties were not found in database. Calculation accuracy will be degraded. Email [email protected]\uFE0F");
builder.setPositiveButton(R.string.i_understand_this_risk, (DialogInterface.OnClickListener) (dialog, which) -> {
dangerousMissingCameraIntrinsicsCount += 1;
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
}

public void copyTargetCoordText(View view) {
if (isTargetCoordDisplayed) {
String text = textViewTargetCoord.getText().toString();
Expand Down

0 comments on commit 80309de

Please sign in to comment.