Search in sources :

Example 1 with NamedIdentifier

use of org.apache.sis.referencing.NamedIdentifier in project sis by apache.

the class DefinitionVerifierTest method testDifferentAxisOrder.

/**
 * Tests with a CRS having wrong axis order.
 *
 * @throws FactoryException if an error occurred while querying the authority factory.
 */
@Test
@DependsOnMethod("testNormalizedCRS")
public void testDifferentAxisOrder() throws FactoryException {
    final Map<String, Object> properties = new HashMap<>(4);
    properties.put(DefaultGeographicCRS.NAME_KEY, "WGS 84");
    properties.put(DefaultGeographicCRS.IDENTIFIERS_KEY, new NamedIdentifier(HardCodedCitations.EPSG, "4326"));
    DefaultGeographicCRS crs = HardCodedCRS.WGS84;
    crs = new DefaultGeographicCRS(properties, crs.getDatum(), crs.getCoordinateSystem());
    final DefinitionVerifier ver = DefinitionVerifier.withAuthority(crs, null, false);
    assertNotNull("Should replace by normalized CRS", ver);
    assertNotSame("Should replace by normalized CRS", crs, ver.authoritative);
    assertSame("Should replace by normalized CRS", CommonCRS.WGS84.normalizedGeographic(), ver.authoritative);
    final LogRecord warning = ver.warning(true);
    assertNotNull("Should emit a warning.", warning);
    final String message = new SimpleFormatter().formatMessage(warning);
    assertTrue(message, message.contains("WGS 84"));
    assertTrue(message, message.contains("EPSG:4326"));
}
Also used : HashMap(java.util.HashMap) LogRecord(java.util.logging.LogRecord) NamedIdentifier(org.apache.sis.referencing.NamedIdentifier) SimpleFormatter(java.util.logging.SimpleFormatter) DefaultGeographicCRS(org.apache.sis.referencing.crs.DefaultGeographicCRS) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 2 with NamedIdentifier

use of org.apache.sis.referencing.NamedIdentifier in project sis by apache.

the class HardCodedCRS method properties.

/**
 * Creates a map of properties for the given name and code with world extent.
 */
private static Map<String, ?> properties(final String name, final String code) {
    final Map<String, Object> properties = new HashMap<>(4);
    properties.put(NAME_KEY, name);
    properties.put(DOMAIN_OF_VALIDITY_KEY, Extents.WORLD);
    if (code != null) {
        properties.put(IDENTIFIERS_KEY, new NamedIdentifier(HardCodedCitations.EPSG, code));
    }
    return properties;
}
Also used : HashMap(java.util.HashMap) NamedIdentifier(org.apache.sis.referencing.NamedIdentifier) IdentifiedObject(org.opengis.referencing.IdentifiedObject)

Example 3 with NamedIdentifier

use of org.apache.sis.referencing.NamedIdentifier in project sis by apache.

the class TensorParameters method createElementDescriptor.

/**
 * Creates a new parameter descriptor for a matrix or tensor element at the given indices.
 * This method is invoked by {@link #getElementDescriptor(int[])} when a new descriptor needs
 * to be created.
 *
 * <div class="section">Default implementation</div>
 * The default implementation converts the given indices to a parameter name by invoking the
 * {@link #indicesToName(int[])} method, then creates a descriptor for an optional parameter
 * of that name. The default value is given by {@link #getDefaultValue(int[])}.
 *
 * <div class="section">Subclassing</div>
 * Subclasses can override this method if they want more control on descriptor properties
 * like identification information, aliases or value domain.
 *
 * @param  indices  the indices of the tensor element for which to create a parameter.
 * @return the parameter descriptor for the given tensor element.
 * @throws IllegalArgumentException if the given array does not have the expected length or have illegal value.
 *
 * @see #indicesToName(int[])
 * @see #getDefaultValue(int[])
 */
