Search in sources :

Example 1 with GenericName

use of org.opengis.util.GenericName in project sis by apache.

the class GO_GenericName method getValue.

/**
 * Returns the {@code LocalName} or {@code ScopedName} to marshal. Returns {@code null} if the name
 * is a {@link TypeName} or a {@link MemberName}, in order to use {@link #getName()} instead.
 * Example:
 *
 * {@preformat xml
 *   <gml:alias>
 *     <gco:LocalName codeSpace=\"A code space\">A name in a scope</gco:LocalName>
 *   </gml:alias>
 * }
 *
 * @return the code for the current name, or {@code null} if none.
 */
@XmlElementRef
public final NameValue getValue() {
    final GenericName name = this.name;
    final NameValue code;
    if (name instanceof LocalName) {
        if (name instanceof TypeName || name instanceof MemberName) {
            return null;
        } else if (FilterByVersion.LEGACY_METADATA.accept()) {
            code = new NameValue.Local();
        } else {
            // ISO 19115-3:2016 does not seem to define gco:LocalName anymore.
            code = new NameValue.Scoped();
        }
    } else if (name instanceof ScopedName) {
        code = new NameValue.Scoped();
    } else {
        return null;
    }
    code.setName(name);
    return code;
}
Also used : GenericName(org.opengis.util.GenericName) DefaultTypeName(org.apache.sis.util.iso.DefaultTypeName) TypeName(org.opengis.util.TypeName) ScopedName(org.opengis.util.ScopedName) DefaultMemberName(org.apache.sis.util.iso.DefaultMemberName) MemberName(org.opengis.util.MemberName) LocalName(org.opengis.util.LocalName) DefaultLocalName(org.apache.sis.util.iso.DefaultLocalName) XmlElementRef(javax.xml.bind.annotation.XmlElementRef)

Example 2 with GenericName

use of org.opengis.util.GenericName in project sis by apache.

the class DefaultScopedNameTest method testSimpleInternationalString.

/**
 * Tests the creation of scoped names where different parts of the name are {@link SimpleInternationalString}
 * instances. The implementation should be able to detect that the names and their hash codes are equal.
 *
 * @see DefaultNameFactoryTest#testSimpleInternationalString()
 */
@Test
public void testSimpleInternationalString() {
    GenericName n1 = new DefaultScopedName(null, Arrays.asList("ns1", "Route"));
    GenericName n2 = new DefaultScopedName(null, Arrays.asList(new SimpleInternationalString("ns1"), "Route"));
    GenericName n3 = new DefaultScopedName(null, Arrays.asList("ns1", new SimpleInternationalString("Route")));
    assertNameEqual(n1, n2);
    assertNameEqual(n1, n3);
    assertNameEqual(n2, n3);
}
Also used : GenericName(org.opengis.util.GenericName) Test(org.junit.Test)

Example 3 with GenericName

use of org.opengis.util.GenericName in project sis by apache.

the class DefaultNameFactoryTest method testNavigation.

/**
 * Tests navigation in a name parsed from a string.
 */
@Test
public void testNavigation() {
    final GenericName name = factory.parseGenericName(null, "codespace:subspace:name");
    assertEquals("codespace:subspace:name", name.toString());
    assertEquals("codespace:subspace", name.tip().scope().name().toString());
    assertEquals("codespace", name.tip().scope().name().tip().scope().name().toString());
    assertSame(name, name.toFullyQualifiedName());
    assertSame(name, name.tip().toFullyQualifiedName());
}
Also used : GenericName(org.opengis.util.GenericName) NameTest(org.opengis.test.util.NameTest) Test(org.junit.Test)

Example 4 with GenericName

use of org.opengis.util.GenericName in project sis by apache.

the class DefaultNameFactoryTest method testSimpleInternationalString.

/**
 * Tests the creation of scoped names where different parts of the name are {@link SimpleInternationalString}
 * instances. The implementation should be able to detect that the names and their hash codes are equal.
 *
 * @see DefaultScopedNameTest#testSimpleInternationalString()
 */
@Test
public void testSimpleInternationalString() {
    GenericName n1 = factory.createGenericName(null, "ns1", "Route");
    GenericName n2 = factory.createGenericName(null, new SimpleInternationalString("ns1"), "Route");
    GenericName n3 = factory.createGenericName(null, "ns1", new SimpleInternationalString("Route"));
    assertSame(n1, n2);
    assertSame(n1, n3);
    assertSame(n2, n3);
}
Also used : GenericName(org.opengis.util.GenericName) NameTest(org.opengis.test.util.NameTest) Test(org.junit.Test)

Example 5 with GenericName

use of org.opengis.util.GenericName 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)

Aggregations

GenericName (org.opengis.util.GenericName)46 Test (org.junit.Test)11 ReferenceIdentifier (org.opengis.referencing.ReferenceIdentifier)9 InternationalString (org.opengis.util.InternationalString)9 ArrayList (java.util.ArrayList)5 IdentifiedObject (org.opengis.referencing.IdentifiedObject)5 NameFactory (org.opengis.util.NameFactory)5 Identifier (org.opengis.metadata.Identifier)4 ScopedName (org.opengis.util.ScopedName)4 HashMap (java.util.HashMap)3 DependsOnMethod (org.apache.sis.test.DependsOnMethod)3 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 Collection (java.util.Collection)2 IdentityHashMap (java.util.IdentityHashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 AbstractIdentifiedType (org.apache.sis.feature.AbstractIdentifiedType)2 NameToIdentifier (org.apache.sis.internal.metadata.NameToIdentifier)2 TableAppender (org.apache.sis.io.TableAppender)2