&& !destinationToSourceTransform.isIdentity()) { throw new IllegalArgumentException( "The coverage coordinateReferenceSystem should be the same for all coverages");
/** Tests whether this transform does not move any points. */ @Override public boolean isIdentity() { return subTransform.isIdentity(); }
/** * Tests whether this transform does not move any points. Default implementation check if the * two transforms are identity. */ @Override public final boolean isIdentity() { return transform1.isIdentity() && transform2.isIdentity(); }
/** Tests whether this transform does not move any points. */ public boolean isIdentity() { return transform.isIdentity(); }
public boolean isIdentity() { return delegate.isIdentity(); }
/** * Returns {@code true} if the specified operation is an identity conversion. This method always * returns {@code false} for transformations even if their associated math transform is an * identity one, because such transformations are usually datum shift and must be visible. */ private static boolean isIdentity(final CoordinateOperation operation) { return (operation instanceof Conversion) && operation.getMathTransform().isIdentity(); }
/** * Returns the number of {@linkplain MathTransform math transform} steps performed by the given * transform. As a special case, we returns 0 for the identity transform since it should be * omitted from the final chain. */ private static int getStepCount(final MathTransform transform) { if (transform.isIdentity()) { return 0; } if (!(transform instanceof ConcatenatedTransform)) { return 1; } return ((ConcatenatedTransform) transform).getStepCount(); }
protected boolean isTransformRequired() { return !getContentToLayerTransform().isIdentity(); }
/** Makes sure that the transform between two EPSG:4326 is the identity transform. */ public void testFindMathTransformIdentity() throws FactoryException { CoordinateReferenceSystem crs1default = CRS.decode("EPSG:4326"); CoordinateReferenceSystem crs2default = CRS.decode("EPSG:4326"); MathTransform tDefault = CRS.findMathTransform(crs1default, crs2default); assertTrue("WSG84 transformed to WSG84 should be Identity", tDefault.isIdentity()); CoordinateReferenceSystem crs1force = CRS.decode("EPSG:4326", true); CoordinateReferenceSystem crs2force = CRS.decode("EPSG:4326", true); MathTransform tForce = CRS.findMathTransform(crs1force, crs2force); assertTrue("WSG84 transformed to WSG84 should be Identity", tForce.isIdentity()); }
@Test public void testTransform() throws NoSuchAuthorityCodeException, FactoryException { CoordinateReferenceSystem epsg0 = CRS.decode("EPSG:" + CODE); CoordinateReferenceSystem epsg42101 = CRS.decode("EPSG:42101"); assertTrue(CRS.findMathTransform(DefaultEngineeringCRS.GENERIC_2D, epsg42101).isIdentity()); assertTrue(CRS.findMathTransform(epsg42101, DefaultEngineeringCRS.GENERIC_2D).isIdentity()); assertTrue(CRS.findMathTransform(epsg0, epsg42101).isIdentity()); assertTrue(CRS.findMathTransform(epsg42101, epsg0).isIdentity()); }
/** Should fails unless GEOT-352 has been fixed. */ @Test(expected = OperationNotFoundException.class) public void testHtoZ() throws Exception { final CoordinateReferenceSystem sourceCRS = crsFactory.createFromWKT(NAD27_H); final CoordinateReferenceSystem targetCRS = crsFactory.createFromWKT(NAD27_Z); final CoordinateOperation op = opFactory.createOperation(sourceCRS, targetCRS); final MathTransform mt = op.getMathTransform(); assertNotSame(sourceCRS, op.getSourceCRS()); assertNotSame(targetCRS, op.getTargetCRS()); assertFalse(mt.isIdentity()); assertInterfaced(mt); }
/** Should fails unless GEOT-352 has been fixed. */ @Test(expected = OperationNotFoundException.class) public void testHtoH() throws Exception { final CoordinateReferenceSystem sourceCRS = crsFactory.createFromWKT(NAD27_H); final CoordinateReferenceSystem targetCRS = crsFactory.createFromWKT(WGS84_H); final CoordinateOperation op = opFactory.createOperation(sourceCRS, targetCRS); final MathTransform mt = op.getMathTransform(); assertNotSame(sourceCRS, op.getSourceCRS()); assertNotSame(targetCRS, op.getTargetCRS()); assertFalse(mt.isIdentity()); assertInterfaced(mt); }
/** Should fails unless GEOT-352 has been fixed. */ @Test(expected = OperationNotFoundException.class) public void test2DtoH() throws Exception { final CoordinateReferenceSystem sourceCRS = crsFactory.createFromWKT(WKT.NAD27); final CoordinateReferenceSystem targetCRS = crsFactory.createFromWKT(WGS84_H); final CoordinateOperation op = opFactory.createOperation(sourceCRS, targetCRS); final MathTransform mt = op.getMathTransform(); if (usingDefaultFactory) { assertSame(sourceCRS, op.getSourceCRS()); assertNotSame(targetCRS, op.getTargetCRS()); } assertFalse(mt.isIdentity()); assertInterfaced(mt); }
/** Tests transformation between vertical CRS. */ @Test public void testHeightIdentity() throws Exception { final CoordinateReferenceSystem sourceCRS = crsFactory.createFromWKT(WKT.HEIGHT); final CoordinateReferenceSystem targetCRS = crsFactory.createFromWKT(WKT.HEIGHT); final CoordinateOperation op = opFactory.createOperation(sourceCRS, targetCRS); final MathTransform mt = op.getMathTransform(); if (usingDefaultFactory) { assertSame(sourceCRS, op.getSourceCRS()); assertSame(targetCRS, op.getTargetCRS()); } assertTrue(op instanceof Conversion); assertTrue(mt.isIdentity()); assertInterfaced(mt); }
/** Tests transformation between vertical CRS. */ @Test public void testZIdentity() throws Exception { final CoordinateReferenceSystem sourceCRS = crsFactory.createFromWKT(WKT.Z); final CoordinateReferenceSystem targetCRS = crsFactory.createFromWKT(WKT.Z); final CoordinateOperation op = opFactory.createOperation(sourceCRS, targetCRS); final MathTransform mt = op.getMathTransform(); if (usingDefaultFactory) { assertSame(sourceCRS, op.getSourceCRS()); assertSame(targetCRS, op.getTargetCRS()); } assertTrue(op instanceof Conversion); assertTrue(mt.isIdentity()); assertInterfaced(mt); }
/** Tests transformation from 2D to 3D with Z above the ellipsoid. */ @Test public void test2D_to_3D() throws Exception { final CoordinateReferenceSystem sourceCRS = crsFactory.createFromWKT(WKT.NAD27); final CoordinateReferenceSystem targetCRS = crsFactory.createFromWKT(WGS84_Z); final CoordinateOperation op = opFactory.createOperation(sourceCRS, targetCRS); final MathTransform mt = op.getMathTransform(); if (usingDefaultFactory) { assertSame(sourceCRS, op.getSourceCRS()); assertNotSame(targetCRS, op.getTargetCRS()); } assertFalse(mt.isIdentity()); assertInterfaced(mt); // Note: Expected values below were computed with Geotools (not an external library). // However, it was tested with both Molodenski and Geocentric transformations. assertTransformEquals2_3( mt, 0, 0, 0.001654978796746043, 0.0012755944235822696, 66.4042236590758); assertTransformEquals2_3( mt, 5, 8, 5.001262960018587, 8.001271733843957, 100.27929787896574); }
/** Tests transformation from 3D to vertical CRS. */ @Test public void test3D_to_Z() throws Exception { final CoordinateReferenceSystem sourceCRS = crsFactory.createFromWKT(NAD27_Z); final CoordinateReferenceSystem targetCRS = crsFactory.createFromWKT(WKT.Z); final CoordinateOperation op = opFactory.createOperation(sourceCRS, targetCRS); final MathTransform mt = op.getMathTransform(); if (usingDefaultFactory) { assertSame(sourceCRS, op.getSourceCRS()); assertSame(targetCRS, op.getTargetCRS()); } assertFalse(mt.isIdentity()); assertInterfaced(mt); assertTransformEquals3_1(mt, 0, 0, 0, 0); assertTransformEquals3_1(mt, 5, 8, 20, 20); assertTransformEquals3_1(mt, -5, -8, 20, 20); }
/** Tests transformation from a 3D Geographic CRS to a single height. */ @Test public void test3D_to_H() throws Exception { final CoordinateReferenceSystem sourceCRS = crsFactory.createFromWKT(NAD27_H); final CoordinateReferenceSystem targetCRS = crsFactory.createFromWKT(WKT.HEIGHT); final CoordinateOperation op = opFactory.createOperation(sourceCRS, targetCRS); final MathTransform mt = op.getMathTransform(); if (usingDefaultFactory) { assertSame(sourceCRS, op.getSourceCRS()); assertSame(targetCRS, op.getTargetCRS()); } assertFalse(mt.isIdentity()); assertInterfaced(mt); assertTransformEquals3_1(mt, 0, 0, 0, 0); assertTransformEquals3_1(mt, 5, 8, 20, 20); assertTransformEquals3_1(mt, -5, -8, 20, 20); }
/** Tests transformation from 3D to 2D Geographic CRS. */ @Test public void test3D_to_2D() throws Exception { final CoordinateReferenceSystem sourceCRS = crsFactory.createFromWKT(NAD27_Z); final CoordinateReferenceSystem targetCRS = crsFactory.createFromWKT(WKT.WGS84_DMHS); final CoordinateOperation op = opFactory.createOperation(sourceCRS, targetCRS); final MathTransform mt = op.getMathTransform(); if (usingDefaultFactory) { assertNotSame(sourceCRS, op.getSourceCRS()); assertSame(targetCRS, op.getTargetCRS()); } assertFalse(mt.isIdentity()); assertInterfaced(mt); // Note: Expected values below were computed with Geotools (not an external library). // However, it was tested with both Molodenski and Geocentric transformations. assertTransformEquals3_2(mt, 0, 0, 0, 0.001654978796746043, 0.0012755944235822696); assertTransformEquals3_2(mt, 5, 8, 20, 5.0012629560319874, 8.001271729856333); assertTransformEquals3_2(mt, 5, 8, -20, 5.001262964005206, 8.001271737831601); }
/** Tests the transformations of an envelope. */ @Test public void testEnvelopeTransformation() throws FactoryException, TransformException { final CoordinateReferenceSystem mapCRS = CRS.parseWKT(WKT.UTM_10N); final CoordinateReferenceSystem WGS84 = DefaultGeographicCRS.WGS84; final MathTransform crsTransform = CRS.findMathTransform(WGS84, mapCRS, true); assertFalse(crsTransform.isIdentity()); final GeneralEnvelope firstEnvelope, transformedEnvelope, oldEnvelope; firstEnvelope = new GeneralEnvelope(new double[] {-124, 42}, new double[] {-122, 43}); firstEnvelope.setCoordinateReferenceSystem(WGS84); transformedEnvelope = CRS.transform(crsTransform, firstEnvelope); transformedEnvelope.setCoordinateReferenceSystem(mapCRS); oldEnvelope = CRS.transform(crsTransform.inverse(), transformedEnvelope); oldEnvelope.setCoordinateReferenceSystem(WGS84); assertTrue(oldEnvelope.contains(firstEnvelope, true)); assertTrue(oldEnvelope.equals(firstEnvelope, 0.02, true)); }