Skip to content

Commit ecdacf9

Browse files
author
Magno Nascimento
committed
#59: Added missing units and updated number of units in test
1 parent 5efea6f commit ecdacf9

File tree

2 files changed

+126
-7
lines changed

2 files changed

+126
-7
lines changed

ucum-java8/src/main/java/systems/uom/ucum/UCUM.java

+125-6
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ public static UCUM getInstance() {
254254
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
255255
public static final Unit<Time> YEAR = addUnit(Units.DAY.multiply(365.25));
256256
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
257+
public static final Unit<Time> WEEK = addUnit(Units.DAY.multiply(7));
258+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
257259
public static final Unit<Time> MONTH_SYNODAL = addUnit(Units.DAY
258260
.multiply(29.53059));
259261
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
@@ -600,6 +602,14 @@ public static UCUM getInstance() {
600602
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
601603
public static final Unit<Volume> CUP_US = addUnit(TABLESPOON_US
602604
.multiply(16));
605+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
606+
public static final Unit<Volume> METRIC_FLUID_OUNCE_US = addUnit(MILLI(LITER).multiply(30));
607+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
608+
public static final Unit<Volume> METRIC_CUP_US = addUnit(MILLI(LITER).multiply(240));
609+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
610+
public static final Unit<Volume> METRIC_TEASPOON_CUP_US = addUnit(MILLI(LITER).multiply(5));
611+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
612+
public static final Unit<Volume> METRIC_TABLESPOON_CUP_US = addUnit(MILLI(LITER).multiply(15));
603613
// ///////////////////////////////////////////////
604614
// BRITISH IMPERIAL VOLUME UNITS: UCUM 4.4 §38 //
605615
// ///////////////////////////////////////////////
@@ -692,6 +702,9 @@ public static UCUM getInstance() {
692702
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
693703
public static final Unit<Mass> POUND_APOTHECARY = addUnit(OUNCE_APOTHECARY
694704
.multiply(12));
705+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
706+
public static final Unit<Mass> METRIC_OUNCE = addUnit(GRAM.multiply(28));
707+
695708
// ///////////////////////////////////////////
696709
// TYPESETTER'S LENGTH UNITS: UCUM 4.4 §42 //
697710
// ///////////////////////////////////////////
@@ -723,8 +736,11 @@ public static UCUM getInstance() {
723736
// OTHER LEGACY UNITS: UCUM 4.5 §43 //
724737
// ////////////////////////////////////
725738
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
726-
public static final Unit<Temperature> FAHRENHEIT = addUnit(KELVIN
727-
.multiply(5).divide(9).shift(459.67));
739+
public static final Unit<Temperature> FAHRENHEIT = addUnit(KELVIN.multiply(9).divide(5).shift(459.67));
740+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
741+
public static final Unit<Temperature> RANKINE = addUnit(KELVIN.divide(9).multiply(5));
742+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
743+
public static final Unit<Temperature> REAUMUR = addUnit(KELVIN.multiply(4).divide(5).shift(218.52));
728744
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
729745
public static final Unit<Energy> CALORIE_AT_15C = addUnit(JOULE.multiply(
730746
41858).divide(10000));
@@ -768,9 +784,110 @@ public static UCUM getInstance() {
768784
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
769785
public static final Unit<Power> HORSEPOWER = addUnit(new ProductUnit<Power>(
770786
FOOT_INTERNATIONAL.multiply(POUND_FORCE).divide(SECOND)));
771-
// ///////////////////////////////////////////////////////
772-
// SECTIONS §44-§46 skipped; implement later if needed //
773-
// ///////////////////////////////////////////////////////
787+
788+
////////////////////////////////////////////
789+
// CLINICAL MEDICINE UNITS: UCUM 4.5 §44 //
790+
// /////////////////////////////////////////
791+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
792+
public static final Unit<Pressure> METER_OF_WATER_COLUMN = addUnit(KILO(PASCAL).multiply(980665).divide(100000));
793+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
794+
public static final Unit<Pressure> METER_OF_MERCURY_COLUMN = addUnit(KILO(PASCAL).multiply(1333220).divide(10000));
795+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
796+
public static final Unit<Pressure> INCH_OF_WATER_COLUMN = addUnit(
797+
new ProductUnit<Pressure>(METER_OF_WATER_COLUMN.multiply(INCH_INTERNATIONAL).divide(METER)));
798+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
799+
public static final Unit<Pressure> INCH_OF_MERCURY_COLUMN = addUnit(
800+
new ProductUnit<Pressure>(METER_OF_MERCURY_COLUMN.multiply(INCH_INTERNATIONAL).divide(METER)));
801+
802+
// public static final Unit PERIPHERAL_VASCULAR_RESISTANCE = addUnit(MILLI(METER_OF_MERCURY_COLUMN).multiply(SECOND).divide(MILLI(LITER)));
803+
// public static final Unit WOOD = addUnit(MILLI(METER_OF_MERCURY_COLUMN).multiply(MINUTE).divide(LITER));
804+
// public static final Unit DIOPTER = addUnit(ONE.divide(METER));
805+
// public static final Unit PRISM_DIOPTER = addUnit(ONE.multiply(100).multiply(Math.tan(1)));
806+
// public static final Unit PERCENT_OF_SLOPE = addUnit(ONE.multiply(100).multiply(Math.tan(1)));
807+
// public static final Unit MESH = addUnit(ONE.divide(INCH_INTERNATIONAL));
808+
// public static final Unit CHARRIERE = addUnit(MILLI(METER).divide(3));
809+
810+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
811+
public static final Unit<Volume> DROP = addUnit(MILLI(LITER).divide(20));
812+
813+
// public static final Unit HOUNSFIELD = addUnit(ONE);
814+
// public static final Unit METABOLIC_EQUIVALENT = addUnit(MILLI(LITER).divide(MINUTE).divide(KILO(GRAM)));
815+
816+
// public static final Unit HOMEOPATHIC_POTENCY_OF_DECIMAL = addUnit(ONE.multiply(-1).multiply(Math.log10(1)));
817+
// public static final Unit HOMEOPATHIC_POTENCY_OF_CENTESIMAL = addUnit(ONE.multiply(-1).multiply(Math.log(1)).divide(Math.log(100)));
818+
// public static final Unit HOMEOPATHIC_POTENCY_OF_MILLESIMAL = addUnit(ONE.multiply(-1).multiply(Math.log(1)).divide(Math.log(1000)));
819+
// public static final Unit HOMEOPATHIC_POTENCY_OF_QUINTALLESIMAL = addUnit(ONE.multiply(-1).multiply(Math.log(1)).divide(Math.log(50000)));
820+
821+
// public static final Unit HOMEOPATHIC_POTENCY_OF_DECIMAL_HAHNEMANNIAN = UNDEFINED;
822+
// public static final Unit HOMEOPATHIC_POTENCY_OF_CENTESIMAL_HAHNEMANNIAN = UNDEFINED;
823+
// public static final Unit HOMEOPATHIC_POTENCY_OF_MILLESIMAL_HAHNEMANNIAN = UNDEFINED;
824+
// public static final Unit HOMEOPATHIC_POTENCY_OF_QUINTAMILLESIMAL_HAHNEMANNIAN = UNDEFINED;
825+
// public static final Unit HOMEOPATHIC_POTENCY_OF_DECIMAL_KORSAKOVIAN = UNDEFINED;
826+
// public static final Unit HOMEOPATHIC_POTENCY_OF_CENTESIMAL_KORSAKOVIAN = UNDEFINED;
827+
// public static final Unit HOMEOPATHIC_POTENCY_OF_MILLESIMAL_KORSAKOVIAN = UNDEFINED;
828+
// public static final Unit HOMEOPATHIC_POTENCY_OF_QUINTAMILLESIMAL_KORSAKOVIAN = UNDEFINED;
829+
830+
// ////////////////////////////////////////////////
831+
// CHEMICAL AND BIOCHEMICAL UNITS: UCUM 4.5 §45 //
832+
// ////////////////////////////////////////////////
833+
// public static final Unit EQUIVALENTS = addUnit(MOLE);
834+
// public static final Unit OSMOLE = addUnit(MOLE);
835+
// public static final Unit PH = addUnit();
836+
// public static final Unit GRAM_PERCENT = addUnit(GRAM.divide(DECI(LITER)));
837+
// public static final Unit SVEDBERG = addUnit(SECOND.multiply(1E-13));
838+
// public static final Unit HIGH_POWER_FIELD = addUnit(ONE);
839+
// public static final Unit LOW_POWER_FIELD = addUnit(ONE);
840+
// public static final Unit KATAL = addUnit(MOLE.divide(SECOND));
841+
// public static final Unit UNIT = addUnit(MICRO(MOLE).divide(MINUTE));
842+
843+
// public static final Unit INTERNATIONAL_UNIT = UNDEFINED;
844+
// public static final Unit ARBITRARY_UNIT = UNDEFINED;
845+
// public static final Unit US_PHARMACOPEIA = UNDEFINED;
846+
// public static final Unit GPL = UNDEFINED;
847+
// public static final Unit MPL = UNDEFINED;
848+
// public static final Unit APL = UNDEFINED;
849+
// public static final Unit BETHESDA = UNDEFINED;
850+
// public static final Unit ANTI_FACTOR_XA = UNDEFINED;
851+
// public static final Unit TODD = UNDEFINED;
852+
// public static final Unit DYE = UNDEFINED;
853+
// public static final Unit SOMOGYI = UNDEFINED;
854+
// public static final Unit BODANSKY = UNDEFINED;
855+
// public static final Unit KING_ARMSTRONG = UNDEFINED;
856+
// public static final Unit KUNKEL = UNDEFINED;
857+
// public static final Unit MAC_LAGAN = UNDEFINED;
858+
// public static final Unit TUBERCULIN = UNDEFINED;
859+
// public static final Unit CELL_CULTURE_INFECTIOUS_50_PERCENT_DOSE = UNDEFINED;
860+
// public static final Unit TISSUE_CULTURE_INFECTIOUS_50_PERCENT_DOSE = UNDEFINED;
861+
// public static final Unit EMBRYO_CULTURE_INFECTIOUS_50_PERCENT_DOSE = UNDEFINED;
862+
// public static final Unit PLAQUE_FORMING = UNDEFINED;
863+
// public static final Unit FOCUS_FORMING = UNDEFINED;
864+
// public static final Unit COLONY_FORMING = UNDEFINED;
865+
// public static final Unit INDEX_OF_REACTIVITY = UNDEFINED;
866+
// public static final Unit BIOEQUIVALENT_ALLERGEN = UNDEFINED;
867+
// public static final Unit ALLERGEN = UNDEFINED;
868+
// public static final Unit ALLERGEN_FOR_AMBROSIA_ARTEMISIIFOLIA = UNDEFINED;
869+
// public static final Unit PROTEIN_NITROGEN = UNDEFINED;
870+
// public static final Unit LIMIT_OF_FLOCCULATION = UNDEFINED;
871+
// public static final Unit D_ANTIGEN = UNDEFINED;
872+
// public static final Unit FIBRINOGEN_EQUIVALENT = UNDEFINED;
873+
// public static final Unit ELISA = UNDEFINED;
874+
// public static final Unit EHRLICH = UNDEFINED;
875+
// public static final Unit CHEMICAL = UNDEFINED;
876+
877+
// ///////////////////////////////
878+
// LEVELS UNITS: UCUM 4.5 §45 //
879+
// //////////////////////////////
880+
// public static final Unit<Level<?>> NEPER = addUnit(new ProductUnit<Level<?>>(ONE.multiply(Math.log(1))));
881+
// public static final Unit<Level<?>> BEL = addUnit(new ProductUnit<Level<?>>(ONE.multiply(Math.log10(1))));
882+
883+
// public static final Unit<Level<Pressure>> BEL_SOUND = addUnit(new ProductUnit<Level<Pressure>>());
884+
// public static final Unit<Level<ElectricPotential>> BEL_VOLT = addUnit(new ProductUnit<Level<ElectricPotential>>());
885+
// public static final Unit<Level<ElectricPotential>> BEL_MILIVOLT = addUnit(new ProductUnit<Level<ElectricPotential>>());
886+
// public static final Unit<Level<ElectricPotential>> BEL_MICROVOLT = addUnit(new ProductUnit<Level<ElectricPotential>>());
887+
// public static final Unit<Level<ElectricPotential>> BEL_10_NANOVOLT = addUnit(new ProductUnit<Level<ElectricPotential>>());
888+
// public static final Unit<Level<Power>> BEL_WATT = addUnit(new ProductUnit<Level<Power>>());
889+
// public static final Unit<Level<Power>> BEL_KILOWATT = addUnit(new ProductUnit<Level<Power>>());
890+
774891
// /////////////////////////////////////
775892
// MISCELLANEOUS UNITS: UCUM 4.5 §47 //
776893
// /////////////////////////////////////
@@ -812,6 +929,8 @@ public static UCUM getInstance() {
812929
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
813930
public static final Unit<Dimensionless> CARAT_GOLD = addUnit(ONE
814931
.divide(24));
932+
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
933+
public static final Unit<Length> SMOOT = addUnit(INCH_INTERNATIONAL.multiply(67));
815934

816935
// //////////////////////////////////////////////
817936
// INFORMATION TECHNOLOGY UNITS: UCUM 4.6 §48 //
@@ -861,4 +980,4 @@ private static <U extends AbstractUnit<?>> U addUnit(U unit,
861980
SimpleUnitFormat.getInstance().label(OUNCE, "oz");
862981
SimpleUnitFormat.getInstance().label(POUND, "lb");
863982
}
864-
}
983+
}

ucum-java8/src/test/java/systems/uom/ucum/SystemOfUnitsServiceTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
public class SystemOfUnitsServiceTest {
4141
private static final String EXPECTED_SYSTEM_NAME = "Unified Code for Units of Measure";
42-
private static final int NUM_OF_UNITS = 212;
42+
private static final int NUM_OF_UNITS = 226;
4343

4444
private static SystemOfUnitsService defaultService;
4545

0 commit comments

Comments
 (0)