Skip to content

Commit

Permalink
Copy coordinates from search also to deg-min-sec
Browse files Browse the repository at this point in the history
  • Loading branch information
hvdwolf committed Dec 4, 2020
1 parent dd57bb7 commit 67df79e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/main/java/org/hvdw/jexiftoolgui/editpane/EditGPSdata.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
import javax.swing.text.NumberFormatter;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.*;

import static org.hvdw.jexiftoolgui.Utils.in_Range;
Expand Down Expand Up @@ -296,4 +299,31 @@ private String checkValue (String value, String int_or_double, int maxvalue) {
return checked_value;
}

/**
* Convert a decimal coordiante back to deg-min-sec for the deg-min-sec textfields
* @param coordinate
* @return
*/
public static String[] decDegToDegMinSec(String coordinate) {
String deg;
double decdegrees = 0.0;
double decminutes = 0.0;
double decseconds = 0.0;

//int intDeg = Integer.parseInt(coordinate);
decdegrees = Double.parseDouble(coordinate);
int intDeg = (int) decdegrees;
decminutes = (decdegrees - intDeg) * 60;
int intMin = (int) decminutes;
decseconds = (decminutes - intMin) * 60;
//logger.info("decdegrees {} intDeg {} decminutes {} intMin {} decseconds {}", String.valueOf(decdegrees), String.valueOf(intDeg), String.valueOf(decminutes), String.valueOf(intMin), String.valueOf(decseconds));

NumberFormat numsecs = NumberFormat.getInstance(new Locale("en", "US" ));
numsecs.setMaximumFractionDigits(2);
String strSeconds = numsecs.format(decseconds);
//logger.info("strSeconds {}", strSeconds);
String[] dmscoordinate = { String.valueOf(intDeg), String.valueOf(intMin), strSeconds};

return dmscoordinate;
}
}
20 changes: 20 additions & 0 deletions src/main/java/org/hvdw/jexiftoolgui/mainScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -2924,6 +2924,26 @@ public void actionPerformed(ActionEvent actionEvent) {
gpsCitytextField.setText(place.get("isolated_dwelling"));
}
}
// Now do the dec-min-sec fields
String[] dmsLat = EGPSd.decDegToDegMinSec(place.get("geoLatitude"));
CalcLatDegtextField.setText(dmsLat[0]);
CalcLatMintextField.setText(dmsLat[1]);
CalcLatSectextField.setText(dmsLat[2]);
if (place.get("geoLatitude").startsWith("-")) {
// Negative means South
CalcSouthRadioButton.setSelected(true);
} else {
CalcNorthRadioButton.setSelected(true);
}
String[] dmsLon = EGPSd.decDegToDegMinSec(place.get("geoLongitude"));
CalcLonDegtextField.setText(dmsLon[0]);
CalcLonMintextField.setText(dmsLon[1]);
CalcLonSectextField.setText(dmsLon[2]);
if (place.get("geoLongitude").startsWith("-")) {
CalcWestRadioButton.setSelected(true);
} else {
CalcEastradioButton.setSelected(true);
}
}
});

Expand Down

0 comments on commit 67df79e

Please sign in to comment.