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