@keilw thanks for your response. I will have a focus on uom-systems to see if it fits.
by "converting UOM symbols" I mean to convert to UOM symbols. that is having arbitrary uom strings (used by a domain which are not standard), parse it into a known unit (very likly via some mapping config) and then get out the actual UCUM symbol from it.
Currently I do have org.geotools:gt-opengis:14
on my classpath which ships with jsr-275 beta jar which provides a UnitFormatter via `UnitFormat.getUCUMInstance(). However, JSR-275 was rejected by the EC.
BaseUnit
has an additional argument Q
, but I see no realistic way to pass that when constructing the class, nor to retrieve it later. Using the Class
maybe, that's already done in other places like unit systems.
Hello, I'm trying to use this api to manage material quantities. I'm trying to parse string units from a DB to a Unit. Can someone advise? I tried this approach, but it seems the ServiceProvider needs to be configured with services. Is there an easier approach to identifying a unit? In this case, I'm assuming it's mass but it could also be a volume.
private void parseMeasurement() {
if (available > 0 && availableUnit != null) {
try {
UnitFormat format = ServiceProvider.current().getFormatService().getUnitFormat();
Unit<?> unit = format.parse(availableUnit);
if (unit.getSystemUnit() instanceof Mass) {
Quantity<?> mass = Quantities.getQuantity(available,unit);
massAvailProperty().set(mass);
} else {
log.debug("Unexpected unit {} is not a Mass", unit.getName());
}
} catch (MeasurementParseException e) {
log.debug("Can't parse unit",e);
}
}
}
Thanks