Skip to content

switch from jsr 108 to jsr 275 for units

Jody Garnett edited this page Apr 11, 2015 · 9 revisions

Description

We make use of a Units library for keeping track of the difference between meters and feet etc... We have been making use of an offical JSR-108 jar.

There were two replacements available once we upgraded to Java 5

  • JScience
  • JSR-275

The JSR-275 jar is now officially available:

Status

The work has been completed.

Voting results:

Tasks

This section is used to make sure your proposal is complete (did you remember documentation?) and has enough paid or volunteer time lined up to be a success

  1. Fix the dependency in GeoAPI, and deploy a new jar
  2. Fix any and all compile errors (mostly import statements; but may make use of the Quantity package with Java 5 generics and catch a few mistakes)
  3. Update the user guide; there is very little documentation on Units use so this will not take long.

API Changes

Change the import; use Quantity package.

There is one additional change related to Converter. I will document it in this page when I will make this change in GeoTools. Since I don't think that many use Converter directly, it will probably impact few peoples.

BEFORE

import javax.units.SI;
import javax.units.NonSI;
import javax.units.Unit;
import javax.units.UnitFormat;
import javax.units.Converter;
import javax.units.ConversionException;

Unit PPM = Unit.ONE.multiply(1E-6);
UnitFormat.label(PPM, "ppm");

AFTER

import javax.measure.unit.SI;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import javax.measure.unit.UnitFormat;
import javax.measure.converter.UnitConverter;
import javax.measure.converter.ConversionException;

Unit PPM = Unit.ONE.times(1E-6);
UnitFormat.getInstance().label(PPM, "ppm");

Note the class name change from Converter to UnitConverter.

Documentation Changes

We will need to change the following:

  • Developers Guide references to JSR-108
  • User Guide references to JSR-108
Clone this wiki locally