double dpi = 100;
Rectangle screen = new Rectangle(100, 100);
ZoomLevels zoomLevels = new ZoomLevels(15000, 20000, 25000, 30000, 350000);
final CenterScaleMapBounds mapBounds = new CenterScaleMapBounds(CH1903, 50000, 50000, new Scale(scale));
final ReferencedEnvelope originalBBox = mapBounds.toReferencedEnvelope(screen, dpi);
BBoxMapBounds linear = new BBoxMapBounds(CH1903, originalBBox.getMinX(), originalBBox.getMinY(),
originalBBox.getMaxX(), originalBBox.getMaxY());
final MapBounds newMapBounds = linear.adjustBoundsToNearestScale(zoomLevels, 0.05,
ZoomLevelSnapStrategy.CLOSEST_LOWER_SCALE_ON_TIE, screen, dpi);
ReferencedEnvelope newBBox = newMapBounds.toReferencedEnvelope(screen, dpi);
final double delta = 0.00001;
assertEquals(originalBBox.getMedian(0), newBBox.getMedian(0), delta);
assertEquals(originalBBox.getMedian(1), newBBox.getMedian(1), delta);
double expectedScale = 25000;
CenterScaleMapBounds expectedMapBounds = new CenterScaleMapBounds(CH1903, originalBBox.centre().x, originalBBox.centre().y,
new Scale(expectedScale));
assertEquals(expectedMapBounds.toReferencedEnvelope(screen, dpi), newBBox);
}