targetValue.getDescriptor().getValueClass())) { final double sourceNum, targetNum; final Unit<?> unit = targetValue.getUnit(); if (unit != null) { sourceNum = sourceValue.doubleValue(unit);
unit = value.getUnit(); warning = descriptor.getName().getCode();
/** * Unconditionally returns the unit of the semi-major axis, which is the unit * in which {@link #doubleValue()} performs its computation. */ @Override public Unit<?> getUnit() { return semiMajor.getUnit(); }
/** * Unconditionally returns the unit of the semi-major axis, which is the unit * in which {@link #doubleValue()} performs its computation. */ @Override public Unit<?> getUnit() { return semiMajor.getUnit(); }
final Unit<?> unit = source.getUnit(); if (unit == null) { target.setValue(v);
/** * Returns {@code true} if the inverse flattening factor has been explicitly specified * and seems to still valid. */ boolean isIvfDefinitive() { if (inverseFlattening > 0) { final Number ca = (Number) semiMajor.getValue(); if (ca != null && ca.doubleValue() == a) { final Number cb = (Number) semiMinor.getValue(); if (cb != null && cb.doubleValue() == b) { return Objects.equals(semiMajor.getUnit(), semiMinor.getUnit()); } } } return false; }
/** * Returns {@code true} if the inverse flattening factor has been explicitely specified * and seems to still valid. */ boolean isIvfDefinitive() { if (inverseFlattening > 0) { final Number ca = (Number) semiMajor.getValue(); if (ca != null && ca.doubleValue() == a) { final Number cb = (Number) semiMinor.getValue(); if (cb != null && cb.doubleValue() == b) { return Objects.equals(semiMajor.getUnit(), semiMinor.getUnit()); } } } return false; }
assertEquals("maximum", 20.0, dDescriptor.getMaximumValue()); assertEquals("value", 12, parameter.intValue()); assertEquals("unit", SI.METRE, parameter.getUnit()); for (int i = 4; i <= 20; i++) { parameter.setValue(i); assertEquals("value", Double.valueOf(i), parameter.getValue()); assertEquals("unit", SI.METRE, parameter.getUnit()); assertEquals("value", i, parameter.doubleValue(SI.METRE), 0); parameter.setValue(i, MetricPrefix.CENTI(SI.METRE)); assertEquals("value", Double.valueOf(i), parameter.getValue()); assertEquals("unit", MetricPrefix.CENTI(SI.METRE), parameter.getUnit()); assertEquals("value", i / 100, parameter.doubleValue(SI.METRE), 0);
/** * Invoked when the parameter value is requested. Computes the inverse flattening factor * from the axis lengths if the currently stored value does not seem to be valid anymore. */ @Override public double doubleValue() { final double ca = semiMajor.doubleValue(); final double cb = semiMinor.doubleValue(semiMajor.getUnit()); if (ca == a && cb == b && inverseFlattening > 0) { return inverseFlattening; } return Formulas.getInverseFlattening(ca, cb); }
/** * Invoked when the parameter value is requested. Computes the inverse flattening factor * from the axis lengths if the currently stored value does not seem to be valid anymore. */ @Override public double doubleValue() { final double ca = semiMajor.doubleValue(); final double cb = semiMinor.doubleValue(semiMajor.getUnit()); if (ca == a && cb == b && inverseFlattening > 0) { return inverseFlattening; } return Formulas.getInverseFlattening(ca, cb); }
/** * Creates a new instance initialized with the values from the specified parameter object. * This is a <em>shallow</em> copy constructor, since the value contained in the given * object is not cloned. * * @param parameter the parameter to copy values from. * * @see #clone() * @see #unmodifiable(ParameterValue) */ public DefaultParameterValue(final ParameterValue<T> parameter) { ensureNonNull("parameter", parameter); descriptor = parameter.getDescriptor(); value = parameter.getValue(); unit = parameter.getUnit(); }
/** * Invoked when the parameter value is requested. Unconditionally computes the authalic radius. * If an Earth radius has been explicitely specified, the result will be the same unless the user * overwrote it with explicit semi-major or semi-minor axis length. */ @Override public double doubleValue() { double r = semiMajor.doubleValue(); if (semiMinor.getValue() != null) { // Compute in unit of the semi-major axis. r = Formulas.getAuthalicRadius(r, semiMinor.doubleValue(semiMajor.getUnit())); } return r; }
/** * Invoked when a new parameter value is set. * This method computes the semi-minor axis length from the given value. */ @Override protected void setValue(final Object value, final Unit<?> unit) { super.setValue(value, unit); // Perform argument check. final double ivf = (Double) value; // At this point, can not be anything else than Double. final Number ca = (Number) semiMajor.getValue(); if (ca != null) { a = ca.doubleValue(); b = Formulas.getSemiMinor(a, ivf); semiMinor.setValue(b, semiMajor.getUnit()); } else { invalidate(); } inverseFlattening = ivf; }
/** * Invoked when the parameter value is requested. Unconditionally computes the authalic radius. * If an Earth radius has been explicitly specified, the result will be the same unless the user * overwrote it with explicit semi-major or semi-minor axis length. */ @Override public double doubleValue() { double r = semiMajor.doubleValue(); if (semiMinor.getValue() != null) { // Compute in unit of the semi-major axis. r = Formulas.getAuthalicRadius(r, semiMinor.doubleValue(semiMajor.getUnit())); } return r; }
/** * Computes the semi-minor axis length from the given inverse flattening value. */ private void update(final double value) { final ParameterValue<?> semiMajor; try { semiMajor = Parameters.castOrWrap(MapProjectionParameters.this).getOrCreate(SEMI_MAJOR); } catch (IllegalStateException e) { // Semi-major axis is not yet defined. // Ignore - we will try to compute gain later. return; } set(SEMI_MINOR, semiMajor.doubleValue()*(1 - 1/value), semiMajor.getUnit()); }
/** * Creates a transform with the same parameters than this transform, * but expecting two-dimensional inputs instead than three-dimensional. */ final EllipsoidToCentricTransform create2D() { final ParameterValue<Double> p = context.getOrCreate(SEMI_MAJOR); final Unit<Length> unit = p.getUnit().asType(Length.class); return new EllipsoidToCentricTransform(p.doubleValue(), context.getOrCreate(SEMI_MINOR).doubleValue(unit), unit, false, getTargetType()); } }
/** * Creates a transform with the same parameters than this transform, * but expecting two-dimensional inputs instead than three-dimensional. */ final EllipsoidToCentricTransform create2D() { final ParameterValue<Double> p = context.getOrCreate(SEMI_MAJOR); final Unit<Length> unit = p.getUnit().asType(Length.class); return new EllipsoidToCentricTransform(p.doubleValue(), context.getOrCreate(SEMI_MINOR).doubleValue(unit), unit, false, getTargetType()); } }
/** * Implementation of {@link #createMathTransform(MathTransformFactory, ParameterValueGroup)} * shared with {@link GeocentricToGeographic}. */ static MathTransform create(final MathTransformFactory factory, final Parameters values) throws FactoryException { final ParameterValue<?> semiMajor = values.parameter(Constants.SEMI_MAJOR); final Unit<Length> unit = semiMajor.getUnit().asType(Length.class); return EllipsoidToCentricTransform.createGeodeticConversion(factory, semiMajor.doubleValue(), values.parameter(Constants.SEMI_MINOR).doubleValue(unit), unit, values.intValue(DIMENSION) >= 3, EllipsoidToCentricTransform.TargetType.CARTESIAN); } }
/** * Implementation of {@link #createMathTransform(MathTransformFactory, ParameterValueGroup)} * shared with {@link GeocentricToGeographic}. */ static MathTransform create(final MathTransformFactory factory, final Parameters values) throws FactoryException { final ParameterValue<?> semiMajor = values.parameter(Constants.SEMI_MAJOR); final Unit<Length> unit = semiMajor.getUnit().asType(Length.class); return EllipsoidToCentricTransform.createGeodeticConversion(factory, semiMajor.doubleValue(), values.parameter(Constants.SEMI_MINOR).doubleValue(unit), unit, values.intValue(DIMENSION) >= 3, EllipsoidToCentricTransform.TargetType.CARTESIAN); } }
/** * Verifies the parameters of a “NTF (Paris) / Lambert zone II” projection. */ private static void validateParisFranceII(final ProjectedCRS crs, final int identifier, final boolean hasToWGS84) { assertNameAndIdentifierEqual("NTF (Paris) / Lambert zone II", identifier, crs); verifyProjectedCS(crs.getCoordinateSystem(), Units.KILOMETRE); final PrimeMeridian pm = verifyNTF(crs.getDatum(), hasToWGS84); assertEquals("angularUnit", Units.GRAD, pm.getAngularUnit()); assertEquals("greenwichLongitude", 2.5969213, pm.getGreenwichLongitude(), STRICT); final ParameterValue<?> param = verifyNTF(crs.getConversionFromBase().getParameterValues()); assertEquals("angularUnit", Units.GRAD, param.getUnit()); assertEquals("latitude_of_origin", 52.0, param.doubleValue(), STRICT); }