javax.measure.converter.UnitConverter dayConverter = unit.getConverterTo(NonSI.DAY); double dayValue = dayConverter.convert(nextValue.getValue().doubleValue()); Duration newValue = new Duration();
javax.measure.converter.UnitConverter dayConverter = unit.getConverterTo(NonSI.DAY); double dayValue = dayConverter.convert(nextValue.getValue().doubleValue()); Duration newValue = new Duration();
javax.measure.converter.UnitConverter dayConverter = unit.getConverterTo(NonSI.DAY); double dayValue = dayConverter.convert(nextValue.getValue().doubleValue()); DurationDt newValue = new DurationDt();
@Override public double doubleValue(Unit<Q> unit) { double norm = Math.sqrt(_x * _x + _y * _y); if ((unit == _unit) || (unit.equals(_unit))) return norm; return _unit.getConverterTo(unit).convert(norm); }
@Override public double doubleValue(Unit<Q> unit) { double norm = Math.sqrt(_x * _x + _y * _y); if ((unit == _unit) || (unit.equals(_unit))) return norm; return _unit.getConverterTo(unit).convert(norm); }
public static Unit<?> getMostGeneralUnit(List<Unit<?>> candidateUnits) { candidateUnits.sort( (o1, o2) -> { UnitConverter converterTo = o1.inverse().getConverterTo(o2.inverse()); if (converterTo.convert(1) > 1) { return -1; } else { return 1; } }); return candidateUnits.isEmpty() ? null : candidateUnits.get(0); }
public double doubleValue(Unit<Q> unit) { if ((unit == _unit) || (unit.equals(_unit))) return _value; return _unit.getConverterTo(unit).convert(_value); }
/** * Returns the latitude value as <code>double</code> * * @param unit the angle unit of the latitude to return. * @return the latitude stated in the specified unit. */ public final double latitudeValue(Unit<Angle> unit) { return (unit == DEGREE_ANGLE) ? _latitude : (unit == RADIAN) ? DEGREE_TO_RADIAN.convert(_latitude) : DEGREE_ANGLE.getConverterTo(unit).convert(_latitude); }
public double doubleValue(Unit<Q> unit) { if ((unit == _unit) || (unit.equals(_unit))) return _value; return _unit.getConverterTo(unit).convert(_value); }
public double doubleValue(Unit<Q> unit) { if ((unit == _unit) || (unit.equals(_unit))) return _value; return _unit.getConverterTo(unit).convert(_value); }
/** * Returns the longitude value as <code>double</code> * * @param unit the angle unit of the longitude to return. * @return the longitude stated in the specified unit. */ public final double longitudeValue(Unit<Angle> unit) { return (unit == DEGREE_ANGLE) ? _longitude : (unit == RADIAN) ? DEGREE_TO_RADIAN.convert(_longitude) : DEGREE_ANGLE.getConverterTo(unit).convert(_longitude); }
/** * Workaround for RFE #4093999 ("Relax constraint on placement of this()/super() * call in constructors"). */ private static UnitConverter getConverter(final Unit<?> source) throws ConversionException { if (source == null) { throw new ConversionException(Errors.format(ErrorKeys.NO_UNIT)); } return source.getConverterTo(MILLISECOND); }
public double doubleValue(Unit<Q> unit) { if ((unit == _unit) || (unit.equals(_unit))) return _value; return _unit.getConverterTo(unit).convert(_value); }
public double doubleValue(Unit<Q> unit) { if ((unit == _unit) || (unit.equals(_unit))) return _value; return _unit.getConverterTo(unit).convert(_value); }
public double doubleValue(Unit<Q> unit) { if ((unit == _unit) || (unit.equals(_unit))) return _value; return _unit.getConverterTo(unit).convert(_value); }
public double getOrdinate(int dimension) throws IndexOutOfBoundsException { if (dimension == 0) { Unit<?> u = GeographicCRS.LATITUDE_LONGITUDE_CS.getAxis(0).getUnit(); return DEGREE_ANGLE.getConverterTo(u).convert(_latitude); } else if (dimension == 1) { Unit<?> u = GeographicCRS.LATITUDE_LONGITUDE_CS.getAxis(1).getUnit(); return DEGREE_ANGLE.getConverterTo(u).convert(_longitude); } else { throw new IndexOutOfBoundsException(); } }
@Override public MultiDimensional<Q> to(Unit<Q> unit) { if ((unit == _unit) || (unit.equals(_unit))) return this; UnitConverter cvtr = _unit.getConverterTo(unit); double[] newValues = new double[_components.length]; for (int i=0; i < _components.length; i++) { newValues[i] = cvtr.convert(_components[i]); } return new MultiDimensional<Q>(newValues, unit); }
@Override public TwoDimensional<Q> to(Unit<Q> unit) { if ((unit == _unit) || (unit.equals(_unit))) return this; UnitConverter cvtr = _unit.getConverterTo(unit); return new TwoDimensional<Q>(cvtr.convert(_x), cvtr.convert(_y), unit); }
@Override public TwoDimensional<Q> to(Unit<Q> unit) { if ((unit == _unit) || (unit.equals(_unit))) return this; UnitConverter cvtr = _unit.getConverterTo(unit); return new TwoDimensional<Q>(cvtr.convert(_x), cvtr.convert(_y), unit); }
@Override public ThreeDimensional<Q> to(Unit<Q> unit) { if ((unit == _unit) || (unit.equals(_unit))) return this; UnitConverter cvtr = _unit.getConverterTo(unit); return new ThreeDimensional<Q>(cvtr.convert(_x), cvtr.convert(_y), cvtr.convert(_z), unit); }