From e47d6481b26e0dfff28ada029b9d4b665a8e313d Mon Sep 17 00:00:00 2001 From: SiboVG Date: Mon, 10 Apr 2023 23:44:12 +0200 Subject: [PATCH] [#2083] Account for uom in material database loader --- core/src/net/sf/openrocket/preset/xml/MaterialDTO.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/net/sf/openrocket/preset/xml/MaterialDTO.java b/core/src/net/sf/openrocket/preset/xml/MaterialDTO.java index 6694dbb7d..7ce9c468d 100644 --- a/core/src/net/sf/openrocket/preset/xml/MaterialDTO.java +++ b/core/src/net/sf/openrocket/preset/xml/MaterialDTO.java @@ -10,6 +10,7 @@ import javax.xml.bind.annotation.XmlRootElement; import net.sf.openrocket.database.Databases; import net.sf.openrocket.material.Material; +import net.sf.openrocket.unit.Unit; import net.sf.openrocket.util.Chars; /** @@ -98,6 +99,13 @@ public class MaterialDTO { if (uom != null) { uom = uom.replace('2', Chars.SQUARED); uom = uom.replace('3', Chars.CUBED); + if (type != null) { + // The density value is stored in the XML file in the units of measure, but OR expects the density to be + // in SI units, so we need to convert it to SI units + Unit uomUnit = type.getORMaterialType().getUnitGroup().getUnit(getUom()); + density = uomUnit.fromUnit(density); + //type.getORMaterialType().getUnitGroup().setDefaultUnit(uomUnit); + } } }