UnitConverter toKilometers = MILE.getConverterTo(KILOMETER); double km = toKilometers.convert(Measure.valueOf(100, MILE).doubleValue(MILE));
double dayValue = dayConverter.convert(nextValue.getValue().doubleValue()); Duration newValue = new Duration(); newValue.setSystem(SearchParamConstants.UCUM_NS);
double dayValue = dayConverter.convert(nextValue.getValue().doubleValue()); Duration newValue = new Duration(); newValue.setSystem(SearchParamConstants.UCUM_NS);
double dayValue = dayConverter.convert(nextValue.getValue().doubleValue()); DurationDt newValue = new DurationDt(); newValue.setSystem(SearchParamConstants.UCUM_NS);
/** * 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); }
/** * Returns the y coordinate value as <code>double</code> * * @param unit the length unit of the x coordinate value to return. * @return the z coordinate stated in the specified unit. */ public double yValue(Unit<Length> unit) { return (unit == METRE) ? _y : METRE.getConverterTo(unit).convert(_y); }
@Override public Polygon getBuffer(double distance) { // convert to the target unit distance = converter.convert(distance); // buffer and return return (Polygon) center.buffer(distance, quadrantSegments); }
/** * Returns the x coordinate value as <code>double</code> * * @param unit the length unit of the x coordinate value to return. * @return the x coordinate stated in the specified unit. */ public double xValue(Unit<Length> unit) { return (unit == METRE) ? _x : METRE.getConverterTo(unit).convert(_x); }
@Override public double doubleValue(Unit<Q> unit) { double normSquare = _components[0] * _components[0]; for (int i=1, n=_components.length; i < n;) { double d = _components[i++]; normSquare += d * d; } if ((unit == _unit) || (unit.equals(_unit))) return Math.sqrt(normSquare); return _unit.getConverterTo(unit).convert(Math.sqrt(normSquare)); }
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); }
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 = TemporalCRS.TIME_CS.getAxis(0).getUnit(); return SECOND.getConverterTo(u).convert(_seconds); } else { throw new IndexOutOfBoundsException(); } }
public double getOrdinate(int dimension) throws IndexOutOfBoundsException { if (dimension == 0) { Unit<?> u = ProjectedCRS.EASTING_NORTHING_CS.getAxis(0).getUnit(); return METRE.getConverterTo(u).convert(_easting); } else if (dimension == 1) { Unit<?> u = ProjectedCRS.EASTING_NORTHING_CS.getAxis(1).getUnit(); return METRE.getConverterTo(u).convert(_northing); } 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); }
public static double parseValueAsUnit(String string, Unit<?> unit) { double parsedValue = parseValue(string); Unit<?> parsedUnit = parseUnit(string); return parsedUnit.getConverterTo(unit).convert(parsedValue); }
AmountWrapper getInternalAmount(String description) { Unit<?> unit = CategoryMapperUtil.findDurationUnit(description); if (unit != null && unit.isCompatible(STANDARD_PER_WEEK_UNIT)) { return AmountWrapper.create( Amount.rangeOf((double) 3, NonSI.DAY.inverse().getConverterTo(unit).convert(1) - 1, unit) .to(STANDARD_PER_WEEK_UNIT), false); } return null; } }
AmountWrapper getInternalAmount(String description) { Unit<?> unit = CategoryMapperUtil.findDurationUnit(description); if (unit != null && unit.isCompatible(STANDARD_PER_WEEK_UNIT)) { return AmountWrapper .create(Amount.rangeOf((double) 3, NonSI.DAY.inverse().getConverterTo(unit).convert(1) - 1, unit) .to(STANDARD_PER_WEEK_UNIT), false); } return null; } }