unitsofmeasurement / uom-systems

Units of Measurement Systems
http://www.uom.systems
Other
36 stars 17 forks source link

UCUM formatter incorrectly parses 'ft3' #144

Closed wnreynoldsWork closed 4 years ago

wnreynoldsWork commented 5 years ago

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 /*

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 <?xml version="1.0" encoding="UTF-8"?>

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
wnreynoldsWork commented 5 years ago

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

keilw commented 5 years ago

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.

wnreynoldsWork commented 5 years ago

Attached is the pom I used, this was taken from the 2.0-EDR tag in the uom-demos repository in github.

I will be happy to try with the 2.0-SNAPSHOT, if you could provide a set of dependencies, I don't see that tag in any of the github repos, further its not obvious how the versions of the various dependencies interact, so I used the dependencies specified in the demos.

On 7/29/2019 3:54 AM, Werner Keil wrote:

Did you use the 2.0-SNAPSHOT or 1.x releases for this?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/unitsofmeasurement/uom-systems/issues/144?email_source=notifications&email_token=AH2VORD72MZFLHKLPGU7ZUTQB2435A5CNFSM4IHHUVXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3AGU4A#issuecomment-515926640, or mute the thread https://github.com/notifications/unsubscribe-auth/AH2VORF6U7VZKPZK3W5IQ4DQB2435ANCNFSM4IHHUVXA.

-- William Reynolds, Ph.D. Stellar Science, LLC wnreynolds@stellarscience.com www.stellarscience.com 877-763-8268 x710 (v)

wnreynoldsWork commented 5 years ago

Just an update, I have tested with the attached pom, which is based on the 2.0-EDR tag of the pom for the ucum-console-demos at https://github.com/unitsofmeasurement/uom-demos/blob/2.0-EDR/console/systems/ucum/pom.xml. https://github.com/unitsofmeasurement/uom-demos/blob/2.0-EDR/console/systems/ucum/pom.xml I generated the effective pom from the ucum-demos module in netbeans and C&P that into this pom. The output exhibits the bug:

m3 dimension =[L]³ ft3 dimension =[M]³

On 7/29/2019 3:54 AM, Werner Keil wrote:

Did you use the 2.0-SNAPSHOT or 1.x releases for this?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/unitsofmeasurement/uom-systems/issues/144?email_source=notifications&email_token=AH2VORD72MZFLHKLPGU7ZUTQB2435A5CNFSM4IHHUVXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3AGU4A#issuecomment-515926640, or mute the thread https://github.com/notifications/unsubscribe-auth/AH2VORF6U7VZKPZK3W5IQ4DQB2435ANCNFSM4IHHUVXA.

-- William Reynolds, Ph.D. Stellar Science, LLC wnreynolds@stellarscience.com www.stellarscience.com 877-763-8268 x710 (v)

/*

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());
}

}

keilw commented 4 years ago

"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.