@Test
public void testEnvelopes() throws NoSuchAuthorityCodeException, FactoryException,
        TransformException {

    // Setting up an UTM and WGS84 CRSs
    // Setup a 3D envelope and return it as 2D, making sure there is no 3rd dimension anymore
    final GeneralEnvelope envelope3D = new GeneralEnvelope(DefaultGeographicCRS.WGS84_3D);
    envelope3D.setEnvelope(0, 0, 0, 10, 10, 10);
    final Envelope requestedEnvelope = Utilities.getRequestedEnvelope2D(envelope3D);
    assertEquals(0, requestedEnvelope.getMinimum(0), DELTA);
    assertEquals(0, requestedEnvelope.getMinimum(1), DELTA);
    assertEquals(10, requestedEnvelope.getMaximum(0), DELTA);
    assertEquals(10, requestedEnvelope.getMaximum(1), DELTA);
    // 3D envelope has 3rd dimension whilst 2D one hasn't
    assertEquals(10, envelope3D.getMaximum(2), DELTA);
    boolean is3D = true;
    try {
        requestedEnvelope.getMaximum(2);
    } catch (IndexOutOfBoundsException e) {
        is3D = false;
    }
    assertFalse(is3D);
}