]> git.gag.com Git - debian/openrocket/blobdiff - src/net/sf/openrocket/file/openrocket/OpenRocketLoader.java
geodetic computation file storage
[debian/openrocket] / src / net / sf / openrocket / file / openrocket / OpenRocketLoader.java
index d6cf61607c0dff5a4ed676074d443821ec0efd55..4c5eb72a0ebd7a9967e53600f0e278dbb43f7c37 100644 (file)
@@ -69,11 +69,12 @@ import net.sf.openrocket.simulation.FlightDataBranch;
 import net.sf.openrocket.simulation.FlightDataType;
 import net.sf.openrocket.simulation.FlightEvent;
 import net.sf.openrocket.simulation.FlightEvent.Type;
-import net.sf.openrocket.simulation.GUISimulationConditions;
+import net.sf.openrocket.simulation.SimulationOptions;
 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
@@ -1257,12 +1258,12 @@ class SingleSimulationHandler extends ElementHandler {
                        status = Simulation.Status.OUTDATED;
                }
                
-               GUISimulationConditions conditions;
+               SimulationOptions conditions;
                if (conditionHandler != null) {
                        conditions = conditionHandler.getConditions();
                } else {
                        warnings.add("Simulation conditions not defined, using defaults.");
-                       conditions = new GUISimulationConditions(doc.getRocket());
+                       conditions = new SimulationOptions(doc.getRocket());
                }
                
                if (name == null)
@@ -1284,14 +1285,16 @@ class SingleSimulationHandler extends ElementHandler {
 
 
 class SimulationConditionsHandler extends ElementHandler {
-       private GUISimulationConditions conditions;
+       private SimulationOptions conditions;
        private AtmosphereHandler atmosphereHandler;
        
        public SimulationConditionsHandler(Rocket rocket) {
-               conditions = new GUISimulationConditions(rocket);
+               conditions = new SimulationOptions(rocket);
+               // Set up default loading settings (which may differ from the new defaults)
+               conditions.setGeodeticComputation(GeodeticComputationStrategy.NONE);
        }
        
-       public GUISimulationConditions getConditions() {
+       public SimulationOptions getConditions() {
                return conditions;
        }
        
@@ -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")) {
@@ -1418,7 +1435,7 @@ class AtmosphereHandler extends ElementHandler {
        }
        
        
-       public void storeSettings(GUISimulationConditions cond, WarningSet warnings) {
+       public void storeSettings(SimulationOptions cond, WarningSet warnings) {
                if (!Double.isNaN(pressure)) {
                        cond.setLaunchPressure(pressure);
                }