Small fixes

Deal with null in xml settings output
Deal with -Infinity going into constrainAngle - however many times you add 360 to -Inf, it remains -Inf, so the function was never returning.
This commit is contained in:
Douglas Gillespie 2024-03-29 19:40:09 +00:00
parent 8252034f13
commit 3e2de8f5dc
3 changed files with 16 additions and 1 deletions

View File

@ -36,7 +36,7 @@ public class PamguardVersionInfo {
/**
* Release date
*/
static public final String date = "22 March 2024";
static public final String date = "29 March 2024";
// /**
// * Release type - Beta or Core

View File

@ -570,6 +570,9 @@ public class PamguardXMLWriter implements PamSettings {
*/
private Element writeSettings(Document doc, PamSettings pamSettings, Object data, ArrayList<Object> objectHierarchy) {
if (data == null) {
return null;
}
Element el = doc.createElement("SETTINGS");
el.setAttribute("Type", pamSettings.getUnitType());
el.setAttribute("Name", pamSettings.getUnitName());

View File

@ -354,6 +354,9 @@ public class PamUtils {
* @return output angle (degrees)
*/
static public double constrainedAngle(double angle) {
if (Double.isInfinite(angle) || Double.isNaN(angle)) {
return angle;
}
while (angle >= 360) {
angle -= 360;
}
@ -369,6 +372,9 @@ public class PamUtils {
* @return output angle (radians)
*/
static public double constrainedAngleR(double angle) {
if (Double.isInfinite(angle) || Double.isNaN(angle)) {
return angle;
}
while (angle >= 2*Math.PI) {
angle -= 2*Math.PI;
}
@ -384,6 +390,9 @@ public class PamUtils {
* @return output angle (degrees)
*/
static public double constrainedAngle(double angle, double maxAngle) {
if (Double.isInfinite(angle) || Double.isNaN(angle)) {
return angle;
}
while (angle >= maxAngle) {
angle -= 360;
}
@ -401,6 +410,9 @@ public class PamUtils {
* @return output angle (radians)
*/
static public double constrainedAngleR(double angle, double maxAngle) {
if (Double.isInfinite(angle) || Double.isNaN(angle)) {
return angle;
}
while (angle > maxAngle) {
angle -= 2*Math.PI;
}