Search in sources :

Example 1 with ReferenceIdentifier

use of org.opengis.referencing.ReferenceIdentifier in project sis by apache.

the class CoordinateOperationMethods method writeName.

/**
 * Writes the primary name and aliases.
 */
private void writeName(final ParameterDescriptor<?> param) throws IOException {
    final int td = openTag("td class=\"sep\"");
    openTag("details");
    final ReferenceIdentifier name = param.getName();
    final String codeSpace = name.getCodeSpace();
    if (Constants.EPSG.equalsIgnoreCase(codeSpace)) {
        println("summary", escape(name.getCode()));
    } else {
        println("summary", "<span class=\"non-epsg\">" + codeSpace + ":</span>" + "<code>" + name.getCode() + "</code>");
    }
    openTag("table class=\"aliases\"");
    for (final GenericName alias : param.getAlias()) {
        reopenTag("tr");
        println("th", escape(alias.head().toString() + ':'));
        println("td", escape(alias.tip().toString()));
    }
    closeTags(td);
}
Also used : GenericName(org.opengis.util.GenericName) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier)

Example 2 with ReferenceIdentifier

use of org.opengis.referencing.ReferenceIdentifier in project sis by apache.

the class CoordinateOperationMethods method writeIdentification.

/**
 * Writes identification info about the given method.
 * This method writes the following information:
 *
 * <ul>
 *   <li>EPSG codes</li>
 *   <li>Aliases</li>
 *   <li>Domain of validity</li>
 * </ul>
 */
private void writeIdentification(final OperationMethod method) throws IOException {
    final int table = openTag("table class=\"info\"");
    /*
         * ────────────────    EPSG IDENTIFIERS    ────────────────────────────────────
         */
    final StringBuilder buffer = new StringBuilder();
    for (final ReferenceIdentifier id : method.getIdentifiers()) {
        if (Constants.EPSG.equalsIgnoreCase(id.getCodeSpace())) {
            if (buffer.length() != 0) {
                buffer.append(", ");
            }
            final boolean isDeprecated = isDeprecated(id);
            if (isDeprecated) {
                buffer.append("<del>");
            }
            buffer.append(id.getCode());
            if (isDeprecated) {
                buffer.append("</del>");
            }
        }
    }
    if (buffer.length() != 0) {
        final int tr = openTag("tr");
        println("th", "EPSG code:");
        println("td", buffer);
        closeTags(tr);
    }
    /*
         * ────────────────    ALIASES    ─────────────────────────────────────────────
         */
    buffer.setLength(0);
    for (final GenericName alias : method.getAlias()) {
        if (buffer.length() != 0) {
            buffer.append(", ");
        }
        final GenericName head = alias.head();
        if (head == alias || Constants.EPSG.equalsIgnoreCase(head.toString())) {
            buffer.append(alias.tip());
        } else {
            buffer.append("<span class=\"non-epsg\">").append(head).append(":</span>").append("<code>").append(alias.tip()).append("</code>");
        }
    }
    if (buffer.length() != 0) {
        final int tr = openTag("tr");
        println("th", "Aliases:");
        println("td", buffer);
        closeTags(tr);
    }
    /*
         * ────────────────    DOMAIN OF VALIDITY    ──────────────────────────────────
         */
    buffer.setLength(0);
    final DefaultGeographicBoundingBox domain = getDomainOfValidity(method);
    if (domain != null) {
        openTag("tr");
        println("th", "Domain of validity:");
        println("td", buffer.append(new Latitude(domain.getSouthBoundLatitude())).append(" to ").append(new Latitude(domain.getNorthBoundLatitude())).append(" and ").append(new Longitude(domain.getWestBoundLongitude())).append(" to ").append(new Longitude(domain.getEastBoundLongitude())));
    }
    closeTags(table);
}
Also used : GenericName(org.opengis.util.GenericName) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox) Latitude(org.apache.sis.measure.Latitude) Longitude(org.apache.sis.measure.Longitude)

