Logger LatLong

Fix a couple of issues which threw and error in the event of a bad NMEA
string.
This commit is contained in:
Douglas Gillespie 2022-11-27 14:44:19 +00:00
parent 3203a0a50f
commit 6995bee65b
2 changed files with 18 additions and 81 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.pamguard</groupId> <groupId>org.pamguard</groupId>
<artifactId>Pamguard</artifactId> <artifactId>Pamguard</artifactId>
<version>2.02.06a</version> <version>2.02.06b</version>
<name>Pamguard Java12+</name> <name>Pamguard Java12+</name>
<description>Pamguard for Java 12+, using Maven to control dependcies</description> <description>Pamguard for Java 12+, using Maven to control dependcies</description>
<url>www.pamguard.org</url> <url>www.pamguard.org</url>

View File

@ -30,6 +30,7 @@ import javax.swing.text.MaskFormatter;
import Array.ArrayManager; import Array.ArrayManager;
import GPS.GPSControl; import GPS.GPSControl;
import GPS.GPSDataBlock; import GPS.GPSDataBlock;
import GPS.GpsData;
import GPS.GpsDataUnit; import GPS.GpsDataUnit;
import NMEA.NMEADataBlock; import NMEA.NMEADataBlock;
import NMEA.NMEADataUnit; import NMEA.NMEADataUnit;
@ -657,98 +658,25 @@ public class LatLongControl extends LoggerControl implements ClipboardOwner{
} }
// private class LatChangeListener implements PropertyChangeListener{
//
// /* (non-Javadoc)
// * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
// */
// @Override
// public void propertyChange(PropertyChangeEvent arg0) {
//
// System.out.println("old:"+arg0.getOldValue());
// System.out.println("new:"+arg0.getNewValue());
// try {
// textFieldLat.commitEdit();
// } catch (ParseException e) {
// // TODO Auto-generated catch block
//// e.printStackTrace();
// }
// }
//
// }
// private class LonChangeListener implements PropertyChangeListener{
//
// /* (non-Javadoc)
// * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
// */
// @Override
// public void propertyChange(PropertyChangeEvent arg0) {
//
//// System.out.println("old:"+arg0.getOldValue());
//// System.out.println("new:"+arg0.getNewValue());
// try {
// textFieldLon.commitEdit();
// } catch (ParseException e) {
// // TODO Auto-generated catch block
//// e.printStackTrace();
// }
// }
//
// }
@Override @Override
public void setData(Object latLong) { public void setData(Object latLong) {
LatLong a = (LatLong)latLong; if (latLong==null || latLong instanceof LatLong == false){
if (a==null){
// System.out.println("latLon null"); // System.out.println("latLon null");
textFieldLat.setValue(null); textFieldLat.setValue(null);
textFieldLon.setValue(null); textFieldLon.setValue(null);
return; return;
} }
LatLong a = (LatLong)latLong;
// System.out.println("a :"+a.toString()); // System.out.println("a :"+a.toString());
textFieldLat.setValue(a.getLatitude()); textFieldLat.setValue(a.getLatitude());
// textFieldLat.setText(a.formatLatitude());
// System.out.println("a latVal:"+textFieldLat.getValue());
// System.out.println("a latTxt:"+textFieldLat.getText());
textFieldLon.setValue(a.getLongitude()); textFieldLon.setValue(a.getLongitude());
// textFieldLon.setText(a.formatLongitude());
// addPropertyChangeListener("value", this);
// try {
// textFieldLat.commitEdit();
// textFieldLon.commitEdit();
// } catch (ParseException e) {
// if (dataWarning==null) dataWarning="";
// dataWarning+=" Unable to setData(...) ";
// e.printStackTrace();
// }
// if (latLong==null){
// System.out.println("LatLont null");
// textFieldLat.setText("");
// textFieldLon.setText("");
// return;
// }
//
// if (latLong.getClass().isAssignableFrom(LatLong.class)){
// System.out.println("LatLont assignable");
// LatLong latLon = (LatLong) latLong;
//
// if (latLon==null){
// System.out.println("LatLont still null");
// textFieldLat.setText("");
// textFieldLon.setText("");
// return;
// }
//
// textFieldLat.setText(LatLong.formatLatitude(latLon.getLatitude()));
// System.out.println(latLon.toString());
// textFieldLon.setText(LatLong.formatLongitude(latLon.getLongitude()));
// }
} }
@Override @Override
@ -856,6 +784,15 @@ public class LatLongControl extends LoggerControl implements ClipboardOwner{
try { try {
GpsDataUnit gpsUnit = findGpsDataBlock().getLastUnit(); GpsDataUnit gpsUnit = findGpsDataBlock().getLastUnit();
if (gpsUnit == null) {
setData(null);
return AUTO_UPDATE_FAIL;
}
GpsData gpsData = gpsUnit.getGpsData();
if (gpsData == null) {
setData(null);
return AUTO_UPDATE_FAIL;
}
latitude = gpsUnit.getGpsData().getLatitude(); latitude = gpsUnit.getGpsData().getLatitude();
longitude = gpsUnit.getGpsData().getLongitude(); longitude = gpsUnit.getGpsData().getLongitude();