/** * Returns a SIS operation method implementation with the same values than the given arbitrary implementation. * If the given object is {@code null}, then {@code null} is returned. * Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged. * Otherwise a new SIS implementation is created and initialized to the attribute values of the given object. * * @param object the object to get as a SIS implementation, or {@code null} if none. * @return a SIS implementation containing the values of the given object (may be the * given object itself), or {@code null} if the argument was null. */ public static DefaultOperationMethod castOrCopy(final OperationMethod object) { return (object == null) || (object instanceof DefaultOperationMethod) ? (DefaultOperationMethod) object : new DefaultOperationMethod(object); }
protected Object readResolve() throws ObjectStreamException { return org.apache.sis.referencing.operation.DefaultOperationMethod.castOrCopy(this); } }
/** * Returns the operation type of the given method. */ private static Class<?> getOperationType(final DefaultOperationMethod method) { Class<?> type = method.getOperationType(); if (type == SingleOperation.class) { if (method instanceof Affine) { // EPSG:9624 - Affine parametric transformation type = Transformation.class; } } return type; }
if (!Objects.equals(getFormula(), ((OperationMethod) object).getFormula())) { return false; final Boolean match = Citations.hasCommonIdentifier(getIdentifiers(), that.getIdentifiers()); if (match != null) { if (!match) { return false; } else if (!isHeuristicMatchForName(that.getName().getCode()) && !IdentifiedObjects.isHeuristicMatchForName(that, getName().getCode())) return Objects.equals(getSourceDimensions(), that.getSourceDimensions()) && Objects.equals(getTargetDimensions(), that.getTargetDimensions()) && Utilities.deepEquals(getParameters(), that.getParameters(), mode);
/** * Returns this operation method with different dimensions, if we are allowed to change dimensionality. * See {@link #redimension(OperationMethod, int, int)} for more information. * * <p>The default implementation performs the following choice: * for each dimension (<var>source</var> and <var>target</var>):</p> * <ul> * <li>If the corresponding dimension of the given method is {@code null}, then * set that dimension to the given value in a new {@code OperationMethod}.</li> * <li>Otherwise if the given value is not equal to the corresponding dimension * in the given method, throw an {@link IllegalArgumentException}.</li> * </ul> * * Subclasses should override this method if they can work with different number of dimensions. * For example a <cite>Molodensky</cite> transform usually works in a three-dimensional space, * but can also work in a two-dimensional space by assuming that the ellipsoidal height is zero * everywhere. * * @param sourceDimensions the desired number of input dimensions. * @param targetDimensions the desired number of output dimensions. * @return the redimensioned operation method, or {@code this} if no change is needed. * @throws IllegalArgumentException if the given dimensions are illegal for this operation method. * * @since 0.6 */ public OperationMethod redimension(final int sourceDimensions, final int targetDimensions) { return redimension(this, sourceDimensions, this.sourceDimensions, targetDimensions, this.targetDimensions); }
method = owner.createOperationMethod(methodCode.toString()); if (isDimensionKnown) { method = DefaultOperationMethod.redimension(method, sourceDimensions, targetDimensions); final Class<?> s = ((DefaultOperationMethod) provider).getOperationType(); if (s != null && opType.isAssignableFrom(s)) { opType = s.asSubclass(SingleOperation.class);
/** * Returns the parameters for the operation method. * * @param name shall be the operation method name. * @return the parameters. * @throws NoSuchIdentifierException if the given name is not the name * of the operation method known to this factory. */ @Override public ParameterValueGroup getDefaultParameters(final String name) throws NoSuchIdentifierException { if (method.isHeuristicMatchForName(name)) { return method.getParameters().createValue(); } throw new NoSuchIdentifierException(null, name); }
/** * Invoked by JAXB at unmarshalling time for storing the result temporarily. * * @param method the unmarshalled element. */ public void setElement(final DefaultOperationMethod method) { if (!CC_GeneralOperationParameter.isValid(method.getParameters())) { /* * Parameters are mandatory and SIS classes need them. Provide an error message * here instead than waiting for a NullPointerException in some arbitrary place. */ throw new IllegalArgumentException(Errors.format(Errors.Keys.MissingValueForProperty_1, "parameters")); } metadata = method; }
/** * Tests {@link DefaultOperationMethod#equals(Object, ComparisonMode)}. */ @Test public void testEquals() { final Integer dim = 2; final DefaultOperationMethod m1 = create("Mercator (variant A)", "9804", "EPSG guidance note #7-2", dim); final DefaultOperationMethod m2 = create("Mercator (variant A)", "9804", "E = FE + a*ko(lon - lonO)", dim); assertFalse ("STRICT", m1.equals(m2, ComparisonMode.STRICT)); assertFalse ("BY_CONTRACT", m1.equals(m2, ComparisonMode.BY_CONTRACT)); assertTrue ("IGNORE_METADATA", m1.equals(m2, ComparisonMode.IGNORE_METADATA)); assertEquals("Hash code should ignore metadata.", m1.hashCode(), m2.hashCode()); final DefaultOperationMethod m3 = create("Mercator (variant B)", "9805", "EPSG guidance note #7-2", dim); final DefaultOperationMethod m4 = create("mercator (variant b)", "9805", "EPSG guidance note #7-2", dim); assertFalse("IGNORE_METADATA", m1.equals(m3, ComparisonMode.IGNORE_METADATA)); assertTrue ("IGNORE_METADATA", m3.equals(m4, ComparisonMode.IGNORE_METADATA)); assertFalse("BY_CONTRACT", m3.equals(m4, ComparisonMode.BY_CONTRACT)); }
/** * Invoked by JAXB for marshalling a citation to the formula. In principle at most one of * {@code getFormulaCitation()} and {@link #getFormulaDescription()} methods can return a * non-null value. However SIS accepts both coexist (but this is invalid GML). */ @XmlElement(name = "formulaCitation") private Citation getFormulaCitation() { final Formula formula = getFormula(); // Give to users a chance to override. return (formula != null) ? formula.getCitation() : null; }
if (!Objects.equals(getFormula(), ((OperationMethod) object).getFormula())) { return false; final Boolean match = Citations.hasCommonIdentifier(getIdentifiers(), that.getIdentifiers()); if (match != null) { if (!match) { return false; } else if (!isHeuristicMatchForName(that.getName().getCode()) && !IdentifiedObjects.isHeuristicMatchForName(that, getName().getCode())) return Objects.equals(getSourceDimensions(), that.getSourceDimensions()) && Objects.equals(getTargetDimensions(), that.getTargetDimensions()) && Utilities.deepEquals(getParameters(), that.getParameters(), mode);
/** * Returns this operation method with different dimensions, if we are allowed to change dimensionality. * See {@link #redimension(OperationMethod, int, int)} for more information. * * <p>The default implementation performs the following choice: * for each dimension (<var>source</var> and <var>target</var>):</p> * <ul> * <li>If the corresponding dimension of the given method is {@code null}, then * set that dimension to the given value in a new {@code OperationMethod}.</li> * <li>Otherwise if the given value is not equal to the corresponding dimension * in the given method, throw an {@link IllegalArgumentException}.</li> * </ul> * * Subclasses should override this method if they can work with different number of dimensions. * For example a <cite>Molodensky</cite> transform usually works in a three-dimensional space, * but can also work in a two-dimensional space by assuming that the ellipsoidal height is zero * everywhere. * * @param sourceDimensions the desired number of input dimensions. * @param targetDimensions the desired number of output dimensions. * @return the redimensioned operation method, or {@code this} if no change is needed. * @throws IllegalArgumentException if the given dimensions are illegal for this operation method. * * @since 0.6 */ public OperationMethod redimension(final int sourceDimensions, final int targetDimensions) { return redimension(this, sourceDimensions, this.sourceDimensions, targetDimensions, this.targetDimensions); }
method = owner.createOperationMethod(methodCode.toString()); if (isDimensionKnown) { method = DefaultOperationMethod.redimension(method, sourceDimensions, targetDimensions); final Class<?> s = ((DefaultOperationMethod) provider).getOperationType(); if (s != null && opType.isAssignableFrom(s)) { opType = s.asSubclass(SingleOperation.class);
/** * Invoked by JAXB at unmarshalling time for storing the result temporarily. * * @param method the unmarshalled element. */ public void setElement(final DefaultOperationMethod method) { if (!CC_GeneralOperationParameter.isValid(method.getParameters())) { /* * Parameters are mandatory and SIS classes need them. Provide an error message * here instead than waiting for a NullPointerException in some arbitrary place. */ throw new IllegalArgumentException(Errors.format(Errors.Keys.MissingValueForProperty_1, "parameters")); } metadata = method; }
/** * Invoked by JAXB for marshalling a citation to the formula. In principle at most one of * {@code getFormulaCitation()} and {@link #getFormulaDescription()} methods can return a * non-null value. However SIS accepts both coexist (but this is invalid GML). */ @XmlElement(name = "formulaCitation") private Citation getFormulaCitation() { final Formula formula = getFormula(); // Give to users a chance to override. return (formula != null) ? formula.getCitation() : null; }
/** * Returns a SIS operation method implementation with the same values than the given arbitrary implementation. * If the given object is {@code null}, then {@code null} is returned. * Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged. * Otherwise a new SIS implementation is created and initialized to the attribute values of the given object. * * @param object the object to get as a SIS implementation, or {@code null} if none. * @return a SIS implementation containing the values of the given object (may be the * given object itself), or {@code null} if the argument was null. */ public static DefaultOperationMethod castOrCopy(final OperationMethod object) { return (object == null) || (object instanceof DefaultOperationMethod) ? (DefaultOperationMethod) object : new DefaultOperationMethod(object); }
protected Object writeReplace() throws ObjectStreamException { return org.apache.sis.referencing.operation.DefaultOperationMethod.castOrCopy(this); }
return ((DefaultOperationMethod) method).redimension(sourceDimensions, targetDimensions); } else { method = redimension(method, sourceDimensions, method.getSourceDimensions(), targetDimensions, method.getTargetDimensions());
final Class<? extends SingleOperation> c = ((DefaultOperationMethod) method).getOperationType(); if (c != null && !type.isAssignableFrom(c)) { return false;
/** * Initializes a complete projection (including conversion from degrees to radians) for the given provider. */ final void createCompleteProjection(final DefaultOperationMethod provider, final double semiMajor, final double semiMinor, final double centralMeridian, final double latitudeOfOrigin, final double standardParallel1, final double standardParallel2, final double scaleFactor, final double falseEasting, final double falseNorthing) throws FactoryException { final Parameters values = Parameters.castOrWrap(provider.getParameters().createValue()); values.parameter(Constants.SEMI_MAJOR).setValue(semiMajor); values.parameter(Constants.SEMI_MINOR).setValue(semiMinor); if (semiMajor == WGS84_A && semiMinor == WGS84_B) { values.parameter(Constants.INVERSE_FLATTENING).setValue(298.257223563); } if (!isNaN(centralMeridian)) values.parameter(Constants.CENTRAL_MERIDIAN) .setValue(centralMeridian); if (!isNaN(latitudeOfOrigin)) values.parameter(Constants.LATITUDE_OF_ORIGIN) .setValue(latitudeOfOrigin); if (!isNaN(standardParallel1)) values.parameter(Constants.STANDARD_PARALLEL_1).setValue(standardParallel1); if (!isNaN(standardParallel2)) values.parameter(Constants.STANDARD_PARALLEL_2).setValue(standardParallel2); if (!isNaN(scaleFactor)) values.parameter(Constants.SCALE_FACTOR) .setValue(scaleFactor); if (!isNaN(falseEasting)) values.parameter(Constants.FALSE_EASTING) .setValue(falseEasting); if (!isNaN(falseNorthing)) values.parameter(Constants.FALSE_NORTHING) .setValue(falseNorthing); transform = new MathTransformFactoryMock(provider).createParameterizedTransform(values); validate(); }