* The local variables to be used for all remaining tests
* (usefull to setup in the debugger).
*/
String code;
CoordinateReferenceSystem crs0, crs1;
CoordinateOperationFactory opFactory = ReferencingFactoryFinder.getCoordinateOperationFactory(null);
MathTransform mt;
Matrix matrix;
/*
* Tests a WGS84 geographic CRS (2D) with (NORTH, EAST) axis directions.
* The factory should reorder the axis with no more operation than an axis swap.
*/
code = "4326";
crs0 = factory0.createCoordinateReferenceSystem(code);
crs1 = factory1.createCoordinateReferenceSystem(code);
final CoordinateReferenceSystem cacheTest = crs1;
assertNotSame(crs0, crs1);
assertNotSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
assertEquals("Expected a left-handed CS.", -90, getAngle(crs0), EPS);
assertEquals("Expected a right-handed CS.", +90, getAngle(crs1), EPS);
assertFalse(crs0.getIdentifiers().isEmpty());
if (METADATA_ERASED) {
assertTrue(crs1.getIdentifiers().isEmpty());
} else {
assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
}
mt = opFactory.createOperation(crs0, crs1).getMathTransform();
assertFalse(mt.isIdentity());
assertTrue(mt instanceof LinearTransform);
matrix = ((LinearTransform) mt).getMatrix();
assertEquals(new GeneralMatrix(new double[][] {
{0, 1, 0},
{1, 0, 0},
{0, 0, 1}}), new GeneralMatrix(matrix));
/*
* Tests a WGS84 geographic CRS (3D) with (NORTH, EAST, UP) axis directions.
* Because this CRS uses sexagesimal units, conversions are not supported and
* will not be tested.
*/
code = "4329";
crs0 = factory0.createCoordinateReferenceSystem(code);
crs1 = factory1.createCoordinateReferenceSystem(code);
assertNotSame(crs0, crs1);
assertNotSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
assertFalse(crs0.getIdentifiers().isEmpty());
if (METADATA_ERASED) {
assertTrue(crs1.getIdentifiers().isEmpty());
} else {
assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
}
/*
* Tests a WGS84 geographic CRS (3D) with (NORTH, EAST, UP) axis directions.
* The factory should reorder the axis with no more operation than an axis swap.
*/
code = "63266413";
crs0 = factory0.createCoordinateReferenceSystem(code);
crs1 = factory1.createCoordinateReferenceSystem(code);
assertNotSame(crs0, crs1);
assertNotSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
assertFalse(crs0.getIdentifiers().isEmpty());
if (METADATA_ERASED) {
assertTrue(crs1.getIdentifiers().isEmpty());
} else {
assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
}
mt = opFactory.createOperation(crs0, crs1).getMathTransform();
assertFalse(mt.isIdentity());
assertTrue(mt instanceof LinearTransform);
matrix = ((LinearTransform) mt).getMatrix();
assertEquals(new GeneralMatrix(new double[][] {
{0, 1, 0, 0},
{1, 0, 0, 0},
{0, 0, 1, 0},
{0, 0, 0, 1}}), new GeneralMatrix(matrix));
/*
* Tests a projected CRS with (EAST, NORTH) axis orientation. No axis reordering is needed,
* which means that their coordinate systems are identical and the math transform should be
* the identity one. Note that while no axis swap is needed, the base GeographicCRS are not
* the same since an axis reordering has been done there.
*/
code = "2027";
crs0 = factory0.createCoordinateReferenceSystem(code);
crs1 = factory1.createCoordinateReferenceSystem(code);
assertNotSame(crs0, crs1);
assertSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
assertNotSame(((ProjectedCRS) crs0).getBaseCRS(), ((ProjectedCRS) crs1).getBaseCRS());
assertFalse(crs0.getIdentifiers().isEmpty());
if (METADATA_ERASED) {
assertTrue(crs1.getIdentifiers().isEmpty());
} else {
assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
}
mt = opFactory.createOperation(crs0, crs1).getMathTransform();
assertTrue(mt.isIdentity());
/*
* Tests a projected CRS with (WEST, SOUTH) axis orientation.
* The factory should arrange the axis with no more operation than a direction change.
* While the end result is a matrix like the GeographicCRS case, the path that lead to
* this result is much more complex.
*/
code = "22275";
crs0 = factory0.createCoordinateReferenceSystem(code);
crs1 = factory1.createCoordinateReferenceSystem(code);
assertNotSame(crs0, crs1);
assertNotSame(crs0.getCoordinateSystem(), crs1.getCoordinateSystem());
assertSame(((SingleCRS) crs0).getDatum(), ((SingleCRS) crs1).getDatum());
assertFalse(crs0.getIdentifiers().isEmpty());
if (METADATA_ERASED) {
assertTrue(crs1.getIdentifiers().isEmpty());
} else {
assertEquals(crs0.getIdentifiers(), crs1.getIdentifiers());
}
mt = opFactory.createOperation(crs0, crs1).getMathTransform();
assertFalse(mt.isIdentity());
assertTrue(mt instanceof LinearTransform);
matrix = ((LinearTransform) mt).getMatrix();
assertEquals(new GeneralMatrix(new double[][] {
{-1, 0, 0},