Search in sources :

Example 1 with CodeType

use of org.apache.sis.internal.storage.CodeType in project sis by apache.

the class ReferencingFunctions method getName.

/**
 * Returns the identified object name from an authority code.
 *
 * @param  codeOrPath  the code allocated by an authority, or the path to a file.
 * @return the object name.
 */
@Override
public String getName(final String codeOrPath) {
    final InternationalString name;
    try {
        final IdentifiedObject object;
        final CodeType type = CodeType.guess(codeOrPath);
        if (type.isCRS) {
            object = new CacheKey<>(IdentifiedObject.class, codeOrPath, null, null).peek();
        } else {
            object = getIdentifiedObject(codeOrPath, type);
        }
        if (object != null) {
            return object.getName().getCode();
        }
        // In Apache SIS implementation, 'getDescriptionText' returns the name.
        name = CRS.getAuthorityFactory(null).getDescriptionText(codeOrPath);
    } catch (Exception exception) {
        return getLocalizedMessage(exception);
    }
    return (name != null) ? name.toString(getJavaLocale()) : noResultString();
}
Also used : InternationalString(org.opengis.util.InternationalString) CodeType(org.apache.sis.internal.storage.CodeType) IdentifiedObject(org.opengis.referencing.IdentifiedObject) AbstractIdentifiedObject(org.apache.sis.referencing.AbstractIdentifiedObject) DataStoreException(org.apache.sis.storage.DataStoreException) IllegalArgumentException(com.sun.star.lang.IllegalArgumentException) FactoryException(org.opengis.util.FactoryException)

Aggregations

IllegalArgumentException (com.sun.star.lang.IllegalArgumentException)1 CodeType (org.apache.sis.internal.storage.CodeType)1 AbstractIdentifiedObject (org.apache.sis.referencing.AbstractIdentifiedObject)1 DataStoreException (org.apache.sis.storage.DataStoreException)1 IdentifiedObject (org.opengis.referencing.IdentifiedObject)1 FactoryException (org.opengis.util.FactoryException)1 InternationalString (org.opengis.util.InternationalString)1