assertEquals("converted to radians", Math.toRadians(90.0), transformer.getRotation(), 1e-9);
}
@Test
public void testGetRotatedBounds_BBoxMapBounds() {
MapBounds bounds = new BBoxMapBounds(DefaultGeographicCRS.WGS84, 5, 45, 25, 55);
// rotate 90 degree
MapfishMapContext transformer = new MapfishMapContext(bounds, null, 90, Constants.PDF_DPI, Constants.PDF_DPI, null, true);
MapBounds rotatedBounds = new BBoxMapBounds(DefaultGeographicCRS.WGS84, 10, 40, 20, 60);
assertEquals(rotatedBounds, transformer.getRotatedBounds());
// rotate 180 degree
transformer = new MapfishMapContext(bounds, null, 180, Constants.PDF_DPI, Constants.PDF_DPI, null, true);
rotatedBounds = new BBoxMapBounds(DefaultGeographicCRS.WGS84, 5, 45, 25, 55);
assertEquals(rotatedBounds, transformer.getRotatedBounds());
// rotate 45 degree
transformer = new MapfishMapContext(bounds, null, 45, Constants.PDF_DPI, Constants.PDF_DPI, null, true);
ReferencedEnvelope rotatedEnvelope =
transformer.getRotatedBounds().toReferencedEnvelope(new Rectangle(1, 1), 72);
assertEquals(4.393398, rotatedEnvelope.getMinX(), 1e-6);
assertEquals(25.606601, rotatedEnvelope.getMaxX(), 1e-6);
assertEquals(39.393398, rotatedEnvelope.getMinY(), 1e-6);
assertEquals(60.606601, rotatedEnvelope.getMaxY(), 1e-6);
// rotate 45 degree
bounds = new BBoxMapBounds(DefaultGeographicCRS.WGS84, -0.5, -0.5, 0.5, 0.5);
transformer = new MapfishMapContext(bounds, null, 45, Constants.PDF_DPI, Constants.PDF_DPI, null, true);
rotatedEnvelope =
transformer.getRotatedBounds().toReferencedEnvelope(new Rectangle(1, 1), 72);
assertEquals(-0.707106, rotatedEnvelope.getMinX(), 1e-6);
assertEquals(0.707106, rotatedEnvelope.getMaxX(), 1e-6);