From 4ef2e330ffbabc05d31b604123545f7573153a63 Mon Sep 17 00:00:00 2001 From: plaa Date: Sun, 28 Aug 2011 14:57:08 +0000 Subject: [PATCH] geodetic computation file storage git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@166 180e2498-e6e9-4542-8430-84ac67f01cd8 --- fileformat.txt | 3 +++ .../file/openrocket/OpenRocketLoader.java | 19 ++++++++++++++++++- .../file/openrocket/OpenRocketSaver.java | 7 +++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/fileformat.txt b/fileformat.txt index 36fe9e17..9e04dcff 100644 --- a/fileformat.txt +++ b/fileformat.txt @@ -36,3 +36,6 @@ The following file format versions exist: motor definitions. The digest uniquely identifies the functional characteristics of a particular thrust curve motor. +1.3: Introduced with OpenRocket 1.1.9. Adds the and + parameters to the simulation conditions element. + diff --git a/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java b/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java index 7719e0e2..4c5eb72a 100644 --- a/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java +++ b/src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java @@ -74,6 +74,7 @@ import net.sf.openrocket.startup.Application; import net.sf.openrocket.unit.UnitGroup; import net.sf.openrocket.util.BugException; import net.sf.openrocket.util.Coordinate; +import net.sf.openrocket.util.GeodeticComputationStrategy; import net.sf.openrocket.util.LineStyle; import net.sf.openrocket.util.Reflection; @@ -158,7 +159,7 @@ public class OpenRocketLoader extends RocketLoader { class DocumentConfig { /* Remember to update OpenRocketSaver as well! */ - public static final String[] SUPPORTED_VERSIONS = { "0.9", "1.0", "1.1", "1.2" }; + public static final String[] SUPPORTED_VERSIONS = { "0.9", "1.0", "1.1", "1.2", "1.3" }; //////// Component constructors @@ -1289,6 +1290,8 @@ class SimulationConditionsHandler extends ElementHandler { public SimulationConditionsHandler(Rocket rocket) { conditions = new SimulationOptions(rocket); + // Set up default loading settings (which may differ from the new defaults) + conditions.setGeodeticComputation(GeodeticComputationStrategy.NONE); } public SimulationOptions getConditions() { @@ -1364,6 +1367,20 @@ class SimulationConditionsHandler extends ElementHandler { } else { conditions.setLaunchLatitude(d); } + } else if (element.equals("launchlongitude")) { + if (Double.isNaN(d)) { + warnings.add("Illegal launch longitude."); + } else { + conditions.setLaunchLongitude(d); + } + } else if (element.equals("geodeticmethod")) { + GeodeticComputationStrategy gcs = + (GeodeticComputationStrategy) DocumentConfig.findEnum(content, GeodeticComputationStrategy.class); + if (gcs != null) { + conditions.setGeodeticComputation(gcs); + } else { + warnings.add("Unknown geodetic computation method '" + content + "'"); + } } else if (element.equals("atmosphere")) { atmosphereHandler.storeSettings(conditions, warnings); } else if (element.equals("timestep")) { diff --git a/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java b/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java index bf237284..6554a537 100644 --- a/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java +++ b/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java @@ -193,6 +193,11 @@ public class OpenRocketSaver extends RocketSaver { * Otherwise use version 1.0. */ + // Check if design has simulations defined (version 1.3) + if (document.getSimulationCount() > 0) { + return FILE_VERSION_DIVISOR + 3; + } + // Check for motor definitions (version 1.2) Iterator iterator = document.getRocket().iterator(); while (iterator.hasNext()) { @@ -311,6 +316,8 @@ public class OpenRocketSaver extends RocketSaver { writeElement("windturbulence", cond.getWindTurbulenceIntensity()); writeElement("launchaltitude", cond.getLaunchAltitude()); writeElement("launchlatitude", cond.getLaunchLatitude()); + writeElement("launchlongitude", cond.getLaunchLongitude()); + writeElement("geodeticmethod", cond.getGeodeticComputation().name().toLowerCase()); if (cond.isISAAtmosphere()) { writeln(""); -- 2.30.2