use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class CodeTest method testWithVersion.
/**
* Tests the {@link Code#Code(ReferenceIdentifier)} constructor with {@code "EPSG:8.3:4326"} identifier.
* This test intentionally uses an identifier with the {@code IOGP} authority instead than EPSG
* for the same reason than {@link #testSimple()}.
*/
@Test
@DependsOnMethod("testSimple")
public void testWithVersion() {
final SimpleCitation IOGP = new SimpleCitation("IOGP");
// See above javadoc.
final ReferenceIdentifier id = new ImmutableIdentifier(IOGP, "EPSG", "4326", "8.2", null);
final Code value = new Code(id);
assertEquals("codeSpace", "EPSG:8.2", value.codeSpace);
assertEquals("code", "4326", value.code);
/*
* Reverse operation. Note that the authority is lost since there is no room for that in a
* <gml:identifier> element. Current implementation sets the authority to the code space.
*/
final ReferenceIdentifier actual = value.getIdentifier();
assertSame("authority", Citations.EPSG, actual.getAuthority());
assertEquals("codeSpace", "EPSG", actual.getCodeSpace());
assertEquals("version", "8.2", actual.getVersion());
assertEquals("code", "4326", actual.getCode());
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class EllipsoidalHeightCombinerTest method testProjectedCRS.
/**
* Tests {@link EllipsoidalHeightCombiner#createCompoundCRS EllipsoidalHeightCombiner.createCompoundCRS(…)}
* with a projected CRS.
*
* @throws FactoryException if a CRS can not be created.
*/
@Test
@DependsOnMethod("testGeographicCRS")
public void testProjectedCRS() throws FactoryException {
final EllipsoidalHeightCombiner services = create();
final GeodeticObjectFactory factory = new GeodeticObjectFactory();
final Map<String, String> properties = Collections.singletonMap(CoordinateReferenceSystem.NAME_KEY, "World Mercator (4D)");
final ProjectedCRS horizontal = factory.createProjectedCRS(properties, HardCodedCRS.WGS84, HardCodedConversions.MERCATOR, HardCodedCS.PROJECTED);
final ProjectedCRS volumetric = factory.createProjectedCRS(properties, HardCodedCRS.WGS84_3D, HardCodedConversions.MERCATOR, HardCodedCS.PROJECTED_3D);
final VerticalCRS vertical = HardCodedCRS.ELLIPSOIDAL_HEIGHT;
final TemporalCRS temporal = HardCodedCRS.TIME;
final VerticalCRS geoidal = HardCodedCRS.GRAVITY_RELATED_HEIGHT;
/*
* createCompoundCRS(…) should not combine ProjectedCRS with non-ellipsoidal height.
*/
CoordinateReferenceSystem compound = services.createCompoundCRS(properties, horizontal, geoidal, temporal);
assertArrayEqualsIgnoreMetadata(new SingleCRS[] { horizontal, geoidal, temporal }, CRS.getSingleComponents(compound).toArray());
/*
* createCompoundCRS(…) should combine ProjectedCRS with ellipsoidal height.
*/
compound = services.createCompoundCRS(properties, horizontal, vertical);
assertArrayEqualsIgnoreMetadata(new SingleCRS[] { volumetric }, CRS.getSingleComponents(compound).toArray());
/*
* createCompoundCRS(…) should combine ProjectedCRS with ellipsoidal height and keep time.
*/
compound = services.createCompoundCRS(properties, horizontal, vertical, temporal);
assertArrayEqualsIgnoreMetadata(new SingleCRS[] { volumetric, temporal }, CRS.getSingleComponents(compound).toArray());
/*
* Non-standard feature: accept (VerticalCRS + ProjectedCRS) order.
*/
compound = services.createCompoundCRS(properties, temporal, vertical, horizontal);
final Object[] components = CRS.getSingleComponents(compound).toArray();
assertEquals(2, components.length);
assertEqualsIgnoreMetadata(temporal, components[0]);
assertInstanceOf("Shall be a three-dimensional projected CRS.", ProjectedCRS.class, components[1]);
assertAxisDirectionsEqual("Shall be a three-dimensional projected CRS.", ((CoordinateReferenceSystem) components[1]).getCoordinateSystem(), AxisDirection.UP, AxisDirection.EAST, AxisDirection.NORTH);
}
use of org.apache.sis.test.DependsOnMethod 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.test.DependsOnMethod in project sis by apache.
the class DefinitionVerifierTest method testNormalizedCRS.
/**
* Tests with a CRS which is conform to the authoritative definition.
*
* @throws FactoryException if an error occurred while querying the authority factory.
*/
@Test
@DependsOnMethod("testConformCRS")
public void testNormalizedCRS() throws FactoryException {
final DefaultGeographicCRS crs = HardCodedCRS.WGS84;
assertNull("No replacement without EPSG code.", DefinitionVerifier.withAuthority(crs, null, false));
final DefinitionVerifier ver = DefinitionVerifier.withAuthority(crs, null, true);
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);
assertNull("Should be silent.", ver.warning(true));
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class TransverseMercatorTest method testSetParameters.
/**
* Tests {@link TransverseMercator.Zoner#setParameters(ParameterValueGroup, double, double)}
* followed by {@link TransverseMercator.Zoner#zone(ParameterValueGroup)}.
*/
@Test
@DependsOnMethod({ "testZone", "testCentralMeridian" })
public void testSetParameters() {
final ParameterValueGroup p = TransverseMercator.PARAMETERS.createValue();
assertEquals("UTM zone 10N", TransverseMercator.Zoner.UTM.setParameters(p, 0, -122));
assertEquals(Constants.CENTRAL_MERIDIAN, -123, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
assertEquals(Constants.FALSE_NORTHING, 0, p.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
assertEquals("UTM.zone(parameters)", 10, TransverseMercator.Zoner.UTM.zone(p));
assertEquals("Transverse Mercator", TransverseMercator.Zoner.ANY.setParameters(p, 0, -122));
assertEquals(Constants.CENTRAL_MERIDIAN, -122, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
assertEquals(Constants.FALSE_NORTHING, 0, p.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
assertEquals("UTM.zone(parameters)", 0, TransverseMercator.Zoner.UTM.zone(p));
assertEquals("UTM zone 10S", TransverseMercator.Zoner.ANY.setParameters(p, -0.0, -123));
assertEquals(Constants.CENTRAL_MERIDIAN, -123, p.parameter(Constants.CENTRAL_MERIDIAN).doubleValue(), STRICT);
assertEquals(Constants.FALSE_NORTHING, 10000000, p.parameter(Constants.FALSE_NORTHING).doubleValue(), STRICT);
assertEquals("UTM.zone(parameters)", -10, TransverseMercator.Zoner.UTM.zone(p));
}
Aggregations