use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class EPSGFactoryTest method testFindGeographic.
/**
* Tests {@link EPSGFactory#newIdentifiedObjectFinder()} method with a geographic CRS.
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@Test
@DependsOnMethod("testWGS84")
public void testFindGeographic() throws FactoryException {
final EPSGFactory factory = TestFactorySource.factory;
assumeNotNull(factory);
final IdentifiedObjectFinder finder = factory.newIdentifiedObjectFinder();
final DefaultGeographicCRS crs = (DefaultGeographicCRS) CRS.fromWKT("GEOGCS[“WGS 84”,\n" + // Use the alias instead than primary name for forcing a deeper search.
" DATUM[“WGS 84”,\n" + // Different name for forcing a deeper search.
" SPHEROID[“WGS 1984”, 6378137.0, 298.257223563]],\n" + " PRIMEM[“Greenwich”, 0.0],\n" + " UNIT[“degree”, 0.017453292519943295],\n" + " AXIS[“Geodetic latitude”, NORTH],\n" + " AXIS[“Geodetic longitude”, EAST]]");
/*
* First, search for a CRS with axis order that does not match the ones in the EPSG database.
* IdentifiedObjectFinder should not accept EPSG:4326 as a match for the given CRS.
*/
assertEquals("Full scan should be enabled by default.", IdentifiedObjectFinder.Domain.VALID_DATASET, finder.getSearchDomain());
assertTrue("Should not find WGS84 because the axis order is not the same.", finder.find(crs.forConvention(AxesConvention.NORMALIZED)).isEmpty());
/*
* Ensure that the cache is empty.
*/
finder.setSearchDomain(IdentifiedObjectFinder.Domain.DECLARATION);
assertTrue("Should not find without a full scan, because the WKT contains no identifier " + "and the CRS name is ambiguous (more than one EPSG object have this name).", finder.find(crs).isEmpty());
/*
* Scan the database for searching the CRS.
*/
finder.setSearchDomain(IdentifiedObjectFinder.Domain.ALL_DATASET);
final IdentifiedObject found = finder.findSingleton(crs);
assertNotNull("With full scan allowed, the CRS should be found.", found);
assertEpsgNameAndIdentifierEqual("WGS 84", 4326, found);
/*
* Should find the CRS without the need of a full scan, because of the cache.
*/
finder.setSearchDomain(IdentifiedObjectFinder.Domain.DECLARATION);
assertSame("The CRS should still in the cache.", found, finder.findSingleton(crs));
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class EPSGFactoryTest method testGeographic3D.
/**
* Tests the "Lao 1997" geographic CRS (EPSG:4993) with an ellipsoidal height.
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@Test
@DependsOnMethod("testGeographic2D")
public void testGeographic3D() throws FactoryException {
final EPSGFactory factory = TestFactorySource.factory;
assumeNotNull(factory);
final GeographicCRS crs = factory.createGeographicCRS("EPSG::4993");
assertEpsgNameAndIdentifierEqual("Lao 1997", 4993, crs);
assertEpsgNameAndIdentifierEqual("Lao National Datum 1997", 6678, crs.getDatum());
assertAxisDirectionsEqual("EPSG::6423", crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST, AxisDirection.UP);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("4993"));
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class EPSGFactoryTest method testCreateFromCoordinateReferenceSystemCodes.
/**
* Tests {@link EPSGDataAccess#createFromCoordinateReferenceSystemCodes(String, String)}.
* This method verifies the presence of 3 {@link Transformation} instances between the same source and target CRS.
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@Test
@DependsOnMethod("testTransformation")
public void testCreateFromCoordinateReferenceSystemCodes() throws FactoryException {
final EPSGFactory factory = TestFactorySource.factory;
assumeNotNull(factory);
/*
* ED50 (4230) to WGS 84 (4326) using
* Geocentric translations (9603).
* Accuracy = 2.5
*/
final CoordinateOperation operation1 = factory.createCoordinateOperation("1087");
final CoordinateReferenceSystem sourceCRS = operation1.getSourceCRS();
final CoordinateReferenceSystem targetCRS = operation1.getTargetCRS();
final MathTransform transform = operation1.getMathTransform();
assertInstanceOf("EPSG::1087", Transformation.class, operation1);
assertEpsgNameAndIdentifierEqual("ED50 to WGS 84 (37)", 1087, operation1);
assertEpsgNameAndIdentifierEqual("ED50", 4230, sourceCRS);
assertEpsgNameAndIdentifierEqual("WGS 84", 4326, targetCRS);
assertFalse("transform.isIdentity()", operation1.getMathTransform().isIdentity());
assertEquals(2.5, AbstractCoordinateOperation.castOrCopy(operation1).getLinearAccuracy(), STRICT);
/*
* ED50 (4230) to WGS 84 (4326) using
* Position Vector 7-param. transformation (9606).
* Accuracy = 1.5
*/
final CoordinateOperation operation2 = factory.createCoordinateOperation("1631");
assertEpsgNameAndIdentifierEqual("ED50 to WGS 84 (27)", 1631, operation2);
assertInstanceOf("EPSG::1631", Transformation.class, operation2);
assertSame("sourceCRS", sourceCRS, operation2.getSourceCRS());
assertSame("targetCRS", targetCRS, operation2.getTargetCRS());
assertFalse("transform.isIdentity()", operation2.getMathTransform().isIdentity());
assertFalse("Should be a more accurate transformation.", transform.equals(operation2.getMathTransform()));
assertEquals(1.5, AbstractCoordinateOperation.castOrCopy(operation2).getLinearAccuracy(), STRICT);
/*
* ED50 (4230) to WGS 84 (4326) using
* Coordinate Frame rotation (9607).
* Accuracy = 1.0
*/
final CoordinateOperation operation3 = factory.createCoordinateOperation("1989");
assertInstanceOf("EPSG::1989", Transformation.class, operation3);
assertEpsgNameAndIdentifierEqual("ED50 to WGS 84 (34)", 1989, operation3);
assertSame("sourceCRS", sourceCRS, operation3.getSourceCRS());
assertSame("targetCRS", targetCRS, operation3.getTargetCRS());
assertFalse("transform.isIdentity()", operation3.getMathTransform().isIdentity());
assertFalse("Should be a more accurate transformation.", transform.equals(operation3.getMathTransform()));
assertEquals(1.0, AbstractCoordinateOperation.castOrCopy(operation3).getLinearAccuracy(), STRICT);
/*
* Creates from CRS codes. There is 40 such operations in EPSG version 6.7.
* The preferred one (according the "supersession" table) is EPSG:1612.
*/
final Set<CoordinateOperation> all = factory.createFromCoordinateReferenceSystemCodes("4230", "4326");
assertTrue("Number of coordinate operations.", all.size() >= 3);
assertTrue("contains(“EPSG::1087”)", all.contains(operation1));
assertTrue("contains(“EPSG::1631”)", all.contains(operation2));
assertTrue("contains(“EPSG::1989”)", all.contains(operation3));
int count = 0;
for (final CoordinateOperation tr : all) {
assertSame("sourceCRS", sourceCRS, tr.getSourceCRS());
assertSame("targetCRS", targetCRS, tr.getTargetCRS());
if (count == 0) {
// Preferred transformation (see above comment).
assertEpsgNameAndIdentifierEqual("ED50 to WGS 84 (23)", 1612, tr);
}
count++;
}
// Size may have been modified after above loop.
assertEquals(count, all.size());
// Too installation-dependent for testing them.
loggings.clear();
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class EPSGFactoryTest method testDeprecatedGeographic.
/**
* Tests a legacy geographic CRS (no longer supported by EPSG).
* This test verifies that the expected warnings are logged.
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@Test
@DependsOnMethod({ "testGeographic2D", "testDeprecatedCoordinateSystems" })
public void testDeprecatedGeographic() throws FactoryException {
final EPSGFactory factory = TestFactorySource.factory;
assumeNotNull(factory);
final GeographicCRS crs = factory.createGeographicCRS("63266405");
assertEpsgNameAndIdentifierEqual("WGS 84 (deg)", 63266405, crs);
assertAxisDirectionsEqual(null, crs.getCoordinateSystem(), AxisDirection.NORTH, AxisDirection.EAST);
assertSame("CRS shall be cached", crs, factory.createCoordinateReferenceSystem("63266405"));
// Coordinate System 6405 is no longer supported by EPSG
loggings.skipNextLogIfContains("EPSG:6405");
// EPSG no longer support codes in the 60000000 series.
loggings.assertNextLogContains("EPSG:63266405", "4326");
loggings.assertNoUnexpectedLog();
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class EPSGFactoryTest method testTransformation.
/**
* Tests "BD72 to WGS 84 (1)" (EPSG:1609) transformation. This one has an unusual unit for the
* "Scale difference" parameter (EPSG:8611). The value is 0.999999 and the unit is "unity" (EPSG:9201)
* instead of the usual "parts per million" (EPSG:9202).
*
* @throws FactoryException if an error occurred while querying the factory.
*/
@Test
@DependsOnMethod("testSimpleTransformation")
public void testTransformation() throws FactoryException {
final EPSGFactory factory = TestFactorySource.factory;
assumeNotNull(factory);
final CoordinateOperation operation = factory.createCoordinateOperation("1609");
assertEpsgNameAndIdentifierEqual("BD72 to WGS 84 (1)", 1609, operation);
assertEquals(1.0, ((AbstractCoordinateOperation) operation).getLinearAccuracy(), STRICT);
assertSame("Operation shall be cached", operation, factory.createCoordinateOperation("1609"));
}
Aggregations