From 05b6611730a2d2514396d9801d441b5bf11149a0 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Sat, 25 Mar 2023 00:18:10 +0100 Subject: [PATCH] Change key names --- .../file/rasaero/importt/BodyTubeHandler.java | 4 ++-- .../file/rasaero/importt/BoosterHandler.java | 6 ++--- .../file/rasaero/importt/FinCanHandler.java | 5 ++--- .../file/rasaero/importt/FinHandler.java | 12 +++++----- .../rasaero/importt/LaunchLugHandler.java | 4 ++-- .../rasaero/importt/LaunchSiteHandler.java | 10 ++++----- .../file/rasaero/importt/NoseConeHandler.java | 4 ++-- .../importt/RASAeroCommonConstants.java | 22 +++++++++---------- .../rasaero/importt/RailGuideHandler.java | 4 ++-- .../file/rasaero/importt/RecoveryHandler.java | 4 ++-- .../rasaero/importt/TransitionHandler.java | 6 ++--- 11 files changed, 40 insertions(+), 41 deletions(-) diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/BodyTubeHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/BodyTubeHandler.java index e43c9b33b..44ea54ac0 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/BodyTubeHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/BodyTubeHandler.java @@ -75,8 +75,8 @@ public class BodyTubeHandler extends BaseHandler { @Override public void endHandler(String element, HashMap attributes, String content, WarningSet warnings) throws SAXException { super.endHandler(element, attributes, content, warnings); - this.bodyTube.setLength(length / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); - this.bodyTube.setOuterRadius(diameter/2 / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); // Not really useful, but included for completeness + this.bodyTube.setLength(length / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); + this.bodyTube.setOuterRadius(diameter/2 / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); // Not really useful, but included for completeness this.bodyTube.setOuterRadiusAutomatic(true); this.bodyTube.setThickness(0.002); // Arbitrary value; RASAero doesn't specify this diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/BoosterHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/BoosterHandler.java index b01f1d886..9b27a7c55 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/BoosterHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/BoosterHandler.java @@ -51,11 +51,11 @@ public class BoosterHandler extends BodyTubeHandler { public void closeElement(String element, HashMap attributes, String content, WarningSet warnings) throws SAXException { super.closeElement(element, attributes, content, warnings); if (RASAeroCommonConstants.BOAT_TAIL_LENGTH.equals(element)) { - this.boatTailLength = Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; + this.boatTailLength = Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH; } else if (RASAeroCommonConstants.BOAT_TAIL_REAR_DIAMETER.equals(element)) { - this.boatTailRearDiameter = Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; + this.boatTailRearDiameter = Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH; } else if (RASAeroCommonConstants.SHOULDER_LENGTH.equals(element)) { - this.shoulderLength = Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; + this.shoulderLength = Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH; } } diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/FinCanHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/FinCanHandler.java index 6a23d0fc4..353f1a3b6 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/FinCanHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/FinCanHandler.java @@ -2,7 +2,6 @@ package net.sf.openrocket.file.rasaero.importt; import net.sf.openrocket.aerodynamics.WarningSet; import net.sf.openrocket.file.DocumentLoadingContext; -import net.sf.openrocket.file.simplesax.ElementHandler; import net.sf.openrocket.rocketcomponent.BodyTube; import net.sf.openrocket.rocketcomponent.PodSet; import net.sf.openrocket.rocketcomponent.RocketComponent; @@ -60,9 +59,9 @@ public class FinCanHandler extends BodyTubeHandler { super.closeElement(element, attributes, content, warnings); try { if (RASAeroCommonConstants.INSIDE_DIAMETER.equals(element)) { - insideDiameter = Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; + insideDiameter = Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH; } else if (RASAeroCommonConstants.SHOULDER_LENGTH.equals(element)) { - shoulderLength = Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; + shoulderLength = Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH; } } catch (NumberFormatException nfe) { warnings.add("Could not convert " + element + " value of " + content + ". It is expected to be a number."); diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/FinHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/FinHandler.java index e184e3e48..a0aca4fcb 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/FinHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/FinHandler.java @@ -46,21 +46,21 @@ public class FinHandler extends AbstractElementHandler { if (RASAeroCommonConstants.FIN_COUNT.equals(element)) { finSet.setFinCount(Integer.parseInt(content)); } else if (RASAeroCommonConstants.FIN_CHORD.equals(element)) { - finSet.setRootChord(Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); + finSet.setRootChord(Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); } else if (RASAeroCommonConstants.FIN_SPAN.equals(element)) { - finSet.setHeight(Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); + finSet.setHeight(Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); } else if (RASAeroCommonConstants.FIN_SWEEP_DISTANCE.equals(element)) { - finSet.setSweep(Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); + finSet.setSweep(Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); } else if (RASAeroCommonConstants.FIN_TIP_CHORD.equals(element)) { - finSet.setTipChord(Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); + finSet.setTipChord(Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); } else if (RASAeroCommonConstants.FIN_THICKNESS.equals(element)) { - finSet.setThickness(Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); + finSet.setThickness(Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); } else if (RASAeroCommonConstants.AIRFOIL_SECTION.equals(element)) { finSet.setCrossSection(RASAeroCommonConstants.getFinCrossSectionFromRASAero(content, warnings)); } else if (RASAeroCommonConstants.LOCATION.equals(element)) { // Location is the location of the front of the fin relative to the bottom of the body tube finSet.setAxialMethod(AxialMethod.BOTTOM); - double location = Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; + double location = Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH; location = -location + finSet.getLength(); finSet.setAxialOffset(location); } diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/LaunchLugHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/LaunchLugHandler.java index 85747c29a..66713f85d 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/LaunchLugHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/LaunchLugHandler.java @@ -14,8 +14,8 @@ import net.sf.openrocket.rocketcomponent.position.AxialMethod; */ public abstract class LaunchLugHandler { public static void addLaunchLug(BodyTube parent, double diameter, double length) { - diameter = diameter / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; - length = length / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; + diameter = diameter / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH; + length = length / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH; LaunchLug lug = generateLaunchLugFromRASAeroRailGuide(diameter, length, parent.getLength()); parent.addChild(lug); diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/LaunchSiteHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/LaunchSiteHandler.java index 77e112603..d8145e260 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/LaunchSiteHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/LaunchSiteHandler.java @@ -36,18 +36,18 @@ public class LaunchSiteHandler extends AbstractElementHandler { public void closeElement(String element, HashMap attributes, String content, WarningSet warnings) throws SAXException { try { if (RASAeroCommonConstants.LAUNCH_ALTITUDE.equals(element)) { - launchSiteSettings.setLaunchAltitude(Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_ALTITUDE); + launchSiteSettings.setLaunchAltitude(Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_ALTITUDE); } else if (RASAeroCommonConstants.LAUNCH_PRESSURE.equals(element)) { - launchSiteSettings.setLaunchPressure(Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_PRESSURE); + launchSiteSettings.setLaunchPressure(Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_PRESSURE); } else if (RASAeroCommonConstants.LAUNCH_ROD_ANGLE.equals(element)) { - launchSiteSettings.setLaunchRodAngle(Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_ANGLE); + launchSiteSettings.setLaunchRodAngle(Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_ANGLE); } else if (RASAeroCommonConstants.LAUNCH_ROD_LENGTH.equals(element)) { - launchSiteSettings.setLaunchRodLength(Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_ALTITUDE); + launchSiteSettings.setLaunchRodLength(Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_ALTITUDE); } else if (RASAeroCommonConstants.LAUNCH_TEMPERATURE.equals(element)) { launchSiteSettings.setLaunchTemperature( RASAeroCommonConstants.RASAERO_TO_OPENROCKET_TEMPERATURE(Double.parseDouble(content))); } else if (RASAeroCommonConstants.LAUNCH_WIND_SPEED.equals(element)) { - launchSiteSettings.setWindSpeedAverage(Double.parseDouble(content) / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_SPEED); + launchSiteSettings.setWindSpeedAverage(Double.parseDouble(content) / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_SPEED); } } catch (NumberFormatException e) { warnings.add("Invalid number format for element " + element + ", ignoring."); diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/NoseConeHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/NoseConeHandler.java index 24866c642..84114e199 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/NoseConeHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/NoseConeHandler.java @@ -63,8 +63,8 @@ public class NoseConeHandler extends BaseHandler { @Override public void endHandler(String element, HashMap attributes, String content, WarningSet warnings) throws SAXException { super.endHandler(element, attributes, content, warnings); - this.noseCone.setLength(length / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); - this.noseCone.setBaseRadius(diameter/2 / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); + this.noseCone.setLength(length / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); + this.noseCone.setBaseRadius(diameter/2 / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); this.noseCone.setThickness(0.002); // Arbitrary value; RASAero doesn't specify this } diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/RASAeroCommonConstants.java b/core/src/net/sf/openrocket/file/rasaero/importt/RASAeroCommonConstants.java index f5e487a70..8d69828e8 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/RASAeroCommonConstants.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/RASAeroCommonConstants.java @@ -124,27 +124,27 @@ public class RASAeroCommonConstants { /** - * Length conversion. RASAero is in inches, OpenRocket in meters. + * Length conversion from OpenRocket units to RASAero units. RASAero is in inches, OpenRocket in meters. */ - public static final double RASAERO_TO_OPENROCKET_LENGTH = 39.37; + public static final double OPENROCKET_TO_RASAERO_TO_LENGTH = 39.37; /** - * Altitude conversion. RASAero is in feet, OpenRocket in meters. + * Altitude conversion from OpenRocket units to RASAero units. RASAero is in feet, OpenRocket in meters. */ - public static final double RASAERO_TO_OPENROCKET_ALTITUDE = 3.28084; + public static final double OPENROCKET_TO_RASAERO_ALTITUDE = 3.28084; /** - * Speed conversion. RASAero is in mph, OpenRocket in m/s. + * Speed conversion from OpenRocket units to RASAero units. RASAero is in mph, OpenRocket in m/s. */ - public static final double RASAERO_TO_OPENROCKET_SPEED = 2.23694; + public static final double OPENROCKET_TO_RASAERO_SPEED = 2.23694; /** - * Pressure conversion. RASAero is in in-hg, OpenRocket in Pa. + * Pressure conversion from OpenRocket units to RASAero units. RASAero is in in-hg, OpenRocket in Pa. */ - public static final double RASAERO_TO_OPENROCKET_PRESSURE = 0.000295301; + public static final double OPENROCKET_TO_RASAERO_PRESSURE = 0.000295301; /** - * Angle conversion. RASAero is in degrees, OpenRocket in rad. + * Angle conversion from OpenRocket units to RASAero units. RASAero is in degrees, OpenRocket in rad. */ - public static final double RASAERO_TO_OPENROCKET_ANGLE = 180 / Math.PI; + public static final double OPENROCKET_TO_RASAERO_ANGLE = 180 / Math.PI; /** - * Temperature conversion. RASAero is in Fahrenheit, OpenRocket in Kelvin. + * Temperature conversion from OpenRocket units to RASAero units. RASAero is in Fahrenheit, OpenRocket in Kelvin. */ public static final double RASAERO_TO_OPENROCKET_TEMPERATURE(Double input) { return (input + 459.67) * 5.0 / 9.0; diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/RailGuideHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/RailGuideHandler.java index 432ea662d..6b7217174 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/RailGuideHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/RailGuideHandler.java @@ -22,8 +22,8 @@ public abstract class RailGuideHandler { * @param height total height of the rail guide, plus the screw height */ public static void addRailGuide(BodyTube parent, double diameter, double height) { - diameter = diameter / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; - height = height / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH; + diameter = diameter / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH; + height = height / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH; RailButton button = generateRailButtonFromRASAeroRailGuide(diameter, height, parent.getLength()); parent.addChild(button); diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/RecoveryHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/RecoveryHandler.java index 01cd4411a..39f6a9768 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/RecoveryHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/RecoveryHandler.java @@ -163,10 +163,10 @@ public class RecoveryHandler extends AbstractElementHandler { recoveryDevice.setName("Recovery Event " + (recoveryDeviceNr+1)); DeploymentConfiguration config = recoveryDevice.getDeploymentConfigurations().getDefault(); - recoveryDevice.setDiameter(size / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); + recoveryDevice.setDiameter(size / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); recoveryDevice.setLineLength(recoveryDevice.getDiameter()); recoveryDevice.setCD(CD); - config.setDeployAltitude(altitude / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_ALTITUDE); + config.setDeployAltitude(altitude / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_ALTITUDE); // There is a special RASAero rule: if event 1 AND event 2 are set to apogee, then set event 2 to altitude if (recoveryDeviceNr == 1 && eventType.equals("Apogee") && this.eventType[0].equals("Apogee")) { diff --git a/core/src/net/sf/openrocket/file/rasaero/importt/TransitionHandler.java b/core/src/net/sf/openrocket/file/rasaero/importt/TransitionHandler.java index 88660244a..6f9893cc3 100644 --- a/core/src/net/sf/openrocket/file/rasaero/importt/TransitionHandler.java +++ b/core/src/net/sf/openrocket/file/rasaero/importt/TransitionHandler.java @@ -54,7 +54,7 @@ public class TransitionHandler extends BaseHandler { super.closeElement(element, attributes, content, warnings); try { if (RASAeroCommonConstants.REAR_DIAMETER.equals(element)) { - this.transition.setAftRadius(Double.parseDouble(content) / 2 / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); + this.transition.setAftRadius(Double.parseDouble(content) / 2 / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); } } catch (NumberFormatException nfe) { warnings.add("Could not convert " + element + " value of " + content + ". It is expected to be a number."); @@ -64,8 +64,8 @@ public class TransitionHandler extends BaseHandler { @Override public void endHandler(String element, HashMap attributes, String content, WarningSet warnings) throws SAXException { super.endHandler(element, attributes, content, warnings); - this.transition.setLength(length / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); - this.transition.setForeRadius(diameter/2 / RASAeroCommonConstants.RASAERO_TO_OPENROCKET_LENGTH); // Not really useful, but adding it for completeness + this.transition.setLength(length / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); + this.transition.setForeRadius(diameter/2 / RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TO_LENGTH); // Not really useful, but adding it for completeness this.transition.setForeRadiusAutomatic(true); this.transition.setThickness(0.002); // Arbitrary value; RASAero doesn't specify this }