Search in sources :

Example 1 with SignReversalComment

use of org.apache.sis.internal.referencing.SignReversalComment in project sis by apache.

the class InverseOperationMethod method create.

/**
 * Returns or create the inverse of the given operation method. If the same operation method can be used
 * for the inverse operation either with the exact same parameter values or with the sign of some values
 * reversed, then the given method is returned as-is. Otherwise a synthetic method is created.
 */
static OperationMethod create(final OperationMethod method) {
    if (method instanceof InverseOperationMethod) {
        return ((InverseOperationMethod) method).inverse;
    }
    if (!isInvertible(method)) {
        boolean useSameParameters = false;
        for (final GeneralParameterDescriptor descriptor : method.getParameters().descriptors()) {
            useSameParameters = (descriptor.getRemarks() instanceof SignReversalComment);
            if (!useSameParameters)
                break;
        }
        if (!useSameParameters) {
            Identifier name = method.getName();
            name = new ImmutableIdentifier(null, null, "Inverse of " + name.getCode());
            final Map<String, Object> properties = new HashMap<>(6);
            properties.put(NAME_KEY, name);
            properties.put(FORMULA_KEY, method.getFormula());
            properties.put(REMARKS_KEY, method.getRemarks());
            if (method instanceof Deprecable) {
                properties.put(DEPRECATED_KEY, ((Deprecable) method).isDeprecated());
            }
            return new InverseOperationMethod(properties, method);
        }
    }
    return method;
}
Also used : ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Identifier(org.opengis.metadata.Identifier) HashMap(java.util.HashMap) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) SignReversalComment(org.apache.sis.internal.referencing.SignReversalComment) InternationalString(org.opengis.util.InternationalString) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Deprecable(org.apache.sis.util.Deprecable)

Aggregations

HashMap (java.util.HashMap)1 SignReversalComment (org.apache.sis.internal.referencing.SignReversalComment)1 ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)1 Deprecable (org.apache.sis.util.Deprecable)1 Identifier (org.opengis.metadata.Identifier)1 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)1 InternationalString (org.opengis.util.InternationalString)1