From 2087d5b0e6554a8cfea1f60d94de87da57700428 Mon Sep 17 00:00:00 2001 From: Jan Paolo Go Date: Thu, 9 Jan 2020 22:56:14 -0600 Subject: [PATCH] add Area cubic yard per foot --- Common/UnitDefinitions/Area.json | 24 +++++++++++++ UnitsNet.Tests/CustomCode/AreaTests.cs | 4 +++ .../GeneratedCode/AreaTestsBase.g.cs | 20 +++++++++++ .../GeneratedCode/Quantities/Area.g.cs | 34 +++++++++++++++++++ .../GeneratedCode/UnitAbbreviationsCache.g.cs | 2 ++ .../GeneratedCode/Units/AreaUnit.g.cs | 2 ++ UnitsNet/GeneratedCode/Quantities/Area.g.cs | 34 +++++++++++++++++++ .../GeneratedCode/UnitAbbreviationsCache.g.cs | 2 ++ UnitsNet/GeneratedCode/UnitConverter.g.cs | 4 +++ UnitsNet/GeneratedCode/Units/AreaUnit.g.cs | 2 ++ 10 files changed, 128 insertions(+) diff --git a/Common/UnitDefinitions/Area.json b/Common/UnitDefinitions/Area.json index b9fe14cfaf..cc169624da 100644 --- a/Common/UnitDefinitions/Area.json +++ b/Common/UnitDefinitions/Area.json @@ -246,6 +246,30 @@ "Abbreviations": ["nmi²"] } ] + }, + { + "SingularName": "CubicYardPerFoot", + "PluralName": "CubicYardsPerFoot", + "FromUnitToBaseFunc": "x*2.50838208", + "FromBaseToUnitFunc": "x/2.50838208", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "yd³/ft" ] + } + ] + }, + { + "SingularName": "CubicYardPerUsSurveyFoot", + "PluralName": "CubicYardsPerUsSurveyFoot", + "FromUnitToBaseFunc": "x*2.50837706323584", + "FromBaseToUnitFunc": "x/2.50837706323584", + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "yd³/ftUS" ] + } + ] } ] } diff --git a/UnitsNet.Tests/CustomCode/AreaTests.cs b/UnitsNet.Tests/CustomCode/AreaTests.cs index d637cd18a9..1c0d314c1d 100644 --- a/UnitsNet.Tests/CustomCode/AreaTests.cs +++ b/UnitsNet.Tests/CustomCode/AreaTests.cs @@ -37,6 +37,10 @@ public class AreaTests : AreaTestsBase protected override double SquareNauticalMilesInOneSquareMeter => 0.00000029155335; + protected override double CubicYardsPerFootInOneSquareMeter => 0.3986633487670267521605; + + protected override double CubicYardsPerUsSurveyFootInOneSquareMeter => 0.3986641460953189427984; + [Fact] public void AreaDividedByLengthEqualsLength() { diff --git a/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs index 411bf18ab4..95fe3e878c 100644 --- a/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/AreaTestsBase.g.cs @@ -35,6 +35,8 @@ namespace UnitsNet.Tests public abstract partial class AreaTestsBase { protected abstract double AcresInOneSquareMeter { get; } + protected abstract double CubicYardsPerFootInOneSquareMeter { get; } + protected abstract double CubicYardsPerUsSurveyFootInOneSquareMeter { get; } protected abstract double HectaresInOneSquareMeter { get; } protected abstract double SquareCentimetersInOneSquareMeter { get; } protected abstract double SquareDecimetersInOneSquareMeter { get; } @@ -51,6 +53,8 @@ public abstract partial class AreaTestsBase // ReSharper disable VirtualMemberNeverOverriden.Global protected virtual double AcresTolerance { get { return 1e-5; } } + protected virtual double CubicYardsPerFootTolerance { get { return 1e-5; } } + protected virtual double CubicYardsPerUsSurveyFootTolerance { get { return 1e-5; } } protected virtual double HectaresTolerance { get { return 1e-5; } } protected virtual double SquareCentimetersTolerance { get { return 1e-5; } } protected virtual double SquareDecimetersTolerance { get { return 1e-5; } } @@ -90,6 +94,8 @@ public void SquareMeterToAreaUnits() { Area squaremeter = Area.FromSquareMeters(1); AssertEx.EqualTolerance(AcresInOneSquareMeter, squaremeter.Acres, AcresTolerance); + AssertEx.EqualTolerance(CubicYardsPerFootInOneSquareMeter, squaremeter.CubicYardsPerFoot, CubicYardsPerFootTolerance); + AssertEx.EqualTolerance(CubicYardsPerUsSurveyFootInOneSquareMeter, squaremeter.CubicYardsPerUsSurveyFoot, CubicYardsPerUsSurveyFootTolerance); AssertEx.EqualTolerance(HectaresInOneSquareMeter, squaremeter.Hectares, HectaresTolerance); AssertEx.EqualTolerance(SquareCentimetersInOneSquareMeter, squaremeter.SquareCentimeters, SquareCentimetersTolerance); AssertEx.EqualTolerance(SquareDecimetersInOneSquareMeter, squaremeter.SquareDecimeters, SquareDecimetersTolerance); @@ -109,6 +115,8 @@ public void SquareMeterToAreaUnits() public void FromValueAndUnit() { AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.Acre).Acres, AcresTolerance); + AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.CubicYardPerFoot).CubicYardsPerFoot, CubicYardsPerFootTolerance); + AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.CubicYardPerUsSurveyFoot).CubicYardsPerUsSurveyFoot, CubicYardsPerUsSurveyFootTolerance); AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.Hectare).Hectares, HectaresTolerance); AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareCentimeter).SquareCentimeters, SquareCentimetersTolerance); AssertEx.EqualTolerance(1, Area.From(1, AreaUnit.SquareDecimeter).SquareDecimeters, SquareDecimetersTolerance); @@ -142,6 +150,8 @@ public void As() { var squaremeter = Area.FromSquareMeters(1); AssertEx.EqualTolerance(AcresInOneSquareMeter, squaremeter.As(AreaUnit.Acre), AcresTolerance); + AssertEx.EqualTolerance(CubicYardsPerFootInOneSquareMeter, squaremeter.As(AreaUnit.CubicYardPerFoot), CubicYardsPerFootTolerance); + AssertEx.EqualTolerance(CubicYardsPerUsSurveyFootInOneSquareMeter, squaremeter.As(AreaUnit.CubicYardPerUsSurveyFoot), CubicYardsPerUsSurveyFootTolerance); AssertEx.EqualTolerance(HectaresInOneSquareMeter, squaremeter.As(AreaUnit.Hectare), HectaresTolerance); AssertEx.EqualTolerance(SquareCentimetersInOneSquareMeter, squaremeter.As(AreaUnit.SquareCentimeter), SquareCentimetersTolerance); AssertEx.EqualTolerance(SquareDecimetersInOneSquareMeter, squaremeter.As(AreaUnit.SquareDecimeter), SquareDecimetersTolerance); @@ -166,6 +176,14 @@ public void ToUnit() AssertEx.EqualTolerance(AcresInOneSquareMeter, (double)acreQuantity.Value, AcresTolerance); Assert.Equal(AreaUnit.Acre, acreQuantity.Unit); + var cubicyardperfootQuantity = squaremeter.ToUnit(AreaUnit.CubicYardPerFoot); + AssertEx.EqualTolerance(CubicYardsPerFootInOneSquareMeter, (double)cubicyardperfootQuantity.Value, CubicYardsPerFootTolerance); + Assert.Equal(AreaUnit.CubicYardPerFoot, cubicyardperfootQuantity.Unit); + + var cubicyardperussurveyfootQuantity = squaremeter.ToUnit(AreaUnit.CubicYardPerUsSurveyFoot); + AssertEx.EqualTolerance(CubicYardsPerUsSurveyFootInOneSquareMeter, (double)cubicyardperussurveyfootQuantity.Value, CubicYardsPerUsSurveyFootTolerance); + Assert.Equal(AreaUnit.CubicYardPerUsSurveyFoot, cubicyardperussurveyfootQuantity.Unit); + var hectareQuantity = squaremeter.ToUnit(AreaUnit.Hectare); AssertEx.EqualTolerance(HectaresInOneSquareMeter, (double)hectareQuantity.Value, HectaresTolerance); Assert.Equal(AreaUnit.Hectare, hectareQuantity.Unit); @@ -224,6 +242,8 @@ public void ConversionRoundTrip() { Area squaremeter = Area.FromSquareMeters(1); AssertEx.EqualTolerance(1, Area.FromAcres(squaremeter.Acres).SquareMeters, AcresTolerance); + AssertEx.EqualTolerance(1, Area.FromCubicYardsPerFoot(squaremeter.CubicYardsPerFoot).SquareMeters, CubicYardsPerFootTolerance); + AssertEx.EqualTolerance(1, Area.FromCubicYardsPerUsSurveyFoot(squaremeter.CubicYardsPerUsSurveyFoot).SquareMeters, CubicYardsPerUsSurveyFootTolerance); AssertEx.EqualTolerance(1, Area.FromHectares(squaremeter.Hectares).SquareMeters, HectaresTolerance); AssertEx.EqualTolerance(1, Area.FromSquareCentimeters(squaremeter.SquareCentimeters).SquareMeters, SquareCentimetersTolerance); AssertEx.EqualTolerance(1, Area.FromSquareDecimeters(squaremeter.SquareDecimeters).SquareMeters, SquareDecimetersTolerance); diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.g.cs index 5aa5ae28a4..8f61ef24b1 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.g.cs @@ -160,6 +160,16 @@ private Area(double value, AreaUnit unit) /// public double Acres => As(AreaUnit.Acre); + /// + /// Get Area in CubicYardsPerFoot. + /// + public double CubicYardsPerFoot => As(AreaUnit.CubicYardPerFoot); + + /// + /// Get Area in CubicYardsPerUsSurveyFoot. + /// + public double CubicYardsPerUsSurveyFoot => As(AreaUnit.CubicYardPerUsSurveyFoot); + /// /// Get Area in Hectares. /// @@ -266,6 +276,26 @@ public static Area FromAcres(double acres) return new Area(value, AreaUnit.Acre); } /// + /// Get Area from CubicYardsPerFoot. + /// + /// If value is NaN or Infinity. + [Windows.Foundation.Metadata.DefaultOverload] + public static Area FromCubicYardsPerFoot(double cubicyardsperfoot) + { + double value = (double) cubicyardsperfoot; + return new Area(value, AreaUnit.CubicYardPerFoot); + } + /// + /// Get Area from CubicYardsPerUsSurveyFoot. + /// + /// If value is NaN or Infinity. + [Windows.Foundation.Metadata.DefaultOverload] + public static Area FromCubicYardsPerUsSurveyFoot(double cubicyardsperussurveyfoot) + { + double value = (double) cubicyardsperussurveyfoot; + return new Area(value, AreaUnit.CubicYardPerUsSurveyFoot); + } + /// /// Get Area from Hectares. /// /// If value is NaN or Infinity. @@ -687,6 +717,8 @@ private double AsBaseUnit() switch(Unit) { case AreaUnit.Acre: return _value*4046.85642; + case AreaUnit.CubicYardPerFoot: return _value*2.50838208; + case AreaUnit.CubicYardPerUsSurveyFoot: return _value*2.50837706323584; case AreaUnit.Hectare: return _value*1e4; case AreaUnit.SquareCentimeter: return _value*1e-4; case AreaUnit.SquareDecimeter: return _value*1e-2; @@ -715,6 +747,8 @@ private double AsBaseNumericType(AreaUnit unit) switch(unit) { case AreaUnit.Acre: return baseUnitValue/4046.85642; + case AreaUnit.CubicYardPerFoot: return baseUnitValue/2.50838208; + case AreaUnit.CubicYardPerUsSurveyFoot: return baseUnitValue/2.50837706323584; case AreaUnit.Hectare: return baseUnitValue/1e4; case AreaUnit.SquareCentimeter: return baseUnitValue/1e-4; case AreaUnit.SquareDecimeter: return baseUnitValue/1e-2; diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs index b50be2ff87..69d312e582 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs @@ -95,6 +95,8 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin ("en-US", typeof(ApparentPowerUnit), (int)ApparentPowerUnit.Megavoltampere, new string[]{"MVA"}), ("en-US", typeof(ApparentPowerUnit), (int)ApparentPowerUnit.Voltampere, new string[]{"VA"}), ("en-US", typeof(AreaUnit), (int)AreaUnit.Acre, new string[]{"ac"}), + ("en-US", typeof(AreaUnit), (int)AreaUnit.CubicYardPerFoot, new string[]{"yd³/ft"}), + ("en-US", typeof(AreaUnit), (int)AreaUnit.CubicYardPerUsSurveyFoot, new string[]{"yd³/ftUS"}), ("en-US", typeof(AreaUnit), (int)AreaUnit.Hectare, new string[]{"ha"}), ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareCentimeter, new string[]{"cm²"}), ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareCentimeter, new string[]{"см²"}), diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaUnit.g.cs index eb71b42116..3444edab97 100644 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaUnit.g.cs +++ b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaUnit.g.cs @@ -27,6 +27,8 @@ public enum AreaUnit { Undefined = 0, Acre, + CubicYardPerFoot, + CubicYardPerUsSurveyFoot, Hectare, SquareCentimeter, SquareDecimeter, diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 07241d5540..cff3c07518 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -51,6 +51,8 @@ static Area() Info = new QuantityInfo(QuantityType.Area, new UnitInfo[] { new UnitInfo(AreaUnit.Acre, BaseUnits.Undefined), + new UnitInfo(AreaUnit.CubicYardPerFoot, BaseUnits.Undefined), + new UnitInfo(AreaUnit.CubicYardPerUsSurveyFoot, BaseUnits.Undefined), new UnitInfo(AreaUnit.Hectare, BaseUnits.Undefined), new UnitInfo(AreaUnit.SquareCentimeter, new BaseUnits(length: LengthUnit.Centimeter)), new UnitInfo(AreaUnit.SquareDecimeter, new BaseUnits(length: LengthUnit.Decimeter)), @@ -181,6 +183,16 @@ public Area(double value, UnitSystem unitSystem) /// public double Acres => As(AreaUnit.Acre); + /// + /// Get Area in CubicYardsPerFoot. + /// + public double CubicYardsPerFoot => As(AreaUnit.CubicYardPerFoot); + + /// + /// Get Area in CubicYardsPerUsSurveyFoot. + /// + public double CubicYardsPerUsSurveyFoot => As(AreaUnit.CubicYardPerUsSurveyFoot); + /// /// Get Area in Hectares. /// @@ -285,6 +297,24 @@ public static Area FromAcres(QuantityValue acres) return new Area(value, AreaUnit.Acre); } /// + /// Get Area from CubicYardsPerFoot. + /// + /// If value is NaN or Infinity. + public static Area FromCubicYardsPerFoot(QuantityValue cubicyardsperfoot) + { + double value = (double) cubicyardsperfoot; + return new Area(value, AreaUnit.CubicYardPerFoot); + } + /// + /// Get Area from CubicYardsPerUsSurveyFoot. + /// + /// If value is NaN or Infinity. + public static Area FromCubicYardsPerUsSurveyFoot(QuantityValue cubicyardsperussurveyfoot) + { + double value = (double) cubicyardsperussurveyfoot; + return new Area(value, AreaUnit.CubicYardPerUsSurveyFoot); + } + /// /// Get Area from Hectares. /// /// If value is NaN or Infinity. @@ -831,6 +861,8 @@ private double GetValueInBaseUnit() switch(Unit) { case AreaUnit.Acre: return _value*4046.85642; + case AreaUnit.CubicYardPerFoot: return _value*2.50838208; + case AreaUnit.CubicYardPerUsSurveyFoot: return _value*2.50837706323584; case AreaUnit.Hectare: return _value*1e4; case AreaUnit.SquareCentimeter: return _value*1e-4; case AreaUnit.SquareDecimeter: return _value*1e-2; @@ -870,6 +902,8 @@ private double GetValueAs(AreaUnit unit) switch(unit) { case AreaUnit.Acre: return baseUnitValue/4046.85642; + case AreaUnit.CubicYardPerFoot: return baseUnitValue/2.50838208; + case AreaUnit.CubicYardPerUsSurveyFoot: return baseUnitValue/2.50837706323584; case AreaUnit.Hectare: return baseUnitValue/1e4; case AreaUnit.SquareCentimeter: return baseUnitValue/1e-4; case AreaUnit.SquareDecimeter: return baseUnitValue/1e-2; diff --git a/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs b/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs index 738ce73bef..cb1f58055d 100644 --- a/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs +++ b/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs @@ -95,6 +95,8 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin ("en-US", typeof(ApparentPowerUnit), (int)ApparentPowerUnit.Megavoltampere, new string[]{"MVA"}), ("en-US", typeof(ApparentPowerUnit), (int)ApparentPowerUnit.Voltampere, new string[]{"VA"}), ("en-US", typeof(AreaUnit), (int)AreaUnit.Acre, new string[]{"ac"}), + ("en-US", typeof(AreaUnit), (int)AreaUnit.CubicYardPerFoot, new string[]{"yd³/ft"}), + ("en-US", typeof(AreaUnit), (int)AreaUnit.CubicYardPerUsSurveyFoot, new string[]{"yd³/ftUS"}), ("en-US", typeof(AreaUnit), (int)AreaUnit.Hectare, new string[]{"ha"}), ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareCentimeter, new string[]{"cm²"}), ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareCentimeter, new string[]{"см²"}), diff --git a/UnitsNet/GeneratedCode/UnitConverter.g.cs b/UnitsNet/GeneratedCode/UnitConverter.g.cs index e9f11f9faa..1a62c308a7 100644 --- a/UnitsNet/GeneratedCode/UnitConverter.g.cs +++ b/UnitsNet/GeneratedCode/UnitConverter.g.cs @@ -134,6 +134,10 @@ public static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ApparentPower.BaseUnit, ApparentPower.BaseUnit, q => q); unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.Acre, q => q.ToUnit(AreaUnit.Acre)); unitConverter.SetConversionFunction(AreaUnit.Acre, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.CubicYardPerFoot, q => q.ToUnit(AreaUnit.CubicYardPerFoot)); + unitConverter.SetConversionFunction(AreaUnit.CubicYardPerFoot, Area.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.CubicYardPerUsSurveyFoot, q => q.ToUnit(AreaUnit.CubicYardPerUsSurveyFoot)); + unitConverter.SetConversionFunction(AreaUnit.CubicYardPerUsSurveyFoot, Area.BaseUnit, q => q.ToBaseUnit()); unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.Hectare, q => q.ToUnit(AreaUnit.Hectare)); unitConverter.SetConversionFunction(AreaUnit.Hectare, Area.BaseUnit, q => q.ToBaseUnit()); unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareCentimeter, q => q.ToUnit(AreaUnit.SquareCentimeter)); diff --git a/UnitsNet/GeneratedCode/Units/AreaUnit.g.cs b/UnitsNet/GeneratedCode/Units/AreaUnit.g.cs index eb71b42116..3444edab97 100644 --- a/UnitsNet/GeneratedCode/Units/AreaUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/AreaUnit.g.cs @@ -27,6 +27,8 @@ public enum AreaUnit { Undefined = 0, Acre, + CubicYardPerFoot, + CubicYardPerUsSurveyFoot, Hectare, SquareCentimeter, SquareDecimeter,