OsmLayer implements RasterLayer { public List<RasterTile> paint(CoordinateReferenceSystem boundsCrs, Envelope bounds, double scale) throws GeomajasException { return tileService.paint(tileServiceState, boundsCrs, bounds, scale); }  String getId(); @Api void setId(String id); CoordinateReferenceSystem getCrs(); @Api void setMaxZoomLevel(int maxZoomLevel); RasterLayerInfo getLayerInfo(); @Api void setLayerInfo(RasterLayerInfo layerInfo); @Api void setTileUrls(List<String> tileUrls); @Api void setUrlSelectionStrategy(UrlSelectionStrategy strategy); List<RasterTile> paint(CoordinateReferenceSystem boundsCrs, Envelope bounds, double scale); static final int DEFAULT_MAX_ZOOM_LEVEL; static final int TILE_SIZE; @Api
	static final List<String> OPEN_STREET_MAP_URLS; @Api
	static final List<String> OPEN_CYCLE_MAP_URLS; @Deprecated
	static final List<String> TILES_AT_HOME_MAP_URLS; }
@Test public void testReprojectOne() throws Exception { Envelope googleEnvelope = new Envelope(10000, 10010, 5000, 5010); Crs google = geoService.getCrs2("EPSG:900913"); Crs latlon = geoService.getCrs2("EPSG:4326"); Envelope latlonEnvelope = geoService.transform(JTS.toGeometry(googleEnvelope), google, latlon) .getEnvelopeInternal(); double latlonScale = ZOOMED_IN_SCALE * googleEnvelope.getWidth() / latlonEnvelope.getWidth(); List<RasterTile> tiles = osm.paint(latlon, latlonEnvelope, latlonScale); Assert.assertEquals(1, tiles.size()); RasterTile tile = tiles.get(0); Assert.assertEquals("http: Assert.assertEquals(4, tile.getCode().getTileLevel()); Assert.assertEquals(8, tile.getCode().getX()); Assert.assertEquals(7, tile.getCode().getY()); Assert.assertEquals(0.0, tile.getBounds().getX(), DELTA); Assert.assertEquals(-244.0, tile.getBounds().getY(), DELTA); Assert.assertEquals(244.0, tile.getBounds().getHeight(), DELTA); Assert.assertEquals(250.0, tile.getBounds().getWidth(), DELTA); }
@Test public void testReprojectSeveral() throws Exception { Envelope googleEnvelope = new Envelope(10000, 13000, 6005000, 6008000); Crs google = geoService.getCrs2("EPSG:900913"); Crs latlon = geoService.getCrs2("EPSG:4326"); Envelope latlonEnvelope = geoService.transform(JTS.toGeometry(googleEnvelope), google, latlon) .getEnvelopeInternal(); double latlonScale = MAX_LEVEL_SCALE * googleEnvelope.getWidth() / latlonEnvelope.getWidth(); List<RasterTile> tiles = osm.paint(latlon, latlonEnvelope, latlonScale); Assert.assertEquals(4, tiles.size()); Assert.assertEquals("http: Assert.assertEquals("http: Assert.assertEquals("http: Assert.assertEquals("http: 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); 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); } } }