I am trying to extend the measurements part of jscience with my own units for fuel efficiency. I defined multiple units within the units: FuelEconomy and FuelConsumption.
Example of some of the defined values:
public static final Unit<FuelEconomy> KILOMETRE_PER_LITRE = nonSI(new ProductUnit<FuelEconomy>(SI.KILOMETRE.divide(NonSI.LITRE)));
public static final Unit<FuelConsumption> LITRE_PER_KILOMETRE = nonSI(new ProductUnit<FuelConsumption>(
NonSI.LITRE.divide(SI.KILOMETRE)));
public static final Unit<FuelConsumption> GALLON_US_PER_MILE = nonSI(new ProductUnit<FuelConsumption>(
NonSI.GALLON_LIQUID_US.divide(NonSI.MILE)));
public static final Unit<FuelEconomy> MILE_PER_GALLON_US = nonSI(new ProductUnit<FuelEconomy>(
NonSI.MILE.divide(NonSI.GALLON_LIQUID_US)));
The problem I currently have is that I would make it possible to convert between these two ( from Km/l to l/KM ), so I want the inverse of a ProductUnit, but I get a problem that I cannot convert because the base units are different ( 1/m2 && m2 )
Am I doing something wrong in the definition of these units, or are there any other options to make this possible?
The library i am using:
http://jscience.org/experimental/javadoc/javax/measure/package-summary.html