@Test
public void testReprojectSeveral() throws Exception {

	// move up north to test latlon flattening
	Envelope googleEnvelope = new Envelope(10000, 13000, 6005000, 6008000);
	// back-transform envelope to latlon
	Crs google = geoService.getCrs2("EPSG:900913");
	Crs latlon = geoService.getCrs2("EPSG:4326");
	Envelope latlonEnvelope = geoService.transform(JTS.toGeometry(googleEnvelope), google, latlon)
			.getEnvelopeInternal();
	// back-transform scale to latlon
	double latlonScale = MAX_LEVEL_SCALE * googleEnvelope.getWidth() / latlonEnvelope.getWidth();
	// paint with reprojection (affine is fine for now...:-)
	List<RasterTile> tiles = osm.paint(latlon, latlonEnvelope, latlonScale);
	Assert.assertEquals(4, tiles.size());
	Assert.assertEquals("http://a.tile.openstreetmap.org/14/8196/5735.png", tiles.get(0).getUrl());
	Assert.assertEquals("http://a.tile.openstreetmap.org/14/8196/5736.png", tiles.get(1).getUrl());
	Assert.assertEquals("http://a.tile.openstreetmap.org/14/8197/5735.png", tiles.get(2).getUrl());
	Assert.assertEquals("http://a.tile.openstreetmap.org/14/8197/5736.png", tiles.get(3).getUrl());
	// test first tile
	double width = tiles.get(0).getBounds().getWidth();
	double height = tiles.get(0).getBounds().getHeight();
	double x = tiles.get(0).getBounds().getX();
	double y = tiles.get(0).getBounds().getY();
	Assert.assertEquals(245, width, DELTA);
	Assert.assertEquals(166, height, DELTA);
	Assert.assertEquals(978, x, DELTA);
	Assert.assertEquals(-527802, y, DELTA);
	// test alignment on grid
	for (int i = 0; i <= 1; i++) {
		for (int j = 0; j <= 1; j++) {
			Assert.assertEquals(x + i * width, tiles.get(2 * i + j).getBounds().getX(), DELTA);
			Assert.assertEquals(y + j * height, tiles.get(2 * i + j).getBounds().getY(), DELTA);
			Assert.assertEquals(width, tiles.get(2 * i + j).getBounds().getWidth(), DELTA);
			Assert.assertEquals(height, tiles.get(2 * i + j).getBounds().getHeight(), DELTA);
		}
	}
}