public Layer createLayer(MapContext mapContext, ClientLayerInfo clientLayerInfo) throws GeomajasException {
if (!(clientLayerInfo instanceof TilebasedClientLayerInfo)) {
throw new IllegalArgumentException(
"TileBasedClientLayerFactory.createLayer() should only be called with TilebasedClientLayerInfo");
}
TilebasedClientLayerInfo rasterInfo = (TilebasedClientLayerInfo) clientLayerInfo;
RasterLayerRasterizingInfo extraInfo = (RasterLayerRasterizingInfo) rasterInfo
.getWidgetInfo(RasterLayerRasterizingInfo.WIDGET_KEY);
List<RasterTile> tiles = rasterInfo.getTiles();
for (RasterTile rasterTile : tiles) {
if (null != rasterTile.getUrl() && !rasterTile.getUrl().isEmpty()) {
rasterTile.setUrl(calculateUrl(rasterTile.getUrl()));
}
}
final RasterLayer layer = configurationService.getRasterLayer(clientLayerInfo.getServerLayerId());
RasterDirectLayer rasterLayer = new RasterDirectLayer(imageThreadPool, getHttpDownloader(layer), tiles,
rasterInfo.getTileHeight(), rasterInfo.getTileWidth(), rasterInfo.getScale(), extraInfo.getCssStyle());
rasterLayer.setTitle(clientLayerInfo.getLabel());
rasterLayer.getUserData().put(USERDATA_KEY_LAYER_ID, rasterInfo.getId());
rasterLayer.getUserData().put(USERDATA_KEY_SHOWING, extraInfo.isShowing());
return rasterLayer;
}