Search in sources :

Example 21 with Identifier

use of org.opengis.metadata.Identifier in project sis by apache.

the class MetadataBuilder method addProcessing.

/**
 * Adds information about the procedure, process and algorithm applied in a process step.
 * If a processing was already defined with a different identifier, then a new processing
 * instance will be created. Storage location is:
 *
 * <ul>
 *   <li>{@code metadata/resourceLineage/processStep/processingInformation/identifier}</li>
 * </ul>
 *
 * @param  authority   identifies the authority that defines processing code, or {@code null} if none.
 * @param  identifier  processing package that produced the data, or {@code null} for no-operation.
 *
 * @see #addSoftwareReference(CharSequence)
 * @see #addHostComputer(CharSequence)
 */
public final void addProcessing(final CharSequence authority, String identifier) {
    if (identifier != null && !(identifier = identifier.trim()).isEmpty()) {
        if (processing != null) {
            final Identifier current = processing.getIdentifier();
            if (current != null) {
                if (identifier.equals(current.getCode())) {
                    return;
                }
                processStep().setProcessingInformation(processing);
                addIfNotPresent(lineage().getProcessSteps(), processStep);
                processing = null;
                processStep = null;
            }
        }
        processing().setIdentifier(sharedIdentifier(authority, identifier));
    }
}
Also used : DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) Identifier(org.opengis.metadata.Identifier)

Example 22 with Identifier

use of org.opengis.metadata.Identifier in project sis by apache.

the class GeodeticObjectParser method parseMethod.

/**
 * Parses a {@code "Method"} (WKT 2) element, without the parameters.
 *
 * @param  parent    the parent element.
 * @param  keywords  the element keywords.
 * @return the operation method.
 * @throws ParseException if the {@code "Method"} element can not be parsed.
 */
private OperationMethod parseMethod(final Element parent, final String... keywords) throws ParseException {
    final Element element = parent.pullElement(MANDATORY, keywords);
    final String name = element.pullString("method");
    Map<String, ?> properties = parseMetadataAndClose(element, name, null);
    // See NOTE 2 in parseDerivingConversion.
    final Identifier id = toIdentifier(properties.remove(IdentifiedObject.IDENTIFIERS_KEY));
    /*
         * The map projection method may be specified by an EPSG identifier (or any other authority),
         * which is preferred to the method name since the later is potentially ambiguous. However not
         * all CoordinateOperationFactory may accept identifier as an argument to 'getOperationMethod'.
         * So if an identifier is present, we will try to use it but fallback on the name if we can
         * not use the identifier.
         */
    FactoryException suppressed = null;
    if (id instanceof ReferenceIdentifier)
        try {
            // CodeSpace is a mandatory attribute in ID[…] elements, so we do not test for null values.
            return referencing.getOperationMethod(opFactory, mtFactory, ((ReferenceIdentifier) id).getCodeSpace() + DefaultNameSpace.DEFAULT_SEPARATOR + id.getCode());
        } catch (FactoryException e) {
            suppressed = e;
        }
    try {
        return referencing.getOperationMethod(opFactory, mtFactory, name);
    } catch (FactoryException e) {
        if (suppressed != null) {
            e.addSuppressed(suppressed);
        }
        throw element.parseFailed(e);
    }
}
Also used : ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) Identifier(org.opengis.metadata.Identifier) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) FactoryException(org.opengis.util.FactoryException)

Example 23 with Identifier

use of org.opengis.metadata.Identifier in project sis by apache.

the class SimpleIdentifiedObject method hashCode.

/**
 * Returns a hash code value for this object.
 */
@Override
public final int hashCode() {
    int code = (int) serialVersionUID;
    final Identifier name = getName();
    if (name != null) {
        code ^= name.hashCode();
    }
    return code;
}
Also used : Identifier(org.opengis.metadata.Identifier) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier)

Example 24 with Identifier

use of org.opengis.metadata.Identifier 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)

Example 25 with Identifier

use of org.opengis.metadata.Identifier in project sldeditor by robward-scisys.

the class CoordManager method populateCRSList.

/**
 * Populate crs list.
 */
public void populateCRSList() {
    if (isPopulated()) {
        Runnable runnable = () -> {
            VendorOptionVersion vendorOptionVersion = VendorOptionManager.getInstance().getDefaultVendorOptionVersion();
            ValueComboBoxData notSetValue = new ValueComboBoxData(NOT_SET_CRS, Localisation.getString(CoordManager.class, "common.notSet"), vendorOptionVersion);
            crsDataList.add(notSetValue);
            Hints hints = null;
            for (AuthorityFactory factory : ReferencingFactoryFinder.getCRSAuthorityFactories(hints)) {
                String authorityCode = NOT_SET_CRS;
                Citation citation = factory.getAuthority();
                if (citation != null) {
                    @SuppressWarnings("unchecked") Collection<Identifier> identifierList = (Collection<Identifier>) citation.getIdentifiers();
                    authorityCode = identifierList.iterator().next().getCode();
                }
                Set<String> codeList;
                try {
                    codeList = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
                    for (String code : codeList) {
                        String fullCode = String.format("%s:%s", authorityCode, code);
                        String descriptionText = factory.getDescriptionText(code).toString();
                        String text = String.format("%s - %s", fullCode, descriptionText);
                        ValueComboBoxData value = new ValueComboBoxData(fullCode, text, vendorOptionVersion);
                        crsDataList.add(value);
                        crsMap.put(fullCode, value);
                    }
                } catch (NoSuchAuthorityCodeException e) {
                // ConsoleManager.getInstance().exception(this, e);
                } catch (FactoryException e) {
                    ConsoleManager.getInstance().exception(this, e);
                }
            }
        };
        Thread thread = new Thread(runnable);
        thread.start();
    }
}
Also used : NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException) Set(java.util.Set) Hints(org.geotools.factory.Hints) FactoryException(org.opengis.referencing.FactoryException) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Identifier(org.opengis.metadata.Identifier) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) Collection(java.util.Collection) AuthorityFactory(org.opengis.referencing.AuthorityFactory) Citation(org.opengis.metadata.citation.Citation)

Aggregations

Identifier (org.opengis.metadata.Identifier)60 ReferenceIdentifier (org.opengis.referencing.ReferenceIdentifier)21 Test (org.junit.Test)14 ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)11 Citation (org.opengis.metadata.citation.Citation)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)10 InternationalString (org.opengis.util.InternationalString)10 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)6 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)6 IdentifierMap (org.apache.sis.xml.IdentifierMap)6 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)5 OperationMethod (org.opengis.referencing.operation.OperationMethod)5 NameToIdentifier (org.apache.sis.internal.metadata.NameToIdentifier)4 NamedIdentifier (org.apache.sis.referencing.NamedIdentifier)4 GenericName (org.opengis.util.GenericName)4 URI (java.net.URI)3 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)3 IdentityHashMap (java.util.IdentityHashMap)2 LinkedHashMap (java.util.LinkedHashMap)2