Change key names
This commit is contained in:
parent
e210415a7b
commit
05b6611730
@ -75,8 +75,8 @@ public class BodyTubeHandler extends BaseHandler<BodyTube> {
|
||||
@Override
|
||||
public void endHandler(String element, HashMap<String, String> 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
|
||||
|
||||
|
@ -51,11 +51,11 @@ public class BoosterHandler extends BodyTubeHandler {
|
||||
public void closeElement(String element, HashMap<String, String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.");
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -36,18 +36,18 @@ public class LaunchSiteHandler extends AbstractElementHandler {
|
||||
public void closeElement(String element, HashMap<String, String> 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.");
|
||||
|
@ -63,8 +63,8 @@ public class NoseConeHandler extends BaseHandler<NoseCone> {
|
||||
@Override
|
||||
public void endHandler(String element, HashMap<String, String> 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
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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")) {
|
||||
|
@ -54,7 +54,7 @@ public class TransitionHandler extends BaseHandler<Transition> {
|
||||
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<Transition> {
|
||||
@Override
|
||||
public void endHandler(String element, HashMap<String, String> 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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user