unitsofmeasurement/uom-systems

UCUM formatter incorrectly parses 'ft3'

wnreynoldsWork opened this issue · 5 comments

The attached code prints out a dimension for 'ft3' as [M]^3. The versions were fetched using the attached pom.

Expected Output:
m3 dimension =[L]³
ft3 dimension =[L]³

Actual Output:
m3 dimension =[L]³
ft3 dimension =[M]³

// begin java code
/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package ucumParserBug;

import java.util.List;

import javax.measure.format.UnitFormat;
import javax.measure.spi.ServiceProvider;
import javax.measure.spi.UnitFormatService;

/**
*
*/
public class FT3Bug {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {

    List<ServiceProvider> providers = ServiceProvider.available();
    ServiceProvider ucumProvider = providers.get(0);
    UnitFormatService ucumFormatService = ucumProvider.getUnitFormatService();
    UnitFormat ucumFormatter = ucumFormatService.getUnitFormat("CS");
    System.out.println("m3 dimension =" + ucumFormatter.parse("m3").getDimension());
    System.out.println("ft3 dimension =" + ucumFormatter.parse("ft3").getDimension());
}

}

//begin pom

4.0.0 ucumParserBug UCUMParserBug 1.0-SNAPSHOT jar 1.8 1.8 1.8 UTF-8 ${jdkVersion} ${jdkVersion} ${jdkVersion} ${jdkVersion} ${jdkVersion} systems.uom systems-quantity 0.9 systems.uom systems-ucum 0.9 systems.uom systems-common 0.9 false bintray-release libs-release http://oss.jfrog.org/artifactory/libs-release true bintray-snapshot libs-snapshot http://oss.jfrog.org/artifactory/libs-snapshot jcenter JCenter http://jcenter.bintray.com bintray-uom Bintray Units of Measurement http://dl.bintray.com/unitsofmeasurement/maven false central Central Repository http://repo.maven.apache.org/maven2

ugh -seems pom was corrupted. I used the same pom dependencies from the uom demos with tag 2.0-EDR.

keilw commented

Did you use the 2.0-SNAPSHOT or 1.x releases for this?
0.9 is not recent enough, but we maintain both a 1.x version (based on JSR 363) and a 2.x version using JSR 385.

keilw commented

"ft3" is an illegal UCUM unit code, the correct one is "[cft_i]", see UCUMServiceDemo. The string you used seems to be parsed as "Femtoton", which is why you get the Mass dimension.