* Tests the transformation of an envelope.
*/
public void testTransformEnvelopeMathTransform() throws FactoryException, TransformException {
Envelope envelope = new Envelope(0, 10, 0, 10);
AffineTransform at = AffineTransform.getScaleInstance(0.5, 1);
MathTransform2D t = (MathTransform2D) ReferencingFactoryFinder.getMathTransformFactory(null)
.createAffineTransform(new GeneralMatrix(at));
envelope = JTS.transform(envelope, t);
assertEquals(new Envelope(0, 5, 0, 10), envelope);
envelope = JTS.transform(envelope, t.inverse());
assertEquals(new Envelope(0, 10, 0, 10), envelope);
envelope = JTS.transform(envelope, null, t, 10);
assertEquals(new Envelope(0, 5, 0, 10), envelope);
envelope = JTS.transform(envelope, null, t.inverse(), 10);
assertEquals(new Envelope(0, 10, 0, 10), envelope);
CoordinateReferenceSystem crs = ReferencingFactoryFinder.getCRSFactory(null).createFromWKT(UTM_ZONE_10N);
t = (MathTransform2D) ReferencingFactoryFinder.getCoordinateOperationFactory(null).createOperation(
DefaultGeographicCRS.WGS84, crs).getMathTransform();
envelope = new Envelope(-123, -133, 55, 60);
envelope = JTS.transform(envelope, t);
envelope = JTS.transform(envelope, t.inverse());
/*
* Use a large tolerance factory for comparaisons because an accurate transformed envelope
* is bigger than the envelope that we get if we transformed only the 4 corners, and the
* inverse envelope way expand yet again the envelope for exactly the same reason.
*/