Example 3 with ReferenceIdentifier

use of org.opengis.referencing.ReferenceIdentifier in project sis by apache.

the class Citations method hasCommonIdentifier.

/**
 * Determines whether a match or mismatch is found between the two given collections of identifiers.
 * If any of the given collections is {@code null} or empty, then this method returns {@code null}.
 *
 * <p>According ISO 19162 (<cite>Well known text representation of coordinate reference systems</cite>),
 * {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getIdentifiers() identifiers} should have precedence over
 * {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getName() name} for identifying {@code IdentifiedObject}s,
 * at least in the case of {@linkplain org.apache.sis.referencing.operation.DefaultOperationMethod operation methods} and
 * {@linkplain org.apache.sis.parameter.AbstractParameterDescriptor parameters}.</p>
 *
 * @param  id1  the first collection of identifiers, or {@code null}.
 * @param  id2  the second collection of identifiers, or {@code null}.
 * @return {@code TRUE} or {@code FALSE} on match or mismatch respectively, or {@code null} if this method
 *         can not determine if there is a match or mismatch.
 */
public static Boolean hasCommonIdentifier(final Iterable<? extends Identifier> id1, final Iterable<? extends Identifier> id2) {
    if (id1 != null && id2 != null) {
        boolean hasFound = false;
        for (final Identifier identifier : id1) {
            final Citation authority = identifier.getAuthority();
            final String codeSpace = (identifier instanceof ReferenceIdentifier) ? ((ReferenceIdentifier) identifier).getCodeSpace() : null;
            for (final Identifier other : id2) {
                if (authorityMatches(identifier, authority, codeSpace)) {
                    if (CharSequences.equalsFiltered(identifier.getCode(), other.getCode(), Characters.Filter.UNICODE_IDENTIFIER, true)) {
                        return Boolean.TRUE;
                    }
                    hasFound = true;
                }
            }
        }
        if (hasFound) {
            return Boolean.FALSE;
        }
    }
    return null;
}
Also used : Identifier(org.opengis.metadata.Identifier) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) Citation(org.opengis.metadata.citation.Citation) InternationalString(org.opengis.util.InternationalString)

Example 4 with ReferenceIdentifier

use of org.opengis.referencing.ReferenceIdentifier in project sis by apache.

the class Citations method identifierMatches.

/**
 * Returns {@code true} if the given citation has at least one identifier equals to the given string,
 * ignoring case and non-alphanumeric characters. If and <em>only</em> if the citation does not contain
 * any identifier, then this method fallback on titles comparison.
 * See {@link org.apache.sis.metadata.iso.citation.Citations#identifierMatches(Citation, String)}
 * for the public documentation of this method.
 *
 * @param  citation    the citation to check for, or {@code null}.
 * @param  identifier  the identifier to compare, or {@code null} if unknown.
 * @param  code        value of {@code identifier.getCode()}, or {@code null}.
 * @return {@code true} if both arguments are non-null, and an identifier matches the given string.
 */
