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();
}
Aggregations