private Unit<?> defaultIntegralUnit() { return unit.times(SI.SECOND); }
/** * Returns the product of this dimension with the one specified. * * @param that the dimension multiplicand. * @return <code>this * that</code> */ public final Dimension times(Dimension that) { return new Dimension(this._pseudoUnit.times(that._pseudoUnit)); }
/** * Returns the product of this dimension with the one specified. * * @param that the dimension multiplicand. * @return <code>this * that</code> */ public final Dimension times(Dimension that) { return new Dimension(this._pseudoUnit.times(that._pseudoUnit)); }
/** * Returns the quotient of this unit with the one specified. * * @param that the unit divisor. * @return <code>this / that</code> */ public final Unit<? extends Quantity> divide(Unit<?> that) { return this.times(that.inverse()); }
/** * Returns the quotient of this unit with the one specified. * * @param that the unit divisor. * @return <code>this / that</code> */ public final Unit<? extends Quantity> divide(Unit<?> that) { return this.times(that.inverse()); }
/** * Returns the quotient of this unit with the one specified. * * @param that the unit divisor. * @return <code>this / that</code> */ public final Unit<? extends Quantity> divide(Unit<?> that) { return this.times(that.inverse()); }
/** * Returns the product of this dimension with the one specified. * * @param that the dimension multiplicand. * @return <code>this * that</code> */ public final Dimension times(Dimension that) { return new Dimension(this._pseudoUnit.times(that._pseudoUnit)); }
public static void main(String[] args) { System.out.println(UnitMapping.findUnitMapping(NonSI.BYTE)); System.out.println(UnitMapping.findUnitMapping(NonSI.BYTE.divide(SI.SECOND))); System.out.println(UnitMapping.findUnitMapping(NonSI.BYTE.times(1024).divide(SI.SECOND))); System.out.println(UnitMapping.findUnitMapping(NonSI.BYTE.times(1024).divide( SI.SECOND.divide(1000)))); System.out.println(UnitMapping.findUnitMapping(Unit.ONE.times(1000).divide(SI.SECOND))); System.out.println(UnitMapping.findUnitMapping(Unit.ONE.times(1000).divide( SI.SECOND.divide(1000)))); System.out.println(UnitMapping.findUnitMapping(Unit.ONE.times(500).divide( SI.SECOND.divide(2)))); System.out.println(UnitMapping.findUnitMapping(Unit.ONE.times(50).divide(SI.BIT))); } }
/** * Returns a unit equals to this unit raised to an exponent. * * @param n the exponent. * @return the result of raising this unit to the exponent. */ public final Unit<? extends Quantity> pow(int n) { if (n > 0) { return this.times(this.pow(n - 1)); } else if (n == 0) { return ONE; } else { // n < 0 return ONE.divide(this.pow(-n)); } }
/** * Returns a unit equals to this unit raised to an exponent. * * @param n the exponent. * @return the result of raising this unit to the exponent. */ public final Unit<? extends Quantity> pow(int n) { if (n > 0) { return this.times(this.pow(n - 1)); } else if (n == 0) { return ONE; } else { // n < 0 return ONE.divide(this.pow(-n)); } }
/** * Returns a unit equals to this unit raised to an exponent. * * @param n the exponent. * @return the result of raising this unit to the exponent. */ public final Unit<? extends Quantity> pow(int n) { if (n > 0) { return this.times(this.pow(n - 1)); } else if (n == 0) { return ONE; } else { // n < 0 return ONE.divide(this.pow(-n)); } }
@Override @SuppressWarnings("unchecked") public Unit<? super Q> getStandardUnit() { if (hasOnlyStandardUnit()) return this; Unit systemUnit = ONE; for (int i = 0; i < _elements.length; i++) { Unit unit = _elements[i]._unit.getStandardUnit(); unit = unit.pow(_elements[i]._pow); unit = unit.root(_elements[i]._root); systemUnit = systemUnit.times(unit); } return systemUnit; }
@SuppressWarnings("unchecked") public static Unit<Area> getAreaUnit(CoordinateReferenceSystem crs) { CoordinateReferenceSystem horCRS = CRS.getHorizontalCRS(crs); if (horCRS instanceof GeographicCRS) { return SI.SQUARE_METRE; // default } else { Unit<?> distUnit = horCRS.getCoordinateSystem().getAxis(0).getUnit(); return (Unit<Area>) distUnit.times(distUnit); } } }
@Override @SuppressWarnings("unchecked") public Unit<? super Q> getStandardUnit() { if (hasOnlyStandardUnit()) return this; Unit systemUnit = ONE; for (int i = 0; i < _elements.length; i++) { Unit unit = _elements[i]._unit.getStandardUnit(); unit = unit.pow(_elements[i]._pow); unit = unit.root(_elements[i]._root); systemUnit = systemUnit.times(unit); } return systemUnit; }
@Override @SuppressWarnings("unchecked") public Unit<? super Q> getStandardUnit() { if (hasOnlyStandardUnit()) return this; Unit systemUnit = ONE; for (int i = 0; i < _elements.length; i++) { Unit unit = _elements[i]._unit.getStandardUnit(); unit = unit.pow(_elements[i]._pow); unit = unit.root(_elements[i]._root); systemUnit = systemUnit.times(unit); } return systemUnit; }
@SuppressWarnings("unchecked") public UnitCalculator(CoordinateReferenceSystem sourceCRS) { this.sourceCRS = sourceCRS; CoordinateReferenceSystem horCRS = CRS.getHorizontalCRS(sourceCRS); if (horCRS instanceof GeographicCRS) { this.distanceUnit = SI.METER; // default this.areaUnit = SI.SQUARE_METRE; // default this.isGeographic = true; } else { CoordinateSystem cs = horCRS.getCoordinateSystem(); this.distanceUnit = (Unit<Length>) cs.getAxis(0).getUnit(); this.areaUnit = (Unit<Area>) distanceUnit.times(distanceUnit); } }
private Unit<?> getBaseUnits() { Unit<?> systemUnit = this.getStandardUnit(); if (systemUnit instanceof BaseUnit) return systemUnit; if (systemUnit instanceof AlternateUnit) return ((AlternateUnit<?>)systemUnit).getParent().getBaseUnits(); if (systemUnit instanceof ProductUnit) { ProductUnit<?> productUnit = (ProductUnit<?>)systemUnit; Unit<?> baseUnits = ONE; for (int i = 0; i < productUnit.getUnitCount(); i++) { Unit<?> unit = productUnit.getUnit(i).getBaseUnits(); unit = unit.pow(productUnit.getUnitPow(i)); unit = unit.root(productUnit.getUnitRoot(i)); baseUnits = baseUnits.times(unit); } return baseUnits; } else { throw new InternalError( "System Unit cannot be an instance of " + this.getClass()); } } private static UnitConverter transformOf(Unit<?> baseUnits) {
public void run() { FastMap<Unit<?>, Unit<?>> leftTable = MULT_LOOKUP.get(left); if (leftTable == null) { leftTable = new FastMap<Unit<?>, Unit<?>>().setKeyComparator( FastComparator.DIRECT); MULT_LOOKUP.put(left, leftTable); } Unit<?> result = leftTable.get(right); if (result == null) { result = left.times(right); leftTable.put(right, result); } } });
private Unit<?> getBaseUnits() { Unit<?> systemUnit = this.getStandardUnit(); if (systemUnit instanceof BaseUnit) return systemUnit; if (systemUnit instanceof AlternateUnit) return ((AlternateUnit<?>)systemUnit).getParent().getBaseUnits(); if (systemUnit instanceof ProductUnit) { ProductUnit<?> productUnit = (ProductUnit<?>)systemUnit; Unit<?> baseUnits = ONE; for (int i = 0; i < productUnit.getUnitCount(); i++) { Unit<?> unit = productUnit.getUnit(i).getBaseUnits(); unit = unit.pow(productUnit.getUnitPow(i)); unit = unit.root(productUnit.getUnitRoot(i)); baseUnits = baseUnits.times(unit); } return baseUnits; } else { throw new InternalError( "System Unit cannot be an instance of " + this.getClass()); } } private static UnitConverter transformOf(Unit<?> baseUnits) {
private Unit<?> getBaseUnits() { Unit<?> systemUnit = this.getStandardUnit(); if (systemUnit instanceof BaseUnit) return systemUnit; if (systemUnit instanceof AlternateUnit) return ((AlternateUnit<?>)systemUnit).getParent().getBaseUnits(); if (systemUnit instanceof ProductUnit) { ProductUnit<?> productUnit = (ProductUnit<?>)systemUnit; Unit<?> baseUnits = ONE; for (int i = 0; i < productUnit.getUnitCount(); i++) { Unit<?> unit = productUnit.getUnit(i).getBaseUnits(); unit = unit.pow(productUnit.getUnitPow(i)); unit = unit.root(productUnit.getUnitRoot(i)); baseUnits = baseUnits.times(unit); } return baseUnits; } else { throw new InternalError( "System Unit cannot be an instance of " + this.getClass()); } } private static UnitConverter transformOf(Unit<?> baseUnits) {