unitsofmeasurement / uom-systems

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

UCUMFormat issues formatting multiples or submultiples #97

Closed keilw closed 7 years ago

keilw commented 7 years ago

Somewhat similar to https://github.com/unitsofmeasurement/uom-se/issues/136 many multiples and submultiples of UCUM units applied a prefix cause problems formatting via UCUMFormat.format(). Parsing seems unaffected.

keilw commented 7 years ago

Main changes are in https://github.com/unitsofmeasurement/uom-se/blob/master/src/main/java/tec/uom/se/format/EBNFHelper.java and https://github.com/unitsofmeasurement/uom-se/blob/master/src/main/java/tec/uom/se/unit/TransformedUnit.java UCUMFormat does not directly benefit, but possibly diverted from EBNFUnitFormat, so what was changed there could be necessary in the UCUM module, too.

keilw commented 7 years ago

@garretwilson @magnonasc I cannot predict how long it might take, but introducing a distinct "parent" to TransformedUnit seems to help with many cases. Especially SimpleUnitFormat still struggles a bit, to be backward-compatible with the RI it must also work with this new setup, but it should be doable pretty soon.

magnonasc commented 7 years ago

Although I can't start working on this again, because I have a lot of other projects to work on right now, I'm happy that I contributed for this a little. I hope to see this library working correctly in the future, maybe someday I can even get back to this project, but right now is not the time, but thank you for the opportunity @keilw, this means a lot.

keilw commented 7 years ago

@magnonasc Thanks for your input and thoughts about the parent vs. system hierarchy. Not sure, if you'll use the UCUM module in productsor projects in the near future, but it looks like this tweak (without major effects on compatibility) allows to use the uom-se typesystem instead of creating a separate one.

garretwilson commented 7 years ago

I cannot predict how long it might take, but introducing a distinct "parent" to TransformedUnit seems to help with many cases. Especially SimpleUnitFormat still struggles a bit, to be backward-compatible with the RI it must also work with this new setup, but it should be doable pretty soon.

@keilw , can you provide us an update on when you will fix this so that the unit tests don't break, for example testFormatUCUMCSMICROLiter()? I'm not sure why this was closed when the issue is still present.

I have hard-coded workarounds to get one or two measurements to work, but my client will soon be needing to use general measurements. I'll have to decide if I'm going to haev to throw uom-systems out altogether or what to do. In any case, as we discussed above, it's broken for UCUM. Do you have an idea when it will be fixed?

garretwilson commented 7 years ago

@magnonasc , @keilw is saying in #107 that this bug has been fixed. If I understand him correctly, he is saying that it is now working on the master branch. (I'm not sure if he is saying that v1.0.7 contains the fix, or if only the current master _built on v1.0.7.) Could you take about half an hour and just confirm whether the problems we discussed above have been addressed? Thank you.

keilw commented 7 years ago

Since this was related to https://github.com/unitsofmeasurement/uom-se/issues/136 it was closed as soon as uom-se addressed the problem. 1.0.7 out now including MavenCentral is used by the current "snapshot" build of uom-systems. The modification of TransformedUnit in both uom-se and the RI is now complete, also see https://groups.google.com/forum/?hl=en#!topic/units-dev/frY7SeOzg8A. Where exactly it slipped into likey the JScience 5 drafts I can't say, but last but not least this approach is also more compatible with JSR 275 and should make it easier for apps wishing to change.

keilw commented 7 years ago

@magnonasc If you can please have a look at the UCUM module and formatting/parsing. Ideally before the 0.7.1 milestone, unless it was something too big to handle by the end of the week.

Thanks.