protected ParameterDescriptor<E> createElementDescriptor(final int[] indices) throws IllegalArgumentException {
    final Citation authority = dimensions[0].getName().getAuthority();
    final String name = indicesToName(indices);
    return new DefaultParameterDescriptor<>(Collections.singletonMap(ParameterDescriptor.NAME_KEY, new NamedIdentifier(authority, name)), 0, 1, elementType, null, null, getDefaultValue(indices));
}
Also used : NamedIdentifier(org.apache.sis.referencing.NamedIdentifier) Citation(org.opengis.metadata.citation.Citation)

Example 4 with NamedIdentifier

use of org.apache.sis.referencing.NamedIdentifier in project sis by apache.

the class MatrixParameters method createElementDescriptor.

/**
 * Creates a new parameter descriptor for a matrix element at the given indices.
 * This method creates:
 *
 * <ul>
 *   <li>The OGC name (e.g. {@code "elt_1_2"}) as primary name.</li>
 *   <li>The alpha-numeric name (e.g. {@code "B2"}) as an alias.</li>
 * </ul>
 *
 * This method does <strong>not</strong> assign the alpha-numeric names to the EPSG authority in order to avoid
 * confusion when formatting the parameters as Well Known Text (WKT). However {@link MatrixParametersAlphaNum}
 * subclass will assign some names to the EPSG authority, as well as their identifier (e.g. EPSG:8641).
 */
@Override
protected ParameterDescriptor<Double> createElementDescriptor(final int[] indices) throws IllegalArgumentException {
    final Map<String, Object> properties = new HashMap<>(4);
    properties.put(ParameterDescriptor.NAME_KEY, new NamedIdentifier(Citations.OGC, Constants.OGC, indicesToName(indices), null, null));
    final String c = indicesToAlias(indices);
    if (c != null) {
        properties.put(ParameterDescriptor.ALIAS_KEY, new NamedIdentifier(Citations.SIS, Constants.SIS, c, null, null));
    }
    return new DefaultParameterDescriptor<>(properties, 0, 1, Double.class, null, null, getDefaultValue(indices));
}
Also used : HashMap(java.util.HashMap) NamedIdentifier(org.apache.sis.referencing.NamedIdentifier)

Example 5 with NamedIdentifier

use of org.apache.sis.referencing.NamedIdentifier in project sis by apache.

the class HardCodedDatum method properties.

/**
 * Creates a map of properties for the given name and EPSG code.
 */
private static Map<String, ?> properties(final String name, final String code, final CharSequence scope) {
    final Map<String, Object> properties = new HashMap<>(4);
    properties.put(NAME_KEY, name);
    if (code != null) {
        properties.put(IDENTIFIERS_KEY, new NamedIdentifier(HardCodedCitations.EPSG, code));
    }
    if (scope != null) {
        properties.put(SCOPE_KEY, scope);
    }
    return properties;
}
Also used : HashMap(java.util.HashMap) NamedIdentifier(org.apache.sis.referencing.NamedIdentifier)

Aggregations

NamedIdentifier (org.apache.sis.referencing.NamedIdentifier)13 HashMap (java.util.HashMap)6 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)5 Citation (org.opengis.metadata.citation.Citation)3 IdentifiedObject (org.opengis.referencing.IdentifiedObject)3 DefaultDomainConsistency (org.apache.sis.metadata.iso.quality.DefaultDomainConsistency)2 Test (org.junit.Test)2 Identifier (org.opengis.metadata.Identifier)2 GenericName (org.opengis.util.GenericName)2 InternationalString (org.opengis.util.InternationalString)2 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 LogRecord (java.util.logging.LogRecord)1 SimpleFormatter (java.util.logging.SimpleFormatter)1 DefaultAssociationRole (org.apache.sis.feature.DefaultAssociationRole)1 Anchor (org.apache.sis.internal.jaxb.gcx.Anchor)1 ReferenceSystemMetadata (org.apache.sis.internal.jaxb.metadata.replace.ReferenceSystemMetadata)1 DeprecatedCode (org.apache.sis.internal.referencing.DeprecatedCode)1 NilReferencingObject (org.apache.sis.internal.referencing.NilReferencingObject)1