|
1 | 1 | package org.mapfish.print.attribute.map; |
2 | 2 |
|
3 | 3 | import static org.junit.Assert.assertEquals; |
| 4 | +import static org.junit.Assert.assertThrows; |
4 | 5 |
|
5 | 6 | import java.awt.Rectangle; |
6 | 7 | import org.geotools.api.referencing.FactoryException; |
@@ -111,4 +112,36 @@ public void testZoomOut() { |
111 | 112 | assertEquals(envelope.getMinY() * 2, newEnvelope.getMinY(), delta); |
112 | 113 | assertEquals(envelope.getMaxY() * 2, newEnvelope.getMaxY(), delta); |
113 | 114 | } |
| 115 | + |
| 116 | + @Test |
| 117 | + public void testRollLongitude() { |
| 118 | + final double denominator = 10000.0; |
| 119 | + final CenterScaleMapBounds bounds = |
| 120 | + new CenterScaleMapBounds(DefaultGeographicCRS.WGS84, 0.0, 0.0, denominator); |
| 121 | + |
| 122 | + assertEquals(0.0, bounds.rollLongitude(0.0), 1e-6); |
| 123 | + assertEquals(180.0, bounds.rollLongitude(-180.0), 1e-6); |
| 124 | + assertEquals(180.0, bounds.rollLongitude(180.0), 1e-6); |
| 125 | + assertEquals(-179.0, bounds.rollLongitude(181.0), 1e-6); |
| 126 | + assertEquals(179.0, bounds.rollLongitude(-181.0), 1e-6); |
| 127 | + assertEquals(1.0, bounds.rollLongitude(361.0), 1e-6); |
| 128 | + assertEquals(-1.0, bounds.rollLongitude(-361.0), 1e-6); |
| 129 | + } |
| 130 | + |
| 131 | + @Test |
| 132 | + public void testRollLatitude() { |
| 133 | + final double denominator = 10000.0; |
| 134 | + final CenterScaleMapBounds bounds = |
| 135 | + new CenterScaleMapBounds(DefaultGeographicCRS.WGS84, 0.0, 0.0, denominator); |
| 136 | + |
| 137 | + assertEquals(0.0, bounds.rollLatitude(0.0), 1e-6); |
| 138 | + assertEquals(90.0, bounds.rollLatitude(90.0), 1e-6); |
| 139 | + assertEquals(-90.0, bounds.rollLatitude(-90.0), 1e-6); |
| 140 | + assertThrows(IllegalArgumentException.class, () -> bounds.rollLatitude(91.0)); |
| 141 | + assertThrows(IllegalArgumentException.class, () -> bounds.rollLatitude(-91.0)); |
| 142 | + assertThrows(IllegalArgumentException.class, () -> bounds.rollLatitude(180.0)); |
| 143 | + assertThrows(IllegalArgumentException.class, () -> bounds.rollLatitude(-180.0)); |
| 144 | + assertThrows(IllegalArgumentException.class, () -> bounds.rollLatitude(181.0)); |
| 145 | + assertThrows(IllegalArgumentException.class, () -> bounds.rollLatitude(-181.0)); |
| 146 | + } |
114 | 147 | } |
0 commit comments