public static boolean identifierMatches(final Citation citation, final Identifier identifier, final CharSequence code) {
    if (citation != null && code != null) {
        final Collection<? extends Identifier> citIds = citation.getIdentifiers();
        Iterator<? extends Identifier> it = iterator(citIds);
        if (it == null) {
            return titleMatches(citation, code);
        }
        while (it.hasNext()) {
            final Identifier citId = it.next();
            if (citId != null && equalsFiltered(code, citId.getCode())) {
                /*
                     * Found a possible match. We will take the code space in account only if it is defined
                     * by both identifiers. If a code space is undefined, we consider that we have a match.
                     */
                if (identifier instanceof ReferenceIdentifier) {
                    final String codeSpace = ((ReferenceIdentifier) identifier).getCodeSpace();
                    if (codeSpace != null && citId instanceof ReferenceIdentifier) {
                        final String cs = ((ReferenceIdentifier) citId).getCodeSpace();
                        if (cs != null && !equalsFiltered(codeSpace, cs)) {
                            // Check other identifiers.
                            continue;
                        }
                    }
                }
                return true;
            }
        }
        /*
             * Before to give up, maybe the given code argument is actually written using a "codeSpace:code" syntax.
             * Try to parse that syntax only if no Identifier argument were specified (otherwise we require the code
             * and code space to be splitted as defined in the identifier).
             */
        if (identifier == null) {
            int s = 0;
            final int length = code.length();
            while ((s = CharSequences.indexOf(code, DEFAULT_SEPARATOR, s, length)) >= 0) {
                final CharSequence codeSpace = code.subSequence(0, s);
                final CharSequence localPart = code.subSequence(++s, length);
                for (it = citIds.iterator(); it.hasNext(); ) {
                    final Identifier id = it.next();
                    if (id instanceof ReferenceIdentifier && equalsFiltered(codeSpace, ((ReferenceIdentifier) id).getCodeSpace()) && equalsFiltered(localPart, id.getCode())) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : Identifier(org.opengis.metadata.Identifier) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) InternationalString(org.opengis.util.InternationalString)

Example 5 with ReferenceIdentifier

use of org.opengis.referencing.ReferenceIdentifier in project sis by apache.

the class MapProjection method copyAliases.

/**
 * Copies all aliases except the ones for the given authority. If the given replacement is non-null,
 * then it will be used instead of the first occurrence of the omitted name.
 *
 * <p>This method does not copy the primary name. It is caller's responsibility to add it first.</p>
 *
 * @param  template     the parameter from which to copy the aliases.
 * @param  exclude      the authority of the alias to omit. Can not be EPSG.
 * @param  replacement  the alias to use instead of the omitted one, or {@code null} if none.
 * @param  newCode      the identifier to use instead of the omitted one, or {@code null} if none.
 * @param  builder      where to add the aliases.
 * @return the given {@code builder}, for method call chaining.
 */
private static ParameterBuilder copyAliases(final ParameterDescriptor<Double> template, final Citation exclude, GenericName replacement, ReferenceIdentifier newCode, final ParameterBuilder builder) {
    for (GenericName alias : template.getAlias()) {
        if (((Identifier) alias).getAuthority() == exclude) {
            if (replacement == null)
                continue;
            alias = replacement;
            replacement = null;
        }
        builder.addName(alias);
    }
    for (ReferenceIdentifier id : template.getIdentifiers()) {
        if (id.getAuthority() == exclude) {
            if (newCode == null)
                continue;
            id = newCode;
            newCode = null;
        }
        builder.addIdentifier(id);
    }
    return builder;
}
Also used : GenericName(org.opengis.util.GenericName) ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier)

Aggregations

ReferenceIdentifier (org.opengis.referencing.ReferenceIdentifier)35 Test (org.junit.Test)12 DependsOnMethod (org.apache.sis.test.DependsOnMethod)8 Identifier (org.opengis.metadata.Identifier)8 GenericName (org.opengis.util.GenericName)8 ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)6 InternationalString (org.opengis.util.InternationalString)5 Citation (org.opengis.metadata.citation.Citation)3 IdentifiedObject (org.opengis.referencing.IdentifiedObject)3 SimpleCitation (org.apache.sis.internal.simple.SimpleCitation)2 FactoryException (org.opengis.referencing.FactoryException)2 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)2 ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)1 CodeDefinition (eu.esdihumboldt.hale.common.instance.geometry.impl.CodeDefinition)1 WKTDefinition (eu.esdihumboldt.hale.common.instance.geometry.impl.WKTDefinition)1 CRSDefinition (eu.esdihumboldt.hale.common.schema.geometry.CRSDefinition)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Code (org.apache.sis.internal.jaxb.referencing.Code)1