diff --git a/Build/build-pack-nano-nugets.psm1 b/Build/build-pack-nano-nugets.psm1 index 6898248bf9..1b15f6f997 100644 --- a/Build/build-pack-nano-nugets.psm1 +++ b/Build/build-pack-nano-nugets.psm1 @@ -8,7 +8,6 @@ function Invoke-BuildNanoNugets { & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Duration\UnitsNet.NanoFramework.Duration.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricCurrent\UnitsNet.NanoFramework.ElectricCurrent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricPotential\UnitsNet.NanoFramework.ElectricPotential.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" - & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricPotentialDc\UnitsNet.NanoFramework.ElectricPotentialDc.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricResistance\UnitsNet.NanoFramework.ElectricResistance.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Frequency\UnitsNet.NanoFramework.Frequency.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Illuminance\UnitsNet.NanoFramework.Illuminance.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" diff --git a/CodeGen/CodeGen.csproj b/CodeGen/CodeGen.csproj index 42b3658625..24c93d5eca 100644 --- a/CodeGen/CodeGen.csproj +++ b/CodeGen/CodeGen.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 latest enable @@ -10,11 +10,11 @@ - - - - - + + + + + diff --git a/CodeGen/Exceptions/UnitsNetCodeGenException.cs b/CodeGen/Exceptions/UnitsNetCodeGenException.cs index 2e98bc3e86..e25340993a 100644 --- a/CodeGen/Exceptions/UnitsNetCodeGenException.cs +++ b/CodeGen/Exceptions/UnitsNetCodeGenException.cs @@ -2,20 +2,11 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; -using System.Runtime.Serialization; namespace CodeGen.Exceptions { internal class UnitsNetCodeGenException : Exception { - public UnitsNetCodeGenException() - { - } - - protected UnitsNetCodeGenException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - public UnitsNetCodeGenException(string message) : base(message) { } diff --git a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs index 885ff15780..b946256f83 100644 --- a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs @@ -25,7 +25,7 @@ public string Generate() UnitsNet.nanoFramework.{_quantity.Name} - 5.74.0 + 6.0.0-pre014 Units.NET {_quantity.Name} - nanoFramework Andreas Gullberg Larsen,nanoframework UnitsNet diff --git a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs index 721c9a94ce..91082c28c0 100644 --- a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs @@ -43,7 +43,7 @@ public struct {_quantity.Name} /// /// The numeric value this quantity was constructed with. /// - private readonly {_quantity.ValueType} _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -53,7 +53,7 @@ public struct {_quantity.Name} /// /// The numeric value this quantity was constructed with. /// - public {_quantity.ValueType} Value => _value; + public double Value => _value; /// public {_unitEnumName} Unit => _unit; @@ -65,8 +65,7 @@ public struct {_quantity.Name} /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - /// If value is NaN or Infinity. - public {_quantity.Name}({_quantity.ValueType} value, {_unitEnumName} unit) + public {_quantity.Name}(double value, {_unitEnumName} unit) {{ _value = value; _unit = unit; @@ -79,29 +78,14 @@ public struct {_quantity.Name} /// /// Represents the largest possible value of {_quantity.Name}. - /// "); - - // Non decimal - Writer.WLCondition(_quantity.ValueType != "decimal", $@" - public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of {_quantity.Name}. /// - public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MinValue, BaseUnit); -"); - - // Decimal MaxValue = 79228162514264337593543950335M - Writer.WLCondition(_quantity.ValueType == "decimal", $@" - public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}(79228162514264337593543950335M, BaseUnit); + public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of {_quantity.Name}. /// - public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}(-79228162514264337593543950335M, BaseUnit); -"); + public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}(double.MinValue, BaseUnit); - Writer.WL($@" /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// @@ -134,7 +118,7 @@ private void GenerateConversionProperties() /// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public {_quantity.ValueType} {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); + public double {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); "); } @@ -157,11 +141,10 @@ private void GenerateStaticFactoryMethods() Writer.WL($@" /// /// Creates a from . - /// - /// If value is NaN or Infinity."); + /// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public static {_quantity.Name} From{unit.PluralName}({_quantity.ValueType} {valueParamName}) => new {_quantity.Name}({valueParamName}, {_unitEnumName}.{unit.SingularName}); + public static {_quantity.Name} From{unit.PluralName}(double {valueParamName}) => new {_quantity.Name}({valueParamName}, {_unitEnumName}.{unit.SingularName}); "); } @@ -172,7 +155,7 @@ private void GenerateStaticFactoryMethods() /// Value to convert from. /// Unit to convert from. /// {_quantity.Name} unit value. - public static {_quantity.Name} From({_quantity.ValueType} value, {_unitEnumName} fromUnit) + public static {_quantity.Name} From(double value, {_unitEnumName} fromUnit) {{ return new {_quantity.Name}(value, fromUnit); }} @@ -190,7 +173,7 @@ private void GenerateConversionMethods() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public {_quantity.ValueType} As({_unitEnumName} unit) => GetValueAs(unit); + public double As({_unitEnumName} unit) => GetValueAs(unit); /// /// Converts this {_quantity.Name} to another {_quantity.Name} with the unit representation . @@ -207,7 +190,7 @@ private void GenerateConversionMethods() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private {_quantity.ValueType} GetValueInBaseUnit() + private double GetValueInBaseUnit() {{ return Unit switch {{"); @@ -223,7 +206,7 @@ private void GenerateConversionMethods() }}; }} - private {_quantity.ValueType} GetValueAs({_unitEnumName} unit) + private double GetValueAs({_unitEnumName} unit) {{ if (Unit == unit) return _value; diff --git a/CodeGen/Generators/NanoFrameworkGenerator.cs b/CodeGen/Generators/NanoFrameworkGenerator.cs index 1753235749..19d8cab43c 100644 --- a/CodeGen/Generators/NanoFrameworkGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGenerator.cs @@ -90,20 +90,6 @@ public static void Generate(string rootDir, Quantity[] quantities, QuantityNameT GenerateQuantity(quantity, Path.Combine(outputQuantities, $"{quantity.Name}.g.cs")); GenerateProject(quantity, Path.Combine(projectPath, $"{quantity.Name}.nfproj"), versions); - // Convert decimal based units to floats; decimals are not supported by nanoFramework - if (quantity.ValueType == "decimal") - { - var replacements = new Dictionary - { - { "(\\d)m", "$1d" }, - { "(\\d)M", "$1d" }, - { " decimal ", " double " }, - { "(decimal ", "(double " } - }; - new FileInfo(Path.Combine(outputDir, "Units", $"{quantity.Name}Unit.g.cs")).EditFile(replacements); - new FileInfo(Path.Combine(outputDir, "Quantities", $"{quantity.Name}.g.cs")).EditFile(replacements); - } - Log.Information("✅ {Quantity} (nanoFramework)", quantity.Name); } Log.Information(""); diff --git a/CodeGen/Generators/QuantityJsonFilesParser.cs b/CodeGen/Generators/QuantityJsonFilesParser.cs index 316e785fd6..e1d50871a7 100644 --- a/CodeGen/Generators/QuantityJsonFilesParser.cs +++ b/CodeGen/Generators/QuantityJsonFilesParser.cs @@ -6,138 +6,89 @@ using System.IO; using System.Linq; using CodeGen.Exceptions; -using CodeGen.Helpers; +using CodeGen.Helpers.PrefixBuilder; using CodeGen.JsonTypes; using Newtonsoft.Json; +using static CodeGen.Helpers.PrefixBuilder.BaseUnitPrefixes; -namespace CodeGen.Generators +namespace CodeGen.Generators; + +/// +/// Parses JSON files that define quantities and their units. +/// This will later be used to generate source code and can be reused for different targets such as .NET framework, +/// .NET Core, .NET nanoFramework and even other programming languages. +/// +internal static class QuantityJsonFilesParser { + private static readonly JsonSerializerSettings JsonSerializerSettings = new() + { + // Don't override the C# default assigned values if no value is set in JSON + NullValueHandling = NullValueHandling.Ignore + }; + + private static readonly string[] BaseQuantityFileNames = + ["Length", "Mass", "Duration", "ElectricCurrent", "Temperature", "AmountOfSubstance", "LuminousIntensity"]; + /// /// Parses JSON files that define quantities and their units. - /// This will later be used to generate source code and can be reused for different targets such as .NET framework, - /// .NET Core, .NET nanoFramework and even other programming languages. /// - internal static class QuantityJsonFilesParser + /// Repository root directory, where you cloned the repo to such as "c:\dev\UnitsNet". + /// The parsed quantities and their units. + public static Quantity[] ParseQuantities(string rootDir) { - private static readonly JsonSerializerSettings JsonSerializerSettings = new JsonSerializerSettings - { - // Don't override the C# default assigned values if no value is set in JSON - NullValueHandling = NullValueHandling.Ignore - }; + var jsonDir = Path.Combine(rootDir, "Common/UnitDefinitions"); + var baseQuantityFiles = BaseQuantityFileNames.Select(baseQuantityName => Path.Combine(jsonDir, baseQuantityName + ".json")).ToArray(); - /// - /// Parses JSON files that define quantities and their units. - /// - /// Repository root directory, where you cloned the repo to such as "c:\dev\UnitsNet". - /// The parsed quantities and their units. - public static Quantity[] ParseQuantities(string rootDir) - { - var jsonDir = Path.Combine(rootDir, "Common/UnitDefinitions"); - var jsonFileNames = Directory.GetFiles(jsonDir, "*.json"); - return jsonFileNames - .OrderBy(fn => fn, StringComparer.InvariantCultureIgnoreCase) - .Select(ParseQuantityFile) - .ToArray(); - } + Quantity[] baseQuantities = ParseQuantities(baseQuantityFiles); + Quantity[] derivedQuantities = ParseQuantities(Directory.GetFiles(jsonDir, "*.json").Except(baseQuantityFiles)); - private static Quantity ParseQuantityFile(string jsonFileName) - { - try - { - var quantity = JsonConvert.DeserializeObject(File.ReadAllText(jsonFileName), JsonSerializerSettings) - ?? throw new UnitsNetCodeGenException($"Unable to parse quantity from JSON file: {jsonFileName}"); - - AddPrefixUnits(quantity); - FixConversionFunctionsForDecimalValueTypes(quantity); - OrderUnitsByName(quantity); - return quantity; - } - catch (Exception e) - { - throw new Exception($"Error parsing quantity JSON file: {jsonFileName}", e); - } - } + return BuildQuantities(baseQuantities, derivedQuantities); + } - private static void OrderUnitsByName(Quantity quantity) - { - quantity.Units = quantity.Units.OrderBy(u => u.SingularName, StringComparer.OrdinalIgnoreCase).ToArray(); - } + private static Quantity[] ParseQuantities(IEnumerable jsonFiles) + { + return jsonFiles.Select(ParseQuantity).ToArray(); + } - private static void FixConversionFunctionsForDecimalValueTypes(Quantity quantity) + private static Quantity ParseQuantity(string jsonFileName) + { + try { - foreach (Unit u in quantity.Units) - // Use decimal for internal calculations if base type is not double, such as for long or int. - { - if (string.Equals(quantity.ValueType, "decimal", StringComparison.OrdinalIgnoreCase)) - { - // Change any double literals like "1024d" to decimal literals "1024m" - u.FromUnitToBaseFunc = u.FromUnitToBaseFunc.Replace("d", "m"); - u.FromBaseToUnitFunc = u.FromBaseToUnitFunc.Replace("d", "m"); - } - } + return JsonConvert.DeserializeObject(File.ReadAllText(jsonFileName), JsonSerializerSettings) + ?? throw new UnitsNetCodeGenException($"Unable to parse quantity from JSON file: {jsonFileName}"); } - - private static void AddPrefixUnits(Quantity quantity) + catch (Exception e) { - var unitsToAdd = new List(); - foreach (Unit unit in quantity.Units) - foreach (Prefix prefix in unit.Prefixes) - { - try - { - var prefixInfo = PrefixInfo.Entries[prefix]; - - unitsToAdd.Add(new Unit - { - SingularName = $"{prefix}{unit.SingularName.ToCamelCase()}", // "Kilo" + "NewtonPerMeter" => "KilonewtonPerMeter" - PluralName = $"{prefix}{unit.PluralName.ToCamelCase()}", // "Kilo" + "NewtonsPerMeter" => "KilonewtonsPerMeter" - BaseUnits = null, // Can we determine this somehow? - FromBaseToUnitFunc = $"({unit.FromBaseToUnitFunc}) / {prefixInfo.Factor}", - FromUnitToBaseFunc = $"({unit.FromUnitToBaseFunc}) * {prefixInfo.Factor}", - Localization = GetLocalizationForPrefixUnit(unit.Localization, prefixInfo), - ObsoleteText = unit.ObsoleteText, - SkipConversionGeneration = unit.SkipConversionGeneration, - AllowAbbreviationLookup = unit.AllowAbbreviationLookup - } ); - } - catch (Exception e) - { - throw new Exception($"Error parsing prefix {prefix} for unit {quantity.Name}.{unit.SingularName}.", e); - } - } - - quantity.Units = quantity.Units.Concat(unitsToAdd).ToArray(); + throw new Exception($"Error parsing quantity JSON file: {jsonFileName}", e); } + } - /// - /// Create unit abbreviations for a prefix unit, given a unit and the prefix. - /// The unit abbreviations are either prefixed with the SI prefix or an explicitly configured abbreviation via - /// . - /// - private static Localization[] GetLocalizationForPrefixUnit(IEnumerable localizations, PrefixInfo prefixInfo) + /// + /// Combines base quantities and derived quantities into a single collection, + /// while generating prefixed units for each quantity. + /// + /// + /// The array of base quantities, each containing its respective units. + /// + /// + /// The array of derived quantities, each containing its respective units. + /// + /// + /// An ordered array of all quantities, including both base and derived quantities, + /// with prefixed units generated and added to their respective unit collections. + /// + /// + /// This method utilizes the to generate prefixed units + /// for each quantity. The resulting quantities are sorted alphabetically by their names. + /// + private static Quantity[] BuildQuantities(Quantity[] baseQuantities, Quantity[] derivedQuantities) + { + var prefixBuilder = new UnitPrefixBuilder(FromBaseUnits(baseQuantities.SelectMany(x => x.Units))); + return baseQuantities.Concat(derivedQuantities).Select(quantity => { - return localizations.Select(loc => - { - if (loc.TryGetAbbreviationsForPrefix(prefixInfo.Prefix, out string[]? unitAbbreviationsForPrefix)) - { - return new Localization - { - Culture = loc.Culture, - Abbreviations = unitAbbreviationsForPrefix - }; - } - - // No prefix unit abbreviations are specified, so fall back to prepending the default SI prefix to each unit abbreviation: - // kilo ("k") + meter ("m") => kilometer ("km") - var prefix = prefixInfo.GetPrefixForCultureOrSiPrefix(loc.Culture); - unitAbbreviationsForPrefix = loc.Abbreviations.Select(unitAbbreviation => $"{prefix}{unitAbbreviation}").ToArray(); - - return new Localization - { - Culture = loc.Culture, - Abbreviations = unitAbbreviationsForPrefix - }; - }).ToArray(); - } + List prefixedUnits = prefixBuilder.GeneratePrefixUnits(quantity); + quantity.Units = quantity.Units.Concat(prefixedUnits).OrderBy(unit => unit.SingularName, StringComparer.OrdinalIgnoreCase).ToArray(); + return quantity; + }).OrderBy(quantity => quantity.Name, StringComparer.InvariantCultureIgnoreCase).ToArray(); } } diff --git a/CodeGen/Generators/QuantityRelationsParser.cs b/CodeGen/Generators/QuantityRelationsParser.cs new file mode 100644 index 0000000000..401c7e7b10 --- /dev/null +++ b/CodeGen/Generators/QuantityRelationsParser.cs @@ -0,0 +1,213 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using CodeGen.Exceptions; +using CodeGen.JsonTypes; +using Newtonsoft.Json; + +namespace CodeGen.Generators +{ + /// + /// Parses the JSON file that defines the relationships (operators) between quantities + /// and applies them to the parsed quantity objects. + /// + internal static class QuantityRelationsParser + { + /// + /// Parse and apply relations to quantities. + /// + /// The relations are defined in UnitRelations.json + /// Each defined relation can be applied multiple times to one or two quantities depending on the operator and the operands. + /// + /// The format of a relation definition is "Quantity.Unit operator Quantity.Unit = Quantity.Unit" (See examples below). + /// "double" can be used as a unitless operand. + /// "1" can be used as the result operand to define inverse relations. + /// + /// Division relations are inferred from multiplication relations, + /// but this can be skipped if the string ends with "NoInferredDivision". + /// + /// + /// [ + /// "1 = Length.Meter * ReciprocalLength.InverseMeter" + /// "Power.Watt = ElectricPotential.Volt * ElectricCurrent.Ampere", + /// "Mass.Kilogram = MassConcentration.KilogramPerCubicMeter * Volume.CubicMeter -- NoInferredDivision", + /// ] + /// + /// Repository root directory. + /// List of previously parsed Quantity objects. + public static void ParseAndApplyRelations(string rootDir, Quantity[] quantities) + { + var quantityDictionary = quantities.ToDictionary(q => q.Name, q => q); + + // Add double and 1 as pseudo-quantities to validate relations that use them. + var pseudoQuantity = new Quantity { Name = null!, Units = [new Unit { SingularName = null! }] }; + quantityDictionary["double"] = pseudoQuantity with { Name = "double" }; + quantityDictionary["1"] = pseudoQuantity with { Name = "1" }; + + var relations = ParseRelations(rootDir, quantityDictionary); + + // Because multiplication is commutative, we can infer the other operand order. + relations.AddRange(relations + .Where(r => r.Operator is "*" or "inverse" && r.LeftQuantity != r.RightQuantity) + .Select(r => r with + { + LeftQuantity = r.RightQuantity, + LeftUnit = r.RightUnit, + RightQuantity = r.LeftQuantity, + RightUnit = r.LeftUnit, + }) + .ToList()); + + // We can infer division relations from multiplication relations. + relations.AddRange(relations + .Where(r => r is { Operator: "*", NoInferredDivision: false }) + .Select(r => r with + { + Operator = "/", + LeftQuantity = r.ResultQuantity, + LeftUnit = r.ResultUnit, + ResultQuantity = r.LeftQuantity, + ResultUnit = r.LeftUnit, + }) + // Skip division between equal quantities because the ratio is already generated as part of the Arithmetic Operators. + .Where(r => r.LeftQuantity != r.RightQuantity) + .ToList()); + + // Sort all relations to keep generated operators in a consistent order. + relations.Sort(); + + var duplicates = relations + .GroupBy(r => r.SortString) + .Where(g => g.Count() > 1) + .Select(g => g.Key) + .ToList(); + + if (duplicates.Any()) + { + var list = string.Join("\n ", duplicates); + throw new UnitsNetCodeGenException($"Duplicate inferred relations:\n {list}"); + } + + var ambiguous = relations + .GroupBy(r => $"{r.LeftQuantity.Name} {r.Operator} {r.RightQuantity.Name}") + .Where(g => g.Count() > 1) + .Select(g => g.Key) + .ToList(); + + if (ambiguous.Any()) + { + var list = string.Join("\n ", ambiguous); + throw new UnitsNetCodeGenException($"Ambiguous inferred relations:\n {list}\n\nHint: you could use NoInferredDivision in the definition file."); + } + + foreach (var quantity in quantities) + { + var quantityRelations = new List(); + + foreach (var relation in relations) + { + if (relation.LeftQuantity == quantity) + { + // The left operand of a relation is responsible for generating the operator. + quantityRelations.Add(relation); + } + else if (relation.RightQuantity == quantity && relation.LeftQuantity.Name is "double") + { + // Because we cannot add operators to double we make the right operand responsible in this case. + quantityRelations.Add(relation); + } + } + + quantity.Relations = quantityRelations.ToArray(); + } + } + + private static List ParseRelations(string rootDir, IReadOnlyDictionary quantities) + { + var relationsFileName = Path.Combine(rootDir, "Common/UnitRelations.json"); + + try + { + var text = File.ReadAllText(relationsFileName); + var relationStrings = JsonConvert.DeserializeObject>(text) ?? []; + + var parsedRelations = relationStrings.Select(relationString => ParseRelation(relationString, quantities)).ToList(); + + // File parsed successfully, save it back to disk in the sorted state. + File.WriteAllText(relationsFileName, JsonConvert.SerializeObject(relationStrings, Formatting.Indented)); + + return parsedRelations; + } + catch (Exception e) + { + throw new UnitsNetCodeGenException($"Error parsing relations file: {relationsFileName}", e); + } + } + + private static QuantityRelation ParseRelation(string relationString, IReadOnlyDictionary quantities) + { + var segments = relationString.Split(' '); + + if (segments is not [_, "=", _, "*", _, ..]) + { + throw new Exception($"Invalid relation string: {relationString}"); + } + + var @operator = segments[3]; + var left = segments[2].Split('.'); + var right = segments[4].Split('.'); + var result = segments[0].Split('.'); + + var leftQuantity = GetQuantity(left[0]); + var rightQuantity = GetQuantity(right[0]); + var resultQuantity = GetQuantity(result[0]); + + var leftUnit = GetUnit(leftQuantity, left.ElementAtOrDefault(1)); + var rightUnit = GetUnit(rightQuantity, right.ElementAtOrDefault(1)); + var resultUnit = GetUnit(resultQuantity, result.ElementAtOrDefault(1)); + + if (resultQuantity.Name == "1") + { + @operator = "inverse"; + } + + return new QuantityRelation + { + NoInferredDivision = segments.Contains("NoInferredDivision"), + Operator = @operator, + LeftQuantity = leftQuantity, + LeftUnit = leftUnit, + RightQuantity = rightQuantity, + RightUnit = rightUnit, + ResultQuantity = resultQuantity, + ResultUnit = resultUnit + }; + + Quantity GetQuantity(string quantityName) + { + if (!quantities.TryGetValue(quantityName, out var quantity)) + { + throw new Exception($"Undefined quantity {quantityName} in relation string: {relationString}"); + } + + return quantity; + } + + Unit GetUnit(Quantity quantity, string? unitName) + { + try + { + return quantity.Units.First(u => u.SingularName == unitName); + } + catch (InvalidOperationException) + { + throw new Exception($"Undefined unit {unitName} in relation string: {relationString}"); + } + } + } + } +} \ No newline at end of file diff --git a/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs b/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs index 750d30125c..4765e49d9e 100644 --- a/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs @@ -40,7 +40,7 @@ public static class NumberTo{_quantityName}Extensions continue; Writer.WL(2, $@" -/// "); +/// "); // Include obsolete text from the quantity per extension method, to make it visible when the class is not explicitly referenced in code. Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit.ObsoleteText ?? _quantity.ObsoleteText)); @@ -49,8 +49,11 @@ public static class NumberTo{_quantityName}Extensions where T : notnull #if NET7_0_OR_GREATER , INumber + => {_quantityName}.From{unit.PluralName}(double.CreateChecked(value)); +#else + , IConvertible + => {_quantityName}.From{unit.PluralName}(value.ToDouble(null)); #endif - => {_quantityName}.From{unit.PluralName}(Convert.ToDouble(value)); "); } diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 5942581dd5..0238c804ae 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -14,7 +14,6 @@ internal class QuantityGenerator : GeneratorBase private readonly bool _isDimensionless; private readonly string _unitEnumName; - private readonly string _valueType; private readonly Unit _baseUnit; public QuantityGenerator(Quantity quantity) @@ -25,7 +24,6 @@ public QuantityGenerator(Quantity quantity) throw new ArgumentException($"No unit found with SingularName equal to BaseUnit [{_quantity.BaseUnit}]. This unit must be defined.", nameof(quantity)); - _valueType = quantity.ValueType; _unitEnumName = $"{quantity.Name}Unit"; BaseDimensions baseDimensions = quantity.BaseDimensions; @@ -42,8 +40,10 @@ public string Generate() using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using UnitsNet.InternalHelpers; using UnitsNet.Units; +#if NET +using System.Numerics; +#endif #nullable enable @@ -67,12 +67,42 @@ namespace UnitsNet [DataContract] [DebuggerTypeProxy(typeof(QuantityDisplay))] public readonly partial struct {_quantity.Name} : - {(_quantity.GenerateArithmetic ? "IArithmeticQuantity" : "IQuantity")}<{_quantity.Name}, {_unitEnumName}, {_quantity.ValueType}>,"); + {(_quantity.GenerateArithmetic ? "IArithmeticQuantity" : "IQuantity")}<{_quantity.Name}, {_unitEnumName}>,"); - if (_quantity.ValueType == "decimal") Writer.WL(@$" - IDecimalQuantity,"); + if (_quantity.Relations.Any(r => r.Operator is "*" or "/")) + { + Writer.WL(@$" +#if NET7_0_OR_GREATER"); + foreach (var relation in _quantity.Relations) + { + if (relation.LeftQuantity == _quantity) + { + switch (relation.Operator) + { + case "*": + Writer.W(@" + IMultiplyOperators"); + break; + case "/": + Writer.W(@" + IDivisionOperators"); + break; + default: + continue; + } + Writer.WL($"<{relation.LeftQuantity.Name}, {relation.RightQuantity.Name}, {relation.ResultQuantity.Name}>,"); + } + } + + Writer.WL(@$" +#endif"); + } Writer.WL(@$" +#if NET7_0_OR_GREATER + IComparisonOperators<{_quantity.Name}, {_quantity.Name}, bool>, + IParsable<{_quantity.Name}>, +#endif IComparable, IComparable<{_quantity.Name}>, IConvertible, @@ -85,7 +115,7 @@ namespace UnitsNet /// The numeric value this quantity was constructed with. /// [DataMember(Name = ""Value"", Order = 1)] - private readonly {_quantity.ValueType} _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -102,6 +132,7 @@ namespace UnitsNet GenerateStaticFactoryMethods(); GenerateStaticParseMethods(); GenerateArithmeticOperators(); + GenerateRelationalOperators(); GenerateEqualityAndComparison(); GenerateConversionMethods(); GenerateToString(); @@ -176,18 +207,17 @@ private void GenerateInstanceConstructors() /// /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. - /// If value is NaN or Infinity. - public {_quantity.Name}({_quantity.ValueType} value, {_unitEnumName} unit) + public {_quantity.Name}(double value, {_unitEnumName} unit) {{"); - Writer.WL(_quantity.ValueType == "double" - ? @" - _value = Guard.EnsureValidNumber(value, nameof(value));" - : @" + Writer.WL(@" _value = value;"); Writer.WL($@" _unit = unit; }} - +"); + if (!_isDimensionless) + { + Writer.WL($@" /// /// Creates an instance of the quantity with the given numeric value in units compatible with the given . /// If multiple compatible units were found, the first match is used. @@ -196,23 +226,13 @@ private void GenerateInstanceConstructors() /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public {_quantity.Name}({_valueType} value, UnitSystem unitSystem) + public {_quantity.Name}(double value, UnitSystem unitSystem) {{ - if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); - - var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); - var firstUnitInfo = unitInfos.FirstOrDefault(); -"); - - Writer.WL(_quantity.ValueType == "double" - ? @" - _value = Guard.EnsureValidNumber(value, nameof(value));" - : @" - _value = value;"); - Writer.WL($@" - _unit = firstUnitInfo?.Value ?? throw new ArgumentException(""No units were found for the given UnitSystem."", nameof(unitSystem)); + _value = value; + _unit = Info.GetDefaultUnit(unitSystem); }} "); + } } private void GenerateStaticProperties() @@ -270,10 +290,10 @@ private void GenerateProperties() /// /// The numeric value this quantity was constructed with. /// - public {_valueType} Value => _value; + public double Value => _value; /// - QuantityValue IQuantity.Value => _value; + double IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -306,11 +326,11 @@ private void GenerateConversionProperties() Writer.WL($@" /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public {_quantity.ValueType} {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); + public double {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); "); } @@ -395,17 +415,14 @@ private void GenerateStaticFactoryMethods() { if (unit.SkipConversionGeneration) continue; - var valueParamName = unit.PluralName.ToLowerInvariant(); Writer.WL($@" /// /// Creates a from . - /// - /// If value is NaN or Infinity."); + /// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public static {_quantity.Name} From{unit.PluralName}(QuantityValue {valueParamName}) + public static {_quantity.Name} From{unit.PluralName}(double value) {{ - {_valueType} value = ({_valueType}) {valueParamName}; return new {_quantity.Name}(value, {_unitEnumName}.{unit.SingularName}); }} "); @@ -418,9 +435,9 @@ private void GenerateStaticFactoryMethods() /// Value to convert from. /// Unit to convert from. /// {_quantity.Name} unit value. - public static {_quantity.Name} From(QuantityValue value, {_unitEnumName} fromUnit) + public static {_quantity.Name} From(double value, {_unitEnumName} fromUnit) {{ - return new {_quantity.Name}(({_valueType})value, fromUnit); + return new {_quantity.Name}(value, fromUnit); }} #endregion @@ -498,7 +515,7 @@ private void GenerateStaticParseMethods() /// /// Length.Parse(""5.5 m"", CultureInfo.GetCultureInfo(""en-US"")); /// - public static bool TryParse(string? str, out {_quantity.Name} result) + public static bool TryParse([NotNullWhen(true)]string? str, out {_quantity.Name} result) {{ return TryParse(str, null, out result); }} @@ -513,7 +530,7 @@ public static bool TryParse(string? str, out {_quantity.Name} result) /// Length.Parse(""5.5 m"", CultureInfo.GetCultureInfo(""en-US"")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParse(string? str, IFormatProvider? provider, out {_quantity.Name} result) + public static bool TryParse([NotNullWhen(true)]string? str, IFormatProvider? provider, out {_quantity.Name} result) {{ return UnitsNetSetup.Default.QuantityParser.TryParse<{_quantity.Name}, {_unitEnumName}>( str, @@ -552,7 +569,7 @@ public static bool TryParse(string? str, IFormatProvider? provider, out {_quanti }} /// - public static bool TryParseUnit(string str, out {_unitEnumName} unit) + public static bool TryParseUnit([NotNullWhen(true)]string? str, out {_unitEnumName} unit) {{ return TryParseUnit(str, null, out unit); }} @@ -567,7 +584,7 @@ public static bool TryParseUnit(string str, out {_unitEnumName} unit) /// Length.TryParseUnit(""m"", CultureInfo.GetCultureInfo(""en-US"")); /// /// Format to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, IFormatProvider? provider, out {_unitEnumName} unit) + public static bool TryParseUnit([NotNullWhen(true)]string? str, IFormatProvider? provider, out {_unitEnumName} unit) {{ return UnitsNetSetup.Default.UnitParser.TryParse<{_unitEnumName}>(str, provider, out unit); }} @@ -609,25 +626,25 @@ private void GenerateArithmeticOperators() }} /// Get from multiplying value and . - public static {_quantity.Name} operator *({_valueType} left, {_quantity.Name} right) + public static {_quantity.Name} operator *(double left, {_quantity.Name} right) {{ return new {_quantity.Name}(left * right.Value, right.Unit); }} /// Get from multiplying value and . - public static {_quantity.Name} operator *({_quantity.Name} left, {_valueType} right) + public static {_quantity.Name} operator *({_quantity.Name} left, double right) {{ return new {_quantity.Name}(left.Value * right, left.Unit); }} /// Get from dividing by value. - public static {_quantity.Name} operator /({_quantity.Name} left, {_valueType} right) + public static {_quantity.Name} operator /({_quantity.Name} left, double right) {{ return new {_quantity.Name}(left.Value / right, left.Unit); }} /// Get ratio value from dividing by . - public static {_quantity.ValueType} operator /({_quantity.Name} left, {_quantity.Name} right) + public static double operator /({_quantity.Name} left, {_quantity.Name} right) {{ return left.{_baseUnit.PluralName} / right.{_baseUnit.PluralName}; }} @@ -667,7 +684,7 @@ private void GenerateLogarithmicArithmeticOperators() }} /// Get from logarithmic multiplication of value and . - public static {_quantity.Name} operator *({_valueType} left, {_quantity.Name} right) + public static {_quantity.Name} operator *(double left, {_quantity.Name} right) {{ // Logarithmic multiplication = addition return new {_quantity.Name}(left + right.Value, right.Unit); @@ -677,14 +694,14 @@ private void GenerateLogarithmicArithmeticOperators() public static {_quantity.Name} operator *({_quantity.Name} left, double right) {{ // Logarithmic multiplication = addition - return new {_quantity.Name}(left.Value + ({_valueType})right, left.Unit); + return new {_quantity.Name}(left.Value + right, left.Unit); }} /// Get from logarithmic division of by value. public static {_quantity.Name} operator /({_quantity.Name} left, double right) {{ // Logarithmic division = subtraction - return new {_quantity.Name}(left.Value - ({_valueType})right, left.Unit); + return new {_quantity.Name}(left.Value - right, left.Unit); }} /// Get ratio value from logarithmic division of by . @@ -698,6 +715,79 @@ private void GenerateLogarithmicArithmeticOperators() " ); } + /// + /// Generates operators that express relations between quantities as applied by . + /// + private void GenerateRelationalOperators() + { + if (!_quantity.Relations.Any()) return; + + Writer.WL($@" + #region Relational Operators +"); + + foreach (QuantityRelation relation in _quantity.Relations) + { + if (relation.Operator == "inverse") + { + Writer.WL($@" + /// Calculates the inverse of this quantity. + /// The corresponding inverse quantity, . + public {relation.RightQuantity.Name} Inverse() + {{ + return {relation.LeftUnit.PluralName} == 0.0 ? {relation.RightQuantity.Name}.Zero : {relation.RightQuantity.Name}.From{relation.RightUnit.PluralName}(1 / {relation.LeftUnit.PluralName}); + }} +"); + } + else + { + var leftParameter = relation.LeftQuantity.Name.ToCamelCase(); + var leftConversionProperty = relation.LeftUnit.PluralName; + var rightParameter = relation.RightQuantity.Name.ToCamelCase(); + var rightConversionProperty = relation.RightUnit.PluralName; + + if (leftParameter == rightParameter) + { + leftParameter = "left"; + rightParameter = "right"; + } + + var leftPart = $"{leftParameter}.{leftConversionProperty}"; + var rightPart = $"{rightParameter}.{rightConversionProperty}"; + + if (leftParameter is "double") + { + leftParameter = leftPart = "value"; + } + + if (rightParameter is "double") + { + rightParameter = rightPart = "value"; + } + + var expression = $"{leftPart} {relation.Operator} {rightPart}"; + + if (relation.ResultQuantity.Name is not "double") + { + expression = $"{relation.ResultQuantity.Name}.From{relation.ResultUnit.PluralName}({expression})"; + } + + Writer.WL($@" + /// Get from {relation.Operator} . + public static {relation.ResultQuantity.Name} operator {relation.Operator}({relation.LeftQuantity.Name} {leftParameter}, {relation.RightQuantity.Name} {rightParameter}) + {{ + return {expression}; + }} +"); + } + } + + Writer.WL($@" + + #endregion +"); + } + private void GenerateEqualityAndComparison() { Writer.WL($@" @@ -835,7 +925,7 @@ public int CompareTo({_quantity.Name} other) /// /// /// Note that it is advised against specifying zero difference, due to the nature - /// of floating-point operations and using {_valueType} internally. + /// of floating-point operations and using double internally. /// /// /// The other quantity to compare to. @@ -843,7 +933,7 @@ public int CompareTo({_quantity.Name} other) /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. [Obsolete(""Use Equals({_quantity.Name} other, {_quantity.Name} tolerance) instead, to check equality across units and to specify the max tolerance for rounding errors due to floating-point arithmetic when converting between units."")] - public bool Equals({_quantity.Name} other, {_quantity.ValueType} tolerance, ComparisonType comparisonType) + public bool Equals({_quantity.Name} other, double tolerance, ComparisonType comparisonType) {{ if (tolerance < 0) throw new ArgumentOutOfRangeException(nameof(tolerance), ""Tolerance must be greater than or equal to 0.""); @@ -897,7 +987,7 @@ private void GenerateConversionMethods() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public {_quantity.ValueType} As({_unitEnumName} unit) + public double As({_unitEnumName} unit) {{ if (Unit == unit) return Value; @@ -906,65 +996,16 @@ private void GenerateConversionMethods() }} "); - if (_quantity.ValueType == "decimal") - { - Writer.WL($@" - - double IQuantity<{_unitEnumName}>.As({_unitEnumName} unit) - {{ - return (double)As(unit); - }} -"); - } - - Writer.WL($@" + Writer.WL( $@" /// - public {_quantity.ValueType} As(UnitSystem unitSystem) - {{ - if (unitSystem is null) - throw new ArgumentNullException(nameof(unitSystem)); - - var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); - - var firstUnitInfo = unitInfos.FirstOrDefault(); - if (firstUnitInfo == null) - throw new ArgumentException(""No units were found for the given UnitSystem."", nameof(unitSystem)); - - return As(firstUnitInfo.Value); - }} -"); - - if (_quantity.ValueType == "decimal") - { - Writer.WL($@" - /// - double IQuantity.As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) {{ - return (double)As(unitSystem); + return As(Info.GetDefaultUnit(unitSystem)); }} "); - } Writer.WL($@" - /// - double IQuantity.As(Enum unit) - {{ - if (!(unit is {_unitEnumName} typedUnit)) - throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - - return (double)As(typedUnit); - }} - - /// - {_quantity.ValueType} IValueQuantity<{_quantity.ValueType}>.As(Enum unit) - {{ - if (!(unit is {_unitEnumName} typedUnit)) - throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - - return As(typedUnit); - }} - /// /// Converts this {_quantity.Name} to another {_quantity.Name} with the unit representation . /// @@ -1060,29 +1101,33 @@ private bool TryToUnit({_unitEnumName} unit, [NotNullWhen(true)] out {_quantity. converted = convertedOrNull.Value; return true; }} +"); + Writer.WL($@" + /// + public {_quantity.Name} ToUnit(UnitSystem unitSystem) + {{ + return ToUnit(Info.GetDefaultUnit(unitSystem)); + }} +"); - /// - IQuantity IQuantity.ToUnit(Enum unit) + Writer.WL($@" + #region Explicit implementations + + double IQuantity.As(Enum unit) {{ - if (!(unit is {_unitEnumName} typedUnit)) + if (unit is not {_unitEnumName} typedUnit) throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return As(typedUnit); }} - /// - public {_quantity.Name} ToUnit(UnitSystem unitSystem) + /// + IQuantity IQuantity.ToUnit(Enum unit) {{ - if (unitSystem is null) - throw new ArgumentNullException(nameof(unitSystem)); - - var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); - - var firstUnitInfo = unitInfos.FirstOrDefault(); - if (firstUnitInfo == null) - throw new ArgumentException(""No units were found for the given UnitSystem."", nameof(unitSystem)); + if (!(unit is {_unitEnumName} typedUnit)) + throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - return ToUnit(firstUnitInfo.Value); + return ToUnit(typedUnit, DefaultConversionFunctions); }} /// @@ -1094,17 +1139,7 @@ IQuantity IQuantity.ToUnit(Enum unit) /// IQuantity<{_unitEnumName}> IQuantity<{_unitEnumName}>.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - /// - IValueQuantity<{_quantity.ValueType}> IValueQuantity<{_quantity.ValueType}>.ToUnit(Enum unit) - {{ - if (unit is not {_unitEnumName} typedUnit) - throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - - return ToUnit(typedUnit); - }} - - /// - IValueQuantity<{_quantity.ValueType}> IValueQuantity<{_quantity.ValueType}>.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); + #endregion #endregion "); @@ -1121,7 +1156,7 @@ private void GenerateToString() /// String representation. public override string ToString() {{ - return ToString(""g""); + return ToString(null, null); }} /// @@ -1131,7 +1166,7 @@ public override string ToString() /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) {{ - return ToString(""g"", provider); + return ToString(null, provider); }} /// @@ -1142,7 +1177,7 @@ public string ToString(IFormatProvider? provider) /// The string representation. public string ToString(string? format) {{ - return ToString(format, CultureInfo.CurrentCulture); + return ToString(format, null); }} /// @@ -1228,7 +1263,7 @@ float IConvertible.ToSingle(IFormatProvider? provider) string IConvertible.ToString(IFormatProvider? provider) {{ - return ToString(""g"", provider); + return ToString(null, provider); }} object IConvertible.ToType(Type conversionType, IFormatProvider? provider) diff --git a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs index b266926ed6..69443fa2d5 100644 --- a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs @@ -49,7 +49,7 @@ public partial class Quantity /// The of the quantity to create. /// The value to construct the quantity with. /// The created quantity. - public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValue value) + public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, double value) { return quantityInfo.Name switch {"); @@ -72,7 +72,7 @@ public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValu /// Unit enum value. /// The resulting quantity if successful, otherwise default. /// True if successful with assigned the value, otherwise false. - public static bool TryFrom(QuantityValue value, Enum? unit, [NotNullWhen(true)] out IQuantity? quantity) + public static bool TryFrom(double value, Enum? unit, [NotNullWhen(true)] out IQuantity? quantity) { quantity = unit switch {"); @@ -100,7 +100,7 @@ public static bool TryFrom(QuantityValue value, Enum? unit, [NotNullWhen(true)] /// Quantity string representation, such as ""1.5 kg"". Must be compatible with given quantity type. /// The resulting quantity if successful, otherwise default. /// The parsed quantity. - public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, string quantityString, [NotNullWhen(true)] out IQuantity? quantity) + public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, [NotNullWhen(true)] string? quantityString, [NotNullWhen(true)] out IQuantity? quantity) { quantity = default(IQuantity); diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index 7ab9d998c8..625e9a8661 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using CodeGen.JsonTypes; @@ -40,11 +41,6 @@ internal class UnitTestBaseClassGenerator : GeneratorBase /// private readonly string _baseUnitFullName; - /// - /// Constructors for decimal-backed quantities require decimal numbers as input, so add the "m" suffix to numbers when constructing those quantities. - /// - private readonly string _numberSuffix; - /// /// Other unit, if more than one unit exists for quantity, otherwise same as . /// @@ -54,6 +50,46 @@ internal class UnitTestBaseClassGenerator : GeneratorBase /// Example: "LengthUnit.Centimeter". /// private readonly string _otherOrBaseUnitFullName; + + /// + /// Indicates whether the quantity is dimensionless. + /// + /// + /// A dimensionless quantity has all base dimensions (L, M, T, I, Θ, N, J) equal to zero. + /// + private readonly bool _isDimensionless; + + /// + /// Stores a mapping of culture names to their corresponding unique unit abbreviations. + /// Each culture maps to a dictionary where the key is the unit abbreviation and the value is the corresponding + /// . + /// This ensures that unit abbreviations are unique within the context of a specific culture. + /// + /// + /// Used for testing culture-specific parsing with non-ambiguous (unique) abbreviations. + /// + private readonly Dictionary> _uniqueAbbreviationsForCulture; + + /// + /// Stores a mapping of culture names to their respective ambiguous unit abbreviations. + /// Each culture maps to a dictionary where the key is the ambiguous abbreviation, and the value is a list of + /// objects + /// that share the same abbreviation within that culture. + /// + /// + /// This field is used to identify and handle unit abbreviations that are not unique within a specific culture. + /// Ambiguities arise when multiple units share the same abbreviation, requiring additional logic to resolve. + /// + private readonly Dictionary>> _ambiguousAbbreviationsForCulture; + + /// + /// The default or fallback culture for unit localizations. + /// + /// + /// This culture, "en-US", is used as a fallback when a specific + /// is not available for the defined unit localizations. + /// + private const string FallbackCultureName = "en-US"; public UnitTestBaseClassGenerator(Quantity quantity) { @@ -66,11 +102,57 @@ public UnitTestBaseClassGenerator(Quantity quantity) _baseUnitEnglishAbbreviation = GetEnglishAbbreviation(_baseUnit); _baseUnitFullName = $"{_unitEnumName}.{_baseUnit.SingularName}"; - _numberSuffix = quantity.ValueType == "decimal" ? "m" : ""; // Try to pick another unit, or fall back to base unit if only a single unit. _otherOrBaseUnit = quantity.Units.Where(u => u != _baseUnit).DefaultIfEmpty(_baseUnit).First(); _otherOrBaseUnitFullName = $"{_unitEnumName}.{_otherOrBaseUnit.SingularName}"; + _isDimensionless = quantity.BaseDimensions is { L: 0, M: 0, T: 0, I: 0, Θ: 0, N: 0, J: 0 }; + + var abbreviationsForCulture = new Dictionary>>(); + foreach (Unit unit in quantity.Units) + { + if (unit.ObsoleteText != null) + { + continue; + } + + foreach (Localization localization in unit.Localization) + { + if (!abbreviationsForCulture.TryGetValue(localization.Culture, out Dictionary>? localizationsForCulture)) + { + abbreviationsForCulture[localization.Culture] = localizationsForCulture = new Dictionary>(); + } + + foreach (var abbreviation in localization.Abbreviations) + { + if (localizationsForCulture.TryGetValue(abbreviation, out List? matchingUnits)) + { + matchingUnits.Add(unit); + } + else + { + localizationsForCulture[abbreviation] = [unit]; + } + } + } + } + + _uniqueAbbreviationsForCulture = new Dictionary>(); + _ambiguousAbbreviationsForCulture = new Dictionary>>(); + foreach ((var cultureName, Dictionary>? abbreviations) in abbreviationsForCulture) + { + var uniqueAbbreviations = abbreviations.Where(pair => pair.Value.Count == 1).ToDictionary(pair => pair.Key, pair => pair.Value[0]); + if (uniqueAbbreviations.Count != 0) + { + _uniqueAbbreviationsForCulture.Add(cultureName, uniqueAbbreviations); + } + + var ambiguousAbbreviations = abbreviations.Where(pair => pair.Value.Count > 1).ToDictionary(); + if (ambiguousAbbreviations.Count != 0) + { + _ambiguousAbbreviationsForCulture.Add(cultureName, ambiguousAbbreviations); + } + } } private string GetUnitFullName(Unit unit) => $"{_unitEnumName}.{unit.SingularName}"; @@ -118,7 +200,7 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase if (unit.SkipConversionGeneration) continue; Writer.WL($@" - protected abstract {_quantity.ValueType} {unit.PluralName}InOne{_baseUnit.SingularName} {{ get; }}"); + protected abstract double {unit.PluralName}InOne{_baseUnit.SingularName} {{ get; }}"); } Writer.WL(); @@ -129,12 +211,12 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase if (unit.SkipConversionGeneration) continue; Writer.WL($@" - protected virtual {_quantity.ValueType} {unit.PluralName}Tolerance {{ get {{ return { (_quantity.ValueType == "decimal" ? "1e-9m" : "1e-5") }; }} }}"); + protected virtual double {unit.PluralName}Tolerance {{ get {{ return 1e-5; }} }}"); } Writer.WL($@" // ReSharper restore VirtualMemberNeverOverriden.Global - protected ({_quantity.ValueType} UnitsInBaseUnit, {_quantity.ValueType} Tolerence) GetConversionFactor({_unitEnumName} unit) + protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor({_unitEnumName} unit) {{ return unit switch {{"); @@ -163,27 +245,31 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() {{ var quantity = new {_quantity.Name}(); - Assert.Equal(0, quantity.Value);"); - if (_quantity.ValueType == "decimal") Writer.WL(@" - Assert.Equal(0m, ((IValueQuantity)quantity).Value);"); - Writer.WL($@" + Assert.Equal(0, quantity.Value); Assert.Equal({_baseUnitFullName}, quantity.Unit); }} -"); - if (_quantity.ValueType == "double") Writer.WL($@" + [Fact] - public void Ctor_WithInfinityValue_ThrowsArgumentException() + public void Ctor_WithInfinityValue_DoNotThrowsArgumentException() {{ - Assert.Throws(() => new {_quantity.Name}(double.PositiveInfinity, {_baseUnitFullName})); - Assert.Throws(() => new {_quantity.Name}(double.NegativeInfinity, {_baseUnitFullName})); + var exception1 = Record.Exception(() => new {_quantity.Name}(double.PositiveInfinity, {_baseUnitFullName})); + var exception2 = Record.Exception(() => new {_quantity.Name}(double.NegativeInfinity, {_baseUnitFullName})); + + Assert.Null(exception1); + Assert.Null(exception2); }} [Fact] - public void Ctor_WithNaNValue_ThrowsArgumentException() + public void Ctor_WithNaNValue_DoNotThrowsArgumentException() {{ - Assert.Throws(() => new {_quantity.Name}(double.NaN, {_baseUnitFullName})); + var exception = Record.Exception(() => new {_quantity.Name}(double.NaN, {_baseUnitFullName})); + + Assert.Null(exception); }} -"); Writer.WL($@" +"); + if (!_isDimensionless) + { + Writer.WL($@" [Fact] public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException() @@ -192,20 +278,24 @@ public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException() }} [Fact] - public void Ctor_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() + public virtual void Ctor_SIUnitSystem_ReturnsQuantityWithSIUnits() {{ - Func TestCode = () => new {_quantity.Name}(value: 1, unitSystem: UnitSystem.SI); - if (SupportsSIUnitSystem) - {{ - var quantity = ({_quantity.Name}) TestCode(); - Assert.Equal(1, quantity.Value); - }} - else - {{ - Assert.Throws(TestCode); - }} + var quantity = new {_quantity.Name}(value: 1, unitSystem: UnitSystem.SI); + Assert.Equal(1, quantity.Value); + Assert.True(quantity.QuantityInfo.UnitInfos.First(x => x.Value == quantity.Unit).BaseUnits.IsSubsetOf(UnitSystem.SI.BaseUnits)); }} + [Fact] + public void Ctor_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + {{ + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + Assert.Throws(() => new {_quantity.Name}(value: 1, unitSystem: unsupportedUnitSystem)); + }} +"); + } + + Writer.WL($@" + [Fact] public void {_quantity.Name}_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() {{ @@ -246,21 +336,24 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() } Writer.WL($@" }} -"); - if (_quantity.ValueType == "double") Writer.WL($@" + [Fact] - public void From{_baseUnit.PluralName}_WithInfinityValue_ThrowsArgumentException() + public void From{_baseUnit.PluralName}_WithInfinityValue_DoNotThrowsArgumentException() {{ - Assert.Throws(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.PositiveInfinity)); - Assert.Throws(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.NegativeInfinity)); + var exception1 = Record.Exception(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.PositiveInfinity)); + var exception2 = Record.Exception(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.NegativeInfinity)); + + Assert.Null(exception1); + Assert.Null(exception2); }} [Fact] - public void From{_baseUnit.PluralName}_WithNanValue_ThrowsArgumentException() + public void From{_baseUnit.PluralName}_WithNanValue_DoNotThrowsArgumentException() {{ - Assert.Throws(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.NaN)); + var exception = Record.Exception(() => {_quantity.Name}.From{_baseUnit.PluralName}(double.NaN)); + + Assert.Null(exception); }} -"); Writer.WL($@" [Fact] public void As() @@ -270,24 +363,193 @@ public void As() AssertEx.EqualTolerance({unit.PluralName}InOne{_baseUnit.SingularName}, {baseUnitVariableName}.As({GetUnitFullName(unit)}), {unit.PluralName}Tolerance);"); Writer.WL($@" }} +"); + if (_isDimensionless) + { + Writer.WL($@" + + [Fact] + public void As_UnitSystem_ReturnsValueInDimensionlessUnit() + {{ + var quantity = new {_quantity.Name}(value: 1, unit: {_baseUnitFullName}); + + var convertedValue = quantity.As(UnitSystem.SI); + + Assert.Equal(quantity.Value, convertedValue); + }} [Fact] - public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() + public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() {{ var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); - Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); + UnitSystem nullUnitSystem = null!; + Assert.Throws(() => quantity.As(nullUnitSystem)); + }} - if (SupportsSIUnitSystem) + [Fact] + public void ToUnitSystem_ReturnsValueInDimensionlessUnit() + {{ + Assert.Multiple(() => {{ - var value = Convert.ToDouble(AsWithSIUnitSystem()); - Assert.Equal(1, value); - }} + var quantity = new {_quantity.Name}(value: 1, unit: {_baseUnitFullName}); + + {_quantity.Name} convertedQuantity = quantity.ToUnit(UnitSystem.SI); + + Assert.Equal({_baseUnitFullName}, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); + }}, () => + {{ + IQuantity<{_unitEnumName}> quantity = new {_quantity.Name}(value: 1, unit: {_baseUnitFullName}); + + IQuantity<{_unitEnumName}> convertedQuantity = quantity.ToUnit(UnitSystem.SI); + + Assert.Equal({_baseUnitFullName}, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); + }}, () => + {{ + IQuantity quantity = new {_quantity.Name}(value: 1, unit: {_baseUnitFullName}); + + IQuantity convertedQuantity = quantity.ToUnit(UnitSystem.SI); + + Assert.Equal({_baseUnitFullName}, convertedQuantity.Unit); + Assert.Equal(quantity.Value, convertedQuantity.Value); + }}); + }} + + [Fact] + public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() + {{ + UnitSystem nullUnitSystem = null!; + Assert.Multiple(() => + {{ + var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + }}, () => + {{ + IQuantity<{_unitEnumName}> quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + }}, () => + {{ + IQuantity quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + }}); + }} +"); + } else + { + Writer.WL($@" + + [Fact] + public virtual void BaseUnit_HasSIBase() + {{ + var baseUnitInfo = {_quantity.Name}.Info.BaseUnitInfo; + Assert.True(baseUnitInfo.BaseUnits.IsSubsetOf(UnitSystem.SI.BaseUnits)); + }} + + [Fact] + public virtual void As_UnitSystem_SI_ReturnsQuantityInSIUnits() + {{ + var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + var expectedValue = quantity.As({_quantity.Name}.Info.GetDefaultUnit(UnitSystem.SI)); + + var convertedValue = quantity.As(UnitSystem.SI); + + Assert.Equal(expectedValue, convertedValue); + }} + + [Fact] + public void As_UnitSystem_ThrowsArgumentNullExceptionIfNull() + {{ + var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + UnitSystem nullUnitSystem = null!; + Assert.Throws(() => quantity.As(nullUnitSystem)); + }} + + [Fact] + public void As_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + {{ + var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + Assert.Throws(() => quantity.As(unsupportedUnitSystem)); + }} + + [Fact] + public virtual void ToUnit_UnitSystem_SI_ReturnsQuantityInSIUnits() + {{ + var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + var expectedUnit = {_quantity.Name}.Info.GetDefaultUnit(UnitSystem.SI); + var expectedValue = quantity.As(expectedUnit); + + Assert.Multiple(() => {{ - Assert.Throws(AsWithSIUnitSystem); - }} + {_quantity.Name} quantityToConvert = quantity; + + {_quantity.Name} convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); + }}, () => + {{ + IQuantity<{_unitEnumName}> quantityToConvert = quantity; + + IQuantity<{_unitEnumName}> convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); + }}, () => + {{ + IQuantity quantityToConvert = quantity; + + IQuantity convertedQuantity = quantityToConvert.ToUnit(UnitSystem.SI); + + Assert.Equal(expectedUnit, convertedQuantity.Unit); + Assert.Equal(expectedValue, convertedQuantity.Value); + }}); + }} + + [Fact] + public void ToUnit_UnitSystem_ThrowsArgumentNullExceptionIfNull() + {{ + UnitSystem nullUnitSystem = null!; + Assert.Multiple(() => + {{ + var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + }}, () => + {{ + IQuantity<{_unitEnumName}> quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + }}, () => + {{ + IQuantity quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + Assert.Throws(() => quantity.ToUnit(nullUnitSystem)); + }}); }} + [Fact] + public void ToUnit_UnitSystem_ThrowsArgumentExceptionIfNotSupported() + {{ + var unsupportedUnitSystem = new UnitSystem(UnsupportedBaseUnits); + Assert.Multiple(() => + {{ + var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); + }}, () => + {{ + IQuantity<{_unitEnumName}> quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); + }}, () => + {{ + IQuantity quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + Assert.Throws(() => quantity.ToUnit(unsupportedUnitSystem)); + }}); + }} +"); + } + + Writer.WL($@" + [Fact] public void Parse() {{"); @@ -327,45 +589,193 @@ public void TryParse() } Writer.WL($@" }} +"); - [Fact] - public void ParseUnit() - {{"); - foreach (var unit in _quantity.Units.Where(u => string.IsNullOrEmpty(u.ObsoleteText))) - foreach (var localization in unit.Localization) - foreach (var abbreviation in localization.Abbreviations) + Writer.WL($@" + [Theory]"); + foreach ((var abbreviation, Unit unit) in _uniqueAbbreviationsForCulture[FallbackCultureName]) { Writer.WL($@" - try - {{ - var parsedUnit = {_quantity.Name}.ParseUnit(""{abbreviation}"", CultureInfo.GetCultureInfo(""{localization.Culture}"")); - Assert.Equal({GetUnitFullName(unit)}, parsedUnit); - }} catch (AmbiguousUnitParseException) {{ /* Some units have the same abbreviations */ }} + [InlineData(""{abbreviation}"", {GetUnitFullName(unit)})]"); + } + Writer.WL($@" + public void ParseUnit_WithUsEnglishCurrentCulture(string abbreviation, {_unitEnumName} expectedUnit) + {{ + // Fallback culture ""{FallbackCultureName}"" is always localized + using var _ = new CultureScope(""{FallbackCultureName}""); + {_unitEnumName} parsedUnit = {_quantity.Name}.ParseUnit(abbreviation); + Assert.Equal(expectedUnit, parsedUnit); + }} "); + + Writer.WL($@" + [Theory]"); + foreach ((var abbreviation, Unit unit) in _uniqueAbbreviationsForCulture[FallbackCultureName]) + { + Writer.WL($@" + [InlineData(""{abbreviation}"", {GetUnitFullName(unit)})]"); } Writer.WL($@" + public void ParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(string abbreviation, {_unitEnumName} expectedUnit) + {{ + // Currently, no abbreviations are localized for Icelandic, so it should fall back to ""{FallbackCultureName}"" when parsing. + using var _ = new CultureScope(""is-IS""); + {_unitEnumName} parsedUnit = {_quantity.Name}.ParseUnit(abbreviation); + Assert.Equal(expectedUnit, parsedUnit); }} +"); - [Fact] - public void TryParseUnit() - {{"); - foreach (var unit in _quantity.Units.Where(u => string.IsNullOrEmpty(u.ObsoleteText))) - foreach (var localization in unit.Localization) - foreach (var abbreviation in localization.Abbreviations) + Writer.WL($@" + [Theory]"); + foreach ((var cultureName, Dictionary abbreviations) in _uniqueAbbreviationsForCulture) { - // Skip units with ambiguous abbreviations, since there is no exception to describe this is why TryParse failed. - if (IsAmbiguousAbbreviation(localization, abbreviation)) continue; + foreach ((var abbreviation, Unit unit) in abbreviations) + { + Writer.WL($@" + [InlineData(""{cultureName}"", ""{abbreviation}"", {GetUnitFullName(unit)})]"); + } + } + Writer.WL($@" + public void ParseUnit_WithCurrentCulture(string culture, string abbreviation, {_unitEnumName} expectedUnit) + {{ + using var _ = new CultureScope(culture); + {_unitEnumName} parsedUnit = {_quantity.Name}.ParseUnit(abbreviation); + Assert.Equal(expectedUnit, parsedUnit); + }} +"); + + Writer.WL($@" + [Theory]"); + foreach ((var cultureName, Dictionary abbreviations) in _uniqueAbbreviationsForCulture) + { + foreach ((var abbreviation, Unit unit) in abbreviations) + { + Writer.WL($@" + [InlineData(""{cultureName}"", ""{abbreviation}"", {GetUnitFullName(unit)})]"); + } + } + Writer.WL($@" + public void ParseUnit_WithCulture(string culture, string abbreviation, {_unitEnumName} expectedUnit) + {{ + {_unitEnumName} parsedUnit = {_quantity.Name}.ParseUnit(abbreviation, CultureInfo.GetCultureInfo(culture)); + Assert.Equal(expectedUnit, parsedUnit); + }} +"); + // we only generate these for a few of the quantities + if (_ambiguousAbbreviationsForCulture.Count != 0) + { Writer.WL($@" - {{ - Assert.True({_quantity.Name}.TryParseUnit(""{abbreviation}"", CultureInfo.GetCultureInfo(""{localization.Culture}""), out var parsedUnit)); - Assert.Equal({GetUnitFullName(unit)}, parsedUnit); - }} + [Theory]"); + foreach ((var cultureName, Dictionary>? abbreviations) in _ambiguousAbbreviationsForCulture) + { + foreach (KeyValuePair> ambiguousPair in abbreviations) + { + Writer.WL($@" + [InlineData(""{cultureName}"", ""{ambiguousPair.Key}"")] // [{string.Join(", ", ambiguousPair.Value.Select(x => x.SingularName))}] "); + } + } + Writer.WL($@" + public void ParseUnitWithAmbiguousAbbreviation(string culture, string abbreviation) + {{ + Assert.Throws(() => {_quantity.Name}.ParseUnit(abbreviation, CultureInfo.GetCultureInfo(culture))); + }} "); + } // ambiguousAbbreviations + + Writer.WL($@" + [Theory]"); + foreach ((var abbreviation, Unit unit) in _uniqueAbbreviationsForCulture[FallbackCultureName]) + { + Writer.WL($@" + [InlineData(""{abbreviation}"", {GetUnitFullName(unit)})]"); + } + Writer.WL($@" + public void TryParseUnit_WithUsEnglishCurrentCulture(string abbreviation, {_unitEnumName} expectedUnit) + {{ + // Fallback culture ""{FallbackCultureName}"" is always localized + using var _ = new CultureScope(""{FallbackCultureName}""); + Assert.True({_quantity.Name}.TryParseUnit(abbreviation, out {_unitEnumName} parsedUnit)); + Assert.Equal(expectedUnit, parsedUnit); + }} +"); + + Writer.WL($@" + [Theory]"); + foreach ((var abbreviation, Unit unit) in _uniqueAbbreviationsForCulture[FallbackCultureName]) + { + Writer.WL($@" + [InlineData(""{abbreviation}"", {GetUnitFullName(unit)})]"); + } + Writer.WL($@" + public void TryParseUnit_WithUnsupportedCurrentCulture_FallsBackToUsEnglish(string abbreviation, {_unitEnumName} expectedUnit) + {{ + // Currently, no abbreviations are localized for Icelandic, so it should fall back to ""{FallbackCultureName}"" when parsing. + using var _ = new CultureScope(""is-IS""); + Assert.True({_quantity.Name}.TryParseUnit(abbreviation, out {_unitEnumName} parsedUnit)); + Assert.Equal(expectedUnit, parsedUnit); + }} +"); + + Writer.WL($@" + [Theory]"); + foreach ((var cultureName, Dictionary abbreviations) in _uniqueAbbreviationsForCulture) + { + foreach ((var abbreviation, Unit unit) in abbreviations) + { + Writer.WL($@" + [InlineData(""{cultureName}"", ""{abbreviation}"", {GetUnitFullName(unit)})]"); + } + } + Writer.WL($@" + public void TryParseUnit_WithCurrentCulture(string culture, string abbreviation, {_unitEnumName} expectedUnit) + {{ + using var _ = new CultureScope(culture); + Assert.True({_quantity.Name}.TryParseUnit(abbreviation, out {_unitEnumName} parsedUnit)); + Assert.Equal(expectedUnit, parsedUnit); + }} +"); + + Writer.WL($@" + [Theory]"); + foreach ((var cultureName, Dictionary abbreviations) in _uniqueAbbreviationsForCulture) + { + foreach ((var abbreviation, Unit unit) in abbreviations) + { + Writer.WL($@" + [InlineData(""{cultureName}"", ""{abbreviation}"", {GetUnitFullName(unit)})]"); + } } Writer.WL($@" + public void TryParseUnit_WithCulture(string culture, string abbreviation, {_unitEnumName} expectedUnit) + {{ + Assert.True({_quantity.Name}.TryParseUnit(abbreviation, CultureInfo.GetCultureInfo(culture), out {_unitEnumName} parsedUnit)); + Assert.Equal(expectedUnit, parsedUnit); }} +"); + // we only generate these for a few of the quantities + if (_ambiguousAbbreviationsForCulture.Count != 0) + { + Writer.WL($@" + [Theory]"); + foreach ((var cultureName, Dictionary>? abbreviations) in _ambiguousAbbreviationsForCulture) + { + foreach (KeyValuePair> ambiguousPair in abbreviations) + { + Writer.WL($@" + [InlineData(""{cultureName}"", ""{ambiguousPair.Key}"")] // [{string.Join(", ", ambiguousPair.Value.Select(x => x.SingularName))}] "); + } + } + Writer.WL($@" + public void TryParseUnitWithAmbiguousAbbreviation(string culture, string abbreviation) + {{ + Assert.False({_quantity.Name}.TryParseUnit(abbreviation, CultureInfo.GetCultureInfo(culture), out _)); + }} +"); + } // ambiguousAbbreviations + + Writer.WL($@" [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit({_unitEnumName} unit) @@ -387,16 +797,16 @@ public void ToUnit_WithSameUnits_AreEqual({_unitEnumName} unit) Assert.Equal(quantity, toUnitWithSameUnit); }} - [Theory{(_quantity.Units.Length == 1 ? "(Skip = \"Multiple units required\")" : string.Empty)}] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit({_unitEnumName} unit) {{ - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = {_quantity.Name}.Units.First(u => u != {_quantity.Name}.BaseUnit); - - var quantity = {_quantity.Name}.From(3.0, fromUnit); - var converted = quantity.ToUnit(unit); - Assert.Equal(converted.Unit, unit); + Assert.All({_quantity.Name}.Units.Where(u => u != {_quantity.Name}.BaseUnit), fromUnit => + {{ + var quantity = {_quantity.Name}.From(3.0, fromUnit); + var converted = quantity.ToUnit(unit); + Assert.Equal(converted.Unit, unit); + }}); }} [Theory] @@ -408,6 +818,25 @@ public virtual void ToUnit_FromDefaultQuantity_ReturnsQuantityWithGivenUnit({_un Assert.Equal(converted.Unit, unit); }} + [Theory] + [MemberData(nameof(UnitTypes))] + public void ToUnit_FromIQuantity_ReturnsTheExpectedIQuantity({_unitEnumName} unit) + {{ + var quantity = {_quantity.Name}.From(3, {_quantity.Name}.BaseUnit); + {_quantity.Name} expectedQuantity = quantity.ToUnit(unit); + Assert.Multiple(() => + {{ + IQuantity<{_unitEnumName}> quantityToConvert = quantity; + IQuantity<{_unitEnumName}> convertedQuantity = quantityToConvert.ToUnit(unit); + Assert.Equal(unit, convertedQuantity.Unit); + }}, () => + {{ + IQuantity quantityToConvert = quantity; + IQuantity convertedQuantity = quantityToConvert.ToUnit(unit); + Assert.Equal(unit, convertedQuantity.Unit); + }}); + }} + [Fact] public void ConversionRoundTrip() {{ @@ -512,7 +941,7 @@ public void CompareToThrowsOnNull() [InlineData(1, {_baseUnitFullName}, 1, {_otherOrBaseUnitFullName}, false)] // Different unit."); } Writer.WL($@" - public void Equals_ReturnsTrue_IfValueAndUnitAreEqual({_quantity.ValueType} valueA, {_unitEnumName} unitA, {_quantity.ValueType} valueB, {_unitEnumName} unitB, bool expectEqual) + public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, {_unitEnumName} unitA, double valueB, {_unitEnumName} unitB, bool expectEqual) {{ var a = new {_quantity.Name}(valueA, unitA); var b = new {_quantity.Name}(valueB, unitB); @@ -554,8 +983,8 @@ public void Equals_RelativeTolerance_IsImplemented() var v = {_quantity.Name}.From{_baseUnit.PluralName}(1); Assert.True(v.Equals({_quantity.Name}.From{_baseUnit.PluralName}(1), {_baseUnit.PluralName}Tolerance, ComparisonType.Relative)); Assert.False(v.Equals({_quantity.Name}.Zero, {_baseUnit.PluralName}Tolerance, ComparisonType.Relative)); - Assert.True({_quantity.Name}.From{_baseUnit.PluralName}(100).Equals({_quantity.Name}.From{_baseUnit.PluralName}(120), ({_quantity.ValueType})0.3m, ComparisonType.Relative)); - Assert.False({_quantity.Name}.From{_baseUnit.PluralName}(100).Equals({_quantity.Name}.From{_baseUnit.PluralName}(120), ({_quantity.ValueType})0.1m, ComparisonType.Relative)); + Assert.True({_quantity.Name}.From{_baseUnit.PluralName}(100).Equals({_quantity.Name}.From{_baseUnit.PluralName}(120), 0.3, ComparisonType.Relative)); + Assert.False({_quantity.Name}.From{_baseUnit.PluralName}(100).Equals({_quantity.Name}.From{_baseUnit.PluralName}(120), 0.1, ComparisonType.Relative)); }} [Fact] @@ -625,20 +1054,20 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() {{ var _ = new CultureScope(CultureInfo.InvariantCulture); - Assert.Equal(""0.1{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s1"")); - Assert.Equal(""0.12{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s2"")); - Assert.Equal(""0.123{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s3"")); - Assert.Equal(""0.1235{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s4"")); + Assert.Equal(""0.1{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456, {_baseUnitFullName}).ToString(""s1"")); + Assert.Equal(""0.12{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456, {_baseUnitFullName}).ToString(""s2"")); + Assert.Equal(""0.123{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456, {_baseUnitFullName}).ToString(""s3"")); + Assert.Equal(""0.1235{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456, {_baseUnitFullName}).ToString(""s4"")); }} [Fact] public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixForGivenCulture() {{ var culture = CultureInfo.InvariantCulture; - Assert.Equal(""0.1{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s1"", culture)); - Assert.Equal(""0.12{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s2"", culture)); - Assert.Equal(""0.123{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s3"", culture)); - Assert.Equal(""0.1235{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s4"", culture)); + Assert.Equal(""0.1{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456, {_baseUnitFullName}).ToString(""s1"", culture)); + Assert.Equal(""0.12{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456, {_baseUnitFullName}).ToString(""s2"", culture)); + Assert.Equal(""0.123{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456, {_baseUnitFullName}).ToString(""s3"", culture)); + Assert.Equal(""0.1235{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456, {_baseUnitFullName}).ToString(""s4"", culture)); }} [Theory] @@ -651,7 +1080,7 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) ? null : CultureInfo.GetCultureInfo(cultureName); - Assert.Equal(quantity.ToString(""g"", formatProvider), quantity.ToString(null, formatProvider)); + Assert.Equal(quantity.ToString(""G"", formatProvider), quantity.ToString(null, formatProvider)); }} [Theory] @@ -803,6 +1232,13 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() Assert.Throws(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); }} + [Fact] + public void Convert_GetTypeCode_Returns_Object() + {{ + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); + Assert.Equal(TypeCode.Object, Convert.GetTypeCode(quantity)); + }} + [Fact] public void GetHashCode_Equals() {{ diff --git a/CodeGen/Generators/UnitsNetGenerator.cs b/CodeGen/Generators/UnitsNetGenerator.cs index ca23308212..907f70e4a6 100644 --- a/CodeGen/Generators/UnitsNetGenerator.cs +++ b/CodeGen/Generators/UnitsNetGenerator.cs @@ -153,6 +153,9 @@ private static void GenerateResourceFiles(Quantity[] quantities, string resource $"{resourcesDirectory}/{quantity.Name}.restext" : $"{resourcesDirectory}/{quantity.Name}.{culture}.restext"; + // Ensure parent folder exists + Directory.CreateDirectory(resourcesDirectory); + using var writer = File.CreateText(fileName); foreach(Unit unit in quantity.Units) diff --git a/CodeGen/Helpers/PrefixBuilder/BaseUnitPrefix.cs b/CodeGen/Helpers/PrefixBuilder/BaseUnitPrefix.cs new file mode 100644 index 0000000000..c73ee0106b --- /dev/null +++ b/CodeGen/Helpers/PrefixBuilder/BaseUnitPrefix.cs @@ -0,0 +1,18 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using CodeGen.JsonTypes; + +namespace CodeGen.Helpers.PrefixBuilder; + +/// +/// Represents a unique combination of a base unit and an optional prefix, used to identify a prefixed unit. +/// +/// +/// The base unit associated with the prefix, such as "Gram". +/// +/// +/// The prefix applied to the base unit, such as . +/// If the prefix exponent value is 0, this parameter will be null. +/// +internal readonly record struct BaseUnitPrefix(string BaseUnit, Prefix? Prefix); diff --git a/CodeGen/Helpers/PrefixBuilder/BaseUnitPrefixes.cs b/CodeGen/Helpers/PrefixBuilder/BaseUnitPrefixes.cs new file mode 100644 index 0000000000..2822de4fc0 --- /dev/null +++ b/CodeGen/Helpers/PrefixBuilder/BaseUnitPrefixes.cs @@ -0,0 +1,176 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using CodeGen.JsonTypes; + +namespace CodeGen.Helpers.PrefixBuilder; + +/// +/// Represents a collection of base unit prefixes and their associated mappings. +/// +/// +/// This class provides functionality to manage and retrieve mappings between base units and their prefixed +/// counterparts, +/// including scale factors and prefixed unit names. It supports operations such as creating mappings from a collection +/// of base units and finding matching prefixes for specific units. +/// +internal class BaseUnitPrefixes +{ + /// + /// A dictionary that maps metric prefixes to their corresponding exponent values. + /// + /// + /// This dictionary excludes binary prefixes such as Kibi, Mebi, Gibi, Tebi, Pebi, and Exbi. + /// + private static readonly Dictionary MetricPrefixFactors = PrefixInfo.Entries.Where(x => x.Key.IsMetricPrefix()) + .ToDictionary(pair => pair.Key, pair => pair.Value.GetDecimalExponent()); + + /// + /// A dictionary that maps the exponent values to their corresponding . + /// This is used to find the appropriate prefix for a given factor. + /// + private static readonly Dictionary PrefixFactorsByValue = MetricPrefixFactors.ToDictionary(pair => pair.Value, pair => pair.Key); + + /// + /// Lookup of prefixed unit name from base unit + prefix pairs, such as ("Gram", Prefix.Kilo) => "Kilogram". + /// + private readonly Dictionary _baseUnitPrefixConversions; + + /// + /// A dictionary that maps prefixed unit strings to their corresponding base unit and fractional factor. + /// + /// + /// This dictionary is used to handle units with SI prefixes, allowing for the conversion of prefixed units + /// to their base units and the associated fractional factors. The keys are the prefixed unit strings, and the values + /// are tuples containing the base unit string and the fractional factor. + /// + private readonly Dictionary _prefixedStringFactors; + + private BaseUnitPrefixes(Dictionary prefixedStringFactors, Dictionary baseUnitPrefixConversions) + { + _prefixedStringFactors = prefixedStringFactors; + _baseUnitPrefixConversions = baseUnitPrefixConversions; + } + + /// + /// Creates an instance of from a collection of base units. + /// + /// + /// A collection of base units, each containing a singular name and associated prefixes. + /// + /// + /// A new instance of containing mappings of base units + /// and their prefixed counterparts. + /// + /// + /// This method processes the provided base units to generate mappings between base unit prefixes + /// and their corresponding prefixed unit names, as well as scale factors for each prefixed unit. + /// + public static BaseUnitPrefixes FromBaseUnits(IEnumerable baseUnits) + { + var baseUnitPrefixConversions = new Dictionary(); + var prefixedStringFactors = new Dictionary(); + foreach (Unit baseUnit in baseUnits) + { + var unitName = baseUnit.SingularName; + prefixedStringFactors[unitName] = new PrefixScaleFactor(unitName, 0); + baseUnitPrefixConversions[new BaseUnitPrefix(unitName, null)] = unitName; + foreach (Prefix prefix in baseUnit.Prefixes) + { + var prefixedUnitName = prefix + unitName.ToCamelCase(); + baseUnitPrefixConversions[new BaseUnitPrefix(unitName, prefix)] = prefixedUnitName; + prefixedStringFactors[prefixedUnitName] = new PrefixScaleFactor(unitName, MetricPrefixFactors[prefix]); + } + } + + return new BaseUnitPrefixes(prefixedStringFactors, baseUnitPrefixConversions); + } + + /// + /// Attempts to find a matching prefix for a given unit name, exponent, and prefix. + /// + /// + /// The name of the unit to match. For example, "Meter". + /// + /// + /// The exponent associated with the unit. For example, 3 for cubic meters. + /// + /// + /// The prefix to match. For example, . + /// + /// + /// When this method returns, contains the matching if a match is found; + /// otherwise, the default value of . + /// + /// + /// if a matching prefix is found; otherwise, . + /// + /// + /// This method determines if a given unit can be associated with a specific prefix, given the exponent of the + /// associated dimension. + /// + internal bool TryGetMatchingPrefix(string unitName, int exponent, Prefix prefix, out BaseUnitPrefix matchingPrefix) + { + if (exponent == 0 || !_prefixedStringFactors.TryGetValue(unitName, out PrefixScaleFactor? targetPrefixFactor)) + { + matchingPrefix = default; + return false; + } + + if (MetricPrefixFactors.TryGetValue(prefix, out var prefixFactor)) + { + var (quotient, remainder) = int.DivRem(prefixFactor, exponent); + // Ensure the prefix factor is divisible by the exponent without a remainder and that there is a valid prefix matching the target scale + if (remainder == 0) + { + if (targetPrefixFactor.ScaleFactor + quotient == 0) + { + // when the resulting exponent is 0: return the non-prefixed BaseUnit + matchingPrefix = new BaseUnitPrefix(targetPrefixFactor.BaseUnit, null); + return true; + } + + if (TryGetPrefixWithScale(targetPrefixFactor.ScaleFactor + quotient, out Prefix calculatedPrefix)) + { + matchingPrefix = new BaseUnitPrefix(targetPrefixFactor.BaseUnit, calculatedPrefix); + return true; + } + } + } + + matchingPrefix = default; + return false; + } + + private static bool TryGetPrefixWithScale(int logScale, out Prefix calculatedPrefix) + { + return PrefixFactorsByValue.TryGetValue(logScale, out calculatedPrefix); + } + + /// + /// Attempts to retrieve the prefixed unit name for a given base unit and prefix combination. + /// + /// + /// A representing the combination of a base unit and a prefix. + /// + /// + /// When this method returns, contains the prefixed unit name if the lookup was successful; otherwise, null. + /// + /// + /// true if the prefixed unit name was successfully retrieved; otherwise, false. + /// + internal bool TryGetPrefixForUnit(BaseUnitPrefix prefix, [NotNullWhen(true)] out string? prefixedUnitName) + { + return _baseUnitPrefixConversions.TryGetValue(prefix, out prefixedUnitName); + } + + /// + /// Represents the scaling factor that is required for converting from the . + /// + /// Name of base unit, e.g. "Meter". + /// The log-scale factor, e.g. 3 for kilometer. + private record PrefixScaleFactor(string BaseUnit, int ScaleFactor); +} diff --git a/CodeGen/Helpers/PrefixBuilder/PrefixBuilderExtensions.cs b/CodeGen/Helpers/PrefixBuilder/PrefixBuilderExtensions.cs new file mode 100644 index 0000000000..a39c526ffa --- /dev/null +++ b/CodeGen/Helpers/PrefixBuilder/PrefixBuilderExtensions.cs @@ -0,0 +1,105 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Collections.Generic; +using System.Globalization; +using CodeGen.JsonTypes; + +namespace CodeGen.Helpers.PrefixBuilder; + +/// +/// Provides extension methods for working with , , +/// and types, enabling operations such as determining metric prefixes, +/// calculating decimal exponents, and retrieving non-zero exponents from base dimensions. +/// +/// +/// This static class contains utility methods designed to simplify and enhance the manipulation +/// of prefix-related data and base dimensions in the context of code generation. +/// +internal static class PrefixBuilderExtensions +{ + /// + /// Determines whether the specified is a metric prefix. + /// + /// The to evaluate. + /// + /// true if the is a metric prefix (ranging from to + /// ); + /// otherwise, false. + /// + internal static bool IsMetricPrefix(this Prefix prefix) + { + return prefix is >= Prefix.Yocto and <= Prefix.Yotta; + } + + /// + /// Calculates the decimal exponent of a metric prefix factor. + /// + /// + /// The instance representing the metric prefix whose decimal exponent is to be calculated. + /// + /// + /// The decimal exponent as an integer, derived from the logarithm base 10 of the prefix factor. + /// + /// + /// This method assumes that the factor is a valid numeric string representing a power of ten. + /// + internal static int GetDecimalExponent(this PrefixInfo prefix) + { + return (int)Math.Log10(double.Parse(prefix.Factor.TrimEnd('d'), NumberStyles.Any, CultureInfo.InvariantCulture)); + } + + /// + /// Retrieves all non-zero exponents from the specified instance. + /// + /// + /// The instance containing the exponents to evaluate. + /// + /// + /// An of integers representing the non-zero exponents in the specified dimensions. + /// + /// + /// This method iterates through the properties of the instance and yields + /// only those exponents that are non-zero. The properties correspond to the base physical dimensions + /// such as time (T), length (L), mass (M), electric current (I), absolute temperature (Θ), + /// amount of substance (N), and luminous intensity (J). + /// + internal static IEnumerable GetNonZeroExponents(this BaseDimensions dimensions) + { + if (dimensions.I != 0) + { + yield return dimensions.I; + } + + if (dimensions.J != 0) + { + yield return dimensions.J; + } + + if (dimensions.L != 0) + { + yield return dimensions.L; + } + + if (dimensions.M != 0) + { + yield return dimensions.M; + } + + if (dimensions.N != 0) + { + yield return dimensions.N; + } + + if (dimensions.T != 0) + { + yield return dimensions.T; + } + + if (dimensions.Θ != 0) + { + yield return dimensions.Θ; + } + } +} diff --git a/CodeGen/Helpers/PrefixBuilder/UnitPrefixBuilder.cs b/CodeGen/Helpers/PrefixBuilder/UnitPrefixBuilder.cs new file mode 100644 index 0000000000..7ef1a63139 --- /dev/null +++ b/CodeGen/Helpers/PrefixBuilder/UnitPrefixBuilder.cs @@ -0,0 +1,334 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using CodeGen.JsonTypes; + +namespace CodeGen.Helpers.PrefixBuilder; + +/// +/// Provides functionality for building the prefixed units of a . +/// +/// +/// This class is responsible for generating prefixed units by applying defined prefixes to existing units. +/// It utilizes the to handle prefix configurations and conversions. +/// +internal class UnitPrefixBuilder +{ + private readonly BaseUnitPrefixes _prefixes; + + /// + /// Initializes a new instance of the class with the specified base unit prefixes. + /// + /// + /// The instance containing the base unit prefixes to be used. + /// This parameter must not be null. + /// + public UnitPrefixBuilder(BaseUnitPrefixes prefixes) + { + _prefixes = prefixes; + } + + /// + /// Generates a list of prefixed units for the specified by applying all defined prefixes + /// to its existing units. + /// + /// + /// The for which prefixed units will be generated. This parameter must not be null. + /// + /// + /// A list of newly created objects that represent the prefixed units. + /// + /// + /// Thrown when an error occurs while processing a prefix for a unit, such as an invalid prefix or unit configuration. + /// + /// + /// This method iterates through the existing units of the specified and applies each defined + /// prefix to generate new prefixed units. It ensures that the singular and plural names, conversion functions, + /// localization, and other properties are appropriately updated for the newly created units. + /// + public List GeneratePrefixUnits(Quantity quantity) + { + var unitsToAdd = new List(); + foreach (Unit unit in quantity.Units) + foreach (Prefix prefix in unit.Prefixes) + { + try + { + PrefixInfo prefixInfo = PrefixInfo.Entries[prefix]; + + unitsToAdd.Add(new Unit + { + SingularName = $"{prefix}{unit.SingularName.ToCamelCase()}", // "Kilo" + "NewtonPerMeter" => "KilonewtonPerMeter" + PluralName = $"{prefix}{unit.PluralName.ToCamelCase()}", // "Kilo" + "NewtonsPerMeter" => "KilonewtonsPerMeter" + BaseUnits = GetPrefixedBaseUnits(quantity.BaseDimensions, unit.BaseUnits, prefixInfo), + FromBaseToUnitFunc = $"({unit.FromBaseToUnitFunc}) / {prefixInfo.Factor}", + FromUnitToBaseFunc = $"({unit.FromUnitToBaseFunc}) * {prefixInfo.Factor}", + Localization = GetLocalizationForPrefixUnit(unit.Localization, prefixInfo), + ObsoleteText = unit.ObsoleteText, + SkipConversionGeneration = unit.SkipConversionGeneration, + AllowAbbreviationLookup = unit.AllowAbbreviationLookup + }); + } + catch (Exception e) + { + throw new Exception($"Error parsing prefix {prefix} for unit {quantity.Name}.{unit.SingularName}.", e); + } + } + + return unitsToAdd; + } + + /// + /// Applies a metric prefix to the specified base units based on the given dimensions and prefix information. + /// + /// + /// The SI base unit dimensions of the quantity, such as L=1 for Length or T=-1 for Speed. + /// + /// + /// The SI base units for a non-prefixed unit, for example, L=Meter for Length.Meter or L=Meter, T=Second for + /// Speed.MeterPerSecond. + /// + /// + /// The information about the metric prefix to apply, including its factor and symbol. + /// + /// + /// A new instance of with the metric prefix applied, or null if no matching + /// prefixed base units could be determined. + /// Note that even if is not null, the result may still be null if no valid + /// prefixed base units are found. + /// + /// + /// The algorithm attempts to find matching prefixed base units by iterating through the non-zero dimension exponents + /// of the provided . The exponents are processed in ascending order of their absolute + /// values, with positive exponents being prioritized over negative ones. This approach improves the likelihood of + /// finding a + /// match that does not deviate too much from the desired prefix. + /// + /// + /// Examples of determining base units of prefix units: + /// + /// + /// Example 1 - Pressure.Micropascal + /// + /// + /// This highlights how UnitsNet chose Gram as the conversion base unit, while SI defines Kilogram as + /// the base mass unit. + /// + /// + /// Requested prefix: Micro (scale -6) for pressure unit Pascal + /// SI base units of Pascal: L=Meter, M=Kilogram, T=Second + /// SI base dimensions, ordered: M=1, L=-1, T=-2 + /// Trying first dimension M=1: + /// SI base mass unit is Kilogram, but UnitsNet base mass unit is Gram so base prefix scale is 3 + /// Inferred prefix is Milli: base prefix scale 3 + requested prefix scale (-6) = -3 + /// ✅ Resulting base units: M=Milligram plus the original L=Meter, T=Second + /// + /// + /// + /// + /// Example 2 - Pressure.Millipascal + /// + /// + /// Similar to example 1, but this time Length is used instead of Mass due to the base unit scale + /// factor of mass canceling out the requested prefix. + /// + /// + /// Requested prefix: Milli (scale -3) for pressure unit Pascal + /// SI base units of Pascal: L=Meter, M=Kilogram, T=Second + /// SI base dimensions, ordered: M=1, L=-1, T=-2 + /// Trying first dimension M=1: + /// SI base unit in mass dimension is Kilogram, but configured base unit is Gram so base prefix scale is 3 + /// ❌ No inferred prefix: base prefix scale 3 + requested prefix scale (-3) = 0 + /// Trying second dimension L=-1: + /// SI base unit in length dimension is Meter, same as configured base unit, so base prefix scale is 0 + /// Inferred prefix is Milli: base prefix scale 0 + requested prefix scale (-3) = -3 + /// ✅ Resulting base units: M=Millimeter plus the original M=Kilogram, T=Second + /// + /// + /// + /// + /// Example 3 - ElectricApparentPower.Kilovoltampere + /// + /// + /// This example demonstrates cases where determining the base units for certain prefixes is not + /// possible or trivial. + /// + /// + /// Requested prefix: Kilo (scale 3) for unit Voltampere + /// SI base units of Voltampere: L=Meter, M=Kilogram, T=Second + /// SI base dimensions, ordered: M=1, L=2, T=-3 + /// Trying first dimension M=1: + /// SI base unit in mass dimension is Kilogram, same as configured base unit, so base prefix scale is 0 + /// Inferred prefix is Kilo: base prefix scale 0 + requested prefix scale (3) = 3 + /// ❌ Kilo prefix for Kilogram unit would be Megagram, but there is no unit Megagram, since Gram does not have this prefix (we could add it) + /// Trying second dimension L=2: + /// ❌ There is no metric prefix we can raise to the power of 2 and get Kilo, e.g., Deca*Deca = Hecto, Kilo*Kilo = Mega, etc. + /// Trying third dimension T=-3: + /// SI base unit in time dimension is Second, same as configured base unit, so base prefix scale is 0 + /// Inferred prefix is Deci: (base prefix scale 0 + requested prefix scale (-3)) / exponent -3 = -3 / -3 = 1 + /// ❌ There is no Duration unit Decasecond (we could add it) + /// + /// + /// + /// + /// + private BaseUnits? GetPrefixedBaseUnits(BaseDimensions dimensions, BaseUnits? baseUnits, PrefixInfo prefixInfo) + { + if (baseUnits is null) return null; + + // Iterate the non-zero dimension exponents in absolute-increasing order, positive first [1, -1, 2, -2...n, -n] + foreach (var degree in dimensions.GetNonZeroExponents().OrderBy(int.Abs).ThenByDescending(x => x)) + { + if (TryPrefixWithExponent(dimensions, baseUnits, prefixInfo.Prefix, degree, out BaseUnits? prefixedUnits)) + { + return prefixedUnits; + } + } + + return null; + } + + /// + /// Attempts to apply a specified prefix to a base unit based on a given exponent. + /// + /// + /// The base dimensions containing the exponents for each dimension (e.g., length, mass, time). + /// + /// + /// The base units to which the prefix will be applied. + /// + /// + /// The prefix to be applied (e.g., Kilo, Milli, Micro). + /// + /// + /// The exponent of the dimension to which the prefix should be applied. + /// + /// + /// When this method returns, contains the prefixed base units if the operation was successful; otherwise, null. + /// + /// + /// true if the prefix was successfully applied to the base unit; otherwise, false. + /// + private bool TryPrefixWithExponent(BaseDimensions dimensions, BaseUnits baseUnits, Prefix prefix, int exponent, + [NotNullWhen(true)] out BaseUnits? prefixedBaseUnits) + { + prefixedBaseUnits = baseUnits.Clone(); + + // look for a dimension that is part of the non-zero exponents + if (baseUnits.N is { } baseAmountUnit && dimensions.N == exponent) + { + if (TryPrefixUnit(baseAmountUnit, exponent, prefix, out var newAmount)) + { + prefixedBaseUnits.N = newAmount; + return true; + } + } + + if (baseUnits.I is { } baseCurrentUnit && dimensions.I == exponent) + { + if (TryPrefixUnit(baseCurrentUnit, exponent, prefix, out var newCurrent)) + { + prefixedBaseUnits.I = newCurrent; + return true; + } + } + + if (baseUnits.L is { } baseLengthUnit && dimensions.L == exponent) + { + if (TryPrefixUnit(baseLengthUnit, exponent, prefix, out var newLength)) + { + prefixedBaseUnits.L = newLength; + return true; + } + } + + if (baseUnits.J is { } baseLuminosityUnit && dimensions.J == exponent) + { + if (TryPrefixUnit(baseLuminosityUnit, exponent, prefix, out var newLuminosity)) + { + prefixedBaseUnits.J = newLuminosity; + return true; + } + } + + if (baseUnits.M is { } baseMassUnit && dimensions.M == exponent) + { + if (TryPrefixUnit(baseMassUnit, exponent, prefix, out var newMass)) + { + prefixedBaseUnits.M = newMass; + return true; + } + } + + if (baseUnits.Θ is { } baseTemperatureUnit && dimensions.Θ == exponent) + { + if (TryPrefixUnit(baseTemperatureUnit, exponent, prefix, out var newTemperature)) + { + prefixedBaseUnits.Θ = newTemperature; + return true; + } + } + + if (baseUnits.T is { } baseDurationUnit && dimensions.T == exponent) + { + if (TryPrefixUnit(baseDurationUnit, exponent, prefix, out var newTime)) + { + prefixedBaseUnits.T = newTime; + return true; + } + } + + return false; + } + + /// + /// Attempts to apply a specified prefix to a unit name based on the given exponent and prefix. + /// + /// The name of the unit to which the prefix should be applied. + /// The exponent associated with the unit, used to determine compatibility with the prefix. + /// The to be applied to the unit. + /// + /// When this method returns, contains the prefixed unit name if the operation was successful; otherwise, null. + /// + /// + /// true if a matching prefix was found; otherwise, false. + /// + private bool TryPrefixUnit(string unitName, int exponent, Prefix prefix, [NotNullWhen(true)] out string? prefixedUnitName) + { + if (_prefixes.TryGetMatchingPrefix(unitName, exponent, prefix, out BaseUnitPrefix unitPrefix) && + _prefixes.TryGetPrefixForUnit(unitPrefix, out prefixedUnitName)) + { + return true; + } + + prefixedUnitName = null; + return false; + } + + /// + /// Create unit abbreviations for a prefix unit, given a unit and the prefix. + /// The unit abbreviations are either prefixed with the SI prefix or an explicitly configured abbreviation via + /// . + /// + private static Localization[] GetLocalizationForPrefixUnit(IEnumerable localizations, PrefixInfo prefixInfo) + { + return localizations.Select(loc => + { + if (loc.TryGetAbbreviationsForPrefix(prefixInfo.Prefix, out var unitAbbreviationsForPrefix)) + { + return new Localization { Culture = loc.Culture, Abbreviations = unitAbbreviationsForPrefix }; + } + + // No prefix unit abbreviations are specified, so fall back to prepending the default SI prefix to each unit abbreviation: + // kilo ("k") + meter ("m") => kilometer ("km") + var prefix = prefixInfo.GetPrefixForCultureOrSiPrefix(loc.Culture); + unitAbbreviationsForPrefix = loc.Abbreviations.Select(unitAbbreviation => $"{prefix}{unitAbbreviation}").ToArray(); + + return new Localization { Culture = loc.Culture, Abbreviations = unitAbbreviationsForPrefix }; + }).ToArray(); + } +} diff --git a/CodeGen/JsonTypes/BaseDimensions.cs b/CodeGen/JsonTypes/BaseDimensions.cs index a6caad21fd..59f9389505 100644 --- a/CodeGen/JsonTypes/BaseDimensions.cs +++ b/CodeGen/JsonTypes/BaseDimensions.cs @@ -1,6 +1,8 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. +// Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. +using System.Text; + namespace CodeGen.JsonTypes { internal class BaseDimensions @@ -25,5 +27,39 @@ internal class BaseDimensions // 0649 Field is never assigned to #pragma warning restore 0649 + + + /// + public override string ToString() + { + var sb = new StringBuilder(); + + // There are many possible choices of base physical dimensions. The SI standard selects the following dimensions and corresponding dimension symbols: + // time (T), length (L), mass (M), electric current (I), absolute temperature (Θ), amount of substance (N) and luminous intensity (J). + AppendDimensionString(sb, "T", T); + AppendDimensionString(sb, "L", L); + AppendDimensionString(sb, "M", M); + AppendDimensionString(sb, "I", I); + AppendDimensionString(sb, "Θ", Θ); + AppendDimensionString(sb, "N", N); + AppendDimensionString(sb, "J", J); + + return sb.ToString(); + } + + private static void AppendDimensionString(StringBuilder sb, string name, int value) + { + switch (value) + { + case 0: + return; + case 1: + sb.AppendFormat("[{0}]", name); + break; + default: + sb.AppendFormat("[{0}^{1}]", name, value); + break; + } + } } } diff --git a/CodeGen/JsonTypes/BaseUnits.cs b/CodeGen/JsonTypes/BaseUnits.cs index d40b54dfeb..ff97054764 100644 --- a/CodeGen/JsonTypes/BaseUnits.cs +++ b/CodeGen/JsonTypes/BaseUnits.cs @@ -1,6 +1,9 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. +using System; +using System.Text; + namespace CodeGen.JsonTypes { internal class BaseUnits @@ -25,5 +28,34 @@ internal class BaseUnits // 0649 Field is never assigned to #pragma warning restore 0649 + + /// + public override string ToString() + { + var sb = new StringBuilder(); + if (N is { } n) sb.Append($"N={n}, "); + if (I is { } i) sb.Append($"I={i}, "); + if (L is { } l) sb.Append($"L={l}, "); + if (J is { } j) sb.Append($"J={j}, "); + if (M is { } m) sb.Append($"M={m}, "); + if (Θ is { } θ) sb.Append($"Θ={θ}, "); + if (T is { } t) sb.Append($"T={t}, "); + + return sb.ToString().TrimEnd(' ', ','); + } + + public BaseUnits Clone() + { + return new BaseUnits + { + N = N, + I = I, + L = L, + J = J, + M = M, + Θ = Θ, + T = T + }; + } } } diff --git a/CodeGen/JsonTypes/Quantity.cs b/CodeGen/JsonTypes/Quantity.cs index 4af26113fc..f471225ad8 100644 --- a/CodeGen/JsonTypes/Quantity.cs +++ b/CodeGen/JsonTypes/Quantity.cs @@ -2,22 +2,24 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; +using System.Diagnostics; namespace CodeGen.JsonTypes { - internal class Quantity + [DebuggerDisplay("{Name}")] + internal record Quantity { // 0649 Field is never assigned to #pragma warning disable 0649 public BaseDimensions BaseDimensions = new(); // Default to empty - public string ValueType = "double"; public string BaseUnit = null!; public bool GenerateArithmetic = true; public bool Logarithmic = false; public int LogarithmicScalingFactor = 1; public string Name = null!; public Unit[] Units = Array.Empty(); + public QuantityRelation[] Relations = Array.Empty(); public string? XmlDocRemarks; public string XmlDocSummary = null!; public string? ObsoleteText; diff --git a/CodeGen/JsonTypes/QuantityRelation.cs b/CodeGen/JsonTypes/QuantityRelation.cs new file mode 100644 index 0000000000..35e97a6bc0 --- /dev/null +++ b/CodeGen/JsonTypes/QuantityRelation.cs @@ -0,0 +1,35 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; + +namespace CodeGen.JsonTypes +{ + internal record QuantityRelation : IComparable + { + public bool NoInferredDivision = false; + public string Operator = null!; + + public Quantity LeftQuantity = null!; + public Unit LeftUnit = null!; + + public Quantity RightQuantity = null!; + public Unit RightUnit = null!; + + public Quantity ResultQuantity = null!; + public Unit ResultUnit = null!; + + public string SortString => ResultQuantity.Name + PrependDot(ResultUnit.SingularName) + + " = " + + LeftQuantity.Name + PrependDot(LeftUnit.SingularName) + + " " + Operator + " " + + RightQuantity.Name + PrependDot(RightUnit.SingularName); + + public int CompareTo(QuantityRelation? other) + { + return string.Compare(SortString, other?.SortString, StringComparison.Ordinal); + } + + private static string PrependDot(string? s) => s == null ? string.Empty : "." + s; + } +} \ No newline at end of file diff --git a/CodeGen/JsonTypes/Unit.cs b/CodeGen/JsonTypes/Unit.cs index 4a775c08f9..982dd5a887 100644 --- a/CodeGen/JsonTypes/Unit.cs +++ b/CodeGen/JsonTypes/Unit.cs @@ -2,9 +2,11 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; +using System.Diagnostics; namespace CodeGen.JsonTypes { + [DebuggerDisplay("{SingularName})")] internal class Unit { // 0649 Field is never assigned to diff --git a/CodeGen/PrefixInfo.cs b/CodeGen/PrefixInfo.cs index 1ec641b3b6..e44c643c48 100644 --- a/CodeGen/PrefixInfo.cs +++ b/CodeGen/PrefixInfo.cs @@ -15,9 +15,6 @@ internal class PrefixInfo public static readonly IReadOnlyDictionary Entries = new[] { - // Need to append 'd' suffix for double in order to later search/replace "d" with "m" - // when creating decimal conversion functions in CodeGen.Generator.FixConversionFunctionsForDecimalValueTypes. - // SI prefixes new PrefixInfo(Prefix.Yocto, "1e-24d", "y",(Chinese, "夭")), new PrefixInfo(Prefix.Zepto, "1e-21d", "z",(Chinese, "仄")), diff --git a/CodeGen/Program.cs b/CodeGen/Program.cs index d5589d5d1d..cfeecb0a93 100644 --- a/CodeGen/Program.cs +++ b/CodeGen/Program.cs @@ -65,10 +65,12 @@ public static int Main(bool verbose = false, DirectoryInfo? repositoryRoot = nul if (verbose) Log.Debug("Verbose output enabled"); var sw = Stopwatch.StartNew(); - var quantities = QuantityJsonFilesParser.ParseQuantities(repositoryRoot.FullName); + var quantities = QuantityJsonFilesParser.ParseQuantities(rootDir); QuantityNameToUnitEnumValues quantityNameToUnitEnumValues = UnitEnumValueAllocator.AllocateNewUnitEnumValues($"{rootDir}/Common/UnitEnumValues.g.json", quantities); + QuantityRelationsParser.ParseAndApplyRelations(rootDir, quantities); + UnitsNetGenerator.Generate(rootDir, quantities, quantityNameToUnitEnumValues); if (updateNanoFrameworkDependencies) diff --git a/Common/UnitDefinitions/Acceleration.json b/Common/UnitDefinitions/Acceleration.json index 8fc62f841e..939df39ce6 100644 --- a/Common/UnitDefinitions/Acceleration.json +++ b/Common/UnitDefinitions/Acceleration.json @@ -75,14 +75,14 @@ "L": "NauticalMile", "T": "Second" }, - "FromUnitToBaseFunc": "{x} * 0.5144444444444", - "FromBaseToUnitFunc": "{x} / 0.5144444444444", + "FromUnitToBaseFunc": "{x} * (1852.0 / 3600.0)", + "FromBaseToUnitFunc": "{x} / (1852.0 / 3600.0)", "Localization": [ { "Culture": "en-US", "Abbreviations": [ "kn/s" ] }, - { + { "Culture": "ru-RU", "Abbreviations": [ "узел/с" ] } @@ -95,14 +95,16 @@ "L": "NauticalMile", "T": "Minute" }, - "FromUnitToBaseFunc": "{x} * 0.5144444444444 / 60", - "FromBaseToUnitFunc": "{x} / 0.5144444444444 * 60", + "XmlDocSummary": "The knot (/nɒt/) is a unit of speed equal to one nautical mile per hour, exactly 1.852 km/h (approximately 1.151 mph or 0.514 m/s).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Knot_(unit)", + "FromUnitToBaseFunc": "{x} * (1852.0 / 3600.0) / 60", + "FromBaseToUnitFunc": "{x} * 60 / (1852.0 / 3600.0)", "Localization": [ { "Culture": "en-US", "Abbreviations": [ "kn/min" ] }, - { + { "Culture": "ru-RU", "Abbreviations": [ "узел/мин" ] } @@ -115,14 +117,16 @@ "L": "NauticalMile", "T": "Hour" }, - "FromUnitToBaseFunc": "{x} * 0.5144444444444 / 3600", - "FromBaseToUnitFunc": "{x} / 0.5144444444444 * 3600", + "XmlDocSummary": "The knot (/nɒt/) is a unit of speed equal to one nautical mile per hour, exactly 1.852 km/h (approximately 1.151 mph or 0.514 m/s).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Knot_(unit)", + "FromUnitToBaseFunc": "{x} * (1852.0 / 3600.0) / 3600", + "FromBaseToUnitFunc": "{x} * 3600 / (1852.0 / 3600.0)", "Localization": [ { "Culture": "en-US", "Abbreviations": [ "kn/h" ] }, - { + { "Culture": "ru-RU", "Abbreviations": [ "узел/час" ] } @@ -131,10 +135,6 @@ { "SingularName": "StandardGravity", "PluralName": "StandardGravity", - "BaseUnits": { - "L": "Meter", - "T": "Second" - }, "FromUnitToBaseFunc": "{x} * 9.80665", "FromBaseToUnitFunc": "{x} / 9.80665", "Prefixes": [ "Milli"], diff --git a/Common/UnitDefinitions/Angle.json b/Common/UnitDefinitions/Angle.json index 1f7b908af1..176335eee4 100644 --- a/Common/UnitDefinitions/Angle.json +++ b/Common/UnitDefinitions/Angle.json @@ -1,13 +1,13 @@ { "Name": "Angle", - "BaseUnit": "Degree", + "BaseUnit": "Radian", "XmlDocSummary": "In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle.", "Units": [ { "SingularName": "Radian", "PluralName": "Radians", - "FromUnitToBaseFunc": "{x} * 180 / Math.PI", - "FromBaseToUnitFunc": "{x} / 180 * Math.PI", + "FromUnitToBaseFunc": "{x}", + "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci" ], "Localization": [ { @@ -24,8 +24,8 @@ "SingularName": "Degree", "PluralName": "Degrees", "Prefixes": [ "Nano", "Micro", "Milli" ], - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", + "FromUnitToBaseFunc": "{x} * Math.PI / 180", + "FromBaseToUnitFunc": "{x} * 180 / Math.PI", "Localization": [ { "Culture": "en-US", @@ -40,8 +40,8 @@ { "SingularName": "Arcminute", "PluralName": "Arcminutes", - "FromUnitToBaseFunc": "{x} / 60", - "FromBaseToUnitFunc": "{x} * 60", + "FromUnitToBaseFunc": "{x} * Math.PI / (60 * 180)", + "FromBaseToUnitFunc": "{x} * 60 * 180 / Math.PI", "Localization": [ { "Culture": "en-US", @@ -52,8 +52,8 @@ { "SingularName": "Arcsecond", "PluralName": "Arcseconds", - "FromUnitToBaseFunc": "{x} / 3600", - "FromBaseToUnitFunc": "{x} * 3600", + "FromUnitToBaseFunc": "{x} * Math.PI / (3600 * 180)", + "FromBaseToUnitFunc": "{x} * 3600 * 180 / Math.PI", "Localization": [ { "Culture": "en-US", @@ -64,8 +64,8 @@ { "SingularName": "Gradian", "PluralName": "Gradians", - "FromUnitToBaseFunc": "{x} * 0.9", - "FromBaseToUnitFunc": "{x} / 0.9", + "FromUnitToBaseFunc": "{x} * Math.PI / 200", + "FromBaseToUnitFunc": "{x} * 200 / Math.PI", "Localization": [ { "Culture": "en-US", @@ -80,8 +80,8 @@ { "SingularName": "NatoMil", "PluralName": "NatoMils", - "FromUnitToBaseFunc": "{x} * 9 / 160", - "FromBaseToUnitFunc": "{x} * 160 / 9", + "FromUnitToBaseFunc": "{x} * Math.PI / 3200", + "FromBaseToUnitFunc": "{x} * 3200 / Math.PI", "Localization": [ { "Culture": "en-US", @@ -92,8 +92,8 @@ { "SingularName": "Revolution", "PluralName": "Revolutions", - "FromUnitToBaseFunc": "{x} * 360", - "FromBaseToUnitFunc": "{x} / 360", + "FromUnitToBaseFunc": "{x} * 2 * Math.PI", + "FromBaseToUnitFunc": "{x} / (2 * Math.PI)", "Localization": [ { "Culture": "en-US", @@ -104,18 +104,6 @@ "Abbreviations": [ "r" ] } ] - }, - { - "SingularName": "Tilt", - "PluralName": "Tilt", - "FromUnitToBaseFunc": "Math.Asin({x}) * 180 / Math.PI", - "FromBaseToUnitFunc": "Math.Sin({x} / 180 * Math.PI)", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "sin(θ)" ] - } - ] } ] } diff --git a/Common/UnitDefinitions/ApparentEnergy.json b/Common/UnitDefinitions/ApparentEnergy.json deleted file mode 100644 index 7f588de3eb..0000000000 --- a/Common/UnitDefinitions/ApparentEnergy.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Name": "ApparentEnergy", - "BaseUnit": "VoltampereHour", - "XmlDocSummary": "A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules.", - "XmlDocRemarks": "ApparentEnergy has been renamed to ElectricApparentEnergy, and will be removed in a later major version.", - "ObsoleteText": "ApparentEnergy has been renamed to ElectricApparentEnergy, and will be removed in a later major version.", - "BaseDimensions": { - "L": 2, - "M": 1, - "T": -2 - }, - "Units": [ - { - "SingularName": "VoltampereHour", - "PluralName": "VoltampereHours", - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", - "Prefixes": [ "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "VAh" ] - } - ] - } - ] -} diff --git a/Common/UnitDefinitions/ApparentPower.json b/Common/UnitDefinitions/ApparentPower.json deleted file mode 100644 index 4aebda1a1c..0000000000 --- a/Common/UnitDefinitions/ApparentPower.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Name": "ApparentPower", - "BaseUnit": "Voltampere", - "XmlDocSummary": "Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current.", - "XmlDocRemarks": "ApparentPower has been renamed to ElectricApparentPower, and will be removed in a later major version.", - "ObsoleteText": "ApparentPower has been renamed to ElectricApparentPower, and will be removed in a later major version.", - "BaseDimensions": { - "L": 2, - "M": 1, - "T": -3 - }, - "Units": [ - { - "SingularName": "Voltampere", - "PluralName": "Voltamperes", - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", - "Prefixes": [ "Micro", "Milli", "Kilo", "Mega", "Giga" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "VA" ] - } - ] - } - ] -} diff --git a/Common/UnitDefinitions/AreaMomentOfInertia.json b/Common/UnitDefinitions/AreaMomentOfInertia.json index 3bb85e08f5..55b2bed639 100644 --- a/Common/UnitDefinitions/AreaMomentOfInertia.json +++ b/Common/UnitDefinitions/AreaMomentOfInertia.json @@ -72,8 +72,8 @@ "BaseUnits": { "L": "Foot" }, - "FromUnitToBaseFunc": "{x} * Math.Pow(0.3048, 4)", - "FromBaseToUnitFunc": "{x} / Math.Pow(0.3048, 4)", + "FromUnitToBaseFunc": "{x} * 0.0086309748412416", + "FromBaseToUnitFunc": "{x} / 0.0086309748412416", "Localization": [ { "Culture": "en-US", @@ -87,8 +87,8 @@ "BaseUnits": { "L": "Inch" }, - "FromUnitToBaseFunc": "{x} * Math.Pow(2.54e-2, 4)", - "FromBaseToUnitFunc": "{x} / Math.Pow(2.54e-2, 4)", + "FromUnitToBaseFunc": "{x} * 0.0000004162314256", + "FromBaseToUnitFunc": "{x} / 0.0000004162314256", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/BitRate.json b/Common/UnitDefinitions/BitRate.json index 8f2ccd1e37..d5c1b97fa6 100644 --- a/Common/UnitDefinitions/BitRate.json +++ b/Common/UnitDefinitions/BitRate.json @@ -1,14 +1,18 @@ { "Name": "BitRate", "BaseUnit": "BitPerSecond", - "ValueType": "decimal", "XmlDocSummary": "In telecommunications and computing, bit rate is the number of bits that are conveyed or processed per unit of time.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Bit_rate", - "BaseDimensions": { "T": -1 }, + "BaseDimensions": { + "T": -1 + }, "Units": [ { "SingularName": "BitPerSecond", "PluralName": "BitsPerSecond", + "BaseUnits": { + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi" ], @@ -22,8 +26,8 @@ { "SingularName": "BytePerSecond", "PluralName": "BytesPerSecond", - "FromUnitToBaseFunc": "{x} * 8m", - "FromBaseToUnitFunc": "{x} / 8m", + "FromUnitToBaseFunc": "{x} * 8", + "FromBaseToUnitFunc": "{x} / 8", "Prefixes": [ "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi" ], "Localization": [ { diff --git a/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json b/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json index ff498144da..b059dde220 100644 --- a/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json +++ b/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json @@ -22,6 +22,10 @@ { "SingularName": "KilogramPerJoule", "PluralName": "KilogramsPerJoule", + "BaseUnits": { + "L": "Meter", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ @@ -34,8 +38,8 @@ { "SingularName": "PoundPerMechanicalHorsepowerHour", "PluralName": "PoundsPerMechanicalHorsepowerHour", - "FromUnitToBaseFunc": "{x} * 1.689659410672e-7", - "FromBaseToUnitFunc": "{x} / 1.689659410672e-7", + "FromUnitToBaseFunc": "{x} * (0.45359237 / (76.0402249 * 9.80665))/3600", + "FromBaseToUnitFunc": "{x} * 3600 / (0.45359237 / (76.0402249 * 9.80665))", "XmlDocSummary": "The pound per horse power hour uses mechanical horse power and the imperial pound", "Localization": [ { diff --git a/Common/UnitDefinitions/Capacitance.json b/Common/UnitDefinitions/Capacitance.json deleted file mode 100644 index d2f0a0bd5f..0000000000 --- a/Common/UnitDefinitions/Capacitance.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "Name": "Capacitance", - "BaseUnit": "Farad", - "XmlDocSummary": "Capacitance is the ability of a body to store an electric charge.", - "XmlDocRemarks": "Capacitance has been renamed to ElectricCapacitance, and will be removed in a later major version.", - "ObsoleteText": "Capacitance has been renamed to ElectricCapacitance, and will be removed in a later major version.", - "BaseDimensions": { - "L": -2, - "M": -1, - "T": 4, - "I": 2 - }, - "Units": [ - { - "SingularName": "Farad", - "PluralName": "Farads", - "BaseUnits": { - "L": "Meter", - "M": "Kilogram", - "T": "Second", - "I": "Ampere" - }, - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", - "Prefixes": [ "Pico", "Nano", "Micro", "Milli", "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "F" ] - } - ] - } - ] -} diff --git a/Common/UnitDefinitions/CoefficientOfThermalExpansion.json b/Common/UnitDefinitions/CoefficientOfThermalExpansion.json index b861dab5e9..34790d395e 100644 --- a/Common/UnitDefinitions/CoefficientOfThermalExpansion.json +++ b/Common/UnitDefinitions/CoefficientOfThermalExpansion.json @@ -6,54 +6,6 @@ "Θ": -1 }, "Units": [ - { - "SingularName": "InverseKelvin", - "PluralName": "InverseKelvin", - "ObsoleteText": "Use PerKelvin instead.", - "BaseUnits": { - "Θ": "Kelvin" - }, - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "1/K" ] - } - ] - }, - { - "SingularName": "InverseDegreeCelsius", - "PluralName": "InverseDegreeCelsius", - "ObsoleteText": "Use PerDegreeCelsius instead.", - "BaseUnits": { - "Θ": "DegreeCelsius" - }, - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "1/°C" ] - } - ] - }, - { - "SingularName": "InverseDegreeFahrenheit", - "PluralName": "InverseDegreeFahrenheit", - "ObsoleteText": "Use PerDegreeFahrenheit instead.", - "BaseUnits": { - "Θ": "DegreeFahrenheit" - }, - "FromUnitToBaseFunc": "{x} * 9 / 5", - "FromBaseToUnitFunc": "{x} * 5 / 9", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "1/°F" ] - } - ] - }, { "SingularName": "PerKelvin", "PluralName": "PerKelvin", @@ -102,9 +54,6 @@ { "SingularName": "PpmPerKelvin", "PluralName": "PpmPerKelvin", - "BaseUnits": { - "Θ": "Kelvin" - }, "FromUnitToBaseFunc": "{x} / 1e6", "FromBaseToUnitFunc": "{x} * 1e6", "Localization": [ @@ -117,9 +66,6 @@ { "SingularName": "PpmPerDegreeCelsius", "PluralName": "PpmPerDegreeCelsius", - "BaseUnits": { - "Θ": "DegreeCelsius" - }, "FromUnitToBaseFunc": "{x} / 1e6", "FromBaseToUnitFunc": "{x} * 1e6", "Localization": [ @@ -132,9 +78,6 @@ { "SingularName": "PpmPerDegreeFahrenheit", "PluralName": "PpmPerDegreeFahrenheit", - "BaseUnits": { - "Θ": "DegreeFahrenheit" - }, "FromUnitToBaseFunc": "{x} * 9 / 5e6", "FromBaseToUnitFunc": "{x} * 5e6 / 9", "Localization": [ diff --git a/Common/UnitDefinitions/Density.json b/Common/UnitDefinitions/Density.json index 25f06d112b..fbcffa7cb1 100644 --- a/Common/UnitDefinitions/Density.json +++ b/Common/UnitDefinitions/Density.json @@ -70,8 +70,8 @@ "L": "Inch", "M": "Pound" }, - "FromUnitToBaseFunc": "{x} / 3.6127298147753e-5", - "FromBaseToUnitFunc": "{x} * 3.6127298147753e-5", + "FromUnitToBaseFunc": "{x} * 0.45359237 / 1.6387064e-5", + "FromBaseToUnitFunc": "{x} * 1.6387064e-5 / 0.45359237", "Prefixes": [ "Kilo" ], "Localization": [ { @@ -88,8 +88,8 @@ "L": "Foot", "M": "Pound" }, - "FromUnitToBaseFunc": "{x} / 0.062427961", - "FromBaseToUnitFunc": "{x} * 0.062427961", + "FromUnitToBaseFunc": "{x} * 0.45359237 / 0.028316846592", + "FromBaseToUnitFunc": "{x} * 0.028316846592 / 0.45359237", "Prefixes": [ "Kilo" ], "Localization": [ { @@ -102,13 +102,13 @@ { "SingularName": "PoundPerCubicYard", "PluralName": "PoundsPerCubicYard", - "XmlDocSummary": "Calculated from the definition of pound and yard compared to metric kilogram and meter.", + "XmlDocSummary": "Calculated from the definition of pound and Cubic yard compared to metric kilogram and meter.", "BaseUnits": { "L": "Yard", "M": "Pound" }, - "FromUnitToBaseFunc": "{x} * (0.45359237 / 0.9144 / 0.9144 / 0.9144)", - "FromBaseToUnitFunc": "{x} / (0.45359237 / 0.9144 / 0.9144 / 0.9144)", + "FromUnitToBaseFunc": "{x} * 0.45359237 / 0.764554857984", + "FromBaseToUnitFunc": "{x} * 0.764554857984 / 0.45359237", "Prefixes": [ "Kilo" ], "Localization": [ { @@ -173,8 +173,8 @@ "L": "Foot", "M": "Slug" }, - "FromUnitToBaseFunc": "{x} * 515.378818", - "FromBaseToUnitFunc": "{x} * 0.00194032033", + "FromUnitToBaseFunc": "{x} * (0.45359237 * 9.80665) / (0.3048 * 0.028316846592)", + "FromBaseToUnitFunc": "{x} * (0.3048 * 0.028316846592) / (0.45359237 * 9.80665)", "Localization": [ { "Culture": "en-US", @@ -185,19 +185,23 @@ { "SingularName": "GramPerLiter", "PluralName": "GramsPerLiter", + "BaseUnits": { + "L": "Decimeter", + "M": "Gram" + }, "FromUnitToBaseFunc": "{x} / 1", "FromBaseToUnitFunc": "{x} * 1", "Prefixes": [ "Femto", "Pico", "Nano", "Micro", "Milli", "Centi", "Deci" ], "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "g/L" ] + "Abbreviations": [ "g/l" ] } ] }, { "SingularName": "GramPerDeciliter", - "PluralName": "GramsPerDeciLiter", + "PluralName": "GramsPerDeciliter", "FromUnitToBaseFunc": "{x} / 1e-1", "FromBaseToUnitFunc": "{x} * 1e-1", "Prefixes": [ "Femto", "Pico", "Nano", "Micro", "Milli", "Centi", "Deci" ], @@ -211,6 +215,10 @@ { "SingularName": "GramPerMilliliter", "PluralName": "GramsPerMilliliter", + "BaseUnits": { + "L": "Centimeter", + "M": "Gram" + }, "FromUnitToBaseFunc": "{x} / 1e-3", "FromBaseToUnitFunc": "{x} * 1e-3", "Prefixes": [ "Femto", "Pico", "Nano", "Micro", "Milli", "Centi", "Deci" ], @@ -224,8 +232,8 @@ { "SingularName": "PoundPerUSGallon", "PluralName": "PoundsPerUSGallon", - "FromUnitToBaseFunc": "{x} * 1.19826427e2", - "FromBaseToUnitFunc": "{x} / 1.19826427e2", + "FromUnitToBaseFunc": "{x} * 0.45359237 / 0.003785411784", + "FromBaseToUnitFunc": "{x} * 0.003785411784 / 0.45359237", "Localization": [ { "Culture": "en-US", @@ -236,8 +244,8 @@ { "SingularName": "PoundPerImperialGallon", "PluralName": "PoundsPerImperialGallon", - "FromUnitToBaseFunc": "{x} * 9.9776398e1", - "FromBaseToUnitFunc": "{x} / 9.9776398e1", + "FromUnitToBaseFunc": "{x} * 0.45359237 / 0.00454609", + "FromBaseToUnitFunc": "{x} * 0.00454609 / 0.45359237", "Localization": [ { "Culture": "en-US", @@ -268,8 +276,8 @@ "L": "Foot", "M": "Tonne" }, - "FromUnitToBaseFunc": "{x} * 3.53146667214886e4", - "FromBaseToUnitFunc": "{x} / 3.53146667214886e4", + "FromUnitToBaseFunc": "{x} * 1000 / 0.028316846592", + "FromBaseToUnitFunc": "{x} * 0.028316846592 / 1000", "Localization": [ { "Culture": "en-US", @@ -284,8 +292,8 @@ "L": "Inch", "M": "Tonne" }, - "FromUnitToBaseFunc": "{x} * 6.10237440947323e7", - "FromBaseToUnitFunc": "{x} / 6.10237440947323e7", + "FromUnitToBaseFunc": "{x} * 1000 / 1.6387064e-5", + "FromBaseToUnitFunc": "{x} * 1.6387064e-5 / 1000", "Localization": [ { "Culture": "en-US", @@ -300,8 +308,8 @@ "L": "Foot", "M": "Gram" }, - "FromUnitToBaseFunc": "{x} * 0.0353146667214886", - "FromBaseToUnitFunc": "{x} / 0.0353146667214886", + "FromUnitToBaseFunc": "{x} * 0.001 / 0.028316846592", + "FromBaseToUnitFunc": "{x} * 0.028316846592 / 0.001", "Localization": [ { "Culture": "en-US", @@ -316,8 +324,8 @@ "L": "Inch", "M": "Gram" }, - "FromUnitToBaseFunc": "{x} * 61.0237440947323", - "FromBaseToUnitFunc": "{x} / 61.0237440947323", + "FromUnitToBaseFunc": "{x} * 0.001 / 1.6387064e-5", + "FromBaseToUnitFunc": "{x} * 1.6387064e-5 / 0.001", "Localization": [ { "Culture": "en-US", @@ -332,8 +340,8 @@ "L": "Meter", "M": "Pound" }, - "FromUnitToBaseFunc": "{x} / 2.204622621848775", - "FromBaseToUnitFunc": "{x} * 2.204622621848775", + "FromUnitToBaseFunc": "{x} * 0.45359237", + "FromBaseToUnitFunc": "{x} / 0.45359237", "Localization": [ { "Culture": "en-US", @@ -348,8 +356,8 @@ "L": "Centimeter", "M": "Pound" }, - "FromUnitToBaseFunc": "{x} / 2.204622621848775e-6", - "FromBaseToUnitFunc": "{x} * 2.204622621848775e-6", + "FromUnitToBaseFunc": "{x} * 0.45359237e6", + "FromBaseToUnitFunc": "{x} / 0.45359237e6", "Localization": [ { "Culture": "en-US", @@ -364,8 +372,8 @@ "L": "Millimeter", "M": "Pound" }, - "FromUnitToBaseFunc": "{x} / 2.204622621848775e-9", - "FromBaseToUnitFunc": "{x} * 2.204622621848775e-9", + "FromUnitToBaseFunc": "{x} * 0.45359237e9", + "FromBaseToUnitFunc": "{x} / 0.45359237e9", "Localization": [ { "Culture": "en-US", @@ -380,8 +388,8 @@ "L": "Meter", "M": "Slug" }, - "FromUnitToBaseFunc": "{x} * 14.5939", - "FromBaseToUnitFunc": "{x} / 14.5939", + "FromUnitToBaseFunc": "{x} * 0.45359237 * 9.80665 / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048 / (0.45359237 * 9.80665)", "Localization": [ { "Culture": "en-US", @@ -396,8 +404,8 @@ "L": "Centimeter", "M": "Slug" }, - "FromUnitToBaseFunc": "{x} * 14593903", - "FromBaseToUnitFunc": "{x} / 14593903", + "FromUnitToBaseFunc": "{x} * 0.45359237e6 * 9.80665 / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048 / (0.45359237e6 * 9.80665)", "Localization": [ { "Culture": "en-US", @@ -412,8 +420,8 @@ "L": "Millimeter", "M": "Slug" }, - "FromUnitToBaseFunc": "{x} * 14593903000", - "FromBaseToUnitFunc": "{x} / 14593903000", + "FromUnitToBaseFunc": "{x} * 0.45359237e9 * 9.80665 / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048 / (0.45359237e9 * 9.80665)", "Localization": [ { "Culture": "en-US", @@ -428,8 +436,8 @@ "L": "Inch", "M": "Slug" }, - "FromUnitToBaseFunc": "{x} * 890574.60201535", - "FromBaseToUnitFunc": "{x} / 890574.60201535", + "FromUnitToBaseFunc": "{x} * (0.45359237 * 9.80665) / (0.3048 * 1.6387064e-5)", + "FromBaseToUnitFunc": "{x} * (0.3048 * 1.6387064e-5) / (0.45359237 * 9.80665)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/DynamicViscosity.json b/Common/UnitDefinitions/DynamicViscosity.json index d42da56383..d5ab8143c9 100644 --- a/Common/UnitDefinitions/DynamicViscosity.json +++ b/Common/UnitDefinitions/DynamicViscosity.json @@ -12,6 +12,11 @@ { "SingularName": "NewtonSecondPerMeterSquared", "PluralName": "NewtonSecondsPerMeterSquared", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ @@ -50,8 +55,8 @@ { "SingularName": "Reyn", "PluralName": "Reyns", - "FromUnitToBaseFunc": "{x} * 6.8947572931683613e3", - "FromBaseToUnitFunc": "{x} / 6.8947572931683613e3", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 0.00064516", + "FromBaseToUnitFunc": "{x} * 0.00064516 / 4.4482216152605", "Localization": [ { "Culture": "en-US", @@ -62,8 +67,8 @@ { "SingularName": "PoundForceSecondPerSquareInch", "PluralName": "PoundsForceSecondPerSquareInch", - "FromUnitToBaseFunc": "{x} * 6.8947572931683613e3", - "FromBaseToUnitFunc": "{x} / 6.8947572931683613e3", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 0.00064516", + "FromBaseToUnitFunc": "{x} * 0.00064516 / 4.4482216152605", "Localization": [ { "Culture": "en-US", @@ -74,8 +79,8 @@ { "SingularName": "PoundForceSecondPerSquareFoot", "PluralName": "PoundsForceSecondPerSquareFoot", - "FromUnitToBaseFunc": "{x} * 4.7880258980335843e1", - "FromBaseToUnitFunc": "{x} / 4.7880258980335843e1", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 9.290304e-2", + "FromBaseToUnitFunc": "{x} * 9.290304e-2 / 4.4482216152605", "Localization": [ { "Culture": "en-US", @@ -86,12 +91,12 @@ { "SingularName": "PoundPerFootSecond", "PluralName": "PoundsPerFootSecond", - "FromUnitToBaseFunc": "{x} * 1.4881639", - "FromBaseToUnitFunc": "{x} / 1.4881639", + "FromUnitToBaseFunc": "{x} * 0.45359237 / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048 / 0.45359237", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "lb/ft·s" ] + "Abbreviations": [ "lb/(ft·s)" ] } ] } diff --git a/Common/UnitDefinitions/ElectricAdmittance.json b/Common/UnitDefinitions/ElectricAdmittance.json index 38c539237b..5f843d752e 100644 --- a/Common/UnitDefinitions/ElectricAdmittance.json +++ b/Common/UnitDefinitions/ElectricAdmittance.json @@ -14,6 +14,12 @@ { "SingularName": "Siemens", "PluralName": "Siemens", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "I": "Ampere" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Kilo", "Mega", "Giga", "Tera" ], diff --git a/Common/UnitDefinitions/ElectricApparentPower.json b/Common/UnitDefinitions/ElectricApparentPower.json index 4173ef577b..52be88ac11 100644 --- a/Common/UnitDefinitions/ElectricApparentPower.json +++ b/Common/UnitDefinitions/ElectricApparentPower.json @@ -12,6 +12,11 @@ { "SingularName": "Voltampere", "PluralName": "Voltamperes", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Micro", "Milli", "Kilo", "Mega", "Giga" ], diff --git a/Common/UnitDefinitions/ElectricCharge.json b/Common/UnitDefinitions/ElectricCharge.json index 1488af22db..7f3639e57f 100644 --- a/Common/UnitDefinitions/ElectricCharge.json +++ b/Common/UnitDefinitions/ElectricCharge.json @@ -11,6 +11,10 @@ { "SingularName": "Coulomb", "PluralName": "Coulombs", + "BaseUnits": { + "I": "Ampere", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Pico", "Nano", "Micro", "Milli", "Kilo", "Mega" ], @@ -24,8 +28,12 @@ { "SingularName": "AmpereHour", "PluralName": "AmpereHours", - "FromUnitToBaseFunc": "{x} / 2.77777777777e-4", - "FromBaseToUnitFunc": "{x} * 2.77777777777e-4", + "BaseUnits": { + "I": "Ampere", + "T": "Hour" + }, + "FromUnitToBaseFunc": "{x} * 3600", + "FromBaseToUnitFunc": "{x} / 3600", "Prefixes": [ "Milli", "Kilo", "Mega" ], "Localization": [ { diff --git a/Common/UnitDefinitions/ElectricConductance.json b/Common/UnitDefinitions/ElectricConductance.json index 910062df0d..46129fe556 100644 --- a/Common/UnitDefinitions/ElectricConductance.json +++ b/Common/UnitDefinitions/ElectricConductance.json @@ -13,6 +13,12 @@ { "SingularName": "Siemens", "PluralName": "Siemens", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "I": "Ampere" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Kilo", "Mega", "Giga", "Tera" ], diff --git a/Common/UnitDefinitions/ElectricConductivity.json b/Common/UnitDefinitions/ElectricConductivity.json index 2bd4a0033b..c6a143678d 100644 --- a/Common/UnitDefinitions/ElectricConductivity.json +++ b/Common/UnitDefinitions/ElectricConductivity.json @@ -31,8 +31,8 @@ { "SingularName": "SiemensPerInch", "PluralName": "SiemensPerInch", - "FromUnitToBaseFunc": "{x} * 3.937007874015748e1", - "FromBaseToUnitFunc": "{x} / 3.937007874015748e1", + "FromUnitToBaseFunc": "{x} / 2.54e-2", + "FromBaseToUnitFunc": "{x} * 2.54e-2", "Localization": [ { "Culture": "en-US", @@ -43,8 +43,8 @@ { "SingularName": "SiemensPerFoot", "PluralName": "SiemensPerFoot", - "FromUnitToBaseFunc": "{x} * 3.2808398950131234", - "FromBaseToUnitFunc": "{x} / 3.2808398950131234", + "FromUnitToBaseFunc": "{x} / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/ElectricCurrentDensity.json b/Common/UnitDefinitions/ElectricCurrentDensity.json index d59571b095..62a5c10735 100644 --- a/Common/UnitDefinitions/ElectricCurrentDensity.json +++ b/Common/UnitDefinitions/ElectricCurrentDensity.json @@ -31,8 +31,8 @@ "L": "Inch", "I": "Ampere" }, - "FromUnitToBaseFunc": "{x} * 1.5500031000062000e3", - "FromBaseToUnitFunc": "{x} / 1.5500031000062000e3", + "FromUnitToBaseFunc": "{x} / 0.00064516", + "FromBaseToUnitFunc": "{x} * 0.00064516", "Localization": [ { "Culture": "en-US", @@ -47,8 +47,8 @@ "L": "Foot", "I": "Ampere" }, - "FromUnitToBaseFunc": "{x} * 1.0763910416709722e1", - "FromBaseToUnitFunc": "{x} / 1.0763910416709722e1", + "FromUnitToBaseFunc": "{x} / 9.290304e-2", + "FromBaseToUnitFunc": "{x} * 9.290304e-2", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/ElectricImpedance.json b/Common/UnitDefinitions/ElectricImpedance.json index 26c63c8540..74ce901203 100644 --- a/Common/UnitDefinitions/ElectricImpedance.json +++ b/Common/UnitDefinitions/ElectricImpedance.json @@ -14,6 +14,12 @@ { "SingularName": "Ohm", "PluralName": "Ohms", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "I": "Ampere" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Kilo", "Mega", "Giga", "Tera" ], diff --git a/Common/UnitDefinitions/ElectricInductance.json b/Common/UnitDefinitions/ElectricInductance.json index 54f55a2c7a..bd361f6153 100644 --- a/Common/UnitDefinitions/ElectricInductance.json +++ b/Common/UnitDefinitions/ElectricInductance.json @@ -13,6 +13,12 @@ { "SingularName": "Henry", "PluralName": "Henries", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "I": "Ampere" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Pico", "Nano", "Micro", "Milli" ], diff --git a/Common/UnitDefinitions/ElectricPotentialAc.json b/Common/UnitDefinitions/ElectricPotentialAc.json deleted file mode 100644 index d1f24e7306..0000000000 --- a/Common/UnitDefinitions/ElectricPotentialAc.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "Name": "ElectricPotentialAc", - "BaseUnit": "VoltAc", - "XmlDocSummary": "The Electric Potential of a system known to use Alternating Current.", - "XmlDocRemarks": "ElectricPotentialAc has been merged into ElectricPotential, and will be removed in a later major version. If you want to map more parameters into the ElectricPotential class (volts RMS, phase angle, etc.), create your own wrapper type such as a record or named tuple.", - "ObsoleteText": "ElectricPotentialAc has been merged into ElectricPotential, and will be removed in a later major version. If you want to map more parameters into the ElectricPotential class (volts RMS, phase angle, etc.), create your own wrapper type such as a record or named tuple.", - "Units": [ - { - "SingularName": "VoltAc", - "PluralName": "VoltsAc", - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", - "Prefixes": [ "Micro", "Milli", "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "Vac" ] - } - ] - } - ] -} diff --git a/Common/UnitDefinitions/ElectricPotentialChangeRate.json b/Common/UnitDefinitions/ElectricPotentialChangeRate.json index ed81c5aa1d..9e7a1916a8 100644 --- a/Common/UnitDefinitions/ElectricPotentialChangeRate.json +++ b/Common/UnitDefinitions/ElectricPotentialChangeRate.json @@ -11,7 +11,7 @@ "Units": [ { "SingularName": "VoltPerSecond", - "PluralName": "VoltsPerSeconds", + "PluralName": "VoltsPerSecond", "BaseUnits": { "L": "Meter", "M": "Kilogram", @@ -30,7 +30,7 @@ }, { "SingularName": "VoltPerMicrosecond", - "PluralName": "VoltsPerMicroseconds", + "PluralName": "VoltsPerMicrosecond", "BaseUnits": { "L": "Meter", "M": "Kilogram", @@ -49,7 +49,7 @@ }, { "SingularName": "VoltPerMinute", - "PluralName": "VoltsPerMinutes", + "PluralName": "VoltsPerMinute", "BaseUnits": { "L": "Meter", "M": "Kilogram", @@ -68,7 +68,7 @@ }, { "SingularName": "VoltPerHour", - "PluralName": "VoltsPerHours", + "PluralName": "VoltsPerHour", "BaseUnits": { "L": "Meter", "M": "Kilogram", diff --git a/Common/UnitDefinitions/ElectricPotentialDc.json b/Common/UnitDefinitions/ElectricPotentialDc.json deleted file mode 100644 index a79efda133..0000000000 --- a/Common/UnitDefinitions/ElectricPotentialDc.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "Name": "ElectricPotentialDc", - "BaseUnit": "VoltDc", - "XmlDocSummary": "The Electric Potential of a system known to use Direct Current.", - "XmlDocRemarks": "ElectricPotentialDc has been merged into ElectricPotential, and will be removed in a later major version. If you want to map more parameters into the ElectricPotential class (volts RMS, phase angle, etc.), create your own wrapper type such as a record or named tuple.", - "ObsoleteText": "ElectricPotentialDc has been merged into ElectricPotential, and will be removed in a later major version. If you want to map more parameters into the ElectricPotential class (volts RMS, phase angle, etc.), create your own wrapper type such as a record or named tuple.", - "Units": [ - { - "SingularName": "VoltDc", - "PluralName": "VoltsDc", - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", - "Prefixes": [ "Micro", "Milli", "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "Vdc" ] - } - ] - } - ] -} diff --git a/Common/UnitDefinitions/ElectricReactance.json b/Common/UnitDefinitions/ElectricReactance.json index fb18130d88..80de1301eb 100644 --- a/Common/UnitDefinitions/ElectricReactance.json +++ b/Common/UnitDefinitions/ElectricReactance.json @@ -13,6 +13,12 @@ { "SingularName": "Ohm", "PluralName": "Ohms", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "I": "Ampere" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Kilo", "Mega", "Giga", "Tera" ], diff --git a/Common/UnitDefinitions/ElectricReactivePower.json b/Common/UnitDefinitions/ElectricReactivePower.json index 8a689161ab..bfcd783412 100644 --- a/Common/UnitDefinitions/ElectricReactivePower.json +++ b/Common/UnitDefinitions/ElectricReactivePower.json @@ -12,6 +12,11 @@ { "SingularName": "VoltampereReactive", "PluralName": "VoltamperesReactive", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega", "Giga" ], diff --git a/Common/UnitDefinitions/ElectricResistance.json b/Common/UnitDefinitions/ElectricResistance.json index edc5c60ece..d705ee2be9 100644 --- a/Common/UnitDefinitions/ElectricResistance.json +++ b/Common/UnitDefinitions/ElectricResistance.json @@ -13,6 +13,12 @@ { "SingularName": "Ohm", "PluralName": "Ohms", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "I": "Ampere" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Kilo", "Mega", "Giga", "Tera" ], diff --git a/Common/UnitDefinitions/ElectricResistivity.json b/Common/UnitDefinitions/ElectricResistivity.json index 66a90070fb..4d8f621272 100644 --- a/Common/UnitDefinitions/ElectricResistivity.json +++ b/Common/UnitDefinitions/ElectricResistivity.json @@ -13,6 +13,12 @@ { "SingularName": "OhmMeter", "PluralName": "OhmMeters", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "I": "Ampere" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Pico", "Nano", "Micro", "Milli", "Kilo", "Mega" ], diff --git a/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json b/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json index 471a6f828a..41091cb4c8 100644 --- a/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json +++ b/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json @@ -51,8 +51,8 @@ "T": "Second", "I": "Ampere" }, - "FromUnitToBaseFunc": "{x} * 1.5500031000062000e3", - "FromBaseToUnitFunc": "{x} / 1.5500031000062000e3", + "FromUnitToBaseFunc": "{x} / 0.00064516", + "FromBaseToUnitFunc": "{x} * 0.00064516", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/ElectricSusceptance.json b/Common/UnitDefinitions/ElectricSusceptance.json index 05e8ad37cf..8eeea029e8 100644 --- a/Common/UnitDefinitions/ElectricSusceptance.json +++ b/Common/UnitDefinitions/ElectricSusceptance.json @@ -13,6 +13,12 @@ { "SingularName": "Siemens", "PluralName": "Siemens", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "I": "Ampere" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Kilo", "Mega", "Giga", "Tera" ], diff --git a/Common/UnitDefinitions/Energy.json b/Common/UnitDefinitions/Energy.json index 7e48f0bdf2..c12d3a934f 100644 --- a/Common/UnitDefinitions/Energy.json +++ b/Common/UnitDefinitions/Energy.json @@ -55,8 +55,10 @@ { "SingularName": "ElectronVolt", "PluralName": "ElectronVolts", - "FromUnitToBaseFunc": "{x} * 1.602176565e-19", - "FromBaseToUnitFunc": "{x} / 1.602176565e-19", + "XmlDocSummary": "In physics, an electronvolt (symbol eV, also written electron-volt and electron volt) is the measure of an amount of kinetic energy gained by a single electron accelerating from rest through an electric potential difference of one volt in vacuum. When used as a unit of energy, the numerical value of 1 eV in joules (symbol J) is equivalent to the numerical value of the charge of an electron in coulombs (symbol C). Under the 2019 redefinition of the SI base units, this sets 1 eV equal to the exact value 1.602176634×10−19 J.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electronvolt", + "FromUnitToBaseFunc": "{x} * 1.602176634e-19", + "FromBaseToUnitFunc": "{x} / 1.602176634e-19", "Prefixes": [ "Kilo", "Mega", @@ -77,8 +79,10 @@ { "SingularName": "FootPound", "PluralName": "FootPounds", - "FromUnitToBaseFunc": "{x} * 1.355817948", - "FromBaseToUnitFunc": "{x} / 1.355817948", + "XmlDocSummary": "A pound-foot (lb⋅ft), abbreviated from pound-force foot (lbf · ft), is a unit of torque representing one pound of force acting at a perpendicular distance of one foot from a pivot point. Conversely one foot pound-force (ft · lbf) is the moment about an axis that applies one pound-force at a radius of one foot.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Pound-foot_(torque)", + "FromUnitToBaseFunc": "{x} * 1.3558179483314004", + "FromBaseToUnitFunc": "{x} / 1.3558179483314004", "Localization": [ { "Culture": "en-US", @@ -89,6 +93,8 @@ { "SingularName": "Erg", "PluralName": "Ergs", + "XmlDocSummary": "The erg is a unit of energy equal to 10−7 joules (100 nJ). It originated in the Centimetre–gram–second system of units (CGS). It has the symbol erg. The erg is not an SI unit. Its name is derived from ergon (ἔργον), a Greek word meaning 'work' or 'task'.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Erg", "FromUnitToBaseFunc": "{x} * 1e-7", "FromBaseToUnitFunc": "{x} / 1e-7", "Localization": [ @@ -135,6 +141,8 @@ { "SingularName": "ThermEc", "PluralName": "ThermsEc", + "XmlDocSummary": "The therm (symbol, thm) is a non-SI unit of heat energy equal to 100,000 British thermal units (BTU), and approximately 105 megajoules, 29.3 kilowatt-hours, 25,200 kilocalories and 25.2 thermies. One therm is the energy content of approximately 100 cubic feet (2.83 cubic metres) of natural gas at standard temperature and pressure. However, the BTU is not standardised worldwide, with slightly different values in the EU, UK, and United States, meaning that the energy content of the therm also varies by territory.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Therm", "FromUnitToBaseFunc": "{x} * 1.05505585262e8", "FromBaseToUnitFunc": "{x} / 1.05505585262e8", "Prefixes": [ "Deca" ], @@ -154,6 +162,8 @@ { "SingularName": "ThermUs", "PluralName": "ThermsUs", + "XmlDocSummary": "The therm (symbol, thm) is a non-SI unit of heat energy equal to 100,000 British thermal units (BTU), and approximately 105 megajoules, 29.3 kilowatt-hours, 25,200 kilocalories and 25.2 thermies. One therm is the energy content of approximately 100 cubic feet (2.83 cubic metres) of natural gas at standard temperature and pressure. However, the BTU is not standardised worldwide, with slightly different values in the EU, UK, and United States, meaning that the energy content of the therm also varies by territory.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Therm", "FromUnitToBaseFunc": "{x} * 1.054804e8", "FromBaseToUnitFunc": "{x} / 1.054804e8", "Prefixes": [ "Deca" ], @@ -173,6 +183,8 @@ { "SingularName": "ThermImperial", "PluralName": "ThermsImperial", + "XmlDocSummary": "The therm (symbol, thm) is a non-SI unit of heat energy equal to 100,000 British thermal units (BTU), and approximately 105 megajoules, 29.3 kilowatt-hours, 25,200 kilocalories and 25.2 thermies. One therm is the energy content of approximately 100 cubic feet (2.83 cubic metres) of natural gas at standard temperature and pressure. However, the BTU is not standardised worldwide, with slightly different values in the EU, UK, and United States, meaning that the energy content of the therm also varies by territory.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Therm", "FromUnitToBaseFunc": "{x} * 1.05505585257348e8", "FromBaseToUnitFunc": "{x} / 1.05505585257348e8", "Prefixes": [ "Deca" ], @@ -192,8 +204,10 @@ { "SingularName": "HorsepowerHour", "PluralName": "HorsepowerHours", - "FromUnitToBaseFunc": "{x} * 2.6845195377e6", - "FromBaseToUnitFunc": "{x} / 2.6845195377e6", + "XmlDocSummary": "A horsepower-hour (symbol: hp⋅h) is an outdated unit of energy, not used in the International System of Units. The unit represents an amount of work a horse is supposed capable of delivering during an hour (1 horsepower integrated over a time interval of an hour).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower-hour", + "FromUnitToBaseFunc": "{x} * 76.0402249 * 9.80665 * 3600", + "FromBaseToUnitFunc": "{x} / (76.0402249 * 9.80665 * 3600)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/Entropy.json b/Common/UnitDefinitions/Entropy.json index b523c8dd49..1ac13b4c54 100644 --- a/Common/UnitDefinitions/Entropy.json +++ b/Common/UnitDefinitions/Entropy.json @@ -12,6 +12,12 @@ { "SingularName": "JoulePerKelvin", "PluralName": "JoulesPerKelvin", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second", + "Θ": "Kelvin" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], @@ -38,6 +44,12 @@ { "SingularName": "JoulePerDegreeCelsius", "PluralName": "JoulesPerDegreeCelsius", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second", + "Θ": "DegreeCelsius" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo" ], diff --git a/Common/UnitDefinitions/Force.json b/Common/UnitDefinitions/Force.json index 675b046598..040f7f749b 100644 --- a/Common/UnitDefinitions/Force.json +++ b/Common/UnitDefinitions/Force.json @@ -112,11 +112,6 @@ { "SingularName": "Poundal", "PluralName": "Poundals", - "BaseUnits": { - "L": "Foot", - "M": "Pound", - "T": "Second" - }, "FromUnitToBaseFunc": "{x} * 0.138254954376", "FromBaseToUnitFunc": "{x} / 0.138254954376", "XmlDocSummary": "The poundal is defined as the force necessary to accelerate 1 pound-mass at 1 foot per second per second. 1 pdl = 0.138254954376 N exactly.", diff --git a/Common/UnitDefinitions/ForceChangeRate.json b/Common/UnitDefinitions/ForceChangeRate.json index 08bb0d754f..8546b4f364 100644 --- a/Common/UnitDefinitions/ForceChangeRate.json +++ b/Common/UnitDefinitions/ForceChangeRate.json @@ -24,6 +24,11 @@ { "SingularName": "NewtonPerSecond", "PluralName": "NewtonsPerSecond", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Kilo" ], @@ -37,8 +42,8 @@ { "SingularName": "PoundForcePerMinute", "PluralName": "PoundsForcePerMinute", - "FromUnitToBaseFunc": "{x} * 4.4482216152605095551842641431421 / 60", - "FromBaseToUnitFunc": "{x} / 4.4482216152605095551842641431421 * 60", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 60", + "FromBaseToUnitFunc": "{x} / 4.4482216152605 * 60", "Prefixes": [ "Kilo" ], "Localization": [ { @@ -51,8 +56,8 @@ { "SingularName": "PoundForcePerSecond", "PluralName": "PoundsForcePerSecond", - "FromUnitToBaseFunc": "{x} * 4.4482216152605095551842641431421", - "FromBaseToUnitFunc": "{x} / 4.4482216152605095551842641431421", + "FromUnitToBaseFunc": "{x} * 4.4482216152605", + "FromBaseToUnitFunc": "{x} / 4.4482216152605", "Prefixes": [ "Kilo" ], "Localization": [ { diff --git a/Common/UnitDefinitions/ForcePerLength.json b/Common/UnitDefinitions/ForcePerLength.json index c5fdb2533a..a5209a996f 100644 --- a/Common/UnitDefinitions/ForcePerLength.json +++ b/Common/UnitDefinitions/ForcePerLength.json @@ -10,6 +10,10 @@ { "SingularName": "NewtonPerMeter", "PluralName": "NewtonsPerMeter", + "BaseUnits": { + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Kilo", "Mega" ], @@ -49,8 +53,8 @@ { "SingularName": "KilogramForcePerMeter", "PluralName": "KilogramsForcePerMeter", - "FromUnitToBaseFunc": "{x} * 9.80665002864", - "FromBaseToUnitFunc": "{x} / 9.80665002864", + "FromUnitToBaseFunc": "{x} * 9.80665", + "FromBaseToUnitFunc": "{x} / 9.80665", "Localization": [ { "Culture": "en-US", @@ -65,8 +69,8 @@ { "SingularName": "KilogramForcePerCentimeter", "PluralName": "KilogramsForcePerCentimeter", - "FromUnitToBaseFunc": "{x} * 980.665002864", - "FromBaseToUnitFunc": "{x} / 980.665002864", + "FromUnitToBaseFunc": "{x} * 980.665", + "FromBaseToUnitFunc": "{x} / 980.665", "Localization": [ { "Culture": "en-US", @@ -81,8 +85,8 @@ { "SingularName": "KilogramForcePerMillimeter", "PluralName": "KilogramsForcePerMillimeter", - "FromUnitToBaseFunc": "{x} * 9.80665002864e3", - "FromBaseToUnitFunc": "{x} / 9.80665002864e3", + "FromUnitToBaseFunc": "{x} * 9.80665e3", + "FromBaseToUnitFunc": "{x} / 9.80665e3", "Localization": [ { "Culture": "en-US", @@ -97,8 +101,8 @@ { "SingularName": "TonneForcePerMeter", "PluralName": "TonnesForcePerMeter", - "FromUnitToBaseFunc": "{x} * 9.80665002864e3", - "FromBaseToUnitFunc": "{x} / 9.80665002864e3", + "FromUnitToBaseFunc": "{x} * 9.80665e3", + "FromBaseToUnitFunc": "{x} / 9.80665e3", "Localization": [ { "Culture": "en-US", @@ -113,8 +117,8 @@ { "SingularName": "TonneForcePerCentimeter", "PluralName": "TonnesForcePerCentimeter", - "FromUnitToBaseFunc": "{x} * 9.80665002864e5", - "FromBaseToUnitFunc": "{x} / 9.80665002864e5", + "FromUnitToBaseFunc": "{x} * 9.80665e5", + "FromBaseToUnitFunc": "{x} / 9.80665e5", "Localization": [ { "Culture": "en-US", @@ -129,8 +133,8 @@ { "SingularName": "TonneForcePerMillimeter", "PluralName": "TonnesForcePerMillimeter", - "FromUnitToBaseFunc": "{x} * 9.80665002864e6", - "FromBaseToUnitFunc": "{x} / 9.80665002864e6", + "FromUnitToBaseFunc": "{x} * 9.80665e6", + "FromBaseToUnitFunc": "{x} / 9.80665e6", "Localization": [ { "Culture": "en-US", @@ -145,8 +149,8 @@ { "SingularName": "PoundForcePerFoot", "PluralName": "PoundsForcePerFoot", - "FromUnitToBaseFunc": "{x} * 14.59390292", - "FromBaseToUnitFunc": "{x} / 14.59390292", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048 / 4.4482216152605", "Localization": [ { "Culture": "en-US", @@ -157,8 +161,8 @@ { "SingularName": "PoundForcePerInch", "PluralName": "PoundsForcePerInch", - "FromUnitToBaseFunc": "{x} * 1.75126835e2", - "FromBaseToUnitFunc": "{x} / 1.75126835e2", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 2.54e-2", + "FromBaseToUnitFunc": "{x} * 2.54e-2 / 4.4482216152605", "Localization": [ { "Culture": "en-US", @@ -169,8 +173,8 @@ { "SingularName": "PoundForcePerYard", "PluralName": "PoundsForcePerYard", - "FromUnitToBaseFunc": "{x} * 4.864634307", - "FromBaseToUnitFunc": "{x} / 4.864634307", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 0.9144", + "FromBaseToUnitFunc": "{x} * 0.9144 / 4.4482216152605", "Localization": [ { "Culture": "en-US", @@ -181,8 +185,8 @@ { "SingularName": "KilopoundForcePerFoot", "PluralName": "KilopoundsForcePerFoot", - "FromUnitToBaseFunc": "{x} * 14593.90292", - "FromBaseToUnitFunc": "{x} / 14593.90292", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 0.3048e-3", + "FromBaseToUnitFunc": "{x} * 0.3048e-3 / 4.4482216152605", "Localization": [ { "Culture": "en-US", @@ -190,11 +194,11 @@ } ] }, - { + { "SingularName": "KilopoundForcePerInch", "PluralName": "KilopoundsForcePerInch", - "FromUnitToBaseFunc": "{x} * 1.75126835e5", - "FromBaseToUnitFunc": "{x} / 1.75126835e5", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 2.54e-5", + "FromBaseToUnitFunc": "{x} * 2.54e-5 / 4.4482216152605", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/Frequency.json b/Common/UnitDefinitions/Frequency.json index 8bbf4f1862..d51919c73f 100644 --- a/Common/UnitDefinitions/Frequency.json +++ b/Common/UnitDefinitions/Frequency.json @@ -9,6 +9,9 @@ { "SingularName": "Hertz", "PluralName": "Hertz", + "BaseUnits": { + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Micro", "Milli", "Kilo", "Mega", "Giga", "Tera" ], @@ -26,8 +29,10 @@ { "SingularName": "RadianPerSecond", "PluralName": "RadiansPerSecond", - "FromUnitToBaseFunc": "{x} / 6.2831853072", - "FromBaseToUnitFunc": "{x} * 6.2831853072", + "XmlDocSummary": "In SI units, angular frequency is normally presented with the unit radian per second, and need not express a rotational value. The unit hertz (Hz) is dimensionally equivalent, but by convention it is only used for frequency f, never for angular frequency ω. This convention is used to help avoid the confusion that arises when dealing with quantities such as frequency and angular quantities because the units of measure (such as cycle or radian) are considered to be one and hence may be omitted when expressing quantities in terms of SI units.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Angular_frequency", + "FromUnitToBaseFunc": "{x} / (2 * Math.PI)", + "FromBaseToUnitFunc": "{x} * (2 * Math.PI)", "OmitExtensionMethod": true, "Localization": [ { @@ -43,6 +48,9 @@ { "SingularName": "CyclePerMinute", "PluralName": "CyclesPerMinute", + "BaseUnits": { + "T": "Minute" + }, "FromUnitToBaseFunc": "{x} / 60", "FromBaseToUnitFunc": "{x} * 60", "Localization": [ @@ -55,6 +63,9 @@ { "SingularName": "CyclePerHour", "PluralName": "CyclesPerHour", + "BaseUnits": { + "T": "Hour" + }, "FromUnitToBaseFunc": "{x} / 3600", "FromBaseToUnitFunc": "{x} * 3600", "Localization": [ @@ -67,6 +78,9 @@ { "SingularName": "BeatPerMinute", "PluralName": "BeatsPerMinute", + "BaseUnits": { + "T": "Minute" + }, "FromUnitToBaseFunc": "{x} / 60", "FromBaseToUnitFunc": "{x} * 60", "Localization": [ @@ -79,6 +93,9 @@ { "SingularName": "PerSecond", "PluralName": "PerSecond", + "BaseUnits": { + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ @@ -91,18 +108,6 @@ "Abbreviations": [ "с⁻¹" ] } ] - }, - { - "SingularName": "BUnit", - "PluralName": "BUnits", - "FromUnitToBaseFunc": "Math.Sqrt({x} * 1e3)", - "FromBaseToUnitFunc": "{x} * {x} * 1e-3", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "B Units" ] - } - ] } ] } diff --git a/Common/UnitDefinitions/FuelEfficiency.json b/Common/UnitDefinitions/FuelEfficiency.json index d0a27ce366..d018d437ba 100644 --- a/Common/UnitDefinitions/FuelEfficiency.json +++ b/Common/UnitDefinitions/FuelEfficiency.json @@ -1,55 +1,67 @@ { - "Name": "FuelEfficiency", - "BaseUnit": "LiterPer100Kilometers", - "XmlDocSummary": "Fuel efficiency is a form of thermal efficiency, meaning the ratio from effort to result of a process that converts chemical potential energy contained in a carrier (fuel) into kinetic energy or work. Fuel economy is stated as \"fuel consumption\" in liters per 100 kilometers (L/100 km). In countries using non-metric system, fuel economy is expressed in miles per gallon (mpg) (imperial galon or US galon).", - "XmlDocRemarks": "https://en.wikipedia.org/wiki/Fuel_efficiency", - "Units": [{ - "SingularName": "LiterPer100Kilometers", - "PluralName": "LitersPer100Kilometers", - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", - "Localization": [{ + "Name": "FuelEfficiency", + "BaseUnit": "KilometerPerLiter", + "XmlDocSummary": "In the context of transport, fuel economy is the energy efficiency of a particular vehicle, given as a ratio of distance traveled per unit of fuel consumed. In most countries, using the metric system, fuel economy is stated as \"fuel consumption\" in liters per 100 kilometers (L/100 km) or kilometers per liter (km/L or kmpl). In countries using non-metric system, fuel economy is expressed in miles per gallon (mpg) (imperial galon or US galon).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Fuel_efficiency", + "BaseDimensions": { + "L": -2 + }, + "Units": [ + { + "SingularName": "LiterPer100Kilometers", + "PluralName": "LitersPer100Kilometers", + "FromUnitToBaseFunc": "100 / {x}", + "FromBaseToUnitFunc": "100 / {x}", + "Localization": [ + { "Culture": "en-US", "Abbreviations": [ - "L/100km" + "l/100km" ] - }] - }, - { - "SingularName": "MilePerUsGallon", - "PluralName": "MilesPerUsGallon", - "FromUnitToBaseFunc": "(100 * 3.785411784) / (1.609344 * {x})", - "FromBaseToUnitFunc": "(100 * 3.785411784) / (1.609344 * {x})", - "Localization": [{ + } + ] + }, + { + "SingularName": "MilePerUsGallon", + "PluralName": "MilesPerUsGallon", + "FromUnitToBaseFunc": "{x} * 1.609344 / 3.785411784", + "FromBaseToUnitFunc": "{x} * 3.785411784 / 1.609344", + "Localization": [ + { "Culture": "en-US", "Abbreviations": [ "mpg (U.S.)" ] - }] - }, - { - "SingularName": "MilePerUkGallon", - "PluralName": "MilesPerUkGallon", - "FromUnitToBaseFunc": "(100 * 4.54609188) / (1.609344 * {x})", - "FromBaseToUnitFunc": "(100 * 4.54609188) / (1.609344 * {x})", - "Localization": [{ + } + ] + }, + { + "SingularName": "MilePerUkGallon", + "PluralName": "MilesPerUkGallon", + "FromUnitToBaseFunc": "{x} * 1.609344 / 4.54609", + "FromBaseToUnitFunc": "{x} * 4.54609 / 1.609344", + "Localization": [ + { "Culture": "en-US", "Abbreviations": [ "mpg (imp.)" ] - }] - }, - { - "SingularName": "KilometerPerLiter", - "PluralName": "KilometersPerLiters", - "FromUnitToBaseFunc": "100 / {x}", - "FromBaseToUnitFunc": "100 / {x}", - "Localization": [{ + } + ] + }, + { + "SingularName": "KilometerPerLiter", + "PluralName": "KilometersPerLiter", + "FromUnitToBaseFunc": "{x}", + "FromBaseToUnitFunc": "{x}", + "Localization": [ + { "Culture": "en-US", "Abbreviations": [ - "km/L" + "km/l" ] - }] - } - ] - } \ No newline at end of file + } + ] + } + ] +} \ No newline at end of file diff --git a/Common/UnitDefinitions/HeatFlux.json b/Common/UnitDefinitions/HeatFlux.json index 2fd41d7dc7..9d3204a3dd 100644 --- a/Common/UnitDefinitions/HeatFlux.json +++ b/Common/UnitDefinitions/HeatFlux.json @@ -27,8 +27,8 @@ { "SingularName": "WattPerSquareInch", "PluralName": "WattsPerSquareInch", - "FromUnitToBaseFunc": "{x} * 1.5500031e3", - "FromBaseToUnitFunc": "{x} / 1.5500031e3", + "FromUnitToBaseFunc": "{x} / (2.54e-2 * 2.54e-2)", + "FromBaseToUnitFunc": "{x} * (2.54e-2 * 2.54e-2)", "Localization": [ { "Culture": "en-US", @@ -39,8 +39,8 @@ { "SingularName": "WattPerSquareFoot", "PluralName": "WattsPerSquareFoot", - "FromUnitToBaseFunc": "{x} * 1.07639e1", - "FromBaseToUnitFunc": "{x} / 1.07639e1", + "FromUnitToBaseFunc": "{x} / (0.3048 * 0.3048)", + "FromBaseToUnitFunc": "{x} * (0.3048 * 0.3048)", "Localization": [ { "Culture": "en-US", @@ -51,81 +51,85 @@ { "SingularName": "BtuPerSecondSquareInch", "PluralName": "BtusPerSecondSquareInch", - "FromUnitToBaseFunc": "{x} * 1.63533984e6", - "FromBaseToUnitFunc": "{x} / 1.63533984e6", + "XmlDocRemarks": "Based on the International Table (IT) definition of the British thermal unit (BTU), where 1 BTU is defined as exactly 1055.05585262 joules (≈1.05506 kJ). See https://en.wikipedia.org/wiki/British_thermal_unit for details.", + "FromUnitToBaseFunc": "{x} * 1055.05585262 / (2.54e-2 * 2.54e-2)", + "FromBaseToUnitFunc": "{x} * (2.54e-2 * 2.54e-2) / 1055.05585262", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "BTU/s·in²" ] + "Abbreviations": [ "BTU/(s·in²)" ] } ] }, { "SingularName": "BtuPerSecondSquareFoot", "PluralName": "BtusPerSecondSquareFoot", - "FromUnitToBaseFunc": "{x} * 1.13565267e4", - "FromBaseToUnitFunc": "{x} / 1.13565267e4", + "XmlDocRemarks": "Based on the International Table (IT) definition of the British thermal unit (BTU), where 1 BTU is defined as exactly 1055.05585262 joules (≈1.05506 kJ). See https://en.wikipedia.org/wiki/British_thermal_unit for details.", + "FromUnitToBaseFunc": "{x} * 1055.05585262 / (0.3048 * 0.3048)", + "FromBaseToUnitFunc": "{x} * (0.3048 * 0.3048) / 1055.05585262", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "BTU/s·ft²" ] + "Abbreviations": [ "BTU/(s·ft²)" ] } ] }, { "SingularName": "BtuPerMinuteSquareFoot", "PluralName": "BtusPerMinuteSquareFoot", - "FromUnitToBaseFunc": "{x} * 1.89275445e2", - "FromBaseToUnitFunc": "{x} / 1.89275445e2", + "XmlDocRemarks": "Based on the International Table (IT) definition of the British thermal unit (BTU), where 1 BTU is defined as exactly 1055.05585262 joules (≈1.05506 kJ). See https://en.wikipedia.org/wiki/British_thermal_unit for details.", + "FromUnitToBaseFunc": "{x} * 1055.05585262 / (0.3048 * 0.3048 * 60)", + "FromBaseToUnitFunc": "{x} * (0.3048 * 0.3048 * 60) / 1055.05585262", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "BTU/min·ft²" ] + "Abbreviations": [ "BTU/(min·ft²)" ] } ] }, { "SingularName": "BtuPerHourSquareFoot", "PluralName": "BtusPerHourSquareFoot", - "FromUnitToBaseFunc": "{x} * 3.15459075", - "FromBaseToUnitFunc": "{x} / 3.15459075", + "XmlDocRemarks": "Based on the International Table (IT) definition of the British thermal unit (BTU), where 1 BTU is defined as exactly 1055.05585262 joules (≈1.05506 kJ). See https://en.wikipedia.org/wiki/British_thermal_unit for details.", + "FromUnitToBaseFunc": "{x} * 1055.05585262 / (0.3048 * 0.3048 * 3600)", + "FromBaseToUnitFunc": "{x} * (0.3048 * 0.3048 * 3600) / 1055.05585262", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "BTU/h·ft²" ] + "Abbreviations": [ "BTU/(h·ft²)" ] } ] }, { "SingularName": "CaloriePerSecondSquareCentimeter", "PluralName": "CaloriesPerSecondSquareCentimeter", - "FromUnitToBaseFunc": "{x} * 4.1868e4", - "FromBaseToUnitFunc": "{x} / 4.1868e4", + "FromUnitToBaseFunc": "{x} * 4.184e4", + "FromBaseToUnitFunc": "{x} / 4.184e4", "Prefixes": [ "Kilo" ], "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "cal/s·cm²" ] + "Abbreviations": [ "cal/(s·cm²)" ] } ] }, { "SingularName": "KilocaloriePerHourSquareMeter", "PluralName": "KilocaloriesPerHourSquareMeter", - "FromUnitToBaseFunc": "{x} * 1.163", - "FromBaseToUnitFunc": "{x} / 1.163", + "FromUnitToBaseFunc": "{x} * 4.184e3 / 3600", + "FromBaseToUnitFunc": "{x} * 3600 / 4.184e3", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "kcal/h·m²" ] + "Abbreviations": [ "kcal/(h·m²)" ] } ] }, { "SingularName": "PoundForcePerFootSecond", "PluralName": "PoundsForcePerFootSecond", - "FromUnitToBaseFunc": "{x} * 1.459390293720636e1", - "FromBaseToUnitFunc": "{x} / 1.459390293720636e1", + "FromUnitToBaseFunc": "{x} * 1.3558179483314004 / 9.290304e-2", + "FromBaseToUnitFunc": "{x} * 9.290304e-2 / 1.3558179483314004", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/HeatTransferCoefficient.json b/Common/UnitDefinitions/HeatTransferCoefficient.json index 75db786ba7..f3108375f2 100644 --- a/Common/UnitDefinitions/HeatTransferCoefficient.json +++ b/Common/UnitDefinitions/HeatTransferCoefficient.json @@ -11,49 +11,46 @@ { "SingularName": "WattPerSquareMeterKelvin", "PluralName": "WattsPerSquareMeterKelvin", + "BaseUnits": { + "M": "Kilogram", + "T": "Second", + "Θ": "Kelvin" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "W/m²·K" ] + "Abbreviations": [ "W/(m²·K)" ] } ] }, { "SingularName": "WattPerSquareMeterCelsius", "PluralName": "WattsPerSquareMeterCelsius", + "BaseUnits": { + "M": "Kilogram", + "T": "Second", + "Θ": "DegreeCelsius" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "W/m²·°C" ] - } - ] - }, - { - "SingularName": "BtuPerSquareFootDegreeFahrenheit", - "PluralName": "BtusPerSquareFootDegreeFahrenheit", - "ObsoleteText": "The name of this definition incorrectly omitted time as divisor, please use BtuPerHourSquareFootDegreeFahrenheit instead", - "FromUnitToBaseFunc": "{x} * 5.6782633411134878", - "FromBaseToUnitFunc": "{x} / 5.6782633411134878", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "Btu/ft²·°F" ] + "Abbreviations": [ "W/(m²·°C)" ] } ] }, { "SingularName": "BtuPerHourSquareFootDegreeFahrenheit", "PluralName": "BtusPerHourSquareFootDegreeFahrenheit", - "FromUnitToBaseFunc": "{x} * 5.6782633411134878", - "FromBaseToUnitFunc": "{x} / 5.6782633411134878", + "FromUnitToBaseFunc": "{x} * ((1055.05585262 / (0.3048 * 0.3048 * 3600)) * 1.8)", + "FromBaseToUnitFunc": "{x} / ((1055.05585262 / (0.3048 * 0.3048 * 3600)) * 1.8)", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "Btu/h·ft²·°F", "Btu/ft²·h·°F", "Btu/hr·ft²·°F", "Btu/ft²·hr·°F" ] + "Abbreviations": [ "Btu/(h·ft²·°F)", "Btu/(ft²·h·°F)", "Btu/(hr·ft²·°F)", "Btu/(ft²·hr·°F)" ] } ] }, @@ -61,12 +58,12 @@ "SingularName": "CaloriePerHourSquareMeterDegreeCelsius", "PluralName": "CaloriesPerHourSquareMeterDegreeCelsius", "Prefixes": [ "Kilo" ], - "FromUnitToBaseFunc": "({x} * 4.1868) / 3600", - "FromBaseToUnitFunc": "({x} / 4.1868) * 3600", + "FromUnitToBaseFunc": "({x} * 4.184) / 3600", + "FromBaseToUnitFunc": "({x} / 4.184) * 3600", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "kcal/h·m²·°C", "kcal/m²·h·°C", "kcal/hr·m²·°C", "kcal/m²·hr·°C" ] + "Abbreviations": [ "kcal/(h·m²·°C)", "kcal/(m²·h·°C)", "kcal/(hr·m²·°C)", "kcal/(m²·hr·°C)" ] } ] } diff --git a/Common/UnitDefinitions/Illuminance.json b/Common/UnitDefinitions/Illuminance.json index 2c8b07c52f..187b9d1226 100644 --- a/Common/UnitDefinitions/Illuminance.json +++ b/Common/UnitDefinitions/Illuminance.json @@ -11,6 +11,10 @@ { "SingularName": "Lux", "PluralName": "Lux", + "BaseUnits": { + "L": "Meter", + "J": "Candela" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Milli", "Kilo", "Mega" ], diff --git a/Common/UnitDefinitions/Impulse.json b/Common/UnitDefinitions/Impulse.json index bc111e0103..193041b8ed 100644 --- a/Common/UnitDefinitions/Impulse.json +++ b/Common/UnitDefinitions/Impulse.json @@ -11,6 +11,11 @@ { "SingularName": "KilogramMeterPerSecond", "PluralName": "KilogramMetersPerSecond", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ @@ -23,6 +28,11 @@ { "SingularName": "NewtonSecond", "PluralName": "NewtonSeconds", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Kilo", "Mega" ], @@ -36,8 +46,13 @@ { "SingularName": "PoundFootPerSecond", "PluralName": "PoundFeetPerSecond", - "FromUnitToBaseFunc": "{x} / 7.230657989877", - "FromBaseToUnitFunc": "{x} * 7.230657989877", + "BaseUnits": { + "L": "Foot", + "M": "Pound", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * (0.45359237 * 0.3048)", + "FromBaseToUnitFunc": "{x} / (0.45359237 * 0.3048)", "Localization": [ { "Culture": "en-US", @@ -48,8 +63,8 @@ { "SingularName": "PoundForceSecond", "PluralName": "PoundForceSeconds", - "FromUnitToBaseFunc": "{x} / 0.2248089430997", - "FromBaseToUnitFunc": "{x} * 0.2248089430997", + "FromUnitToBaseFunc": "{x} * 0.45359237 * 9.80665", + "FromBaseToUnitFunc": "{x} / (0.45359237 * 9.80665)", "Localization": [ { "Culture": "en-US", @@ -60,8 +75,13 @@ { "SingularName": "SlugFootPerSecond", "PluralName": "SlugFeetPerSecond", - "FromUnitToBaseFunc": "{x} / 0.224735720691", - "FromBaseToUnitFunc": "{x} * 0.224735720691", + "BaseUnits": { + "L": "Foot", + "M": "Slug", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * (0.45359237 * 9.80665)", + "FromBaseToUnitFunc": "{x} / (0.45359237 * 9.80665)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/Information.json b/Common/UnitDefinitions/Information.json index 39cb9f0636..f327f00ca5 100644 --- a/Common/UnitDefinitions/Information.json +++ b/Common/UnitDefinitions/Information.json @@ -1,14 +1,13 @@ { "Name": "Information", "BaseUnit": "Bit", - "ValueType": "decimal", "XmlDocSummary": "In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables.", "Units": [ { "SingularName": "Byte", "PluralName": "Bytes", - "FromUnitToBaseFunc": "{x} * 8m", - "FromBaseToUnitFunc": "{x} / 8m", + "FromUnitToBaseFunc": "{x} * 8", + "FromBaseToUnitFunc": "{x} / 8", "Prefixes": [ "Kilo", "Mega", "Giga", "Tera", "Peta", "Exa", "Kibi", "Mebi", "Gibi", "Tebi", "Pebi", "Exbi" ], "Localization": [ { diff --git a/Common/UnitDefinitions/Irradiance.json b/Common/UnitDefinitions/Irradiance.json index 6608bdfb98..50d92bb8b9 100644 --- a/Common/UnitDefinitions/Irradiance.json +++ b/Common/UnitDefinitions/Irradiance.json @@ -10,6 +10,10 @@ { "SingularName": "WattPerSquareMeter", "PluralName": "WattsPerSquareMeter", + "BaseUnits": { + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Pico", "Nano", "Micro", "Milli", "Kilo", "Mega" ], diff --git a/Common/UnitDefinitions/Irradiation.json b/Common/UnitDefinitions/Irradiation.json index 3689cd0db4..b80882b633 100644 --- a/Common/UnitDefinitions/Irradiation.json +++ b/Common/UnitDefinitions/Irradiation.json @@ -11,6 +11,10 @@ { "SingularName": "JoulePerSquareMeter", "PluralName": "JoulesPerSquareMeter", + "BaseUnits": { + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo" ], @@ -62,8 +66,8 @@ { "SingularName": "BtuPerSquareFoot", "PluralName": "BtusPerSquareFoot", - "FromUnitToBaseFunc": "{x} * (52752792631d / 4645152d)", - "FromBaseToUnitFunc": "{x} / (52752792631d / 4645152d)", + "FromUnitToBaseFunc": "{x} * 1055.05585262 / 9.290304e-2", + "FromBaseToUnitFunc": "{x} * 9.290304e-2 / 1055.05585262", "Prefixes": [ "Kilo" ], "Localization": [ { diff --git a/Common/UnitDefinitions/Jerk.json b/Common/UnitDefinitions/Jerk.json index c2cf906e84..99d4855f90 100644 --- a/Common/UnitDefinitions/Jerk.json +++ b/Common/UnitDefinitions/Jerk.json @@ -71,10 +71,6 @@ { "SingularName": "StandardGravitiesPerSecond", "PluralName": "StandardGravitiesPerSecond", - "BaseUnits": { - "L": "Meter", - "T": "Second" - }, "FromUnitToBaseFunc": "{x} * 9.80665", "FromBaseToUnitFunc": "{x} / 9.80665", "Prefixes": [ "Milli"], diff --git a/Common/UnitDefinitions/KinematicViscosity.json b/Common/UnitDefinitions/KinematicViscosity.json index 5de0e4c458..a40ec9a10b 100644 --- a/Common/UnitDefinitions/KinematicViscosity.json +++ b/Common/UnitDefinitions/KinematicViscosity.json @@ -11,6 +11,10 @@ { "SingularName": "SquareMeterPerSecond", "PluralName": "SquareMetersPerSecond", + "BaseUnits": { + "L": "Meter", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ @@ -44,8 +48,12 @@ { "SingularName": "SquareFootPerSecond", "PluralName": "SquareFeetPerSecond", - "FromUnitToBaseFunc": "{x} / 10.7639", - "FromBaseToUnitFunc": "{x} * 10.7639", + "BaseUnits": { + "L": "Foot", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 9.290304e-2", + "FromBaseToUnitFunc": "{x} / 9.290304e-2", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/LeakRate.json b/Common/UnitDefinitions/LeakRate.json index 14654f3501..eb4f59919b 100644 --- a/Common/UnitDefinitions/LeakRate.json +++ b/Common/UnitDefinitions/LeakRate.json @@ -12,6 +12,11 @@ { "SingularName": "PascalCubicMeterPerSecond", "PluralName": "PascalCubicMetersPerSecond", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ diff --git a/Common/UnitDefinitions/Length.json b/Common/UnitDefinitions/Length.json index 728e38602a..cb3419436e 100644 --- a/Common/UnitDefinitions/Length.json +++ b/Common/UnitDefinitions/Length.json @@ -90,6 +90,8 @@ "FromUnitToBaseFunc": "{x} * 0.3048", "FromBaseToUnitFunc": "{x} / 0.3048", "Prefixes": [ "Kilo" ], + "XmlDocSummary": "The foot (pl. feet; standard symbol: ft) is a unit of length in the British imperial and United States customary systems of measurement. The prime symbol, ′, is commonly used to represent the foot. In both customary and imperial units, one foot comprises 12 inches, and one yard comprises three feet. Since an international agreement in 1959, the foot is defined as equal to exactly 0.3048 meters.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Foot_(unit)", "Localization": [ { "Culture": "en-US", @@ -130,6 +132,8 @@ }, "FromUnitToBaseFunc": "{x} * 2.54e-2", "FromBaseToUnitFunc": "{x} / 2.54e-2", + "XmlDocSummary": "The inch (symbol: in or ″) is a unit of length in the British Imperial and the United States customary systems of measurement. It is equal to 1/36 yard or 1/12 of a foot. Derived from the Roman uncia (\"twelfth\"), the word inch is also sometimes used to translate similar units in other measurement systems, usually understood as deriving from the width of the human thumb.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Inch", "Localization": [ { "Culture": "en-US", @@ -250,8 +254,10 @@ "BaseUnits": { "L": "PrinterPoint" }, - "FromUnitToBaseFunc": "({x} / 72.27) * 2.54e-2", - "FromBaseToUnitFunc": "({x} / 2.54e-2) * 72.27", + "XmlDocSummary": "In typography, the point is the smallest unit of measure. It is used for measuring font size, leading, and other items on a printed page. In modern times this size of the point has been approximated as exactly 1⁄72.27 (0.01383700013837) of the inch by Donald Knuth for the default unit of his TeX computer typesetting system and is thus sometimes known as the TeX point.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Point_(typography)", + "FromUnitToBaseFunc": "{x} * 2.54e-2 / 72.27 ", + "FromBaseToUnitFunc": "{x} * 72.27 / 2.54e-2", "Localization": [ { "Culture": "en-US", @@ -265,8 +271,10 @@ "BaseUnits": { "L": "DtpPoint" }, - "FromUnitToBaseFunc": "({x} / 72) * 2.54e-2", - "FromBaseToUnitFunc": "({x} / 2.54e-2) * 72", + "XmlDocSummary": "The desktop publishing point (DTP) is defined as 1⁄72 of an inch (1/72 × 25.4 mm ≈ 0.353 mm) and, as with earlier American point sizes, is considered to be 1⁄12 of a pica.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Point_(typography)", + "FromUnitToBaseFunc": "{x} * 2.54e-2 / 72", + "FromBaseToUnitFunc": "{x} * 72 / 2.54e-2", "Localization": [ { "Culture": "en-US", @@ -280,8 +288,10 @@ "BaseUnits": { "L": "PrinterPica" }, - "FromUnitToBaseFunc": "{x} / 237.106301584", - "FromBaseToUnitFunc": "{x} * 237.106301584", + "XmlDocSummary": "The American pica of 0.16604 inches (~4.217 mm) was established by the United States Type Founders' Association in 1886. In TeX one pica is 400⁄2409 of an inch.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Pica_(typography)", + "FromUnitToBaseFunc": "{x} * 2.54e-2 * 400 / 2409", + "FromBaseToUnitFunc": "{x} / (2.54e-2 * 400 / 2409)", "Localization": [ { "Culture": "en-US", @@ -295,8 +305,10 @@ "BaseUnits": { "L": "DtpPica" }, - "FromUnitToBaseFunc": "{x} / 236.220472441", - "FromBaseToUnitFunc": "{x} * 236.220472441", + "XmlDocSummary": "The pica is a typographic unit of measure corresponding to approximately 1⁄6 of an inch, or from 1⁄68 to 1⁄73 of a foot. One pica is further divided into 12 points.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Pica_(typography)", + "FromUnitToBaseFunc": "{x} * 2.54e-2 / 6", + "FromBaseToUnitFunc": "{x} * 6 / 2.54e-2", "Localization": [ { "Culture": "en-US", @@ -310,8 +322,10 @@ "BaseUnits": { "L": "Twip" }, - "FromUnitToBaseFunc": "{x} / 56692.913385826", - "FromBaseToUnitFunc": "{x} * 56692.913385826", + "XmlDocSummary": "A twip (abbreviating \"twentieth of a point\" or \"twentieth of an inch point\") is a typographical measurement, defined as 1⁄20 of a typographical point. One twip is 1⁄1440 inch, or ~17.64 μm.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Twip", + "FromUnitToBaseFunc": "{x} * 2.54e-2 / 1440", + "FromBaseToUnitFunc": "{x} * 1440 / 2.54e-2", "Localization": [ { "Culture": "en-US", @@ -325,6 +339,8 @@ "BaseUnits": { "L": "Hand" }, + "XmlDocSummary": "The hand is a non-SI unit of measurement of length standardized to 4 in (101.6 mm). It is used to measure the height of horses in many English-speaking countries, including Australia, Canada, Ireland, the United Kingdom, and the United States. It was originally based on the breadth of a human hand.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Hand_(unit)", "FromUnitToBaseFunc": "{x} * 1.016e-1", "FromBaseToUnitFunc": "{x} / 1.016e-1", "Localization": [ @@ -337,6 +353,9 @@ { "SingularName": "AstronomicalUnit", "PluralName": "AstronomicalUnits", + "BaseUnits": { + "L": "AstronomicalUnit" + }, "FromUnitToBaseFunc": "{x} * 1.4959787070e11", "FromBaseToUnitFunc": "{x} / 1.4959787070e11", "XmlDocSummary": "One Astronomical Unit is the distance from the solar system Star, the sun, to planet Earth.", @@ -351,6 +370,9 @@ { "SingularName": "Parsec", "PluralName": "Parsecs", + "BaseUnits": { + "L": "Parsec" + }, "FromUnitToBaseFunc": "{x} * 3.08567758128e16", "FromBaseToUnitFunc": "{x} / 3.08567758128e16", "XmlDocSummary": "A parsec is defined as the distance at which one astronomical unit (AU) subtends an angle of one arcsecond.", @@ -366,6 +388,9 @@ { "SingularName": "LightYear", "PluralName": "LightYears", + "BaseUnits": { + "L": "LightYear" + }, "FromUnitToBaseFunc": "{x} * 9.46073047258e15", "FromBaseToUnitFunc": "{x} / 9.46073047258e15", "XmlDocSummary": "A Light Year (ly) is the distance that light travel during an Earth year, ie 365 days.", @@ -381,6 +406,9 @@ { "SingularName": "SolarRadius", "PluralName": "SolarRadiuses", + "BaseUnits": { + "L": "SolarRadius" + }, "FromUnitToBaseFunc": "{x} * 6.95700e8", "FromBaseToUnitFunc": "{x} / 6.95700e8", "XmlDocSummary": "Solar radius is a ratio unit to the radius of the solar system star, the sun.", @@ -398,6 +426,8 @@ "BaseUnits": { "L": "Chain" }, + "XmlDocSummary": "The chain (abbreviated ch) is a unit of length equal to 66 feet (22 yards), used in both the US customary and Imperial unit systems. It is subdivided into 100 links. There are 10 chains in a furlong, and 80 chains in one statute mile. In metric terms, it is 20.1168 m long.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Chain_(unit)", "FromUnitToBaseFunc": "{x} * 20.1168", "FromBaseToUnitFunc": "{x} / 20.1168", "Localization": [ @@ -410,6 +440,9 @@ { "SingularName": "Angstrom", "PluralName": "Angstroms", + "BaseUnits": { + "L": "Angstrom" + }, "FromUnitToBaseFunc": "{x} * 1e-10", "FromBaseToUnitFunc": "{x} / 1e-10", "XmlDocSummary": "Angstrom is a metric unit of length equal to 1e-10 meter", @@ -424,6 +457,9 @@ { "SingularName": "DataMile", "PluralName": "DataMiles", + "BaseUnits": { + "L": "DataMile" + }, "FromUnitToBaseFunc": "{x} * 1828.8", "FromBaseToUnitFunc": "{x} / 1828.8", "XmlDocSummary": "In radar-related subjects and in JTIDS, a data mile is a unit of distance equal to 6000 feet (1.8288 kilometres or 0.987 nautical miles).", diff --git a/Common/UnitDefinitions/LinearDensity.json b/Common/UnitDefinitions/LinearDensity.json index 7d08f3b9a8..966badfbfb 100644 --- a/Common/UnitDefinitions/LinearDensity.json +++ b/Common/UnitDefinitions/LinearDensity.json @@ -11,6 +11,10 @@ { "SingularName": "GramPerMillimeter", "PluralName": "GramsPerMillimeter", + "BaseUnits": { + "M": "Gram", + "L": "Millimeter" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Micro", "Milli", "Kilo" ], @@ -24,6 +28,10 @@ { "SingularName": "GramPerCentimeter", "PluralName": "GramsPerCentimeter", + "BaseUnits": { + "M": "Gram", + "L": "Centimeter" + }, "FromUnitToBaseFunc": "{x} * 1e-1", "FromBaseToUnitFunc": "{x} / 1e-1", "Prefixes": [ "Micro", "Milli", "Kilo" ], @@ -37,6 +45,10 @@ { "SingularName": "GramPerMeter", "PluralName": "GramsPerMeter", + "BaseUnits": { + "M": "Gram", + "L": "Meter" + }, "FromUnitToBaseFunc": "{x} * 1e-3", "FromBaseToUnitFunc": "{x} / 1e-3", "Prefixes": [ "Micro", "Milli", "Kilo" ], @@ -50,8 +62,12 @@ { "SingularName": "PoundPerInch", "PluralName": "PoundsPerInch", - "FromUnitToBaseFunc": "{x} / 5.5997415e-2", - "FromBaseToUnitFunc": "{x} * 5.5997415e-2", + "BaseUnits": { + "M": "Pound", + "L": "Inch" + }, + "FromUnitToBaseFunc": "{x} * 0.45359237 / 2.54e-2", + "FromBaseToUnitFunc": "{x} * 2.54e-2 / 0.45359237", "Localization": [ { "Culture": "en-US", @@ -62,8 +78,12 @@ { "SingularName": "PoundPerFoot", "PluralName": "PoundsPerFoot", - "FromUnitToBaseFunc": "{x} * 1.48816394", - "FromBaseToUnitFunc": "{x} / 1.48816394", + "BaseUnits": { + "M": "Pound", + "L": "Foot" + }, + "FromUnitToBaseFunc": "{x} * 0.45359237 / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048 / 0.45359237", "Localization": [ { "Culture": "en-US", @@ -74,6 +94,10 @@ { "SingularName": "GramPerFoot", "PluralName": "GramsPerFoot", + "BaseUnits": { + "M": "Gram", + "L": "Foot" + }, "FromUnitToBaseFunc": "{x} * ( 1e-3 / 0.3048 )", "FromBaseToUnitFunc": "{x} / ( 1e-3 / 0.3048 )", "Prefixes": [ "Micro", "Milli", "Kilo" ], diff --git a/Common/UnitDefinitions/LinearPowerDensity.json b/Common/UnitDefinitions/LinearPowerDensity.json index 2802ee7aa1..cc0ccfe824 100644 --- a/Common/UnitDefinitions/LinearPowerDensity.json +++ b/Common/UnitDefinitions/LinearPowerDensity.json @@ -12,9 +12,14 @@ { "SingularName": "WattPerMeter", "PluralName": "WattsPerMeter", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", - "Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ], + "Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ], "Localization": [ { "Culture": "en-US", @@ -27,7 +32,7 @@ "PluralName": "WattsPerCentimeter", "FromUnitToBaseFunc": "{x} * 1e2", "FromBaseToUnitFunc": "{x} / 1e2", - "Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ], + "Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ], "Localization": [ { "Culture": "en-US", @@ -35,12 +40,12 @@ } ] }, - { + { "SingularName": "WattPerMillimeter", "PluralName": "WattsPerMillimeter", "FromUnitToBaseFunc": "{x} * 1e3", "FromBaseToUnitFunc": "{x} / 1e3", - "Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ], + "Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ], "Localization": [ { "Culture": "en-US", @@ -51,9 +56,9 @@ { "SingularName": "WattPerInch", "PluralName": "WattsPerInch", - "FromUnitToBaseFunc": "{x} * 39.37007874", - "FromBaseToUnitFunc": "{x} / 39.37007874", - "Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ], + "FromUnitToBaseFunc": "{x} / 2.54e-2", + "FromBaseToUnitFunc": "{x} * 2.54e-2", + "Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ], "Localization": [ { "Culture": "en-US", @@ -64,9 +69,9 @@ { "SingularName": "WattPerFoot", "PluralName": "WattsPerFoot", - "FromUnitToBaseFunc": "{x} * 3.280839895", - "FromBaseToUnitFunc": "{x} / 3.280839895", - "Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ], + "FromUnitToBaseFunc": "{x} / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048", + "Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ], "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/Luminance.json b/Common/UnitDefinitions/Luminance.json index adda90e9ff..0784d0047c 100644 --- a/Common/UnitDefinitions/Luminance.json +++ b/Common/UnitDefinitions/Luminance.json @@ -26,11 +26,11 @@ } ] }, - { + { "SingularName": "CandelaPerSquareFoot", "PluralName": "CandelasPerSquareFoot", - "FromUnitToBaseFunc": "{x}* 1.07639e1", - "FromBaseToUnitFunc": "{x}/ 1.07639e1", + "FromUnitToBaseFunc": "{x} / 9.290304e-2", + "FromBaseToUnitFunc": "{x} * 9.290304e-2", "Localization": [ { "Culture": "en-US", @@ -38,11 +38,11 @@ } ] }, - { + { "SingularName": "CandelaPerSquareInch", "PluralName": "CandelasPerSquareInch", - "FromUnitToBaseFunc": "{x}* 1.5500031e3", - "FromBaseToUnitFunc": "{x}/ 1.5500031e3", + "FromUnitToBaseFunc": "{x} / 0.00064516", + "FromBaseToUnitFunc": "{x} * 0.00064516", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/Luminosity.json b/Common/UnitDefinitions/Luminosity.json index e0caa0eab7..149b53b773 100644 --- a/Common/UnitDefinitions/Luminosity.json +++ b/Common/UnitDefinitions/Luminosity.json @@ -12,6 +12,11 @@ { "SingularName": "Watt", "PluralName": "Watts", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Femto", "Pico", "Nano", "Micro", "Milli", "Deci", "Deca", "Kilo", "Mega", "Giga", "Tera", "Peta" ], @@ -25,9 +30,10 @@ { "SingularName": "SolarLuminosity", "PluralName": "SolarLuminosities", - "FromUnitToBaseFunc": "{x} * 3.846e26", - "FromBaseToUnitFunc": "{x} / 3.846e26", - "XmlDocRemarks": "https://www.britannica.com/science/luminosity", + "XmlDocSummary": "The IAU has defined a nominal solar luminosity of 3.828×10^26 W to promote publication of consistent and comparable values in units of the solar luminosity.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminosity#Measurement", + "FromUnitToBaseFunc": "{x} * 3.828e26", + "FromBaseToUnitFunc": "{x} / 3.828e26", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/LuminousFlux.json b/Common/UnitDefinitions/LuminousFlux.json index 844a6f2b69..f0d77ce38c 100644 --- a/Common/UnitDefinitions/LuminousFlux.json +++ b/Common/UnitDefinitions/LuminousFlux.json @@ -10,6 +10,9 @@ { "SingularName": "Lumen", "PluralName": "Lumens", + "BaseUnits": { + "J": "Candela" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ diff --git a/Common/UnitDefinitions/MagneticField.json b/Common/UnitDefinitions/MagneticField.json index 4f356e2650..644e3c32c8 100644 --- a/Common/UnitDefinitions/MagneticField.json +++ b/Common/UnitDefinitions/MagneticField.json @@ -12,6 +12,11 @@ { "SingularName": "Tesla", "PluralName": "Teslas", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "I": "Ampere" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli" ], diff --git a/Common/UnitDefinitions/MagneticFlux.json b/Common/UnitDefinitions/MagneticFlux.json index 5307d9fad3..be32c3baf8 100644 --- a/Common/UnitDefinitions/MagneticFlux.json +++ b/Common/UnitDefinitions/MagneticFlux.json @@ -13,6 +13,12 @@ { "SingularName": "Weber", "PluralName": "Webers", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "I": "Ampere" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ diff --git a/Common/UnitDefinitions/Mass.json b/Common/UnitDefinitions/Mass.json index 1c2cfff129..711e3c53ce 100644 --- a/Common/UnitDefinitions/Mass.json +++ b/Common/UnitDefinitions/Mass.json @@ -36,6 +36,8 @@ "BaseUnits": { "M": "Tonne" }, + "XmlDocSummary": "The tonne is a unit of mass equal to 1,000 kilograms. It is a non-SI unit accepted for use with SI. It is also referred to as a metric ton in the United States to distinguish it from the non-metric units of the short ton (United States customary units) and the long ton (British imperial units). It is equivalent to approximately 2,204.6 pounds, 1.102 short tons, and 0.984 long tons.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Tonne", "FromUnitToBaseFunc": "{x} * 1e3", "FromBaseToUnitFunc": "{x} / 1e3", "Prefixes": [ "Kilo", "Mega" ], @@ -60,10 +62,10 @@ "BaseUnits": { "M": "ShortTon" }, - "FromUnitToBaseFunc": "{x} * 9.0718474e2", - "FromBaseToUnitFunc": "{x} / 9.0718474e2", "XmlDocSummary": "The short ton is a unit of mass equal to 2,000 pounds (907.18474 kg), that is most commonly used in the United States – known there simply as the ton.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Short_ton", + "FromUnitToBaseFunc": "{x} * 907.18474", + "FromBaseToUnitFunc": "{x} / 907.18474", "Localization": [ { "Culture": "en-US", @@ -85,10 +87,10 @@ "BaseUnits": { "M": "LongTon" }, - "FromUnitToBaseFunc": "{x} * 1.0160469088e3", - "FromBaseToUnitFunc": "{x} / 1.0160469088e3", "XmlDocSummary": "Long ton (weight ton or Imperial ton) is a unit of mass equal to 2,240 pounds (1,016 kg) and is the name for the unit called the \"ton\" in the avoirdupois or Imperial system of measurements that was used in the United Kingdom and several other Commonwealth countries before metrication.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Long_ton", + "FromUnitToBaseFunc": "{x} * 1016.0469088", + "FromBaseToUnitFunc": "{x} / 1016.0469088", "Localization": [ { "Culture": "en-US", @@ -110,10 +112,10 @@ "BaseUnits": { "M": "Pound" }, - "FromUnitToBaseFunc": "{x} * 0.45359237", - "FromBaseToUnitFunc": "{x} / 0.45359237", "XmlDocSummary": "The pound or pound-mass (abbreviations: lb, lbm) is a unit of mass used in the imperial, United States customary and other systems of measurement. A number of different definitions have been used, the most common today being the international avoirdupois pound which is legally defined as exactly 0.45359237 kilograms, and which is divided into 16 avoirdupois ounces.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Pound_(mass)", + "FromUnitToBaseFunc": "{x} * 0.45359237", + "FromBaseToUnitFunc": "{x} / 0.45359237", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { @@ -136,10 +138,10 @@ "BaseUnits": { "M": "Ounce" }, - "FromUnitToBaseFunc": "{x} * 0.028349523125", - "FromBaseToUnitFunc": "{x} / 0.028349523125", "XmlDocSummary": "The international avoirdupois ounce (abbreviated oz) is defined as exactly 28.349523125 g under the international yard and pound agreement of 1959, signed by the United States and countries of the Commonwealth of Nations. 16 oz make up an avoirdupois pound.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Ounce", + "FromUnitToBaseFunc": "{x} * 0.028349523125", + "FromBaseToUnitFunc": "{x} / 0.028349523125", "Localization": [ { "Culture": "en-US", @@ -157,10 +159,10 @@ "BaseUnits": { "M": "Slug" }, - "FromUnitToBaseFunc": "{x} / 6.852176556196105e-2", - "FromBaseToUnitFunc": "{x} * 6.852176556196105e-2", "XmlDocSummary": "The slug (abbreviation slug) is a unit of mass that is accelerated by 1 ft/s² when a force of one pound (lbf) is exerted on it.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Slug_(unit)", + "FromUnitToBaseFunc": "{x} * 0.45359237 * 9.80665 / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048 / (0.45359237 * 9.80665)", "Localization": [ { "Culture": "en-US", @@ -174,10 +176,10 @@ "BaseUnits": { "M": "Stone" }, - "FromUnitToBaseFunc": "{x} / 0.1574731728702698", - "FromBaseToUnitFunc": "{x} * 0.1574731728702698", "XmlDocSummary": "The stone (abbreviation st) is a unit of mass equal to 14 pounds avoirdupois (about 6.35 kilograms) used in Great Britain and Ireland for measuring human body weight.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Stone_(unit)", + "FromUnitToBaseFunc": "{x} * 6.35029318", + "FromBaseToUnitFunc": "{x} / 6.35029318", "Localization": [ { "Culture": "en-US", @@ -191,10 +193,10 @@ "BaseUnits": { "M": "ShortHundredweight" }, - "FromUnitToBaseFunc": "{x} / 0.022046226218487758", - "FromBaseToUnitFunc": "{x} * 0.022046226218487758", "XmlDocSummary": "The short hundredweight (abbreviation cwt) is a unit of mass equal to 100 pounds in US and Canada. In British English, the short hundredweight is referred to as the \"cental\".", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Hundredweight", + "FromUnitToBaseFunc": "{x} * 45.359237", + "FromBaseToUnitFunc": "{x} / 45.359237", "Localization": [ { "Culture": "en-US", @@ -208,10 +210,10 @@ "BaseUnits": { "M": "LongHundredweight" }, - "FromUnitToBaseFunc": "{x} / 0.01968413055222121", - "FromBaseToUnitFunc": "{x} * 0.01968413055222121", "XmlDocSummary": "The long or imperial hundredweight (abbreviation cwt) is a unit of mass equal to 112 pounds in US and Canada.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Hundredweight", + "FromUnitToBaseFunc": "{x} * 50.80234544", + "FromBaseToUnitFunc": "{x} / 50.80234544", "Localization": [ { "Culture": "en-US", @@ -225,10 +227,10 @@ "BaseUnits": { "M": "Grain" }, - "FromUnitToBaseFunc": "{x} / 15432.358352941431", - "FromBaseToUnitFunc": "{x} * 15432.358352941431", "XmlDocSummary": "A grain is a unit of measurement of mass, and in the troy weight, avoirdupois, and Apothecaries' system, equal to exactly 64.79891 milligrams.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Grain_(unit)", + "FromUnitToBaseFunc": "{x} * 64.79891e-6", + "FromBaseToUnitFunc": "{x} / 64.79891e-6", "Localization": [ { "Culture": "en-US", @@ -242,10 +244,10 @@ "BaseUnits": { "M": "SolarMass" }, - "FromUnitToBaseFunc": "{x} * 1.98947e30", - "FromBaseToUnitFunc": "{x} / 1.98947e30", "XmlDocSummary": "Solar mass is a ratio unit to the mass of the solar system star, the sun.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Solar_mass", + "FromUnitToBaseFunc": "{x} * 1.98947e30", + "FromBaseToUnitFunc": "{x} / 1.98947e30", "Localization": [ { "Culture": "en-US", @@ -259,10 +261,10 @@ "BaseUnits": { "M": "EarthMass" }, - "FromUnitToBaseFunc": "{x} * 5.9722E+24", - "FromBaseToUnitFunc": "{x} / 5.9722E+24", "XmlDocSummary": "Earth mass is a ratio unit to the mass of planet Earth.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Earth_mass", + "FromUnitToBaseFunc": "{x} * 5.9722E+24", + "FromBaseToUnitFunc": "{x} / 5.9722E+24", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/MassConcentration.json b/Common/UnitDefinitions/MassConcentration.json index a8f7d6097c..851e05a170 100644 --- a/Common/UnitDefinitions/MassConcentration.json +++ b/Common/UnitDefinitions/MassConcentration.json @@ -66,17 +66,13 @@ { "SingularName": "GramPerMicroliter", "PluralName": "GramsPerMicroliter", - "BaseUnits": { - "M": "Gram", - "L": "Centimeter" - }, "FromUnitToBaseFunc": "{x} / 1e-6", "FromBaseToUnitFunc": "{x} * 1e-6", "Prefixes": [ "Pico", "Nano", "Micro", "Milli", "Centi", "Deci" ], "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "g/μL" ] + "Abbreviations": [ "g/μl" ] } ] }, @@ -93,7 +89,7 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "g/mL" ] + "Abbreviations": [ "g/ml" ] } ] }, @@ -106,7 +102,7 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "g/dL" ] + "Abbreviations": [ "g/dl" ] } ] }, @@ -123,7 +119,7 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "g/L"] + "Abbreviations": [ "g/l"] } ] }, @@ -182,8 +178,8 @@ "M": "Pound", "L": "Inch" }, - "FromUnitToBaseFunc": "{x} / 3.6127298147753e-5", - "FromBaseToUnitFunc": "{x} * 3.6127298147753e-5", + "FromUnitToBaseFunc": "{x} * 0.45359237 / 1.6387064e-5", + "FromBaseToUnitFunc": "{x} * 1.6387064e-5 / 0.45359237", "Prefixes": [ "Kilo" ], "Localization": [ { @@ -200,8 +196,8 @@ "M": "Pound", "L": "Foot" }, - "FromUnitToBaseFunc": "{x} / 0.062427961", - "FromBaseToUnitFunc": "{x} * 0.062427961", + "FromUnitToBaseFunc": "{x} * 0.45359237 / 0.028316846592", + "FromBaseToUnitFunc": "{x} * 0.028316846592 / 0.45359237", "Prefixes": [ "Kilo" ], "Localization": [ { @@ -218,8 +214,8 @@ "M": "Slug", "L": "Foot" }, - "FromUnitToBaseFunc": "{x} * 515.378818", - "FromBaseToUnitFunc": "{x} * 0.00194032033", + "FromUnitToBaseFunc": "{x} * (0.45359237 * 9.80665) / (0.3048 * 0.028316846592)", + "FromBaseToUnitFunc": "{x} * (0.3048 * 0.028316846592) / (0.45359237 * 9.80665)", "Localization": [ { "Culture": "en-US", @@ -230,8 +226,8 @@ { "SingularName": "PoundPerUSGallon", "PluralName": "PoundsPerUSGallon", - "FromUnitToBaseFunc": "{x} * 1.19826427e2", - "FromBaseToUnitFunc": "{x} / 1.19826427e2", + "FromUnitToBaseFunc": "{x} * 0.45359237 / 0.003785411784", + "FromBaseToUnitFunc": "{x} * 0.003785411784 / 0.45359237", "Localization": [ { "Culture": "en-US", @@ -239,11 +235,11 @@ } ] }, - { + { "SingularName": "OuncePerUSGallon", "PluralName": "OuncesPerUSGallon", - "FromUnitToBaseFunc": " {x} / 0.1335264711843", - "FromBaseToUnitFunc": "{x} * 0.1335264711843", + "FromUnitToBaseFunc": "{x} * 0.028349523125 / 0.003785411784", + "FromBaseToUnitFunc": "{x} * 0.003785411784 / 0.028349523125", "Localization": [ { "Culture": "en-US", @@ -251,11 +247,11 @@ } ] }, - { + { "SingularName": "OuncePerImperialGallon", "PluralName": "OuncesPerImperialGallon", - "FromUnitToBaseFunc": " {x} / 0.1603586720609", - "FromBaseToUnitFunc": "{x} * 0.1603586720609", + "FromUnitToBaseFunc": "{x} * 0.028349523125 / 0.00454609", + "FromBaseToUnitFunc": "{x} * 0.00454609 / 0.028349523125", "Localization": [ { "Culture": "en-US", @@ -266,8 +262,8 @@ { "SingularName": "PoundPerImperialGallon", "PluralName": "PoundsPerImperialGallon", - "FromUnitToBaseFunc": "{x} * 9.9776398e1", - "FromBaseToUnitFunc": "{x} / 9.9776398e1", + "FromUnitToBaseFunc": "{x} * 0.45359237 / 0.00454609", + "FromBaseToUnitFunc": "{x} * 0.00454609 / 0.45359237", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/MassFlow.json b/Common/UnitDefinitions/MassFlow.json index 509abd6a53..015ce62f12 100644 --- a/Common/UnitDefinitions/MassFlow.json +++ b/Common/UnitDefinitions/MassFlow.json @@ -10,6 +10,10 @@ { "SingularName": "GramPerSecond", "PluralName": "GramsPerSecond", + "BaseUnits": { + "M": "Gram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo" ], @@ -23,6 +27,10 @@ { "SingularName": "GramPerDay", "PluralName": "GramsPerDay", + "BaseUnits": { + "M": "Gram", + "T": "Day" + }, "FromUnitToBaseFunc": "{x} / 86400", "FromBaseToUnitFunc": "{x} * 86400", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo", "Mega" ], @@ -36,6 +44,10 @@ { "SingularName": "GramPerHour", "PluralName": "GramsPerHour", + "BaseUnits": { + "M": "Gram", + "T": "Hour" + }, "FromUnitToBaseFunc": "{x} / 3600", "FromBaseToUnitFunc": "{x} * 3600", "Localization": [ @@ -48,6 +60,10 @@ { "SingularName": "KilogramPerHour", "PluralName": "KilogramsPerHour", + "BaseUnits": { + "M": "Kilogram", + "T": "Hour" + }, "FromUnitToBaseFunc": "{x} / 3.6", "FromBaseToUnitFunc": "{x} * 3.6", "Localization": [ @@ -64,6 +80,10 @@ { "SingularName": "KilogramPerMinute", "PluralName": "KilogramsPerMinute", + "BaseUnits": { + "M": "Kilogram", + "T": "Minute" + }, "FromUnitToBaseFunc": "{x} / 0.06", "FromBaseToUnitFunc": "{x} * 0.06", "Localization": [ @@ -80,7 +100,11 @@ { "SingularName": "TonnePerHour", "PluralName": "TonnesPerHour", - "FromUnitToBaseFunc": "1000 * {x} / 3.6", + "BaseUnits": { + "M": "Tonne", + "T": "Hour" + }, + "FromUnitToBaseFunc": "{x} * 1000 / 3.6", "FromBaseToUnitFunc": "{x} * 3.6 / 1000", "Localization": [ { @@ -92,8 +116,12 @@ { "SingularName": "PoundPerDay", "PluralName": "PoundsPerDay", - "FromUnitToBaseFunc": "{x} / 190.47936", - "FromBaseToUnitFunc": "{x} * 190.47936", + "BaseUnits": { + "M": "Pound", + "T": "Day" + }, + "FromUnitToBaseFunc": "{x} * 453.59237 / 86400", + "FromBaseToUnitFunc": "{x} * 86400 / 453.59237", "Prefixes": [ "Mega" ], "Localization": [ { @@ -105,8 +133,12 @@ { "SingularName": "PoundPerHour", "PluralName": "PoundsPerHour", - "FromUnitToBaseFunc": "{x} / 7.93664", - "FromBaseToUnitFunc": "{x} * 7.93664", + "BaseUnits": { + "M": "Pound", + "T": "Hour" + }, + "FromUnitToBaseFunc": "{x} * 453.59237 / 3600", + "FromBaseToUnitFunc": "{x} * 3600 / 453.59237", "Prefixes": [ "Mega" ], "Localization": [ { @@ -118,8 +150,12 @@ { "SingularName": "PoundPerMinute", "PluralName": "PoundsPerMinute", - "FromUnitToBaseFunc": "{x} / 0.132277", - "FromBaseToUnitFunc": "{x} * 0.132277", + "BaseUnits": { + "M": "Pound", + "T": "Minute" + }, + "FromUnitToBaseFunc": "{x} * 453.59237 / 60", + "FromBaseToUnitFunc": "{x} * 60 / 453.59237", "Prefixes": [ "Mega" ], "Localization": [ { @@ -131,6 +167,10 @@ { "SingularName": "PoundPerSecond", "PluralName": "PoundsPerSecond", + "BaseUnits": { + "M": "Pound", + "T": "Second" + }, "FromUnitToBaseFunc": "{x} * 453.59237", "FromBaseToUnitFunc": "{x} / 453.59237", "Prefixes": [ "Mega" ], @@ -144,6 +184,10 @@ { "SingularName": "TonnePerDay", "PluralName": "TonnesPerDay", + "BaseUnits": { + "M": "Tonne", + "T": "Day" + }, "FromUnitToBaseFunc": "{x} / 0.0864000", "FromBaseToUnitFunc": "{x} * 0.0864000", "Localization": [ @@ -156,8 +200,12 @@ { "SingularName": "ShortTonPerHour", "PluralName": "ShortTonsPerHour", - "FromUnitToBaseFunc": "{x} * 251.9957611", - "FromBaseToUnitFunc": "{x} / 251.9957611", + "BaseUnits": { + "M": "ShortTon", + "T": "Hour" + }, + "FromUnitToBaseFunc": "{x} * 907.18474 / 3.6", + "FromBaseToUnitFunc": "{x} * 3.6 / 907.18474", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/MassFlux.json b/Common/UnitDefinitions/MassFlux.json index fe66af7430..c3bcc9bdc0 100644 --- a/Common/UnitDefinitions/MassFlux.json +++ b/Common/UnitDefinitions/MassFlux.json @@ -11,6 +11,11 @@ { "SingularName": "GramPerSecondPerSquareMeter", "PluralName": "GramsPerSecondPerSquareMeter", + "BaseUnits": { + "M": "Gram", + "T": "Second", + "L": "Meter" + }, "FromUnitToBaseFunc": "{x} / 1e3", "FromBaseToUnitFunc": "{x} * 1e3", "Prefixes": [ "Kilo" ], @@ -24,6 +29,11 @@ { "SingularName": "GramPerSecondPerSquareCentimeter", "PluralName": "GramsPerSecondPerSquareCentimeter", + "BaseUnits": { + "M": "Gram", + "T": "Second", + "L": "Centimeter" + }, "FromUnitToBaseFunc": "{x} / 1e-1", "FromBaseToUnitFunc": "{x} * 1e-1", "Prefixes": [ "Kilo" ], @@ -37,6 +47,11 @@ { "SingularName": "GramPerSecondPerSquareMillimeter", "PluralName": "GramsPerSecondPerSquareMillimeter", + "BaseUnits": { + "M": "Gram", + "T": "Second", + "L": "Millimeter" + }, "FromUnitToBaseFunc": "{x} / 1e-3", "FromBaseToUnitFunc": "{x} * 1e-3", "Prefixes": [ "Kilo" ], @@ -50,6 +65,11 @@ { "SingularName": "GramPerHourPerSquareMeter", "PluralName": "GramsPerHourPerSquareMeter", + "BaseUnits": { + "M": "Gram", + "T": "Hour", + "L": "Meter" + }, "FromUnitToBaseFunc": "{x} / 3.6e6", "FromBaseToUnitFunc": "{x} * 3.6e6", "Prefixes": [ "Kilo" ], @@ -63,6 +83,11 @@ { "SingularName": "GramPerHourPerSquareCentimeter", "PluralName": "GramsPerHourPerSquareCentimeter", + "BaseUnits": { + "M": "Gram", + "T": "Hour", + "L": "Centimeter" + }, "FromUnitToBaseFunc": "{x} / 3.6e2", "FromBaseToUnitFunc": "{x} * 3.6e2", "Prefixes": [ "Kilo" ], @@ -76,6 +101,11 @@ { "SingularName": "GramPerHourPerSquareMillimeter", "PluralName": "GramsPerHourPerSquareMillimeter", + "BaseUnits": { + "M": "Gram", + "T": "Hour", + "L": "Millimeter" + }, "FromUnitToBaseFunc": "{x} / 3.6e0", "FromBaseToUnitFunc": "{x} * 3.6e0", "Prefixes": [ "Kilo" ], diff --git a/Common/UnitDefinitions/MassMomentOfInertia.json b/Common/UnitDefinitions/MassMomentOfInertia.json index 87f7a4ee11..bacf328d60 100644 --- a/Common/UnitDefinitions/MassMomentOfInertia.json +++ b/Common/UnitDefinitions/MassMomentOfInertia.json @@ -10,6 +10,10 @@ { "SingularName": "GramSquareMeter", "PluralName": "GramSquareMeters", + "BaseUnits": { + "L": "Meter", + "M": "Gram" + }, "FromUnitToBaseFunc": "{x} / 1e3", "FromBaseToUnitFunc": "{x} * 1e3", "Prefixes": [ "Milli", "Kilo" ], @@ -23,6 +27,10 @@ { "SingularName": "GramSquareDecimeter", "PluralName": "GramSquareDecimeters", + "BaseUnits": { + "L": "Decimeter", + "M": "Gram" + }, "FromUnitToBaseFunc": "{x} / 1e5", "FromBaseToUnitFunc": "{x} * 1e5", "Prefixes": [ "Milli", "Kilo" ], @@ -36,6 +44,10 @@ { "SingularName": "GramSquareCentimeter", "PluralName": "GramSquareCentimeters", + "BaseUnits": { + "L": "Centimeter", + "M": "Gram" + }, "FromUnitToBaseFunc": "{x} / 1e7", "FromBaseToUnitFunc": "{x} * 1e7", "Prefixes": [ "Milli", "Kilo" ], @@ -49,6 +61,10 @@ { "SingularName": "GramSquareMillimeter", "PluralName": "GramSquareMillimeters", + "BaseUnits": { + "L": "Millimeter", + "M": "Gram" + }, "FromUnitToBaseFunc": "{x} / 1e9", "FromBaseToUnitFunc": "{x} * 1e9", "Prefixes": [ "Milli", "Kilo" ], @@ -62,6 +78,10 @@ { "SingularName": "TonneSquareMeter", "PluralName": "TonneSquareMeters", + "BaseUnits": { + "L": "Meter", + "M": "Tonne" + }, "FromUnitToBaseFunc": "{x} / 1e-3", "FromBaseToUnitFunc": "{x} * 1e-3", "Prefixes": [ "Kilo", "Mega" ], @@ -75,6 +95,10 @@ { "SingularName": "TonneSquareDecimeter", "PluralName": "TonneSquareDecimeters", + "BaseUnits": { + "L": "Decimeter", + "M": "Tonne" + }, "FromUnitToBaseFunc": "{x} / 1e-1", "FromBaseToUnitFunc": "{x} * 1e-1", "Prefixes": [ "Kilo", "Mega" ], @@ -88,6 +112,10 @@ { "SingularName": "TonneSquareCentimeter", "PluralName": "TonneSquareCentimeters", + "BaseUnits": { + "L": "Centimeter", + "M": "Tonne" + }, "FromUnitToBaseFunc": "{x} / 1e1", "FromBaseToUnitFunc": "{x} * 1e1", "Prefixes": [ "Kilo", "Mega" ], @@ -99,8 +127,12 @@ ] }, { - "SingularName": "TonneSquareMilimeter", - "PluralName": "TonneSquareMilimeters", + "SingularName": "TonneSquareMillimeter", + "PluralName": "TonneSquareMillimeters", + "BaseUnits": { + "L": "Millimeter", + "M": "Tonne" + }, "FromUnitToBaseFunc": "{x} / 1e3", "FromBaseToUnitFunc": "{x} * 1e3", "Prefixes": [ "Kilo", "Mega" ], @@ -114,8 +146,12 @@ { "SingularName": "PoundSquareFoot", "PluralName": "PoundSquareFeet", - "FromUnitToBaseFunc": "{x} * 4.21401101e-2", - "FromBaseToUnitFunc": "{x} / 4.21401101e-2", + "BaseUnits": { + "L": "Foot", + "M": "Pound" + }, + "FromUnitToBaseFunc": "{x} * (0.45359237 * 9.290304e-2)", + "FromBaseToUnitFunc": "{x} / (0.45359237 * 9.290304e-2)", "Localization": [ { "Culture": "en-US", @@ -126,8 +162,12 @@ { "SingularName": "PoundSquareInch", "PluralName": "PoundSquareInches", - "FromUnitToBaseFunc": "{x} * 2.9263965e-4", - "FromBaseToUnitFunc": "{x} / 2.9263965e-4", + "BaseUnits": { + "L": "Inch", + "M": "Pound" + }, + "FromUnitToBaseFunc": "{x} * (0.45359237 * 0.00064516)", + "FromBaseToUnitFunc": "{x} / (0.45359237 * 0.00064516)", "Localization": [ { "Culture": "en-US", @@ -138,8 +178,12 @@ { "SingularName": "SlugSquareFoot", "PluralName": "SlugSquareFeet", - "FromUnitToBaseFunc": "{x} * 1.3558179619", - "FromBaseToUnitFunc": "{x} / 1.3558179619", + "BaseUnits": { + "L": "Foot", + "M": "Slug" + }, + "FromUnitToBaseFunc": "{x} * 0.45359237 * 9.290304e-2 * 9.80665 / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048 / (0.45359237 * 9.290304e-2 * 9.80665)", "Localization": [ { "Culture": "en-US", @@ -150,8 +194,12 @@ { "SingularName": "SlugSquareInch", "PluralName": "SlugSquareInches", - "FromUnitToBaseFunc": "{x} * 9.41540242e-3", - "FromBaseToUnitFunc": "{x} / 9.41540242e-3", + "BaseUnits": { + "L": "Inch", + "M": "Slug" + }, + "FromUnitToBaseFunc": "{x} * 0.45359237 * 0.00064516 * 9.80665 / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048 / (0.45359237 * 0.00064516 * 9.80665)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/MolarEnergy.json b/Common/UnitDefinitions/MolarEnergy.json index 93add4f13e..2855d507d8 100644 --- a/Common/UnitDefinitions/MolarEnergy.json +++ b/Common/UnitDefinitions/MolarEnergy.json @@ -12,6 +12,12 @@ { "SingularName": "JoulePerMole", "PluralName": "JoulesPerMole", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "N": "Mole" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], diff --git a/Common/UnitDefinitions/MolarEntropy.json b/Common/UnitDefinitions/MolarEntropy.json index 5179ead524..96032caed6 100644 --- a/Common/UnitDefinitions/MolarEntropy.json +++ b/Common/UnitDefinitions/MolarEntropy.json @@ -13,6 +13,13 @@ { "SingularName": "JoulePerMoleKelvin", "PluralName": "JoulesPerMoleKelvin", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "Θ": "Kelvin", + "N": "Mole" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], diff --git a/Common/UnitDefinitions/MolarMass.json b/Common/UnitDefinitions/MolarMass.json index 36401297c6..edcda34e72 100644 --- a/Common/UnitDefinitions/MolarMass.json +++ b/Common/UnitDefinitions/MolarMass.json @@ -10,6 +10,10 @@ { "SingularName": "GramPerMole", "PluralName": "GramsPerMole", + "BaseUnits": { + "M": "Gram", + "N": "Mole" + }, "FromUnitToBaseFunc": "{x} / 1e3", "FromBaseToUnitFunc": "{x} * 1e3", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo" ], @@ -27,6 +31,10 @@ { "SingularName": "KilogramPerKilomole", "PluralName": "KilogramsPerKilomole", + "BaseUnits": { + "M": "Kilogram", + "N": "Kilomole" + }, "FromUnitToBaseFunc": "{x} / 1e3", "FromBaseToUnitFunc": "{x} * 1e3", "Localization": [ @@ -39,6 +47,10 @@ { "SingularName": "PoundPerMole", "PluralName": "PoundsPerMole", + "BaseUnits": { + "M": "Pound", + "N": "Mole" + }, "FromUnitToBaseFunc": "{x} * 0.45359237", "FromBaseToUnitFunc": "{x} / 0.45359237", "Prefixes": [ "Kilo", "Mega" ], diff --git a/Common/UnitDefinitions/Molarity.json b/Common/UnitDefinitions/Molarity.json index 81a0c605dc..0c2471845f 100644 --- a/Common/UnitDefinitions/Molarity.json +++ b/Common/UnitDefinitions/Molarity.json @@ -38,7 +38,7 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "mol/L", "M" ] + "Abbreviations": [ "mol/l", "M" ] } ] }, @@ -49,8 +49,8 @@ "L": "Foot", "N": "PoundMole" }, - "FromUnitToBaseFunc": "{x} / 6.2427960576144611956325455827221e-5", - "FromBaseToUnitFunc": "{x} * 6.2427960576144611956325455827221e-5", + "FromUnitToBaseFunc": "{x} * 1000 * 0.45359237 / 0.028316846592", + "FromBaseToUnitFunc": "{x} / (1000 * 0.45359237 / 0.028316846592)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/Permeability.json b/Common/UnitDefinitions/Permeability.json index cb6c794fe4..3984be7463 100644 --- a/Common/UnitDefinitions/Permeability.json +++ b/Common/UnitDefinitions/Permeability.json @@ -13,6 +13,12 @@ { "SingularName": "HenryPerMeter", "PluralName": "HenriesPerMeter", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "I": "Ampere" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ diff --git a/Common/UnitDefinitions/Permittivity.json b/Common/UnitDefinitions/Permittivity.json index ebdd6232f1..7ac18b96f6 100644 --- a/Common/UnitDefinitions/Permittivity.json +++ b/Common/UnitDefinitions/Permittivity.json @@ -13,6 +13,12 @@ { "SingularName": "FaradPerMeter", "PluralName": "FaradsPerMeter", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "I": "Ampere" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ diff --git a/Common/UnitDefinitions/PorousMediumPermeability.json b/Common/UnitDefinitions/PorousMediumPermeability.json index 5f6a0f78ae..746e8805ab 100644 --- a/Common/UnitDefinitions/PorousMediumPermeability.json +++ b/Common/UnitDefinitions/PorousMediumPermeability.json @@ -10,6 +10,8 @@ { "SingularName": "Darcy", "PluralName": "Darcys", + "XmlDocSummary": "The darcy (or darcy unit) and millidarcy (md or mD) are units of permeability, named after Henry Darcy. They are not SI units, but they are widely used in petroleum engineering and geology.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Darcy_(unit)", "FromUnitToBaseFunc": "{x} * 9.869233e-13", "FromBaseToUnitFunc": "{x} / 9.869233e-13", "Prefixes": [ "Micro", "Milli" ], diff --git a/Common/UnitDefinitions/Power.json b/Common/UnitDefinitions/Power.json index 0db3f6ea48..c850f494f2 100644 --- a/Common/UnitDefinitions/Power.json +++ b/Common/UnitDefinitions/Power.json @@ -1,7 +1,6 @@ { "Name": "Power", "BaseUnit": "Watt", - "ValueType": "decimal", "XmlDocSummary": "In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time.", "BaseDimensions": { "L": 2, @@ -30,8 +29,10 @@ { "SingularName": "MechanicalHorsepower", "PluralName": "MechanicalHorsepower", - "FromUnitToBaseFunc": "{x} * 745.69m", - "FromBaseToUnitFunc": "{x} / 745.69m", + "XmlDocSummary": "Assuming the third CGPM (1901, CR 70) definition of standard gravity, gn = 9.80665 m/s2, is used to define the pound-force as well as the kilogram force, and the international avoirdupois pound (1959), one imperial horsepower is: 76.0402249 × 9.80665 kg⋅m2/s3", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Imperial_horsepower", + "FromUnitToBaseFunc": "{x} * 76.0402249 * 9.80665", + "FromBaseToUnitFunc": "{x} / (76.0402249 * 9.80665)", "Localization": [ { "Culture": "en-US", @@ -42,8 +43,10 @@ { "SingularName": "MetricHorsepower", "PluralName": "MetricHorsepower", - "FromUnitToBaseFunc": "{x} * 735.49875m", - "FromBaseToUnitFunc": "{x} / 735.49875m", + "XmlDocSummary": "DIN 66036 defines one metric horsepower as the power to raise a mass of 75 kilograms against the Earth's gravitational force over a distance of one metre in one second:[18] 75 kg × 9.80665 m/s2 × 1 m / 1 s = 75 kgf⋅m/s = 1 PS. This is equivalent to 735.49875 W, or 98.6% of an imperial horsepower.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Metric_horsepower_(PS,_KM,_cv,_hk,_pk,_k,_ks,_ch)", + "FromUnitToBaseFunc": "{x} * 75 * 9.80665", + "FromBaseToUnitFunc": "{x} / (75 * 9.80665)", "Localization": [ { "Culture": "en-US", @@ -54,8 +57,10 @@ { "SingularName": "ElectricalHorsepower", "PluralName": "ElectricalHorsepower", - "FromUnitToBaseFunc": "{x} * 746m", - "FromBaseToUnitFunc": "{x} / 746m", + "XmlDocSummary": "Nameplates on electrical motors show their power output, not the power input (the power delivered at the shaft, not the power consumed to drive the motor). This power output is ordinarily stated in watts or kilowatts. In the United States, the power output is stated in horsepower, which for this purpose is defined as exactly 746 W.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Electrical_horsepower", + "FromUnitToBaseFunc": "{x} * 746", + "FromBaseToUnitFunc": "{x} / 746", "Localization": [ { "Culture": "en-US", @@ -66,8 +71,10 @@ { "SingularName": "BoilerHorsepower", "PluralName": "BoilerHorsepower", - "FromUnitToBaseFunc": "{x} * 9812.5m", - "FromBaseToUnitFunc": "{x} / 9812.5m", + "XmlDocSummary": "Boiler horsepower is a boiler's capacity to deliver steam to a steam engine and is not the same unit of power as the 550 ft lb/s definition. One boiler horsepower is equal to the thermal energy rate required to evaporate 34.5 pounds (15.6 kg) of fresh water at 212 °F (100 °C) in one hour.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Boiler_horsepower", + "FromUnitToBaseFunc": "{x} * 9812.5", + "FromBaseToUnitFunc": "{x} / 9812.5", "Localization": [ { "Culture": "en-US", @@ -78,8 +85,10 @@ { "SingularName": "HydraulicHorsepower", "PluralName": "HydraulicHorsepower", - "FromUnitToBaseFunc": "{x} * 745.69988145m", - "FromBaseToUnitFunc": "{x} / 745.69988145m", + "XmlDocSummary": "Hydraulic horsepower can represent the power available within hydraulic machinery, power through the down-hole nozzle of a drilling rig, or can be used to estimate the mechanical power needed to generate a known hydraulic flow rate.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Horsepower#Hydraulic_horsepower", + "FromUnitToBaseFunc": "{x} * 745.69987158227022", + "FromBaseToUnitFunc": "{x} / 745.69987158227022", "Localization": [ { "Culture": "en-US", @@ -90,8 +99,9 @@ { "SingularName": "BritishThermalUnitPerHour", "PluralName": "BritishThermalUnitsPerHour", - "FromUnitToBaseFunc": "{x} * 0.29307107017m", - "FromBaseToUnitFunc": "{x} / 0.29307107017m", + "XmlDocRemarks": "Based on the International Table (IT) definition of the British thermal unit (BTU), where 1 BTU is defined as exactly 1055.05585262 joules (≈1.05506 kJ). See https://en.wikipedia.org/wiki/British_thermal_unit for details.", + "FromUnitToBaseFunc": "{x} * 1055.05585262 / 3600", + "FromBaseToUnitFunc": "{x} * 3600 / 1055.05585262", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { @@ -103,8 +113,8 @@ { "SingularName": "JoulePerHour", "PluralName": "JoulesPerHour", - "FromUnitToBaseFunc": "{x} / 3600m", - "FromBaseToUnitFunc": "{x} * 3600m", + "FromUnitToBaseFunc": "{x} / 3600", + "FromBaseToUnitFunc": "{x} * 3600", "Prefixes": [ "Milli", "Kilo", "Mega", "Giga" ], "Localization": [ { @@ -116,8 +126,8 @@ { "SingularName": "TonOfRefrigeration", "PluralName": "TonsOfRefrigeration", - "FromUnitToBaseFunc": "{x} * 3516.853m", - "FromBaseToUnitFunc": "{x} / 3516.853m", + "FromUnitToBaseFunc": "{x} * 3516.853", + "FromBaseToUnitFunc": "{x} / 3516.853", "Prefixes": [ ], "Localization": [ { diff --git a/Common/UnitDefinitions/PowerDensity.json b/Common/UnitDefinitions/PowerDensity.json index 0318d9cd42..8a4d3fa962 100644 --- a/Common/UnitDefinitions/PowerDensity.json +++ b/Common/UnitDefinitions/PowerDensity.json @@ -29,8 +29,8 @@ { "SingularName": "WattPerCubicInch", "PluralName": "WattsPerCubicInch", - "FromUnitToBaseFunc": "{x} * 6.102374409473228e4", - "FromBaseToUnitFunc": "{x} / 6.102374409473228e4", + "FromUnitToBaseFunc": "{x} / 1.6387064e-5", + "FromBaseToUnitFunc": "{x} * 1.6387064e-5", "Prefixes": [ "Pico", "Nano", "Micro", "Milli", "Deci", "Deca", "Kilo", "Mega", "Giga", "Tera" ], "Localization": [ { @@ -42,8 +42,8 @@ { "SingularName": "WattPerCubicFoot", "PluralName": "WattsPerCubicFoot", - "FromUnitToBaseFunc": "{x} * 3.531466672148859e1", - "FromBaseToUnitFunc": "{x} / 3.531466672148859e1", + "FromUnitToBaseFunc": "{x} / 0.028316846592", + "FromBaseToUnitFunc": "{x} * 0.028316846592", "Prefixes": [ "Pico", "Nano", "Micro", "Milli", "Deci", "Deca", "Kilo", "Mega", "Giga", "Tera" ], "Localization": [ { diff --git a/Common/UnitDefinitions/Pressure.json b/Common/UnitDefinitions/Pressure.json index 663b8007fe..b93674197f 100644 --- a/Common/UnitDefinitions/Pressure.json +++ b/Common/UnitDefinitions/Pressure.json @@ -33,6 +33,8 @@ { "SingularName": "Atmosphere", "PluralName": "Atmospheres", + "XmlDocSummary": "The standard atmosphere (symbol: atm) is a unit of pressure defined as 101325 Pa. It is sometimes used as a reference pressure or standard pressure. It is approximately equal to Earth's average atmospheric pressure at sea level.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Standard_atmosphere_(unit)", "FromUnitToBaseFunc": "{x} * 1.01325 * 1e5", "FromBaseToUnitFunc": "{x} / (1.01325 * 1e5)", "Localization": [ @@ -49,6 +51,8 @@ { "SingularName": "Bar", "PluralName": "Bars", + "XmlDocSummary": "The bar is a metric unit of pressure defined as 100,000 Pa (100 kPa), though not part of the International System of Units (SI). A pressure of 1 bar is slightly less than the current average atmospheric pressure on Earth at sea level (approximately 1.013 bar).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Bar_(unit)", "FromUnitToBaseFunc": "{x} * 1e5", "FromBaseToUnitFunc": "{x} / 1e5", "Prefixes": [ "Micro", "Milli", "Centi", "Deci", "Kilo", "Mega" ], @@ -66,8 +70,8 @@ { "SingularName": "KilogramForcePerSquareMeter", "PluralName": "KilogramsForcePerSquareMeter", - "FromUnitToBaseFunc": "{x} * 9.80665019960652", - "FromBaseToUnitFunc": "{x} * 0.101971619222242", + "FromUnitToBaseFunc": "{x} * 9.80665", + "FromBaseToUnitFunc": "{x} / 9.80665", "Localization": [ { "Culture": "en-US", @@ -82,11 +86,8 @@ { "SingularName": "KilogramForcePerSquareCentimeter", "PluralName": "KilogramsForcePerSquareCentimeter", - "BaseUnits": { - "L": "Centimeter", - "M": "Kilogram", - "T": "Second" - }, + "XmlDocSummary": "A kilogram-force per centimetre square (kgf/cm2), often just kilogram per square centimetre (kg/cm2), or kilopond per centimetre square (kp/cm2) is a deprecated unit of pressure using metric units. It is not a part of the International System of Units (SI), the modern metric system. 1 kgf/cm2 equals 98.0665 kPa (kilopascals). It is also known as a technical atmosphere (symbol: at).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Kilogram-force_per_square_centimetre", "FromUnitToBaseFunc": "{x} * 9.80665e4", "FromBaseToUnitFunc": "{x} / 9.80665e4", "Localization": [ @@ -119,6 +120,11 @@ { "SingularName": "NewtonPerSquareMeter", "PluralName": "NewtonsPerSquareMeter", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], @@ -170,8 +176,10 @@ { "SingularName": "TechnicalAtmosphere", "PluralName": "TechnicalAtmospheres", - "FromUnitToBaseFunc": "{x} * 9.80680592331 * 1e4", - "FromBaseToUnitFunc": "{x} / (9.80680592331 * 1e4)", + "XmlDocSummary": "A kilogram-force per centimetre square (kgf/cm2), often just kilogram per square centimetre (kg/cm2), or kilopond per centimetre square (kp/cm2) is a deprecated unit of pressure using metric units. It is not a part of the International System of Units (SI), the modern metric system. 1 kgf/cm2 equals 98.0665 kPa (kilopascals). It is also known as a technical atmosphere (symbol: at).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Kilogram-force_per_square_centimetre", + "FromUnitToBaseFunc": "{x} * 9.80665e4", + "FromBaseToUnitFunc": "{x} / 9.80665e4", "Localization": [ { "Culture": "en-US", @@ -186,8 +194,10 @@ { "SingularName": "Torr", "PluralName": "Torrs", - "FromUnitToBaseFunc": "{x} * 1.3332266752 * 1e2", - "FromBaseToUnitFunc": "{x} / (1.3332266752 * 1e2)", + "XmlDocSummary": "The torr (symbol: Torr) is a unit of pressure based on an absolute scale, defined as exactly 1/760 of a standard atmosphere (101325 Pa). Thus one torr is exactly 101325/760 pascals (≈ 133.32 Pa).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Torr", + "FromUnitToBaseFunc": "{x} * 101325 / 760", + "FromBaseToUnitFunc": "{x} * 760 / 101325", "Localization": [ { "Culture": "en-US", @@ -202,13 +212,8 @@ { "SingularName": "PoundForcePerSquareInch", "PluralName": "PoundsForcePerSquareInch", - "BaseUnits": { - "L": "Inch", - "M": "Pound", - "T": "Second" - }, - "FromUnitToBaseFunc": "{x} * 6.894757293168361e3", - "FromBaseToUnitFunc": "{x} / 6.894757293168361e3", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 0.00064516", + "FromBaseToUnitFunc": "{x} * 0.00064516 / 4.4482216152605", "Prefixes": [ "Kilo" ], "Localization": [ { @@ -226,13 +231,8 @@ { "SingularName": "PoundForcePerSquareMil", "PluralName": "PoundsForcePerSquareMil", - "BaseUnits": { - "L": "Mil", - "M": "Pound", - "T": "Second" - }, - "FromUnitToBaseFunc": "{x} * 6.894757293168361e9", - "FromBaseToUnitFunc": "{x} / 6.894757293168361e9", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / (2.54e-5 * 2.54e-5)", + "FromBaseToUnitFunc": "{x} * (2.54e-5 * 2.54e-5) / 4.4482216152605", "Prefixes": [ "Kilo" ], "Localization": [ { @@ -245,13 +245,8 @@ { "SingularName": "PoundForcePerSquareFoot", "PluralName": "PoundsForcePerSquareFoot", - "BaseUnits": { - "L": "Foot", - "M": "Pound", - "T": "Second" - }, - "FromUnitToBaseFunc": "{x} * 4.788025898033584e1", - "FromBaseToUnitFunc": "{x} / 4.788025898033584e1", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 9.290304e-2", + "FromBaseToUnitFunc": "{x} * 9.290304e-2 / 4.4482216152605", "Prefixes": [ "Kilo" ], "Localization": [ { @@ -264,11 +259,6 @@ { "SingularName": "TonneForcePerSquareMillimeter", "PluralName": "TonnesForcePerSquareMillimeter", - "BaseUnits": { - "L": "Millimeter", - "M": "Tonne", - "T": "Second" - }, "FromUnitToBaseFunc": "{x} * 9.80665e9", "FromBaseToUnitFunc": "{x} / 9.80665e9", "Localization": [ @@ -281,11 +271,6 @@ { "SingularName": "TonneForcePerSquareMeter", "PluralName": "TonnesForcePerSquareMeter", - "BaseUnits": { - "L": "Meter", - "M": "Tonne", - "T": "Second" - }, "FromUnitToBaseFunc": "{x} * 9.80665e3", "FromBaseToUnitFunc": "{x} / 9.80665e3", "Localization": [ @@ -299,7 +284,7 @@ "SingularName": "MeterOfHead", "PluralName": "MetersOfHead", "FromUnitToBaseFunc": "{x} * 9804.139432", - "FromBaseToUnitFunc": "{x} * 0.0001019977334", + "FromBaseToUnitFunc": "{x} / 9804.139432", "Localization": [ { "Culture": "en-US", @@ -310,11 +295,6 @@ { "SingularName": "TonneForcePerSquareCentimeter", "PluralName": "TonnesForcePerSquareCentimeter", - "BaseUnits": { - "L": "Centimeter", - "M": "Tonne", - "T": "Second" - }, "FromUnitToBaseFunc": "{x} * 9.80665e7", "FromBaseToUnitFunc": "{x} / 9.80665e7", "Localization": [ @@ -327,8 +307,8 @@ { "SingularName": "FootOfHead", "PluralName": "FeetOfHead", - "FromUnitToBaseFunc": "{x} * 2989.0669", - "FromBaseToUnitFunc": "{x} * 0.000334552565551", + "FromUnitToBaseFunc": "{x} * 9804.139432 * 0.3048", + "FromBaseToUnitFunc": "{x} / (9804.139432 * 0.3048)", "Localization": [ { "Culture": "en-US", @@ -339,8 +319,10 @@ { "SingularName": "MillimeterOfMercury", "PluralName": "MillimetersOfMercury", - "FromUnitToBaseFunc": "{x} / 7.50061561302643e-3", - "FromBaseToUnitFunc": "{x} * 7.50061561302643e-3", + "XmlDocSummary": "A millimetre of mercury is a manometric unit of pressure, formerly defined as the extra pressure generated by a column of mercury one millimetre high, and currently defined as exactly 133.322387415 pascals.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Millimetre_of_mercury", + "FromUnitToBaseFunc": "{x} * 133.322387415", + "FromBaseToUnitFunc": "{x} / 133.322387415", "Localization": [ { "Culture": "en-US", @@ -355,8 +337,10 @@ { "SingularName": "InchOfMercury", "PluralName": "InchesOfMercury", - "FromUnitToBaseFunc": "{x} / 2.95299830714159e-4", - "FromBaseToUnitFunc": "{x} * 2.95299830714159e-4", + "XmlDocSummary": "Inch of mercury (inHg and ″Hg) is a non-SI unit of measurement for pressure. It is used for barometric pressure in weather reports, refrigeration and aviation in the United States. It is the pressure exerted by a column of mercury 1 inch (25.4 mm) in height at the standard acceleration of gravity.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Inch_of_mercury", + "FromUnitToBaseFunc": "{x} * 2.54e1 * 133.322387415", + "FromBaseToUnitFunc": "{x} / (2.54e1 * 133.322387415)", "Localization": [ { "Culture": "en-US", @@ -379,8 +363,8 @@ { "SingularName": "PoundPerInchSecondSquared", "PluralName": "PoundsPerInchSecondSquared", - "FromUnitToBaseFunc": "{x} * 1.785796732283465e1", - "FromBaseToUnitFunc": "{x} / 1.785796732283465e1", + "FromUnitToBaseFunc": "{x} * (4.4482216152605 / 0.00064516) / 386.0886", + "FromBaseToUnitFunc": "{x} * 386.0886 / (4.4482216152605 / 0.00064516)", "Localization": [ { "Culture": "en-US", @@ -391,8 +375,10 @@ { "SingularName": "MeterOfWaterColumn", "PluralName": "MetersOfWaterColumn", - "FromUnitToBaseFunc": "{x} * 9.806650000000272e3", - "FromBaseToUnitFunc": "{x} / 9.806650000000272e3", + "XmlDocSummary": "A centimetre of water is defined as the pressure exerted by a column of water of 1 cm in height at 4 °C (temperature of maximum density) at the standard acceleration of gravity, so that 1 cmH2O (4°C) = 999.9720 kg/m3 × 9.80665 m/s2 × 1 cm = 98.063754138 Pa, but conventionally a nominal maximum water density of 1000 kg/m3 is used, giving 98.0665 Pa.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Centimetre_or_millimetre_of_water", + "FromUnitToBaseFunc": "{x} * 9.80665e3", + "FromBaseToUnitFunc": "{x} / 9.80665e3", "Prefixes": [ "Milli", "Centi" ], "Localization": [ { @@ -404,38 +390,16 @@ { "SingularName": "InchOfWaterColumn", "PluralName": "InchesOfWaterColumn", - "FromUnitToBaseFunc": "{x} * 249.08890833333", - "FromBaseToUnitFunc": "{x} / 249.08890833333", + "XmlDocSummary": "Inches of water is a non-SI unit for pressure. It is defined as the pressure exerted by a column of water of 1 inch in height at defined conditions. At a temperature of 4 °C (39.2 °F) pure water has its highest density (1000 kg/m3). At that temperature and assuming the standard acceleration of gravity, 1 inAq is approximately 249.082 pascals (0.0361263 psi).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Inch_of_water", + "FromUnitToBaseFunc": "{x} * 2.54e-2 * 9.80665e3", + "FromBaseToUnitFunc": "{x} / (2.54e-2 * 9.80665e3)", "Localization": [ { "Culture": "en-US", "Abbreviations": [ "inH2O", "inch wc", "wc" ] } ] - }, - { - "SingularName": "MeterOfElevation", - "PluralName": "MetersOfElevation", - "FromUnitToBaseFunc": "Math.Pow(1.0 - ({x} / 44307.69396), 5.2553026003237266401799415610351) * 101325.0", - "FromBaseToUnitFunc": "(1.0 - Math.Pow({x} / 101325.0, 0.190284)) * 44307.69396", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "m of elevation" ] - } - ] - }, - { - "SingularName": "FootOfElevation", - "PluralName": "FeetOfElevation", - "FromUnitToBaseFunc": "Math.Pow(1.0 - ({x} / 145366.45), 5.2553026003237266401799415610351) * 101325.0", - "FromBaseToUnitFunc": "(1.0 - Math.Pow({x} / 101325.0, 0.190284)) * 145366.45", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "ft of elevation" ] - } - ] } ] } diff --git a/Common/UnitDefinitions/PressureChangeRate.json b/Common/UnitDefinitions/PressureChangeRate.json index c10ba8f7fe..81de2bce94 100644 --- a/Common/UnitDefinitions/PressureChangeRate.json +++ b/Common/UnitDefinitions/PressureChangeRate.json @@ -55,8 +55,8 @@ { "SingularName": "MillimeterOfMercuryPerSecond", "PluralName": "MillimetersOfMercuryPerSecond", - "FromUnitToBaseFunc": "{x} * 133.322", - "FromBaseToUnitFunc": "{x} / 133.322", + "FromUnitToBaseFunc": "{x} * 133.322387415", + "FromBaseToUnitFunc": "{x} / 133.322387415", "Localization": [ { "Culture": "en-US", @@ -92,8 +92,8 @@ "M": "Pound", "T": "Second" }, - "FromUnitToBaseFunc": "{x} * 6.894757293168361e3", - "FromBaseToUnitFunc": "{x} / 6.894757293168361e3", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 0.00064516", + "FromBaseToUnitFunc": "{x} * 0.00064516 / 4.4482216152605", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { @@ -116,8 +116,8 @@ "M": "Pound", "T": "Minute" }, - "FromUnitToBaseFunc": "{x} * 6.894757293168361e3 / 60", - "FromBaseToUnitFunc": "{x} / 6.894757293168361e3 * 60", + "FromUnitToBaseFunc": "{x} * (4.4482216152605 / 0.00064516) / 60", + "FromBaseToUnitFunc": "{x} * 60 / (4.4482216152605 / 0.00064516)", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { diff --git a/Common/UnitDefinitions/RadiationEquivalentDoseRate.json b/Common/UnitDefinitions/RadiationEquivalentDoseRate.json index e33d3bae8e..8057849e78 100644 --- a/Common/UnitDefinitions/RadiationEquivalentDoseRate.json +++ b/Common/UnitDefinitions/RadiationEquivalentDoseRate.json @@ -28,6 +28,10 @@ { "SingularName": "SievertPerSecond", "PluralName": "SievertsPerSecond", + "BaseUnits": { + "L": "Meter", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli" ], diff --git a/Common/UnitDefinitions/RatioChangeRate.json b/Common/UnitDefinitions/RatioChangeRate.json index be72a57bde..572c51513a 100644 --- a/Common/UnitDefinitions/RatioChangeRate.json +++ b/Common/UnitDefinitions/RatioChangeRate.json @@ -2,7 +2,9 @@ "Name": "RatioChangeRate", "BaseUnit": "DecimalFractionPerSecond", "XmlDocSummary": "The change in ratio per unit of time.", - "BaseDimensions": { "T": -1 }, + "BaseDimensions": { + "T": -1 + }, "Units": [ { "SingularName": "PercentPerSecond", @@ -19,6 +21,9 @@ { "SingularName": "DecimalFractionPerSecond", "PluralName": "DecimalFractionsPerSecond", + "BaseUnits": { + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ diff --git a/Common/UnitDefinitions/ReactiveEnergy.json b/Common/UnitDefinitions/ReactiveEnergy.json deleted file mode 100644 index 89a648ccc9..0000000000 --- a/Common/UnitDefinitions/ReactiveEnergy.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Name": "ReactiveEnergy", - "BaseUnit": "VoltampereReactiveHour", - "XmlDocSummary": "The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour.", - "XmlDocRemarks": "ReactiveEnergy has been renamed to ElectricReactiveEnergy, and will be removed in a later major version.", - "ObsoleteText": "ReactiveEnergy has been renamed to ElectricReactiveEnergy, and will be removed in a later major version.", - "BaseDimensions": { - "L": 2, - "M": 1, - "T": -2 - }, - "Units": [ - { - "SingularName": "VoltampereReactiveHour", - "PluralName": "VoltampereReactiveHours", - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", - "Prefixes": [ "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "varh" ] - } - ] - } - ] -} diff --git a/Common/UnitDefinitions/ReactivePower.json b/Common/UnitDefinitions/ReactivePower.json deleted file mode 100644 index 48a84dd22d..0000000000 --- a/Common/UnitDefinitions/ReactivePower.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Name": "ReactivePower", - "BaseUnit": "VoltampereReactive", - "XmlDocSummary": "Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase.", - "XmlDocRemarks": "ReactivePower has been renamed to ElectricReactivePower, and will be removed in a later major version.", - "ObsoleteText": "ReactivePower has been renamed to ElectricReactivePower, and will be removed in a later major version.", - "BaseDimensions": { - "L": 2, - "M": 1, - "T": -3 - }, - "Units": [ - { - "SingularName": "VoltampereReactive", - "PluralName": "VoltamperesReactive", - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", - "Prefixes": [ "Kilo", "Mega", "Giga" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "var" ] - } - ] - } - ] -} diff --git a/Common/UnitDefinitions/ReciprocalArea.json b/Common/UnitDefinitions/ReciprocalArea.json index 425302d1cd..37490de552 100644 --- a/Common/UnitDefinitions/ReciprocalArea.json +++ b/Common/UnitDefinitions/ReciprocalArea.json @@ -10,6 +10,9 @@ { "SingularName": "InverseSquareMeter", "PluralName": "InverseSquareMeters", + "BaseUnits": { + "L": "Meter" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ @@ -22,6 +25,9 @@ { "SingularName": "InverseSquareKilometer", "PluralName": "InverseSquareKilometers", + "BaseUnits": { + "L": "Kilometer" + }, "FromUnitToBaseFunc": "{x} / 1e6", "FromBaseToUnitFunc": "{x} * 1e6", "Localization": [ @@ -34,6 +40,9 @@ { "SingularName": "InverseSquareDecimeter", "PluralName": "InverseSquareDecimeters", + "BaseUnits": { + "L": "Decimeter" + }, "FromUnitToBaseFunc": "{x} / 1e-2", "FromBaseToUnitFunc": "{x} * 1e-2", "Localization": [ @@ -46,6 +55,9 @@ { "SingularName": "InverseSquareCentimeter", "PluralName": "InverseSquareCentimeters", + "BaseUnits": { + "L": "Centimeter" + }, "FromUnitToBaseFunc": "{x} / 1e-4", "FromBaseToUnitFunc": "{x} * 1e-4", "Localization": [ @@ -58,6 +70,9 @@ { "SingularName": "InverseSquareMillimeter", "PluralName": "InverseSquareMillimeters", + "BaseUnits": { + "L": "Millimeter" + }, "FromUnitToBaseFunc": "{x} / 1e-6", "FromBaseToUnitFunc": "{x} * 1e-6", "Localization": [ @@ -70,6 +85,9 @@ { "SingularName": "InverseSquareMicrometer", "PluralName": "InverseSquareMicrometers", + "BaseUnits": { + "L": "Micrometer" + }, "FromUnitToBaseFunc": "{x} / 1e-12", "FromBaseToUnitFunc": "{x} * 1e-12", "Localization": [ @@ -82,8 +100,11 @@ { "SingularName": "InverseSquareMile", "PluralName": "InverseSquareMiles", - "FromUnitToBaseFunc": "{x} / 2.59e6", - "FromBaseToUnitFunc": "{x} * 2.59e6", + "BaseUnits": { + "L": "Mile" + }, + "FromUnitToBaseFunc": "{x} / (1609.344 * 1609.344)", + "FromBaseToUnitFunc": "{x} * (1609.344 * 1609.344)", "Localization": [ { "Culture": "en-US", @@ -94,8 +115,11 @@ { "SingularName": "InverseSquareYard", "PluralName": "InverseSquareYards", - "FromUnitToBaseFunc": "{x} / 0.836127", - "FromBaseToUnitFunc": "{x} * 0.836127", + "BaseUnits": { + "L": "Yard" + }, + "FromUnitToBaseFunc": "{x} / (0.9144 * 0.9144)", + "FromBaseToUnitFunc": "{x} * (0.9144 * 0.9144)", "Localization": [ { "Culture": "en-US", @@ -106,8 +130,11 @@ { "SingularName": "InverseSquareFoot", "PluralName": "InverseSquareFeet", - "FromUnitToBaseFunc": "{x} / 0.092903", - "FromBaseToUnitFunc": "{x} * 0.092903", + "BaseUnits": { + "L": "Foot" + }, + "FromUnitToBaseFunc": "{x} / 9.290304e-2", + "FromBaseToUnitFunc": "{x} * 9.290304e-2", "Localization": [ { "Culture": "en-US", @@ -118,8 +145,11 @@ { "SingularName": "InverseUsSurveySquareFoot", "PluralName": "InverseUsSurveySquareFeet", - "FromUnitToBaseFunc": "{x} / 0.09290341161", - "FromBaseToUnitFunc": "{x} * 0.09290341161", + "BaseUnits": { + "L": "UsSurveyFoot" + }, + "FromUnitToBaseFunc": "{x} / (1200.0 / 3937.0) / (1200.0 / 3937.0)", + "FromBaseToUnitFunc": "{x} * (1200.0 / 3937.0) * (1200.0 / 3937.0)", "Localization": [ { "Culture": "en-US", @@ -130,6 +160,9 @@ { "SingularName": "InverseSquareInch", "PluralName": "InverseSquareInches", + "BaseUnits": { + "L": "Inch" + }, "FromUnitToBaseFunc": "{x} / 0.00064516", "FromBaseToUnitFunc": "{x} * 0.00064516", "Localization": [ diff --git a/Common/UnitDefinitions/ReciprocalLength.json b/Common/UnitDefinitions/ReciprocalLength.json index 400599c29f..2ea4841425 100644 --- a/Common/UnitDefinitions/ReciprocalLength.json +++ b/Common/UnitDefinitions/ReciprocalLength.json @@ -10,6 +10,9 @@ { "SingularName": "InverseMeter", "PluralName": "InverseMeters", + "BaseUnits": { + "L": "Meter" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ @@ -22,6 +25,9 @@ { "SingularName": "InverseCentimeter", "PluralName": "InverseCentimeters", + "BaseUnits": { + "L": "Centimeter" + }, "FromUnitToBaseFunc": "{x} * 1e2", "FromBaseToUnitFunc": "{x} / 1e2", "Localization": [ @@ -34,6 +40,9 @@ { "SingularName": "InverseMillimeter", "PluralName": "InverseMillimeters", + "BaseUnits": { + "L": "Millimeter" + }, "FromUnitToBaseFunc": "{x} * 1e3", "FromBaseToUnitFunc": "{x} / 1e3", "Localization": [ @@ -46,6 +55,9 @@ { "SingularName": "InverseMile", "PluralName": "InverseMiles", + "BaseUnits": { + "L": "Mile" + }, "FromUnitToBaseFunc": "{x} / 1609.344", "FromBaseToUnitFunc": "{x} * 1609.344", "Localization": [ @@ -58,6 +70,9 @@ { "SingularName": "InverseYard", "PluralName": "InverseYards", + "BaseUnits": { + "L": "Yard" + }, "FromUnitToBaseFunc": "{x} / 0.9144", "FromBaseToUnitFunc": "{x} * 0.9144", "Localization": [ @@ -70,6 +85,9 @@ { "SingularName": "InverseFoot", "PluralName": "InverseFeet", + "BaseUnits": { + "L": "Foot" + }, "FromUnitToBaseFunc": "{x} / 0.3048", "FromBaseToUnitFunc": "{x} * 0.3048", "Localization": [ @@ -82,6 +100,9 @@ { "SingularName": "InverseUsSurveyFoot", "PluralName": "InverseUsSurveyFeet", + "BaseUnits": { + "L": "UsSurveyFoot" + }, "FromUnitToBaseFunc": "{x} * 3937 / 1200", "FromBaseToUnitFunc": "{x} * 1200 / 3937", "Localization": [ @@ -94,6 +115,9 @@ { "SingularName": "InverseInch", "PluralName": "InverseInches", + "BaseUnits": { + "L": "Inch" + }, "FromUnitToBaseFunc": "{x} / 2.54e-2", "FromBaseToUnitFunc": "{x} * 2.54e-2", "Localization": [ @@ -106,6 +130,9 @@ { "SingularName": "InverseMil", "PluralName": "InverseMils", + "BaseUnits": { + "L": "Mil" + }, "FromUnitToBaseFunc": "{x} / 2.54e-5", "FromBaseToUnitFunc": "{x} * 2.54e-5", "Localization": [ @@ -118,6 +145,9 @@ { "SingularName": "InverseMicroinch", "PluralName": "InverseMicroinches", + "BaseUnits": { + "L": "Microinch" + }, "FromUnitToBaseFunc": "{x} / 2.54e-8", "FromBaseToUnitFunc": "{x} * 2.54e-8", "Localization": [ diff --git a/Common/UnitDefinitions/RotationalAcceleration.json b/Common/UnitDefinitions/RotationalAcceleration.json index 90e7ce0879..6f6df6f2bd 100644 --- a/Common/UnitDefinitions/RotationalAcceleration.json +++ b/Common/UnitDefinitions/RotationalAcceleration.json @@ -9,6 +9,9 @@ { "SingularName": "RadianPerSecondSquared", "PluralName": "RadiansPerSecondSquared", + "BaseUnits": { + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ diff --git a/Common/UnitDefinitions/RotationalSpeed.json b/Common/UnitDefinitions/RotationalSpeed.json index 0ee2d13ab0..b64a6569e5 100644 --- a/Common/UnitDefinitions/RotationalSpeed.json +++ b/Common/UnitDefinitions/RotationalSpeed.json @@ -9,6 +9,9 @@ { "SingularName": "RadianPerSecond", "PluralName": "RadiansPerSecond", + "BaseUnits": { + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci" ], @@ -55,8 +58,8 @@ { "SingularName": "RevolutionPerSecond", "PluralName": "RevolutionsPerSecond", - "FromUnitToBaseFunc": "{x} * 6.2831853072", - "FromBaseToUnitFunc": "{x} / 6.2831853072", + "FromUnitToBaseFunc": "{x} * 2 * Math.PI", + "FromBaseToUnitFunc": "{x} / (2 * Math.PI)", "Localization": [ { "Culture": "en-US", @@ -71,8 +74,8 @@ { "SingularName": "RevolutionPerMinute", "PluralName": "RevolutionsPerMinute", - "FromUnitToBaseFunc": "({x} * 6.2831853072) / 60", - "FromBaseToUnitFunc": "({x} / 6.2831853072) * 60", + "FromUnitToBaseFunc": "({x} * 2 * Math.PI) / 60", + "FromBaseToUnitFunc": "({x} / (2 * Math.PI)) * 60", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/RotationalStiffness.json b/Common/UnitDefinitions/RotationalStiffness.json index eeadfe573d..a77c0f55ed 100644 --- a/Common/UnitDefinitions/RotationalStiffness.json +++ b/Common/UnitDefinitions/RotationalStiffness.json @@ -11,6 +11,11 @@ { "SingularName": "NewtonMeterPerRadian", "PluralName": "NewtonMetersPerRadian", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], @@ -24,8 +29,8 @@ { "SingularName": "PoundForceFootPerDegrees", "PluralName": "PoundForceFeetPerDegrees", - "FromUnitToBaseFunc": "{x} * 77.6826", - "FromBaseToUnitFunc": "{x} / 77.6826", + "FromUnitToBaseFunc": "{x} * (4.4482216152605 * 0.3048 * 180 / Math.PI)", + "FromBaseToUnitFunc": "{x} / (4.4482216152605 * 0.3048 * 180 / Math.PI)", "Localization": [ { "Culture": "en-US", @@ -36,8 +41,8 @@ { "SingularName": "KilopoundForceFootPerDegrees", "PluralName": "KilopoundForceFeetPerDegrees", - "FromUnitToBaseFunc": "{x} * 77682.6", - "FromBaseToUnitFunc": "{x} / 77682.6", + "FromUnitToBaseFunc": "{x} * (4.4482216152605e3 * 0.3048 * 180 / Math.PI)", + "FromBaseToUnitFunc": "{x} / (4.4482216152605e3 * 0.3048 * 180 / Math.PI)", "Localization": [ { "Culture": "en-US", @@ -87,8 +92,8 @@ { "SingularName": "PoundForceFeetPerRadian", "PluralName": "PoundForceFeetPerRadian", - "FromUnitToBaseFunc": "{x} * 1.3558179483314", - "FromBaseToUnitFunc": "{x} / 1.3558179483314", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 * 0.3048", + "FromBaseToUnitFunc": "{x} / (4.4482216152605 * 0.3048)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/RotationalStiffnessPerLength.json b/Common/UnitDefinitions/RotationalStiffnessPerLength.json index 791ee833a1..ebfd1861d5 100644 --- a/Common/UnitDefinitions/RotationalStiffnessPerLength.json +++ b/Common/UnitDefinitions/RotationalStiffnessPerLength.json @@ -11,6 +11,11 @@ { "SingularName": "NewtonMeterPerRadianPerMeter", "PluralName": "NewtonMetersPerRadianPerMeter", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], @@ -24,8 +29,8 @@ { "SingularName": "PoundForceFootPerDegreesPerFoot", "PluralName": "PoundForceFeetPerDegreesPerFeet", - "FromUnitToBaseFunc": "{x} * 254.864324570", - "FromBaseToUnitFunc": "{x} / 254.864324570", + "FromUnitToBaseFunc": "{x} * (4.4482216152605 * 180 / Math.PI)", + "FromBaseToUnitFunc": "{x} / (4.4482216152605 * 180 / Math.PI)", "Localization": [ { "Culture": "en-US", @@ -36,8 +41,8 @@ { "SingularName": "KilopoundForceFootPerDegreesPerFoot", "PluralName": "KilopoundForceFeetPerDegreesPerFeet", - "FromUnitToBaseFunc": "{x} * 254864.324570", - "FromBaseToUnitFunc": "{x} / 254864.324570", + "FromUnitToBaseFunc": "{x} * (4.4482216152605e3 * 180 / Math.PI)", + "FromBaseToUnitFunc": "{x} / (4.4482216152605e3 * 180 / Math.PI)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/SpecificEnergy.json b/Common/UnitDefinitions/SpecificEnergy.json index ad8ed862f2..2fa10c2ccc 100644 --- a/Common/UnitDefinitions/SpecificEnergy.json +++ b/Common/UnitDefinitions/SpecificEnergy.json @@ -11,6 +11,10 @@ { "SingularName": "JoulePerKilogram", "PluralName": "JoulesPerKilogram", + "BaseUnits": { + "L": "Meter", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], @@ -114,8 +118,8 @@ { "SingularName": "BtuPerPound", "PluralName": "BtuPerPound", - "FromUnitToBaseFunc": "{x} * 2326.000075362", - "FromBaseToUnitFunc": "{x} / 2326.000075362", + "FromUnitToBaseFunc": "{x} * 1055.05585262 / 0.45359237", + "FromBaseToUnitFunc": "{x} * 0.45359237 / 1055.05585262", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/SpecificEntropy.json b/Common/UnitDefinitions/SpecificEntropy.json index 998c6e9bd7..16d2433958 100644 --- a/Common/UnitDefinitions/SpecificEntropy.json +++ b/Common/UnitDefinitions/SpecificEntropy.json @@ -11,6 +11,11 @@ { "SingularName": "JoulePerKilogramKelvin", "PluralName": "JoulesPerKilogramKelvin", + "BaseUnits": { + "L": "Meter", + "T": "Second", + "Θ": "Kelvin" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], @@ -24,6 +29,11 @@ { "SingularName": "JoulePerKilogramDegreeCelsius", "PluralName": "JoulesPerKilogramDegreeCelsius", + "BaseUnits": { + "L": "Meter", + "T": "Second", + "Θ": "DegreeCelsius" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], @@ -55,7 +65,7 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "BTU/lb·°F", "BTU/lbm·°F" ] + "Abbreviations": [ "BTU/(lb·°F)", "BTU/(lbm·°F)" ] } ] } diff --git a/Common/UnitDefinitions/SpecificFuelConsumption.json b/Common/UnitDefinitions/SpecificFuelConsumption.json index 82f94b6804..fefde34c37 100644 --- a/Common/UnitDefinitions/SpecificFuelConsumption.json +++ b/Common/UnitDefinitions/SpecificFuelConsumption.json @@ -1,14 +1,18 @@ { "Name": "SpecificFuelConsumption", - "BaseUnit": "GramPerKiloNewtonSecond", + "BaseUnit": "GramPerKilonewtonSecond", "XmlDocSummary": "SFC is the fuel efficiency of an engine design with respect to thrust output", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Thrust-specific_fuel_consumption", + "BaseDimensions": { + "L": -1, + "T": 1 + }, "Units": [ { "SingularName": "PoundMassPerPoundForceHour", "PluralName": "PoundsMassPerPoundForceHour", - "FromUnitToBaseFunc": "{x} * 28.33", - "FromBaseToUnitFunc": "{x} / 28.33", + "FromUnitToBaseFunc": "{x} * 1000 / (9.80665e-3 * 3600)", + "FromBaseToUnitFunc": "{x} * 9.80665e-3 * 3600 / 1000", "Localization": [ { "Culture": "en-US", @@ -19,8 +23,8 @@ { "SingularName": "KilogramPerKilogramForceHour", "PluralName": "KilogramsPerKilogramForceHour", - "FromUnitToBaseFunc": "{x} * 28.33", - "FromBaseToUnitFunc": "{x} / 28.33", + "FromUnitToBaseFunc": "{x} * 1000 / (9.80665e-3 * 3600)", + "FromBaseToUnitFunc": "{x} * 9.80665e-3 * 3600 / 1000", "Localization": [ { "Culture": "en-US", @@ -29,8 +33,12 @@ ] }, { - "SingularName": "GramPerKiloNewtonSecond", - "PluralName": "GramsPerKiloNewtonSecond", + "SingularName": "GramPerKilonewtonSecond", + "PluralName": "GramsPerKilonewtonSecond", + "BaseUnits": { + "L": "Meter", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo" ], diff --git a/Common/UnitDefinitions/SpecificVolume.json b/Common/UnitDefinitions/SpecificVolume.json index a428f3355d..aa9939832a 100644 --- a/Common/UnitDefinitions/SpecificVolume.json +++ b/Common/UnitDefinitions/SpecificVolume.json @@ -10,6 +10,10 @@ { "SingularName": "CubicMeterPerKilogram", "PluralName": "CubicMetersPerKilogram", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Milli" ], @@ -23,8 +27,12 @@ { "SingularName": "CubicFootPerPound", "PluralName": "CubicFeetPerPound", - "FromUnitToBaseFunc": "{x} / 16.01846353", - "FromBaseToUnitFunc": "{x} * 16.01846353", + "BaseUnits": { + "L": "Foot", + "M": "Pound" + }, + "FromUnitToBaseFunc": "{x} * 0.028316846592 / 0.45359237", + "FromBaseToUnitFunc": "{x} * 0.45359237 / 0.028316846592", "Prefixes": [], "Localization": [ { diff --git a/Common/UnitDefinitions/SpecificWeight.json b/Common/UnitDefinitions/SpecificWeight.json index 3ff8a8f11a..f56d545639 100644 --- a/Common/UnitDefinitions/SpecificWeight.json +++ b/Common/UnitDefinitions/SpecificWeight.json @@ -38,6 +38,11 @@ { "SingularName": "NewtonPerCubicMeter", "PluralName": "NewtonsPerCubicMeter", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], @@ -87,8 +92,8 @@ { "SingularName": "PoundForcePerCubicInch", "PluralName": "PoundsForcePerCubicInch", - "FromUnitToBaseFunc": "{x} * 2.714471375263134e5", - "FromBaseToUnitFunc": "{x} / 2.714471375263134e5", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 1.6387064e-5", + "FromBaseToUnitFunc": "{x} * 1.6387064e-5 / 4.4482216152605", "Prefixes": [ "Kilo" ], "Localization": [ { @@ -101,8 +106,8 @@ { "SingularName": "PoundForcePerCubicFoot", "PluralName": "PoundsForcePerCubicFoot", - "FromUnitToBaseFunc": "{x} * 1.570874638462462e2", - "FromBaseToUnitFunc": "{x} / 1.570874638462462e2", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 / 0.028316846592", + "FromBaseToUnitFunc": "{x} * 0.028316846592 / 4.4482216152605", "Prefixes": [ "Kilo" ], "Localization": [ { diff --git a/Common/UnitDefinitions/Speed.json b/Common/UnitDefinitions/Speed.json index f17f8a321c..6a127121e5 100644 --- a/Common/UnitDefinitions/Speed.json +++ b/Common/UnitDefinitions/Speed.json @@ -30,7 +30,7 @@ }, { "SingularName": "MeterPerMinute", - "PluralName": "MetersPerMinutes", + "PluralName": "MetersPerMinute", "BaseUnits": { "L": "Meter", "T": "Minute" diff --git a/Common/UnitDefinitions/StandardVolumeFlow.json b/Common/UnitDefinitions/StandardVolumeFlow.json index bf731df37e..7cf13a7837 100644 --- a/Common/UnitDefinitions/StandardVolumeFlow.json +++ b/Common/UnitDefinitions/StandardVolumeFlow.json @@ -10,6 +10,10 @@ { "SingularName": "StandardCubicMeterPerSecond", "PluralName": "StandardCubicMetersPerSecond", + "BaseUnits": { + "L": "Meter", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ @@ -22,6 +26,10 @@ { "SingularName": "StandardCubicMeterPerMinute", "PluralName": "StandardCubicMetersPerMinute", + "BaseUnits": { + "L": "Meter", + "T": "Minute" + }, "FromUnitToBaseFunc": "{x} / 60", "FromBaseToUnitFunc": "{x} * 60", "Localization": [ @@ -34,6 +42,10 @@ { "SingularName": "StandardCubicMeterPerHour", "PluralName": "StandardCubicMetersPerHour", + "BaseUnits": { + "L": "Meter", + "T": "Hour" + }, "FromUnitToBaseFunc": "{x} / 3600", "FromBaseToUnitFunc": "{x} * 3600", "Localization": [ @@ -46,6 +58,10 @@ { "SingularName": "StandardCubicMeterPerDay", "PluralName": "StandardCubicMetersPerDay", + "BaseUnits": { + "L": "Meter", + "T": "Day" + }, "FromUnitToBaseFunc": "{x} / 86400", "FromBaseToUnitFunc": "{x} * 86400", "Localization": [ @@ -58,6 +74,10 @@ { "SingularName": "StandardCubicCentimeterPerMinute", "PluralName": "StandardCubicCentimetersPerMinute", + "BaseUnits": { + "L": "Centimeter", + "T": "Minute" + }, "FromUnitToBaseFunc": "{x} / 6e7", "FromBaseToUnitFunc": "{x} * 6e7", "Localization": [ @@ -70,6 +90,10 @@ { "SingularName": "StandardLiterPerMinute", "PluralName": "StandardLitersPerMinute", + "BaseUnits": { + "L": "Decimeter", + "T": "Minute" + }, "FromUnitToBaseFunc": "{x} / 60000", "FromBaseToUnitFunc": "{x} * 60000", "Localization": [ @@ -82,8 +106,12 @@ { "SingularName": "StandardCubicFootPerSecond", "PluralName": "StandardCubicFeetPerSecond", - "FromUnitToBaseFunc": "{x} / 35.314666721", - "FromBaseToUnitFunc": "{x} * 35.314666721", + "BaseUnits": { + "L": "Foot", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 0.028316846592", + "FromBaseToUnitFunc": "{x} / 0.028316846592", "Localization": [ { "Culture": "en-US", @@ -94,8 +122,12 @@ { "SingularName": "StandardCubicFootPerMinute", "PluralName": "StandardCubicFeetPerMinute", - "FromUnitToBaseFunc": "{x} / 2118.88000326", - "FromBaseToUnitFunc": "{x} * 2118.88000326", + "BaseUnits": { + "L": "Foot", + "T": "Minute" + }, + "FromUnitToBaseFunc": "{x} * 0.028316846592 / 60", + "FromBaseToUnitFunc": "{x} / (0.028316846592 / 60)", "Localization": [ { "Culture": "en-US", @@ -106,8 +138,12 @@ { "SingularName": "StandardCubicFootPerHour", "PluralName": "StandardCubicFeetPerHour", - "FromUnitToBaseFunc": "{x} * 7.8657907199999087346816086183876e-6", - "FromBaseToUnitFunc": "{x} / 7.8657907199999087346816086183876e-6", + "BaseUnits": { + "L": "Foot", + "T": "Hour" + }, + "FromUnitToBaseFunc": "{x} * 0.028316846592 / 3600", + "FromBaseToUnitFunc": "{x} / (0.028316846592 / 3600)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/Temperature.json b/Common/UnitDefinitions/Temperature.json index 9a5ec73aee..c782600ae7 100644 --- a/Common/UnitDefinitions/Temperature.json +++ b/Common/UnitDefinitions/Temperature.json @@ -41,7 +41,7 @@ "SingularName": "MillidegreeCelsius", "PluralName": "MillidegreesCelsius", "BaseUnits": { - "Θ": "DegreeCelsius" + "Θ": "MillidegreeCelsius" }, "FromUnitToBaseFunc": "{x} / 1000 + 273.15", "FromBaseToUnitFunc": "({x} - 273.15) * 1000", @@ -145,6 +145,9 @@ { "SingularName": "SolarTemperature", "PluralName": "SolarTemperatures", + "BaseUnits": { + "Θ": "SolarTemperature" + }, "FromUnitToBaseFunc": "{x} * 5778", "FromBaseToUnitFunc": "{x} / 5778", "Localization": [ diff --git a/Common/UnitDefinitions/TemperatureChangeRate.json b/Common/UnitDefinitions/TemperatureChangeRate.json index 1a8bc7b534..dbb72d4473 100644 --- a/Common/UnitDefinitions/TemperatureChangeRate.json +++ b/Common/UnitDefinitions/TemperatureChangeRate.json @@ -10,6 +10,10 @@ { "SingularName": "DegreeCelsiusPerSecond", "PluralName": "DegreesCelsiusPerSecond", + "BaseUnits": { + "Θ": "DegreeCelsius", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo" ], @@ -23,6 +27,10 @@ { "SingularName": "DegreeCelsiusPerMinute", "PluralName": "DegreesCelsiusPerMinute", + "BaseUnits": { + "Θ": "DegreeCelsius", + "T": "Minute" + }, "FromUnitToBaseFunc": "{x} / 60", "FromBaseToUnitFunc": "{x} * 60", "Localization": [ @@ -35,6 +43,10 @@ { "SingularName": "DegreeKelvinPerMinute", "PluralName": "DegreesKelvinPerMinute", + "BaseUnits": { + "Θ": "Kelvin", + "T": "Minute" + }, "FromUnitToBaseFunc": "{x} / 60", "FromBaseToUnitFunc": "{x} * 60", "Prefixes": [], @@ -48,6 +60,10 @@ { "SingularName": "DegreeFahrenheitPerMinute", "PluralName": "DegreesFahrenheitPerMinute", + "BaseUnits": { + "Θ": "DegreeFahrenheit", + "T": "Minute" + }, "FromUnitToBaseFunc": "{x} * 5 / 9 / 60", "FromBaseToUnitFunc": "{x} * 9 / 5 * 60", "Localization": [ @@ -60,6 +76,10 @@ { "SingularName": "DegreeFahrenheitPerSecond", "PluralName": "DegreesFahrenheitPerSecond", + "BaseUnits": { + "Θ": "DegreeFahrenheit", + "T": "Second" + }, "FromUnitToBaseFunc": "{x} * 5 / 9", "FromBaseToUnitFunc": "{x} * 9 / 5", "Localization": [ @@ -72,6 +92,10 @@ { "SingularName": "DegreeKelvinPerSecond", "PluralName": "DegreesKelvinPerSecond", + "BaseUnits": { + "Θ": "Kelvin", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [], @@ -85,6 +109,10 @@ { "SingularName": "DegreeCelsiusPerHour", "PluralName": "DegreesCelsiusPerHour", + "BaseUnits": { + "Θ": "DegreeCelsius", + "T": "Hour" + }, "FromUnitToBaseFunc": "{x} / 3600", "FromBaseToUnitFunc": "{x} * 3600", "Localization": [ @@ -97,6 +125,10 @@ { "SingularName": "DegreeKelvinPerHour", "PluralName": "DegreesKelvinPerHour", + "BaseUnits": { + "Θ": "Kelvin", + "T": "Hour" + }, "FromUnitToBaseFunc": "{x} / 3600", "FromBaseToUnitFunc": "{x} * 3600", "Prefixes": [], @@ -110,6 +142,10 @@ { "SingularName": "DegreeFahrenheitPerHour", "PluralName": "DegreesFahrenheitPerHour", + "BaseUnits": { + "Θ": "DegreeFahrenheit", + "T": "Hour" + }, "FromUnitToBaseFunc": "{x} * 5 / 9 / 3600", "FromBaseToUnitFunc": "{x} * 9 / 5 * 3600", "Localization": [ diff --git a/Common/UnitDefinitions/TemperatureDelta.json b/Common/UnitDefinitions/TemperatureDelta.json index 9215f4ec24..04ef0a53a9 100644 --- a/Common/UnitDefinitions/TemperatureDelta.json +++ b/Common/UnitDefinitions/TemperatureDelta.json @@ -9,6 +9,9 @@ { "SingularName": "Kelvin", "PluralName": "Kelvins", + "BaseUnits": { + "Θ": "Kelvin" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ @@ -21,6 +24,9 @@ { "SingularName": "DegreeCelsius", "PluralName": "DegreesCelsius", + "BaseUnits": { + "Θ": "DegreeCelsius" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Milli" ], @@ -35,6 +41,9 @@ { "SingularName": "DegreeDelisle", "PluralName": "DegreesDelisle", + "BaseUnits": { + "Θ": "DegreeDelisle" + }, "FromUnitToBaseFunc": "{x} * -2 / 3", "FromBaseToUnitFunc": "{x} * -3 / 2", "Localization": [ @@ -47,6 +56,9 @@ { "SingularName": "DegreeFahrenheit", "PluralName": "DegreesFahrenheit", + "BaseUnits": { + "Θ": "DegreeFahrenheit" + }, "FromUnitToBaseFunc": "{x} * 5 / 9", "FromBaseToUnitFunc": "{x} * 9 / 5", "Localization": [ @@ -59,6 +71,9 @@ { "SingularName": "DegreeNewton", "PluralName": "DegreesNewton", + "BaseUnits": { + "Θ": "DegreeNewton" + }, "FromUnitToBaseFunc": "{x} * 100 / 33", "FromBaseToUnitFunc": "{x} * 33 / 100", "Localization": [ @@ -71,6 +86,9 @@ { "SingularName": "DegreeRankine", "PluralName": "DegreesRankine", + "BaseUnits": { + "Θ": "DegreeRankine" + }, "FromUnitToBaseFunc": "{x} * 5 / 9", "FromBaseToUnitFunc": "{x} * 9 / 5", "Localization": [ @@ -83,6 +101,9 @@ { "SingularName": "DegreeReaumur", "PluralName": "DegreesReaumur", + "BaseUnits": { + "Θ": "DegreeReaumur" + }, "FromUnitToBaseFunc": "{x} * 5 / 4", "FromBaseToUnitFunc": "{x} * 4 / 5", "Localization": [ @@ -95,6 +116,9 @@ { "SingularName": "DegreeRoemer", "PluralName": "DegreesRoemer", + "BaseUnits": { + "Θ": "DegreeRoemer" + }, "FromUnitToBaseFunc": "{x} * 40 / 21", "FromBaseToUnitFunc": "{x} * 21 / 40", "Localization": [ diff --git a/Common/UnitDefinitions/TemperatureGradient.json b/Common/UnitDefinitions/TemperatureGradient.json index d0cf566fc1..d2c9d5f5bd 100644 --- a/Common/UnitDefinitions/TemperatureGradient.json +++ b/Common/UnitDefinitions/TemperatureGradient.json @@ -25,7 +25,7 @@ }, { "SingularName": "DegreeCelsiusPerMeter", - "PluralName": "DegreesCelciusPerMeter", + "PluralName": "DegreesCelsiusPerMeter", "BaseUnits": { "L": "Meter", "Θ": "DegreeCelsius" @@ -57,7 +57,7 @@ }, { "SingularName": "DegreeCelsiusPerKilometer", - "PluralName": "DegreesCelciusPerKilometer", + "PluralName": "DegreesCelsiusPerKilometer", "BaseUnits": { "L": "Kilometer", "Θ": "DegreeCelsius" diff --git a/Common/UnitDefinitions/ThermalConductivity.json b/Common/UnitDefinitions/ThermalConductivity.json index 46f26a935e..c5f30282b8 100644 --- a/Common/UnitDefinitions/ThermalConductivity.json +++ b/Common/UnitDefinitions/ThermalConductivity.json @@ -13,24 +13,30 @@ { "SingularName": "WattPerMeterKelvin", "PluralName": "WattsPerMeterKelvin", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second", + "Θ": "Kelvin" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "W/m·K" ] + "Abbreviations": [ "W/(m·K)" ] } ] }, { "SingularName": "BtuPerHourFootFahrenheit", "PluralName": "BtusPerHourFootFahrenheit", - "FromUnitToBaseFunc": "{x} * 1.73073467", - "FromBaseToUnitFunc": "{x} / 1.73073467", + "FromUnitToBaseFunc": "{x} * ((1055.05585262 / (0.3048 * 3600)) * 1.8)", + "FromBaseToUnitFunc": "{x} / ((1055.05585262 / (0.3048 * 3600)) * 1.8)", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "BTU/h·ft·°F" ] + "Abbreviations": [ "BTU/(h·ft·°F)" ] } ] } diff --git a/Common/UnitDefinitions/ThermalResistance.json b/Common/UnitDefinitions/ThermalInsulance.json similarity index 62% rename from Common/UnitDefinitions/ThermalResistance.json rename to Common/UnitDefinitions/ThermalInsulance.json index 91da569fbc..7e9ae0a217 100644 --- a/Common/UnitDefinitions/ThermalResistance.json +++ b/Common/UnitDefinitions/ThermalInsulance.json @@ -1,7 +1,7 @@ { - "Name": "ThermalResistance", + "Name": "ThermalInsulance", "BaseUnit": "SquareMeterKelvinPerKilowatt", - "XmlDocSummary": "Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat.", + "XmlDocSummary": "Thermal insulance (R-value) is a measure of a material's resistance to the heat current. It quantifies how effectively a material can resist the transfer of heat through conduction, convection, and radiation. It has the units square metre kelvins per watt (m2⋅K/W) in SI units or square foot degree Fahrenheit–hours per British thermal unit (ft2⋅°F⋅h/Btu) in imperial units. The higher the thermal insulance, the better a material insulates against heat transfer. It is commonly used in construction to assess the insulation properties of materials such as walls, roofs, and insulation products.", "BaseDimensions": { "M": -1, "T": 3, @@ -23,6 +23,11 @@ { "SingularName": "SquareMeterKelvinPerWatt", "PluralName": "SquareMeterKelvinsPerWatt", + "BaseUnits": { + "M": "Kilogram", + "T": "Second", + "Θ": "Kelvin" + }, "FromUnitToBaseFunc": "{x} * 1000", "FromBaseToUnitFunc": "{x} / 1000", "Localization": [ @@ -35,6 +40,11 @@ { "SingularName": "SquareMeterDegreeCelsiusPerWatt", "PluralName": "SquareMeterDegreesCelsiusPerWatt", + "BaseUnits": { + "M": "Kilogram", + "T": "Second", + "Θ": "DegreeCelsius" + }, "FromUnitToBaseFunc": "{x} * 1000.0", "FromBaseToUnitFunc": "{x} / 1000.0", "Localization": [ @@ -59,8 +69,8 @@ { "SingularName": "SquareCentimeterHourDegreeCelsiusPerKilocalorie", "PluralName": "SquareCentimeterHourDegreesCelsiusPerKilocalorie", - "FromUnitToBaseFunc": "{x} * 0.0859779507590433", - "FromBaseToUnitFunc": "{x} / 0.0859779507590433", + "FromUnitToBaseFunc": "{x} * (0.0001 * 3600) / 4.184", + "FromBaseToUnitFunc": "{x} * 4.184 / (0.0001 * 3600)", "Localization": [ { "Culture": "en-US", @@ -71,8 +81,8 @@ { "SingularName": "HourSquareFeetDegreeFahrenheitPerBtu", "PluralName": "HourSquareFeetDegreesFahrenheitPerBtu", - "FromUnitToBaseFunc": "{x} * 176.1121482159839", - "FromBaseToUnitFunc": "{x} / 176.1121482159839", + "FromUnitToBaseFunc": "{x} * (1000 * 0.3048 * 0.3048 * 3600) / (1055.05585262 * 1.8)", + "FromBaseToUnitFunc": "{x} * (1055.05585262 * 1.8) / (1000 * 0.3048 * 0.3048 * 3600)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/Torque.json b/Common/UnitDefinitions/Torque.json index 4567759fe8..d19cebd6ad 100644 --- a/Common/UnitDefinitions/Torque.json +++ b/Common/UnitDefinitions/Torque.json @@ -37,6 +37,11 @@ { "SingularName": "NewtonMeter", "PluralName": "NewtonMeters", + "BaseUnits": { + "L": "Meter", + "M": "Kilogram", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], @@ -54,8 +59,8 @@ { "SingularName": "PoundalFoot", "PluralName": "PoundalFeet", - "FromUnitToBaseFunc": "{x} * 4.21401100938048e-2", - "FromBaseToUnitFunc": "{x} / 4.21401100938048e-2", + "FromUnitToBaseFunc": "{x} * 0.138254954376 * 0.3048", + "FromBaseToUnitFunc": "{x} / (0.138254954376 * 0.3048)", "Localization": [ { "Culture": "en-US", @@ -66,8 +71,8 @@ { "SingularName": "PoundForceInch", "PluralName": "PoundForceInches", - "FromUnitToBaseFunc": "{x} * 1.129848290276167e-1", - "FromBaseToUnitFunc": "{x} / 1.129848290276167e-1", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 * 2.54e-2", + "FromBaseToUnitFunc": "{x} / (4.4482216152605 * 2.54e-2)", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { @@ -80,8 +85,8 @@ { "SingularName": "PoundForceFoot", "PluralName": "PoundForceFeet", - "FromUnitToBaseFunc": "{x} * 1.3558179483314", - "FromBaseToUnitFunc": "{x} / 1.3558179483314", + "FromUnitToBaseFunc": "{x} * 4.4482216152605 * 0.3048", + "FromBaseToUnitFunc": "{x} / (4.4482216152605 * 0.3048)", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { diff --git a/Common/UnitDefinitions/TorquePerLength.json b/Common/UnitDefinitions/TorquePerLength.json deleted file mode 100644 index 89728fdc7f..0000000000 --- a/Common/UnitDefinitions/TorquePerLength.json +++ /dev/null @@ -1,155 +0,0 @@ -{ - "Name": "TorquePerLength", - "BaseUnit": "NewtonMeterPerMeter", - "XmlDocSummary": "The magnitude of torque per unit length.", - "BaseDimensions": { - "L": 1, - "M": 1, - "T": -2 - }, - "Units": [ - { - "SingularName": "NewtonMillimeterPerMeter", - "PluralName": "NewtonMillimetersPerMeter", - "FromUnitToBaseFunc": "{x} * 0.001", - "FromBaseToUnitFunc": "{x} * 1000", - "Prefixes": [ "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "N·mm/m" ] - } - ] - }, - { - "SingularName": "NewtonCentimeterPerMeter", - "PluralName": "NewtonCentimetersPerMeter", - "FromUnitToBaseFunc": "{x} * 0.01", - "FromBaseToUnitFunc": "{x} * 100", - "Prefixes": [ "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "N·cm/m" ] - } - ] - }, - { - "SingularName": "NewtonMeterPerMeter", - "PluralName": "NewtonMetersPerMeter", - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", - "Prefixes": [ "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "N·m/m" ] - }, - { - "Culture": "ru-RU", - "Abbreviations": [ "Н·м/м" ] - } - ] - }, - { - "SingularName": "PoundForceInchPerFoot", - "PluralName": "PoundForceInchesPerFoot", - "FromUnitToBaseFunc": "{x} * 0.370685147638", - "FromBaseToUnitFunc": "{x} / 0.370685147638", - "Prefixes": [ "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "lbf·in/ft" ], - "AbbreviationsForPrefixes": { "Kilo": "kipf·in/ft" } - } - ] - }, - { - "SingularName": "PoundForceFootPerFoot", - "PluralName": "PoundForceFeetPerFoot", - "FromUnitToBaseFunc": "{x} * 4.44822161526", - "FromBaseToUnitFunc": "{x} / 4.44822161526", - "Prefixes": [ "Kilo", "Mega" ], - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "lbf·ft/ft" ], - "AbbreviationsForPrefixes": { "Kilo": "kipf·ft/ft" } - } - ] - }, - { - "SingularName": "KilogramForceMillimeterPerMeter", - "PluralName": "KilogramForceMillimetersPerMeter", - "FromUnitToBaseFunc": "{x} * 0.00980665019960652", - "FromBaseToUnitFunc": "{x} * 101.971619222242", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "kgf·mm/m" ] - } - ] - }, - { - "SingularName": "KilogramForceCentimeterPerMeter", - "PluralName": "KilogramForceCentimetersPerMeter", - "FromUnitToBaseFunc": "{x} * 0.0980665019960652", - "FromBaseToUnitFunc": "{x} * 10.1971619222242", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "kgf·cm/m" ] - } - ] - }, - { - "SingularName": "KilogramForceMeterPerMeter", - "PluralName": "KilogramForceMetersPerMeter", - "FromUnitToBaseFunc": "{x} * 9.80665019960652", - "FromBaseToUnitFunc": "{x} * 0.101971619222242", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "kgf·m/m" ] - } - ] - }, - { - "SingularName": "TonneForceMillimeterPerMeter", - "PluralName": "TonneForceMillimetersPerMeter", - "FromUnitToBaseFunc": "{x} * 9.80665019960652", - "FromBaseToUnitFunc": "{x} * 0.101971619222242", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "tf·mm/m" ] - } - ] - }, - { - "SingularName": "TonneForceCentimeterPerMeter", - "PluralName": "TonneForceCentimetersPerMeter", - "FromUnitToBaseFunc": "{x} * 98.0665019960652", - "FromBaseToUnitFunc": "{x} * 0.0101971619222242", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "tf·cm/m" ] - } - ] - }, - { - "SingularName": "TonneForceMeterPerMeter", - "PluralName": "TonneForceMetersPerMeter", - "FromUnitToBaseFunc": "{x} * 9806.65019960653", - "FromBaseToUnitFunc": "{x} * 0.000101971619222242", - "Localization": [ - { - "Culture": "en-US", - "Abbreviations": [ "tf·m/m" ] - } - ] - } - ] -} diff --git a/Common/UnitDefinitions/Volume.json b/Common/UnitDefinitions/Volume.json index 270d3d2275..6abde4c0d0 100644 --- a/Common/UnitDefinitions/Volume.json +++ b/Common/UnitDefinitions/Volume.json @@ -9,6 +9,9 @@ { "SingularName": "Liter", "PluralName": "Liters", + "BaseUnits": { + "L": "Decimeter" + }, "FromUnitToBaseFunc": "{x} / 1e3", "FromBaseToUnitFunc": "{x} * 1e3", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo", "Mega" ], @@ -46,6 +49,9 @@ { "SingularName": "CubicKilometer", "PluralName": "CubicKilometers", + "BaseUnits": { + "L": "Kilometer" + }, "FromUnitToBaseFunc": "{x} * 1e9", "FromBaseToUnitFunc": "{x} / 1e9", "Localization": [ @@ -81,6 +87,9 @@ { "SingularName": "CubicDecimeter", "PluralName": "CubicDecimeters", + "BaseUnits": { + "L": "Decimeter" + }, "FromUnitToBaseFunc": "{x} / 1e3", "FromBaseToUnitFunc": "{x} * 1e3", "Localization": [ @@ -97,6 +106,9 @@ { "SingularName": "CubicCentimeter", "PluralName": "CubicCentimeters", + "BaseUnits": { + "L": "Centimeter" + }, "FromUnitToBaseFunc": "{x} / 1e6", "FromBaseToUnitFunc": "{x} * 1e6", "Localization": [ @@ -113,6 +125,9 @@ { "SingularName": "CubicMillimeter", "PluralName": "CubicMillimeters", + "BaseUnits": { + "L": "Millimeter" + }, "FromUnitToBaseFunc": "{x} / 1e9", "FromBaseToUnitFunc": "{x} * 1e9", "Localization": [ @@ -129,6 +144,9 @@ { "SingularName": "CubicMicrometer", "PluralName": "CubicMicrometers", + "BaseUnits": { + "L": "Micrometer" + }, "FromUnitToBaseFunc": "{x} / 1e18", "FromBaseToUnitFunc": "{x} * 1e18", "Localization": [ @@ -145,8 +163,13 @@ { "SingularName": "CubicMile", "PluralName": "CubicMiles", - "FromUnitToBaseFunc": "{x} * 4.16818182544058e9", - "FromBaseToUnitFunc": "{x} / 4.16818182544058e9", + "BaseUnits": { + "L": "Mile" + }, + "XmlDocSummary": "A cubic mile (abbreviation: cu mi or mi3) is an imperial and US customary (non-SI non-metric) unit of volume, used in the United States, Canada and the United Kingdom. It is defined as the volume of a cube with sides of 1 mile (63360 inches, 5280 feet, 1760 yards or ~1.609 kilometres) in length.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Cubic_mile", + "FromUnitToBaseFunc": "{x} * 4.168181825440579584e9", + "FromBaseToUnitFunc": "{x} / 4.168181825440579584e9", "Localization": [ { "Culture": "en-US", @@ -161,8 +184,13 @@ { "SingularName": "CubicYard", "PluralName": "CubicYards", - "FromUnitToBaseFunc": "{x} * 0.764554858", - "FromBaseToUnitFunc": "{x} / 0.764554858", + "BaseUnits": { + "L": "Yard" + }, + "XmlDocSummary": "A cubic yard is an Imperial / U.S. customary (non-SI non-metric) unit of volume, used in Canada and the United States. It is defined as the volume of a cube with sides of 1 yard (3 feet, 36 inches, 0.9144 meters) in length.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Cubic_yard", + "FromUnitToBaseFunc": "{x} * 0.764554857984", + "FromBaseToUnitFunc": "{x} / 0.764554857984", "Localization": [ { "Culture": "en-US", @@ -177,8 +205,13 @@ { "SingularName": "CubicFoot", "PluralName": "CubicFeet", - "FromUnitToBaseFunc": "{x} * 2.8316846592e-2", - "FromBaseToUnitFunc": "{x} / 2.8316846592e-2", + "BaseUnits": { + "L": "Foot" + }, + "XmlDocSummary": "The cubic foot (symbol ft3 or cu ft) is an imperial and US customary (non-metric) unit of volume, used in the United States and the United Kingdom. It is defined as the volume of a cube with sides of one foot (0.3048 m) in length.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Cubic_foot", + "FromUnitToBaseFunc": "{x} * 0.028316846592", + "FromBaseToUnitFunc": "{x} / 0.028316846592", "Prefixes": [ "Hecto", "Kilo", "Mega" ], "Localization": [ { @@ -194,6 +227,11 @@ { "SingularName": "CubicInch", "PluralName": "CubicInches", + "BaseUnits": { + "L": "Inch" + }, + "XmlDocSummary": "The cubic inch (symbol in3) is a unit of volume in the Imperial units and United States customary units systems. It is the volume of a cube with each of its three dimensions (length, width, and height) being one inch long which is equivalent to 1/231 of a US gallon.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Cubic_yard", "FromUnitToBaseFunc": "{x} * 1.6387064e-5", "FromBaseToUnitFunc": "{x} / 1.6387064e-5", "Localization": [ @@ -210,10 +248,10 @@ { "SingularName": "ImperialGallon", "PluralName": "ImperialGallons", - "FromUnitToBaseFunc": "{x} * 0.00454609", - "FromBaseToUnitFunc": "{x} / 0.00454609", "XmlDocSummary": "The British imperial gallon (frequently called simply \"gallon\") is defined as exactly 4.54609 litres.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Gallon#Imperial_gallon", + "FromUnitToBaseFunc": "{x} * 0.00454609", + "FromBaseToUnitFunc": "{x} / 0.00454609", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { @@ -229,8 +267,10 @@ { "SingularName": "ImperialOunce", "PluralName": "ImperialOunces", - "FromUnitToBaseFunc": "{x} * 2.8413062499962901241875439064617e-5", - "FromBaseToUnitFunc": "{x} / 2.8413062499962901241875439064617e-5", + "XmlDocSummary": "An imperial fluid ounce is 1⁄20 of an imperial pint, 1⁄160 of an imperial gallon or exactly 28.4130625 mL.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Fluid_ounce", + "FromUnitToBaseFunc": "{x} * 2.84130625e-5", + "FromBaseToUnitFunc": "{x} / 2.84130625e-5", "Localization": [ { "Culture": "en-US", @@ -245,10 +285,10 @@ { "SingularName": "UsGallon", "PluralName": "UsGallons", - "FromUnitToBaseFunc": "{x} * 0.003785411784", - "FromBaseToUnitFunc": "{x} / 0.003785411784", "XmlDocSummary": "The US liquid gallon (frequently called simply \"gallon\") is legally defined as 231 cubic inches, which is exactly 3.785411784 litres.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Gallon#US_liquid_gallon", + "FromUnitToBaseFunc": "{x} * 0.003785411784", + "FromBaseToUnitFunc": "{x} / 0.003785411784", "Prefixes": [ "Deca", "Deci", "Hecto", "Kilo", "Mega" ], "Localization": [ { @@ -264,8 +304,10 @@ { "SingularName": "UsOunce", "PluralName": "UsOunces", - "FromUnitToBaseFunc": "{x} * 2.957352956253760505068307980135e-5", - "FromBaseToUnitFunc": "{x} / 2.957352956253760505068307980135e-5", + "XmlDocSummary": "A US customary fluid ounce is 1⁄16 of a US liquid pint and 1⁄128 of a US liquid gallon or exactly 29.5735295625 mL, making it about 4.08% larger than the imperial fluid ounce.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Fluid_ounce", + "FromUnitToBaseFunc": "{x} * 2.95735295625e-5", + "FromBaseToUnitFunc": "{x} / 2.95735295625e-5", "Localization": [ { "Culture": "en-US", @@ -280,6 +322,8 @@ { "SingularName": "UsTablespoon", "PluralName": "UsTablespoons", + "XmlDocSummary": "The traditional U.S. interpretation of the tablespoon as a unit of volume is: 1 US tablespoon = 4 fluid drams, or 3 teaspoons or 1/2 US fluid ounce (≈ 14.8 ml)", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Tablespoon#United_States", "FromUnitToBaseFunc": "{x} * 1.478676478125e-5", "FromBaseToUnitFunc": "{x} / 1.478676478125e-5", "Localization": [ @@ -300,6 +344,8 @@ { "SingularName": "AuTablespoon", "PluralName": "AuTablespoons", + "XmlDocSummary": "In Australia, the definition of the tablespoon is 20 ml (0.70 imp fl oz).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Tablespoon#Australia", "FromUnitToBaseFunc": "{x} * 2e-5", "FromBaseToUnitFunc": "{x} / 2e-5", "Localization": [ @@ -320,6 +366,8 @@ { "SingularName": "UkTablespoon", "PluralName": "UkTablespoons", + "XmlDocSummary": "In nutrition labeling in the U.S. and the U.K., a tablespoon is defined as 15 ml (0.51 US fl oz). In Australia, the definition of the tablespoon is 20 ml (0.70 imp fl oz).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Tablespoon#International", "FromUnitToBaseFunc": "{x} * 1.5e-5", "FromBaseToUnitFunc": "{x} / 1.5e-5", "Localization": [ @@ -340,6 +388,8 @@ { "SingularName": "MetricTeaspoon", "PluralName": "MetricTeaspoons", + "XmlDocSummary": "The metric teaspoon as a unit of culinary measure is 5 ml (0.18 imp fl oz; 0.17 US fl oz),[17] equal to 5 cm3, 1⁄3 UK/Canadian metric tablespoon, or 1⁄4 Australian metric tablespoon.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Teaspoon#Metric_teaspoon", "FromUnitToBaseFunc": "{x} * 0.5e-5", "FromBaseToUnitFunc": "{x} / 0.5e-5", "Localization": [ @@ -360,6 +410,8 @@ { "SingularName": "UsTeaspoon", "PluralName": "UsTeaspoons", + "XmlDocSummary": "As a unit of culinary measure, one teaspoon in the United States is 1⁄3 tablespoon, exactly 4.92892159375 ml, 1 1⁄3 US fluid drams, 1⁄6 US fl oz, 1⁄48 US cup, 1⁄768 US liquid gallon, or 77⁄256 (0.30078125) cubic inches.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Teaspoon#United_States_customary_unit", "FromUnitToBaseFunc": "{x} * 4.92892159375e-6", "FromBaseToUnitFunc": "{x} / 4.92892159375e-6", "Localization": [ @@ -380,6 +432,8 @@ { "SingularName": "MetricCup", "PluralName": "MetricCups", + "XmlDocSummary": "Australia, Canada, New Zealand, and some other members of the Commonwealth of Nations, being former British colonies that have since metricated, employ a metric cup of 250 millilitres. Although derived from the metric system, it is not an SI unit.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Cup_(unit)#Metric_cup", "FromUnitToBaseFunc": "{x} * 0.00025", "FromBaseToUnitFunc": "{x} / 0.00025", "Localization": [ @@ -392,6 +446,8 @@ { "SingularName": "UsCustomaryCup", "PluralName": "UsCustomaryCups", + "XmlDocSummary": "In the United States, the customary cup is half of a liquid pint or 1⁄16 US customary gallon which is 236.5882365 milliliters exactly.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Cup_(unit)#Customary_cup", "FromUnitToBaseFunc": "{x} * 0.0002365882365", "FromBaseToUnitFunc": "{x} / 0.0002365882365", "Localization": [ @@ -404,6 +460,8 @@ { "SingularName": "UsLegalCup", "PluralName": "UsLegalCups", + "XmlDocSummary": "The cup currently used in the United States for nutrition labelling is defined in United States law as 240 ml.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Cup_(unit)#Legal_cup", "FromUnitToBaseFunc": "{x} * 0.00024", "FromBaseToUnitFunc": "{x} / 0.00024", "Localization": [ @@ -416,6 +474,8 @@ { "SingularName": "OilBarrel", "PluralName": "OilBarrels", + "XmlDocSummary": "In the oil industry, one barrel (unit symbol bbl) is a unit of volume used for measuring oil defined as exactly 42 US gallons, approximately 159 liters, or 35 imperial gallons.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Barrel_(unit)#Oil_barrel", "FromUnitToBaseFunc": "{x} * 0.158987294928", "FromBaseToUnitFunc": "{x} / 0.158987294928", "Localization": [ @@ -428,8 +488,10 @@ { "SingularName": "UsBeerBarrel", "PluralName": "UsBeerBarrels", - "FromUnitToBaseFunc": "{x} * 0.1173477658", - "FromBaseToUnitFunc": "{x} / 0.1173477658", + "XmlDocSummary": "Fluid barrels vary depending on what is being measured and where. In the US most fluid barrels (apart from oil) are 31.5 US gallons (26 imp gal; 119 L) (half a hogshead), but a beer barrel is 31 US gallons (26 imp gal; 117 L).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Barrel_(unit)#Fluid_barrel_in_the_US_and_UK", + "FromUnitToBaseFunc": "{x} * 0.117347765304", + "FromBaseToUnitFunc": "{x} / 0.117347765304", "Localization": [ { "Culture": "en-US", @@ -440,6 +502,8 @@ { "SingularName": "ImperialBeerBarrel", "PluralName": "ImperialBeerBarrels", + "XmlDocSummary": "Fluid barrels vary depending on what is being measured and where. In the UK a beer barrel is 36 imperial gallons (43 US gal; ~164 L).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Barrel_(unit)#Fluid_barrel_in_the_US_and_UK", "FromUnitToBaseFunc": "{x} * 0.16365924", "FromBaseToUnitFunc": "{x} / 0.16365924", "Localization": [ @@ -452,6 +516,8 @@ { "SingularName": "UsQuart", "PluralName": "UsQuarts", + "XmlDocSummary": "The US liquid quart equals 57.75 cubic inches, which is exactly equal to 0.946352946 L.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Quart#US_liquid_quart", "FromUnitToBaseFunc": "{x} * 9.46352946e-4", "FromBaseToUnitFunc": "{x} / 9.46352946e-4", "Localization": [ @@ -464,6 +530,8 @@ { "SingularName": "ImperialQuart", "PluralName": "ImperialQuarts", + "XmlDocSummary": "The imperial quart, which is used for both liquid and dry capacity, is equal to one quarter of an imperial gallon, or exactly 1.1365225 liters.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Quart#Imperial_quart", "FromUnitToBaseFunc": "{x} * 1.1365225e-3", "FromBaseToUnitFunc": "{x} / 1.1365225e-3", "Localization": [ @@ -476,6 +544,8 @@ { "SingularName": "UsPint", "PluralName": "UsPints", + "XmlDocSummary": "The pint is a unit of volume or capacity in both the imperial and United States customary measurement systems. In both of those systems it is traditionally one eighth of a gallon. The British imperial pint is about 20% larger than the American pint because the two systems are defined differently.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Pint#US_liquid_pint", "FromUnitToBaseFunc": "{x} * 4.73176473e-4", "FromBaseToUnitFunc": "{x} / 4.73176473e-4", "Localization": [ @@ -488,8 +558,10 @@ { "SingularName": "AcreFoot", "PluralName": "AcreFeet", - "FromUnitToBaseFunc": "{x} / 0.000810714", - "FromBaseToUnitFunc": "{x} * 0.000810714", + "XmlDocSummary": "An acre-foot is 43,560 cubic feet (~1,233.5 m3).", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Acre-foot", + "FromUnitToBaseFunc": "{x} * 1233.48183754752", + "FromBaseToUnitFunc": "{x} / 1233.48183754752", "Localization": [ { "Culture": "en-US", @@ -500,9 +572,8 @@ { "SingularName": "ImperialPint", "PluralName": "ImperialPints", - "BaseUnits": { - "L": "Decimeter" - }, + "XmlDocSummary": "The pint is a unit of volume or capacity in both the imperial and United States customary measurement systems. In both of those systems it is traditionally one eighth of a gallon. The British imperial pint is about 20% larger than the American pint because the two systems are defined differently.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Pint#Imperial_pint", "FromUnitToBaseFunc": "{x} * 5.6826125e-4", "FromBaseToUnitFunc": "{x} / 5.6826125e-4", "Localization": [ @@ -515,8 +586,10 @@ { "SingularName": "BoardFoot", "PluralName": "BoardFeet", - "FromUnitToBaseFunc": "{x} * 2.3597372158e-3", - "FromBaseToUnitFunc": "{x} / 2.3597372158e-3", + "XmlDocSummary": "The board foot or board-foot is a unit of measurement for the volume of lumber in the United States and Canada. It equals the volume of a board that is one-foot (305 mm) in length, one-foot (305 mm) in width, and one-inch (25.4 mm) in thickness.", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Board_foot", + "FromUnitToBaseFunc": "{x} * (0.028316846592 / 12)", + "FromBaseToUnitFunc": "{x} / (0.028316846592 / 12)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/VolumeConcentration.json b/Common/UnitDefinitions/VolumeConcentration.json index d72be50504..4cb5f09795 100644 --- a/Common/UnitDefinitions/VolumeConcentration.json +++ b/Common/UnitDefinitions/VolumeConcentration.json @@ -17,7 +17,7 @@ ] }, { - "SingularName": "LitersPerLiter", + "SingularName": "LiterPerLiter", "PluralName": "LitersPerLiter", "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", @@ -25,20 +25,20 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "L/L" ] + "Abbreviations": [ "l/l" ] } ] }, { - "SingularName": "LitersPerMililiter", - "PluralName": "LitersPerMililiter", + "SingularName": "LiterPerMilliliter", + "PluralName": "LitersPerMilliliter", "FromUnitToBaseFunc": "{x} / 1e-3", "FromBaseToUnitFunc": "{x} * 1e-3", "Prefixes": [ "Pico", "Nano", "Micro", "Milli", "Centi", "Deci" ], "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "L/mL" ] + "Abbreviations": [ "l/ml" ] } ] }, diff --git a/Common/UnitDefinitions/VolumeFlow.json b/Common/UnitDefinitions/VolumeFlow.json index e824e590f4..0df447b2b5 100644 --- a/Common/UnitDefinitions/VolumeFlow.json +++ b/Common/UnitDefinitions/VolumeFlow.json @@ -10,6 +10,10 @@ { "SingularName": "CubicMeterPerSecond", "PluralName": "CubicMetersPerSecond", + "BaseUnits": { + "L": "Meter", + "T": "Second" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Localization": [ @@ -26,6 +30,10 @@ { "SingularName": "CubicMeterPerMinute", "PluralName": "CubicMetersPerMinute", + "BaseUnits": { + "L": "Meter", + "T": "Minute" + }, "FromUnitToBaseFunc": "{x} / 60", "FromBaseToUnitFunc": "{x} * 60", "Localization": [ @@ -42,6 +50,10 @@ { "SingularName": "CubicMeterPerHour", "PluralName": "CubicMetersPerHour", + "BaseUnits": { + "L": "Meter", + "T": "Hour" + }, "FromUnitToBaseFunc": "{x} / 3600", "FromBaseToUnitFunc": "{x} * 3600", "Localization": [ @@ -58,6 +70,10 @@ { "SingularName": "CubicMeterPerDay", "PluralName": "CubicMetersPerDay", + "BaseUnits": { + "L": "Meter", + "T": "Day" + }, "FromUnitToBaseFunc": "{x} / 86400", "FromBaseToUnitFunc": "{x} * 86400", "Localization": [ @@ -70,8 +86,12 @@ { "SingularName": "CubicFootPerSecond", "PluralName": "CubicFeetPerSecond", - "FromUnitToBaseFunc": "{x} / 35.314666721", - "FromBaseToUnitFunc": "{x} * 35.314666721", + "BaseUnits": { + "L": "Foot", + "T": "Second" + }, + "FromUnitToBaseFunc": "{x} * 0.028316846592", + "FromBaseToUnitFunc": "{x} / 0.028316846592", "Localization": [ { "Culture": "en-US", @@ -82,8 +102,12 @@ { "SingularName": "CubicFootPerMinute", "PluralName": "CubicFeetPerMinute", - "FromUnitToBaseFunc": "{x} / 2118.88000326", - "FromBaseToUnitFunc": "{x} * 2118.88000326", + "BaseUnits": { + "L": "Foot", + "T": "Minute" + }, + "FromUnitToBaseFunc": "{x} * 0.028316846592 / 60", + "FromBaseToUnitFunc": "{x} / (0.028316846592 / 60)", "Localization": [ { "Culture": "en-US", @@ -94,8 +118,12 @@ { "SingularName": "CubicFootPerHour", "PluralName": "CubicFeetPerHour", - "FromUnitToBaseFunc": "{x} * 7.8657907199999087346816086183876e-6", - "FromBaseToUnitFunc": "{x} / 7.8657907199999087346816086183876e-6", + "BaseUnits": { + "L": "Foot", + "T": "Hour" + }, + "FromUnitToBaseFunc": "{x} * 0.028316846592 / 3600", + "FromBaseToUnitFunc": "{x} / (0.028316846592 / 3600)", "Localization": [ { "Culture": "en-US", @@ -118,8 +146,12 @@ { "SingularName": "CubicYardPerMinute", "PluralName": "CubicYardsPerMinute", - "FromUnitToBaseFunc": "{x} * 0.0127425809664", - "FromBaseToUnitFunc": "{x} / 0.0127425809664", + "BaseUnits": { + "L": "Yard", + "T": "Minute" + }, + "FromUnitToBaseFunc": "{x} * 0.764554857984 / 60", + "FromBaseToUnitFunc": "{x} / (0.764554857984 / 60)", "Localization": [ { "Culture": "en-US", @@ -130,8 +162,12 @@ { "SingularName": "CubicYardPerHour", "PluralName": "CubicYardsPerHour", - "FromUnitToBaseFunc": "{x} * 2.1237634944E-4", - "FromBaseToUnitFunc": "{x} / 2.1237634944E-4", + "BaseUnits": { + "L": "Yard", + "T": "Hour" + }, + "FromUnitToBaseFunc": "{x} * 0.764554857984 / 3600", + "FromBaseToUnitFunc": "{x} / (0.764554857984 / 3600)", "Localization": [ { "Culture": "en-US", @@ -142,8 +178,12 @@ { "SingularName": "CubicYardPerDay", "PluralName": "CubicYardsPerDay", - "FromUnitToBaseFunc": "{x} / 113007", - "FromBaseToUnitFunc": "{x} * 113007", + "BaseUnits": { + "L": "Yard", + "T": "Day" + }, + "FromUnitToBaseFunc": "{x} * 0.764554857984 / 86400", + "FromBaseToUnitFunc": "{x} / (0.764554857984 / 86400)", "Localization": [ { "Culture": "en-US", @@ -154,8 +194,8 @@ { "SingularName": "MillionUsGallonPerDay", "PluralName": "MillionUsGallonsPerDay", - "FromUnitToBaseFunc": "{x} / 22.824465227", - "FromBaseToUnitFunc": "{x} * 22.824465227", + "FromUnitToBaseFunc": "{x} * 1e6 * 0.003785411784 / 86400", + "FromBaseToUnitFunc": "{x} / (1e6 * 0.003785411784 / 86400)", "Localization": [ { "Culture": "en-US", @@ -166,8 +206,8 @@ { "SingularName": "UsGallonPerDay", "PluralName": "UsGallonsPerDay", - "FromUnitToBaseFunc": "{x} / 22824465.227", - "FromBaseToUnitFunc": "{x} * 22824465.227", + "FromUnitToBaseFunc": "{x} * 0.003785411784 / 86400", + "FromBaseToUnitFunc": "{x} / (0.003785411784 / 86400)", "Prefixes": [ "Mega" ], "Localization": [ { @@ -185,7 +225,7 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "L/s", "LPS" ] + "Abbreviations": [ "l/s", "LPS" ] }, { "Culture": "ru-RU", @@ -196,13 +236,13 @@ { "SingularName": "LiterPerMinute", "PluralName": "LitersPerMinute", - "FromUnitToBaseFunc": "{x} / 60000.00000", - "FromBaseToUnitFunc": "{x} * 60000.00000", + "FromUnitToBaseFunc": "{x} / (1000 * 60)", + "FromBaseToUnitFunc": "{x} * (1000 * 60)", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo", "Mega" ], "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "L/min", "LPM" ] + "Abbreviations": [ "l/min", "LPM" ] }, { "Culture": "ru-RU", @@ -213,13 +253,13 @@ { "SingularName": "LiterPerHour", "PluralName": "LitersPerHour", - "FromUnitToBaseFunc": "{x} / 3600000.000", - "FromBaseToUnitFunc": "{x} * 3600000.000", + "FromUnitToBaseFunc": "{x} / (1000 * 3600)", + "FromBaseToUnitFunc": "{x} * (1000 * 3600)", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo", "Mega" ], "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "L/h", "LPH" ] + "Abbreviations": [ "l/h", "LPH" ] }, { "Culture": "ru-RU", @@ -230,21 +270,21 @@ { "SingularName": "LiterPerDay", "PluralName": "LitersPerDay", - "FromUnitToBaseFunc": "{x} / 86400000", - "FromBaseToUnitFunc": "{x} * 86400000", + "FromUnitToBaseFunc": "{x} / (1000 * 86400)", + "FromBaseToUnitFunc": "{x} * (1000 * 86400)", "Prefixes": [ "Nano", "Micro", "Milli", "Centi", "Deci", "Deca", "Hecto", "Kilo", "Mega" ], "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "l/day", "L/d", "LPD" ] + "Abbreviations": [ "l/day", "l/d", "LPD" ] } ] }, { "SingularName": "UsGallonPerSecond", "PluralName": "UsGallonsPerSecond", - "FromUnitToBaseFunc": "{x} / 264.1720523581484", - "FromBaseToUnitFunc": "{x} * 264.1720523581484", + "FromUnitToBaseFunc": "{x} * 0.003785411784", + "FromBaseToUnitFunc": "{x} / 0.003785411784", "Localization": [ { "Culture": "en-US", @@ -255,8 +295,8 @@ { "SingularName": "UsGallonPerMinute", "PluralName": "UsGallonsPerMinute", - "FromUnitToBaseFunc": "{x} / 15850.323141489", - "FromBaseToUnitFunc": "{x} * 15850.323141489", + "FromUnitToBaseFunc": "{x} * 0.003785411784 / 60", + "FromBaseToUnitFunc": "{x} / (0.003785411784 / 60)", "Localization": [ { "Culture": "en-US", @@ -267,8 +307,8 @@ { "SingularName": "UkGallonPerDay", "PluralName": "UkGallonsPerDay", - "FromUnitToBaseFunc": "{x} / 19005304", - "FromBaseToUnitFunc": "{x} * 19005304", + "FromUnitToBaseFunc": "{x} * 0.00454609 / 86400", + "FromBaseToUnitFunc": "{x} / (0.00454609 / 86400)", "Prefixes": [ "Mega" ], "Localization": [ { @@ -280,8 +320,8 @@ { "SingularName": "UkGallonPerHour", "PluralName": "UkGallonsPerHour", - "FromUnitToBaseFunc": "{x} / 791887.667", - "FromBaseToUnitFunc": "{x} * 791887.667", + "FromUnitToBaseFunc": "{x} * 0.00454609 / 3600", + "FromBaseToUnitFunc": "{x} / (0.00454609 / 3600)", "Localization": [ { "Culture": "en-US", @@ -292,8 +332,8 @@ { "SingularName": "UkGallonPerMinute", "PluralName": "UkGallonsPerMinute", - "FromUnitToBaseFunc": "{x} / 13198.2", - "FromBaseToUnitFunc": "{x} * 13198.2", + "FromUnitToBaseFunc": "{x} * 0.00454609 / 60", + "FromBaseToUnitFunc": "{x} / (0.00454609 / 60)", "Localization": [ { "Culture": "en-US", @@ -304,8 +344,8 @@ { "SingularName": "UkGallonPerSecond", "PluralName": "UkGallonsPerSecond", - "FromUnitToBaseFunc": "{x} / 219.969", - "FromBaseToUnitFunc": "{x} * 219.969", + "FromUnitToBaseFunc": "{x} * 0.00454609", + "FromBaseToUnitFunc": "{x} / 0.00454609", "Prefixes": [ "Mega" ], "Localization": [ { @@ -317,8 +357,8 @@ { "SingularName": "KilousGallonPerMinute", "PluralName": "KilousGallonsPerMinute", - "FromUnitToBaseFunc": "{x} / 15.850323141489", - "FromBaseToUnitFunc": "{x} * 15.850323141489", + "FromUnitToBaseFunc": "{x} * 1000 * 0.003785411784 / 60", + "FromBaseToUnitFunc": "{x} / (1000 * 0.003785411784 / 60)", "Localization": [ { "Culture": "en-US", @@ -329,8 +369,8 @@ { "SingularName": "UsGallonPerHour", "PluralName": "UsGallonsPerHour", - "FromUnitToBaseFunc": "{x} / 951019.38848933424", - "FromBaseToUnitFunc": "{x} * 951019.38848933424", + "FromUnitToBaseFunc": "{x} * 0.003785411784 / 3600", + "FromBaseToUnitFunc": "{x} / (0.003785411784 / 3600)", "Localization": [ { "Culture": "en-US", @@ -341,6 +381,10 @@ { "SingularName": "CubicDecimeterPerMinute", "PluralName": "CubicDecimetersPerMinute", + "BaseUnits": { + "L": "Decimeter", + "T": "Minute" + }, "FromUnitToBaseFunc": "{x} / 60000.00000", "FromBaseToUnitFunc": "{x} * 60000.00000", "Localization": [ @@ -357,8 +401,8 @@ { "SingularName": "OilBarrelPerDay", "PluralName": "OilBarrelsPerDay", - "FromUnitToBaseFunc": "{x} * 1.8401307283333333333333333333333e-6", - "FromBaseToUnitFunc": "{x} / 1.8401307283333333333333333333333e-6", + "FromUnitToBaseFunc": "{x} * 0.158987294928 / 86400", + "FromBaseToUnitFunc": "{x} / (0.158987294928 / 86400)", "Localization": [ { "Culture": "en-US", @@ -369,8 +413,8 @@ { "SingularName": "OilBarrelPerMinute", "PluralName": "OilBarrelsPerMinute", - "FromUnitToBaseFunc": "{x} * 2.64978825e-3", - "FromBaseToUnitFunc": "{x} / 2.64978825e-3", + "FromUnitToBaseFunc": "{x} * 0.158987294928 / 60", + "FromBaseToUnitFunc": "{x} / (0.158987294928 / 60)", "Localization": [ { "Culture": "en-US", @@ -381,8 +425,8 @@ { "SingularName": "OilBarrelPerHour", "PluralName": "OilBarrelsPerHour", - "FromUnitToBaseFunc": "{x} * 4.41631375e-5", - "FromBaseToUnitFunc": "{x} / 4.41631375e-5", + "FromUnitToBaseFunc": "{x} * 0.158987294928 / 3600", + "FromBaseToUnitFunc": "{x} / (0.158987294928 / 3600)", "Localization": [ { "Culture": "en-US", @@ -393,8 +437,8 @@ { "SingularName": "OilBarrelPerSecond", "PluralName": "OilBarrelsPerSecond", - "FromUnitToBaseFunc": "{x} / 6.28981", - "FromBaseToUnitFunc": "{x} * 6.28981", + "FromUnitToBaseFunc": "{x} * 0.158987294928", + "FromBaseToUnitFunc": "{x} / 0.158987294928", "Localization": [ { "Culture": "en-US", @@ -405,6 +449,10 @@ { "SingularName": "CubicMillimeterPerSecond", "PluralName": "CubicMillimetersPerSecond", + "BaseUnits": { + "L": "Millimeter", + "T": "Second" + }, "FromUnitToBaseFunc": "{x} * 1e-9", "FromBaseToUnitFunc": "{x} / 1e-9", "Localization": [ @@ -421,8 +469,8 @@ { "SingularName": "AcreFootPerSecond", "PluralName": "AcreFeetPerSecond", - "FromUnitToBaseFunc": "{x} / 0.000810713194", - "FromBaseToUnitFunc": "{x} * 0.000810713194", + "FromUnitToBaseFunc": "{x} * 1233.48183754752", + "FromBaseToUnitFunc": "{x} / 1233.48183754752", "Localization": [ { "Culture": "en-US", @@ -433,8 +481,8 @@ { "SingularName": "AcreFootPerMinute", "PluralName": "AcreFeetPerMinute", - "FromUnitToBaseFunc": "{x} / 0.0486427916", - "FromBaseToUnitFunc": "{x} * 0.0486427916", + "FromUnitToBaseFunc": "{x} * 1233.48183754752 / 60", + "FromBaseToUnitFunc": "{x} / (1233.48183754752 / 60)", "Localization": [ { "Culture": "en-US", @@ -445,8 +493,8 @@ { "SingularName": "AcreFootPerHour", "PluralName": "AcreFeetPerHour", - "FromUnitToBaseFunc": "{x} / 2.91857", - "FromBaseToUnitFunc": "{x} * 2.91857", + "FromUnitToBaseFunc": "{x} * 1233.48183754752 / 3600", + "FromBaseToUnitFunc": "{x} / (1233.48183754752 / 3600)", "Localization": [ { "Culture": "en-US", @@ -457,8 +505,8 @@ { "SingularName": "AcreFootPerDay", "PluralName": "AcreFeetPerDay", - "FromUnitToBaseFunc": "{x} / 70.0457", - "FromBaseToUnitFunc": "{x} * 70.0457", + "FromUnitToBaseFunc": "{x} * 1233.48183754752 / 86400", + "FromBaseToUnitFunc": "{x} / (1233.48183754752 / 86400)", "Localization": [ { "Culture": "en-US", @@ -469,8 +517,12 @@ { "SingularName": "CubicCentimeterPerMinute", "PluralName": "CubicCentimetersPerMinute", - "FromUnitToBaseFunc": "{x} * 1.6666666666667e-8", - "FromBaseToUnitFunc": "{x} / 1.6666666666667e-8", + "BaseUnits": { + "L": "Centimeter", + "T": "Minute" + }, + "FromUnitToBaseFunc": "{x} * 1e-6 / 60", + "FromBaseToUnitFunc": "{x} / (1e-6 / 60)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/VolumeFlowPerArea.json b/Common/UnitDefinitions/VolumeFlowPerArea.json index 0e015027d0..4ca48a9994 100644 --- a/Common/UnitDefinitions/VolumeFlowPerArea.json +++ b/Common/UnitDefinitions/VolumeFlowPerArea.json @@ -31,8 +31,8 @@ "T": "Minute" }, - "FromUnitToBaseFunc": "{x} / 196.850394", - "FromBaseToUnitFunc": "{x} * 196.850394", + "FromUnitToBaseFunc": "{x} * (0.028316846592 / 60) / 9.290304e-2", + "FromBaseToUnitFunc": "{x} * 9.290304e-2 / (0.028316846592 / 60)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/VolumePerLength.json b/Common/UnitDefinitions/VolumePerLength.json index c436ca013f..96c4e0e5c1 100644 --- a/Common/UnitDefinitions/VolumePerLength.json +++ b/Common/UnitDefinitions/VolumePerLength.json @@ -67,8 +67,8 @@ { "SingularName": "OilBarrelPerFoot", "PluralName": "OilBarrelsPerFoot", - "FromUnitToBaseFunc": "{x} / 1.91713408", - "FromBaseToUnitFunc": "{x} * 1.91713408", + "FromUnitToBaseFunc": "{x} * 0.158987294928 / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048 / 0.158987294928", "Prefixes": [], "Localization": [ { @@ -80,8 +80,8 @@ { "SingularName": "CubicYardPerFoot", "PluralName": "CubicYardsPerFoot", - "FromUnitToBaseFunc": "{x} * 2.50838208", - "FromBaseToUnitFunc": "{x} / 2.50838208", + "FromUnitToBaseFunc": "{x} * 0.764554857984 / 0.3048", + "FromBaseToUnitFunc": "{x} * 0.3048 / 0.764554857984", "Localization": [ { "Culture": "en-US", @@ -92,8 +92,8 @@ { "SingularName": "CubicYardPerUsSurveyFoot", "PluralName": "CubicYardsPerUsSurveyFoot", - "FromUnitToBaseFunc": "{x} * 2.50837706323584", - "FromBaseToUnitFunc": "{x} / 2.50837706323584", + "FromUnitToBaseFunc": "{x} * 0.764554857984 * 3937 / 1200", + "FromBaseToUnitFunc": "{x} * 1200 / (0.764554857984 * 3937)", "Localization": [ { "Culture": "en-US", @@ -104,8 +104,8 @@ { "SingularName": "UsGallonPerMile", "PluralName": "UsGallonsPerMile", - "FromUnitToBaseFunc": "{x} / (1000 * 1609.344 / 3.785411784)", - "FromBaseToUnitFunc": "{x} * (1000 * 1609.344 / 3.785411784)", + "FromUnitToBaseFunc": "{x} * 0.003785411784 / 1609.344", + "FromBaseToUnitFunc": "{x} * 1609.344 / 0.003785411784", "Localization": [ { "Culture": "en-US", @@ -116,8 +116,8 @@ { "SingularName": "ImperialGallonPerMile", "PluralName": "ImperialGallonsPerMile", - "FromUnitToBaseFunc": "{x} / (1000 * 1609.344 / 4.54609)", - "FromBaseToUnitFunc": "{x} * (1000 * 1609.344 / 4.54609)", + "FromUnitToBaseFunc": "{x} * 0.00454609 / 1609.344", + "FromBaseToUnitFunc": "{x} * 1609.344 / 0.00454609", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/VolumetricHeatCapacity.json b/Common/UnitDefinitions/VolumetricHeatCapacity.json index 0beebc41bd..08a9d02103 100644 --- a/Common/UnitDefinitions/VolumetricHeatCapacity.json +++ b/Common/UnitDefinitions/VolumetricHeatCapacity.json @@ -13,51 +13,64 @@ { "SingularName": "JoulePerCubicMeterKelvin", "PluralName": "JoulesPerCubicMeterKelvin", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second", + "Θ": "Kelvin" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "J/m³·K" ] + "Abbreviations": [ "J/(m³·K)" ] } ] }, { "SingularName": "JoulePerCubicMeterDegreeCelsius", "PluralName": "JoulesPerCubicMeterDegreeCelsius", + "BaseUnits": { + "M": "Kilogram", + "L": "Meter", + "T": "Second", + "Θ": "DegreeCelsius" + }, "FromUnitToBaseFunc": "{x}", "FromBaseToUnitFunc": "{x}", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "J/m³·°C" ] + "Abbreviations": [ "J/(m³·°C)" ] } ] }, { "SingularName": "CaloriePerCubicCentimeterDegreeCelsius", "PluralName": "CaloriesPerCubicCentimeterDegreeCelsius", - "FromUnitToBaseFunc": "{x} / 2.388459e-7", - "FromBaseToUnitFunc": "{x} * 2.388459e-7", + "FromUnitToBaseFunc": "{x} * 4.184e6", + "FromBaseToUnitFunc": "{x} / 4.184e6", "Prefixes": [ "Kilo" ], "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "cal/cm³·°C" ] + "Abbreviations": [ "cal/(cm³·°C)" ] } ] }, { "SingularName": "BtuPerCubicFootDegreeFahrenheit", "PluralName": "BtusPerCubicFootDegreeFahrenheit", - "FromUnitToBaseFunc": "{x} / 1.4910660e-5", - "FromBaseToUnitFunc": "{x} * 1.4910660e-5", + "XmlDocRemarks": "Based on the International Table (IT) definition of the British thermal unit (BTU), where 1 BTU is defined as exactly 1055.05585262 joules (≈1.05506 kJ). See https://en.wikipedia.org/wiki/British_thermal_unit for details.", + "FromUnitToBaseFunc": "{x} * (1055.05585262 / 0.028316846592) * 1.8", + "FromBaseToUnitFunc": "{x} / ((1055.05585262 / 0.028316846592) * 1.8)", "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "BTU/ft³·°F" ] + "Abbreviations": [ "BTU/(ft³·°F)" ] } ] } diff --git a/Common/UnitDefinitions/WarpingMomentOfInertia.json b/Common/UnitDefinitions/WarpingMomentOfInertia.json index 8142bc641d..dddb9188d6 100644 --- a/Common/UnitDefinitions/WarpingMomentOfInertia.json +++ b/Common/UnitDefinitions/WarpingMomentOfInertia.json @@ -72,8 +72,8 @@ "BaseUnits": { "L": "Foot" }, - "FromUnitToBaseFunc": "{x} * Math.Pow(0.3048, 6)", - "FromBaseToUnitFunc": "{x} / Math.Pow(0.3048, 6)", + "FromUnitToBaseFunc": "{x} * 0.000801843800914862014464", + "FromBaseToUnitFunc": "{x} / 0.000801843800914862014464", "Localization": [ { "Culture": "en-US", @@ -87,8 +87,8 @@ "BaseUnits": { "L": "Inch" }, - "FromUnitToBaseFunc": "{x} * Math.Pow(2.54e-2, 6)", - "FromBaseToUnitFunc": "{x} / Math.Pow(2.54e-2, 6)", + "FromUnitToBaseFunc": "{x} * 0.000000000268535866540096", + "FromBaseToUnitFunc": "{x} / 0.000000000268535866540096", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitEnumValues.g.json b/Common/UnitEnumValues.g.json index 61e715b277..ca73979277 100644 --- a/Common/UnitEnumValues.g.json +++ b/Common/UnitEnumValues.g.json @@ -67,19 +67,6 @@ "Revolution": 15, "Tilt": 16 }, - "ApparentEnergy": { - "KilovoltampereHour": 1, - "MegavoltampereHour": 2, - "VoltampereHour": 3 - }, - "ApparentPower": { - "Gigavoltampere": 1, - "Kilovoltampere": 2, - "Megavoltampere": 3, - "Voltampere": 4, - "Microvoltampere": 6, - "Millivoltampere": 7 - }, "Area": { "Acre": 1, "Hectare": 2, @@ -142,15 +129,6 @@ "KilogramPerJoule": 2, "PoundPerMechanicalHorsepowerHour": 3 }, - "Capacitance": { - "Farad": 1, - "Kilofarad": 2, - "Megafarad": 3, - "Microfarad": 4, - "Millifarad": 5, - "Nanofarad": 6, - "Picofarad": 7 - }, "CoefficientOfThermalExpansion": { "InverseDegreeCelsius": 1, "InverseDegreeFahrenheit": 2, @@ -358,13 +336,6 @@ "Volt": 5, "Nanovolt": 11 }, - "ElectricPotentialAc": { - "KilovoltAc": 1, - "MegavoltAc": 2, - "MicrovoltAc": 3, - "MillivoltAc": 4, - "VoltAc": 5 - }, "ElectricPotentialChangeRate": { "KilovoltPerHour": 1, "KilovoltPerMicrosecond": 2, @@ -387,13 +358,6 @@ "VoltPerMinute": 19, "VoltPerSecond": 20 }, - "ElectricPotentialDc": { - "KilovoltDc": 1, - "MegavoltDc": 2, - "MicrovoltDc": 3, - "MillivoltDc": 4, - "VoltDc": 5 - }, "ElectricResistance": { "Gigaohm": 1, "Kiloohm": 2, @@ -985,11 +949,11 @@ "KilotonneSquareCentimeter": 9, "KilotonneSquareDecimeter": 10, "KilotonneSquareMeter": 11, - "KilotonneSquareMilimeter": 12, + "KilotonneSquareMillimeter": 12, "MegatonneSquareCentimeter": 13, "MegatonneSquareDecimeter": 14, "MegatonneSquareMeter": 15, - "MegatonneSquareMilimeter": 16, + "MegatonneSquareMillimeter": 16, "MilligramSquareCentimeter": 17, "MilligramSquareDecimeter": 18, "MilligramSquareMeter": 19, @@ -1001,7 +965,7 @@ "TonneSquareCentimeter": 25, "TonneSquareDecimeter": 26, "TonneSquareMeter": 27, - "TonneSquareMilimeter": 28 + "TonneSquareMillimeter": 28 }, "MolarEnergy": { "JoulePerMole": 1, @@ -1226,17 +1190,6 @@ "DecimalFractionPerSecond": 1, "PercentPerSecond": 2 }, - "ReactiveEnergy": { - "KilovoltampereReactiveHour": 1, - "MegavoltampereReactiveHour": 2, - "VoltampereReactiveHour": 3 - }, - "ReactivePower": { - "GigavoltampereReactive": 1, - "KilovoltampereReactive": 2, - "MegavoltampereReactive": 3, - "VoltampereReactive": 4 - }, "ReciprocalArea": { "InverseSquareCentimeter": 1, "InverseSquareDecimeter": 2, @@ -1378,9 +1331,9 @@ "MegajoulePerKilogramKelvin": 9 }, "SpecificFuelConsumption": { - "GramPerKiloNewtonSecond": 1, + "GramPerKilonewtonSecond": 1, "KilogramPerKilogramForceHour": 2, - "KilogramPerKiloNewtonSecond": 3, + "KilogramPerKilonewtonSecond": 3, "PoundMassPerPoundForceHour": 4 }, "SpecificVolume": { @@ -1626,26 +1579,26 @@ "ImperialQuart": 57 }, "VolumeConcentration": { - "CentilitersPerLiter": 1, - "CentilitersPerMililiter": 2, - "DecilitersPerLiter": 3, - "DecilitersPerMililiter": 4, + "CentiliterPerLiter": 1, + "CentiliterPerMilliliter": 2, + "DeciliterPerLiter": 3, + "DeciliterPerMilliliter": 4, "DecimalFraction": 5, - "LitersPerLiter": 6, - "LitersPerMililiter": 7, - "MicrolitersPerLiter": 8, - "MicrolitersPerMililiter": 9, - "MillilitersPerLiter": 10, - "MillilitersPerMililiter": 11, - "NanolitersPerLiter": 12, - "NanolitersPerMililiter": 13, + "LiterPerLiter": 6, + "LiterPerMilliliter": 7, + "MicroliterPerLiter": 8, + "MicroliterPerMilliliter": 9, + "MilliliterPerLiter": 10, + "MilliliterPerMilliliter": 11, + "NanoliterPerLiter": 12, + "NanoliterPerMilliliter": 13, "PartPerBillion": 14, "PartPerMillion": 15, "PartPerThousand": 16, "PartPerTrillion": 17, "Percent": 18, - "PicolitersPerLiter": 19, - "PicolitersPerMililiter": 20 + "PicoliterPerLiter": 19, + "PicoliterPerMilliliter": 20 }, "VolumeFlow": { "AcreFootPerDay": 1, @@ -1928,27 +1881,6 @@ "MilligraySquareMeter": 11, "MilligraySquareMillimeter": 12 }, - "FluidResistance": { - "DyneSecondPerCentimeterToTheFifth": 6, - "MegapascalSecondPerCubicMeter": 7, - "MillimeterMercuryMinutePerCubicCentimeter": 3, - "MillimeterMercuryMinutePerCubicMeter": 5, - "MillimeterMercuryMinutePerLiter": 2, - "MillimeterMercuryMinutePerMilliliter": 9, - "MillimeterMercurySecondPerCubicCentimeter": 8, - "MillimeterMercurySecondPerCubicMeter": 10, - "MillimeterMercurySecondPerLiter": 4, - "MillimeterMercurySecondPerMilliliter": 1, - "PascalMinutePerCubicCentimeter": 19, - "PascalMinutePerCubicMeter": 16, - "PascalMinutePerLiter": 15, - "PascalMinutePerMilliliter": 12, - "PascalSecondPerCubicCentimeter": 18, - "PascalSecondPerCubicMeter": 13, - "PascalSecondPerLiter": 11, - "PascalSecondPerMilliliter": 20, - "WoodUnit": 17 - }, "ElectricApparentEnergy": { "KilovoltampereHour": 7, "MegavoltampereHour": 3, @@ -2019,5 +1951,34 @@ "Nanoohm": 7, "Ohm": 6, "Teraohm": 5 + }, + "FluidResistance": { + "DyneSecondPerCentimeterToTheFifth": 6, + "MegapascalSecondPerCubicMeter": 7, + "MillimeterMercuryMinutePerCubicCentimeter": 3, + "MillimeterMercuryMinutePerCubicMeter": 5, + "MillimeterMercuryMinutePerLiter": 2, + "MillimeterMercuryMinutePerMilliliter": 9, + "MillimeterMercurySecondPerCubicCentimeter": 8, + "MillimeterMercurySecondPerCubicMeter": 10, + "MillimeterMercurySecondPerLiter": 4, + "MillimeterMercurySecondPerMilliliter": 1, + "PascalMinutePerCubicCentimeter": 19, + "PascalMinutePerCubicMeter": 16, + "PascalMinutePerLiter": 15, + "PascalMinutePerMilliliter": 12, + "PascalSecondPerCubicCentimeter": 18, + "PascalSecondPerCubicMeter": 13, + "PascalSecondPerLiter": 11, + "PascalSecondPerMilliliter": 20, + "WoodUnit": 17 + }, + "ThermalInsulance": { + "HourSquareFeetDegreeFahrenheitPerBtu": 2, + "SquareCentimeterHourDegreeCelsiusPerKilocalorie": 6, + "SquareCentimeterKelvinPerWatt": 7, + "SquareMeterDegreeCelsiusPerWatt": 3, + "SquareMeterKelvinPerKilowatt": 5, + "SquareMeterKelvinPerWatt": 4 } } diff --git a/Common/UnitRelations.json b/Common/UnitRelations.json new file mode 100644 index 0000000000..bded89653c --- /dev/null +++ b/Common/UnitRelations.json @@ -0,0 +1,85 @@ +[ + "1 = Area.SquareMeter * ReciprocalArea.InverseSquareMeter", + "1 = Density.KilogramPerCubicMeter * SpecificVolume.CubicMeterPerKilogram", + "1 = ElectricResistivity.OhmMeter * ElectricConductivity.SiemensPerMeter", + "1 = Length.Meter * ReciprocalLength.InverseMeter", + "Acceleration.MeterPerSecondSquared = Jerk.MeterPerSecondCubed * Duration.Second", + "AmountOfSubstance.Mole = MolarFlow.MolePerSecond * Duration.Second", + "AmountOfSubstance.Mole = Molarity.MolePerCubicMeter * Volume.CubicMeter", + "Angle.Radian = RotationalSpeed.RadianPerSecond * Duration.Second", + "Area.SquareMeter = KinematicViscosity.SquareMeterPerSecond * Duration.Second -- NoInferredDivision", + "Area.SquareMeter = Length.Meter * Length.Meter", + "Area.SquareMeter = Volume.CubicMeter * ReciprocalLength.InverseMeter", + "AreaMomentOfInertia.MeterToTheFourth = Volume.CubicMeter * Length.Meter", + "double = SpecificEnergy.JoulePerKilogram * BrakeSpecificFuelConsumption.KilogramPerJoule", + "DynamicViscosity.NewtonSecondPerMeterSquared = Density.KilogramPerCubicMeter * KinematicViscosity.SquareMeterPerSecond", + "ElectricCharge.AmpereHour = ElectricCurrent.Ampere * Duration.Hour", + "ElectricCurrent.Ampere = ElectricCurrentGradient.AmperePerSecond * Duration.Second", + "ElectricPotential.Volt = ElectricCurrent.Ampere * ElectricResistance.Ohm", + "Energy.Joule = ElectricPotential.Volt * ElectricCharge.Coulomb", + "Energy.Joule = EnergyDensity.JoulePerCubicMeter * Volume.CubicMeter", + "Energy.Joule = MolarEnergy.JoulePerMole * AmountOfSubstance.Mole", + "Energy.Joule = Power.Watt * Duration.Second", + "Energy.Joule = SpecificEnergy.JoulePerKilogram * Mass.Kilogram", + "Energy.Joule = TemperatureDelta.Kelvin * Entropy.JoulePerKelvin", + "Entropy.JoulePerKelvin = SpecificEntropy.JoulePerKilogramKelvin * Mass.Kilogram", + "Force.Newton = ForceChangeRate.NewtonPerSecond * Duration.Second", + "Force.Newton = ForcePerLength.NewtonPerMeter * Length.Meter", + "Force.Newton = Mass.Kilogram * Acceleration.MeterPerSecondSquared", + "Force.Newton = Pressure.Pascal * Area.SquareMeter", + "ForcePerLength.NewtonPerMeter = Force.Newton * ReciprocalLength.InverseMeter", + "ForcePerLength.NewtonPerMeter = Pressure.NewtonPerSquareMeter * Length.Meter", + "ForcePerLength.NewtonPerMeter = SpecificWeight.NewtonPerCubicMeter * Area.SquareMeter", + "KinematicViscosity.SquareMeterPerSecond = Length.Meter * Speed.MeterPerSecond", + "Length.Meter = Area.SquareMeter * ReciprocalLength.InverseMeter", + "Length.Meter = Speed.MeterPerSecond * Duration.Second", + "Length.Meter = Volume.CubicMeter * ReciprocalArea.InverseSquareMeter", + "LinearDensity.KilogramPerMeter = Area.SquareMeter * Density.KilogramPerCubicMeter", + "LuminousFlux.Lumen = Illuminance.Lux * Area.SquareMeter", + "LuminousIntensity.Candela = Luminance.CandelaPerSquareMeter * Area.SquareMeter", + "Mass.Kilogram = AmountOfSubstance.Mole * MolarMass.KilogramPerMole", + "Mass.Kilogram = AreaDensity.KilogramPerSquareMeter * Area.SquareMeter", + "Mass.Kilogram = Density.KilogramPerCubicMeter * Volume.CubicMeter", + "Mass.Kilogram = LinearDensity.KilogramPerMeter * Length.Meter", + "Mass.Kilogram = MassConcentration.KilogramPerCubicMeter * Volume.CubicMeter -- NoInferredDivision", + "Mass.Kilogram = MassFlow.KilogramPerSecond * Duration.Second", + "Mass.Kilogram = MassFraction.DecimalFraction * Mass.Kilogram", + "MassConcentration.KilogramPerCubicMeter = Molarity.MolePerCubicMeter * MolarMass.KilogramPerMole", + "MassConcentration.KilogramPerCubicMeter = VolumeConcentration.DecimalFraction * Density.KilogramPerCubicMeter", + "MassFlow.KilogramPerSecond = Area.SquareMeter * MassFlux.KilogramPerSecondPerSquareMeter", + "MassFlow.KilogramPerSecond = MolarFlow.KilomolePerSecond * MolarMass.KilogramPerKilomole", + "MassFlow.KilogramPerSecond = Power.Watt * BrakeSpecificFuelConsumption.KilogramPerJoule", + "MassFlow.KilogramPerSecond = VolumeFlow.CubicMeterPerSecond * Density.KilogramPerCubicMeter", + "MassFlux.KilogramPerSecondPerSquareMeter = Speed.MeterPerSecond * Density.KilogramPerCubicMeter", + "MolarFlow.MolePerSecond = VolumeFlow.CubicMeterPerSecond * Molarity.MolePerCubicMeter", + "Molarity.MolePerCubicMeter = Molarity.MolePerCubicMeter * VolumeConcentration.DecimalFraction", + "Power.Watt = ElectricPotential.Volt * ElectricCurrent.Ampere", + "Power.Watt = Energy.Joule * Frequency.PerSecond", + "Power.Watt = Force.Newton * Speed.MeterPerSecond", + "Power.Watt = HeatFlux.WattPerSquareMeter * Area.SquareMeter", + "Power.Watt = SpecificEnergy.JoulePerKilogram * MassFlow.KilogramPerSecond", + "Power.Watt = Torque.NewtonMeter * RotationalSpeed.RadianPerSecond", + "Pressure.NewtonPerSquareMeter = Force.Newton * ReciprocalArea.InverseSquareMeter", + "Pressure.NewtonPerSquareMeter = ForcePerLength.NewtonPerMeter * ReciprocalLength.InverseMeter", + "Pressure.Pascal = PressureChangeRate.PascalPerSecond * Duration.Second", + "Pressure.Pascal = SpecificWeight.NewtonPerCubicMeter * Length.Meter", + "RadiationEquivalentDose.Sievert = RadiationEquivalentDoseRate.SievertPerHour * Duration.Hour", + "Ratio.DecimalFraction = Area.SquareMeter * ReciprocalArea.InverseSquareMeter -- NoInferredDivision", + "Ratio.DecimalFraction = TemperatureDelta.Kelvin * CoefficientOfThermalExpansion.PerKelvin -- NoInferredDivision", + "ReciprocalArea.InverseSquareMeter = ReciprocalLength.InverseMeter * ReciprocalLength.InverseMeter", + "ReciprocalLength.InverseMeter = Length.Meter * ReciprocalArea.InverseSquareMeter", + "RotationalStiffness.NewtonMeterPerRadian = RotationalStiffnessPerLength.NewtonMeterPerRadianPerMeter * Length.Meter", + "SpecificEnergy.JoulePerKilogram = SpecificEntropy.JoulePerKilogramKelvin * TemperatureDelta.Kelvin", + "SpecificEnergy.JoulePerKilogram = Speed.MeterPerSecond * Speed.MeterPerSecond", + "SpecificWeight.NewtonPerCubicMeter = Acceleration.MeterPerSecondSquared * Density.KilogramPerCubicMeter", + "Speed.MeterPerSecond = Acceleration.MeterPerSecondSquared * Duration.Second", + "TemperatureDelta.DegreeCelsius = TemperatureChangeRate.DegreeCelsiusPerSecond * Duration.Second", + "TemperatureDelta.DegreeCelsius = TemperatureGradient.DegreeCelsiusPerKilometer * Length.Kilometer", + "Torque.NewtonMeter = ForcePerLength.NewtonPerMeter * Area.SquareMeter", + "Torque.NewtonMeter = Length.Meter * Force.Newton", + "Torque.NewtonMeter = RotationalStiffness.NewtonMeterPerRadian * Angle.Radian", + "Volume.CubicMeter = Length.Meter * Area.SquareMeter", + "Volume.CubicMeter = SpecificVolume.CubicMeterPerKilogram * Mass.Kilogram", + "Volume.CubicMeter = VolumeFlow.CubicMeterPerSecond * Duration.Second", + "VolumeFlow.CubicMeterPerSecond = Area.SquareMeter * Speed.MeterPerSecond" +] \ No newline at end of file diff --git a/Directory.Build.props b/Directory.Build.props index 59cfd13c48..2fa148beba 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -21,8 +21,14 @@ 612,618 + + + true + snupkg + + - \ No newline at end of file + diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000000..54479369db --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,20 @@ + + + true + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + \ No newline at end of file diff --git a/PerfTests/PerfTest_Startup_v4_144_0/PerfTest_Startup_v4_144_0.csproj b/PerfTests/PerfTest_Startup_v4_144_0/PerfTest_Startup_v4_144_0.csproj index 72f0d30d29..c585fb0727 100644 --- a/PerfTests/PerfTest_Startup_v4_144_0/PerfTest_Startup_v4_144_0.csproj +++ b/PerfTests/PerfTest_Startup_v4_144_0/PerfTest_Startup_v4_144_0.csproj @@ -9,7 +9,7 @@ - + diff --git a/PerfTests/PerfTest_Startup_v4_72_0/PerfTest_Startup_v4_72_0.csproj b/PerfTests/PerfTest_Startup_v4_72_0/PerfTest_Startup_v4_72_0.csproj index 7627f1bbe4..6e31c36338 100644 --- a/PerfTests/PerfTest_Startup_v4_72_0/PerfTest_Startup_v4_72_0.csproj +++ b/PerfTests/PerfTest_Startup_v4_72_0/PerfTest_Startup_v4_72_0.csproj @@ -9,7 +9,7 @@ - + diff --git a/Samples/Directory.Packages.props b/Samples/Directory.Packages.props new file mode 100644 index 0000000000..3f24827b01 --- /dev/null +++ b/Samples/Directory.Packages.props @@ -0,0 +1,13 @@ + + + true + + + + + + + + + + \ No newline at end of file diff --git a/Samples/MvvmSample.Wpf/MvvmSample.Wpf/App.xaml.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/App.xaml.cs index 41c001cc97..9b9bf71e09 100644 --- a/Samples/MvvmSample.Wpf/MvvmSample.Wpf/App.xaml.cs +++ b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/App.xaml.cs @@ -16,7 +16,7 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry) protected override Window CreateShell() { - return new MainWindow(); + return Container.Resolve(); } } } diff --git a/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Converters/UnitToStringConverter.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Converters/UnitToStringConverter.cs index 04dcdb901e..f7f2806f73 100644 --- a/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Converters/UnitToStringConverter.cs +++ b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Converters/UnitToStringConverter.cs @@ -6,7 +6,7 @@ using System.Windows.Controls; using System.Windows.Data; using System.Windows.Markup; -using CommonServiceLocator; +using Prism.Ioc; using UnitsNet; using WpfMVVMSample.Settings; @@ -22,7 +22,7 @@ public UnitToStringConverter() { if (!DesignerProperties.GetIsInDesignMode(new DependencyObject())) { - _settings = ServiceLocator.Current.GetInstance(); + _settings = Prism.Ioc.ContainerLocator.Container.Resolve(); } } diff --git a/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindow.xaml.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindow.xaml.cs index e0d2d6299d..2245d7f9cf 100644 --- a/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindow.xaml.cs +++ b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindow.xaml.cs @@ -1,17 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; +using System.Windows; namespace WpfMVVMSample { diff --git a/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindowViewModel.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindowViewModel.cs index bb9a26aafd..0019962e88 100644 --- a/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindowViewModel.cs +++ b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindowViewModel.cs @@ -1,14 +1,5 @@ -using Prism.Commands; -using Prism.Mvvm; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Prism.Mvvm; using UnitsNet; -using UnitsNet.Units; -using WpfMVVMSample.Converters; -using WpfMVVMSample.Properties; using WpfMVVMSample.Settings; namespace WpfMVVMSample diff --git a/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MvvmSample.Wpf.csproj b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MvvmSample.Wpf.csproj index 05e93234d6..cb757e1ceb 100644 --- a/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MvvmSample.Wpf.csproj +++ b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MvvmSample.Wpf.csproj @@ -1,163 +1,25 @@ - - - + - Debug - AnyCPU - {B72F9215-70FF-4155-89BC-9A02CC550447} + net48 WinExe WpfMVVMSample - MvvmSample.Wpf - v4.8 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + true + true - - ..\..\packages\Unity.5.8.11\lib\net47\CommonServiceLocator.dll - - - ..\..\packages\Prism.Core.7.1.0.431\lib\net45\Prism.dll - - - ..\..\packages\Prism.Unity.7.1.0.431\lib\net45\Prism.Unity.Wpf.dll - - - ..\..\packages\Prism.Wpf.7.1.0.431\lib\net45\Prism.Wpf.dll - - + + + + - - ..\..\packages\System.Configuration.ConfigurationManager.4.5.0\lib\net461\System.Configuration.ConfigurationManager.dll - - - - - ..\..\packages\System.Security.AccessControl.4.5.0\lib\net461\System.Security.AccessControl.dll - - - ..\..\packages\System.Security.Permissions.4.5.0\lib\net461\System.Security.Permissions.dll - - - ..\..\packages\System.Security.Principal.Windows.4.5.1\lib\net461\System.Security.Principal.Windows.dll - - - ..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll - - - ..\..\packages\Prism.Wpf.7.1.0.431\lib\net45\System.Windows.Interactivity.dll - - - - - - - - - 4.0 - - - ..\..\packages\UnitsNet.5.9.0\lib\netstandard2.0\UnitsNet.dll - - - ..\..\packages\Unity.Abstractions.3.3.1\lib\net47\Unity.Abstractions.dll - - - ..\..\packages\Unity.5.8.11\lib\net47\Unity.Configuration.dll - - - ..\..\packages\Unity.Container.5.8.11\lib\net47\Unity.Container.dll - - - ..\..\packages\Unity.5.8.11\lib\net47\Unity.Interception.dll - - - ..\..\packages\Unity.5.8.11\lib\net47\Unity.Interception.Configuration.dll - - - ..\..\packages\Unity.5.8.11\lib\net47\Unity.RegistrationByConvention.dll - - - ..\..\packages\Unity.5.8.11\lib\net47\Unity.ServiceLocation.dll - - - - - - - - MSBuild:Compile - Designer - - - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - - MainWindow.xaml - Code - - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - SettingsSingleFileGenerator - Settings.Designer.cs - + - + - \ No newline at end of file diff --git a/Samples/MvvmSample.Wpf/MvvmSample.Wpf/packages.config b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/packages.config deleted file mode 100644 index c7e5ee450f..0000000000 --- a/Samples/MvvmSample.Wpf/MvvmSample.Wpf/packages.config +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/Samples.sln b/Samples/Samples.sln index 2101631750..84ba089fe6 100644 --- a/Samples/Samples.sln +++ b/Samples/Samples.sln @@ -9,6 +9,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmSample.Wpf", "MvvmSampl EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitConverter.Console", "UnitConverter.Console\UnitConverter.Console.csproj", "{B3141011-CEF2-46DE-B3DD-7FECD0D6108C}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Files", "_Files", "{D3B39B9C-CE85-4929-A268-1AEBD945127C}" + ProjectSection(SolutionItems) = preProject + build.bat = build.bat + Directory.Packages.props = Directory.Packages.props + msbuild.cmd = msbuild.cmd + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/Samples/UnitConverter.Console/UnitConverter.Console.csproj b/Samples/UnitConverter.Console/UnitConverter.Console.csproj index 21a2269189..3f3de72140 100644 --- a/Samples/UnitConverter.Console/UnitConverter.Console.csproj +++ b/Samples/UnitConverter.Console/UnitConverter.Console.csproj @@ -1,14 +1,14 @@ - - Exe - net7.0 - enable - enable - + + Exe + net8.0 + enable + enable + - - - + + + - + \ No newline at end of file diff --git a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/App.xaml b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/App.xaml index 0601f215a0..86dd63140b 100644 --- a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/App.xaml +++ b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/App.xaml @@ -8,10 +8,8 @@ - - - - + + diff --git a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/IMainWindowVm.cs b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/IMainWindowVm.cs index d727ec84a3..c2ed86fb67 100644 --- a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/IMainWindowVm.cs +++ b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/IMainWindowVm.cs @@ -1,4 +1,4 @@ -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Windows.Input; using UnitsNet.Samples.UnitConverter.Wpf.Properties; @@ -23,8 +23,8 @@ public interface IMainWindowVm : INotifyPropertyChanged string FromHeader { get; } string ToHeader { get; } - decimal FromValue { get; set; } - decimal ToValue { get; } + double FromValue { get; set; } + double ToValue { get; } ICommand SwapCommand { get; } } } diff --git a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/MainWindow.xaml b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/MainWindow.xaml index 26fcdf48f5..81d8491452 100644 --- a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/MainWindow.xaml +++ b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/MainWindow.xaml @@ -7,12 +7,15 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:wpf="clr-namespace:UnitsNet.Samples.UnitConverter.Wpf" mc:Ignorable="d" - Title="UnitsNet - WPF unit converter sample app" Height="350" Width="525" + WindowStartupLocation="CenterScreen" + Title="UnitsNet - WPF unit converter sample app" Height="800" Width="800" + d:DesignHeight="600" d:DesignWidth="600" d:DataContext="{d:DesignInstance wpf:MainWindowDesignVm, IsDesignTimeCreatable=True}"> + @@ -29,7 +32,7 @@ SelectionChanged="Selector_OnSelectionChanged" /> - + - + - - - - - - + - -