private boolean isYIndexUp(List<RasterTile> tiles) { RasterTile first = tiles.iterator().next(); for (RasterTile tile : tiles) { if (tile.getCode().getY() > first.getCode().getY()) { return tile.getBounds().getY() > first.getBounds().getY(); } else if (tile.getCode().getY() < first.getCode().getY()) { return tile.getBounds().getY() < first.getBounds().getY(); } } return false; }
private RasterTile createTile(TileCode tileCode) { Bbox worldBounds = tileService.getWorldBoundsForTile(layer.getViewPort(), layer.getTileConfig(), tileCode); RasterTile tile = new RasterTile(getScreenBounds(worldBounds), tileCode.toString()); tile.setCode(tileCode); tile.setUrl(wmsService.getMapUrl(layer.getConfig(), layer.getCrs(), worldBounds, layer.getTileConfig() .getTileWidth(), layer.getTileConfig().getTileHeight())); return tile; }
double xOffset = result.getRasterImage().getCode().getX() * imageWidth - pixelBounds.getX(); double yOffset = 0; yOffset = result.getRasterImage().getCode().getY() * imageHeight - pixelBounds.getY(); } else { yOffset = (float) (pixelBounds.getMaxY() - (result.getRasterImage().getCode() .getY() + 1) + result.getRasterImage().getUrl()); RenderedImage translated = TranslateDescriptor.create(colored, (float) xOffset, (float) yOffset, new InterpolationNearest(), null); ImageIO.write(mosaic, "png", baos); log.debug("rendering done, size = " + baos.toByteArray().length); RasterTile mosaicTile = new RasterTile(); mosaicTile.setBounds(getWorldBounds(tiles)); ImageResult mosaicResult = new ImageResult(mosaicTile); mosaicResult.setImage(baos.toByteArray());
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; }
@Override public List<RasterTile> getTiles(Bbox worldBounds) { List<RasterTile> result = new ArrayList<RasterTile>(); for (RasterTile rasterTile : tiles.values()) { Bbox screenBounds = getScreenBounds(worldBounds); if (BboxService.intersects(screenBounds, rasterTile.getBounds())) { result.add(rasterTile); } } return result; }
public RasterImageDownloadCallable(int retries, RasterTile rasterImage) { this.result = new ImageResult(rasterImage); this.retries = retries; String externalUrl = rasterImage.getUrl(); url = dispatcherUrlService.localize(externalUrl); }
protected void addTiles(List<org.geomajas.layer.tile.RasterTile> rasterTiles) { nrLoadingTiles = 0; for (RasterTile tile : rasterTiles) { TileCode code = tile.getCode().clone(); // Add only new tiles to the list: if (!tiles.containsKey(code)) { nrLoadingTiles++; // Add the tile to the list and render it: tiles.put(code, tile); renderTile(tile, new ImageCounter()); } } deferred = null; renderingImages = true; }
private RasterTile toRasterTile(Tile tile) { RasterTile rTile = new RasterTile(tile.getBounds(), tile.getCode().toString()); rTile.setCode(new TileCode(tile.getCode().getTileLevel(), tile.getCode().getX(), tile.getCode().getY())); rTile.setUrl(tile.getUrl()); return rTile; }
private Bbox getWorldBounds(List<RasterTile> tiles) { Bbox bounds = null; for (RasterTile tile : tiles) { Bbox tileBounds = new Bbox(tile.getBounds().getX(), tile.getBounds().getY(), tile.getBounds().getWidth(), tile.getBounds().getHeight()); if (bounds == null) { bounds = new Bbox(tileBounds.getX(), tileBounds.getY(), tileBounds.getWidth(), tileBounds.getHeight()); } else { double minx = Math.min(tileBounds.getX(), bounds.getX()); double maxx = Math.max(tileBounds.getMaxX(), bounds.getMaxX()); double miny = Math.min(tileBounds.getY(), bounds.getY()); double maxy = Math.max(tileBounds.getMaxY(), bounds.getMaxY()); bounds = new Bbox(minx, miny, maxx - minx, maxy - miny); } } return bounds; }
private Bbox getPixelBounds(List<RasterTile> tiles) { Bbox bounds = null; int imageWidth = configurationService.getRasterLayerInfo(getLayerId()).getTileWidth(); int imageHeight = configurationService.getRasterLayerInfo(getLayerId()).getTileHeight(); for (RasterTile tile : tiles) { Bbox tileBounds = new Bbox(tile.getCode().getX() * imageWidth, tile.getCode().getY() * imageHeight, imageWidth, imageHeight); if (bounds == null) { bounds = new Bbox(tileBounds.getX(), tileBounds.getY(), tileBounds.getWidth(), tileBounds.getHeight()); } else { double minx = Math.min(tileBounds.getX(), bounds.getX()); double maxx = Math.max(tileBounds.getMaxX(), bounds.getMaxX()); double miny = Math.min(tileBounds.getY(), bounds.getY()); double maxy = Math.max(tileBounds.getMaxY(), bounds.getMaxY()); bounds = new Bbox(minx, miny, maxx - minx, maxy - miny); } } return bounds; }
@Override public List<RasterTile> getTiles(double scale, Bbox worldBounds) { List<TileCode> codes = tileService.getTileCodesForBounds(getViewPort(), tileConfig, worldBounds, scale); List<RasterTile> tiles = new ArrayList<RasterTile>(); if (!codes.isEmpty()) { double actualScale = viewPort.getZoomStrategy().getZoomStepScale(codes.get(0).getTileLevel()); for (TileCode code : codes) { Bbox bounds = tileService.getWorldBoundsForTile(getViewPort(), tileConfig, code); RasterTile tile = new RasterTile(getScreenBounds(actualScale, bounds), code.toString()); tile.setCode(code); tile.setUrl(wmsService.getMapUrl(getConfig(), getCrs(), bounds, tileConfig.getTileWidth(), tileConfig.getTileHeight())); tiles.add(tile); } } return tiles; }
/** * Add image in the document. * * @param context PDF context * @param imageResult image * @throws BadElementException PDF construction problem * @throws IOException PDF construction problem */ protected void addImage(PdfContext context, ImageResult imageResult) throws BadElementException, IOException { Bbox imageBounds = imageResult.getRasterImage().getBounds(); float scaleFactor = (float) (72 / getMap().getRasterResolution()); float width = (float) imageBounds.getWidth() * scaleFactor; float height = (float) imageBounds.getHeight() * scaleFactor; // subtract screen position of lower-left corner float x = (float) (imageBounds.getX() - rasterScale * bbox.getMinX()) * scaleFactor; // shift y to lowerleft corner, flip y to user space and subtract // screen position of lower-left // corner float y = (float) (-imageBounds.getY() - imageBounds.getHeight() - rasterScale * bbox.getMinY()) * scaleFactor; if (log.isDebugEnabled()) { log.debug("adding image, width=" + width + ",height=" + height + ",x=" + x + ",y=" + y); } // opacity log.debug("before drawImage"); context.drawImage(Image.getInstance(imageResult.getImage()), new Rectangle(x, y, x + width, y + height), getSize(), getOpacity()); log.debug("after drawImage"); }
int y = yScreenUpperLeft - (j - jMin) * screenWidth; RasterTile image = new RasterTile(new Bbox(x, -y, screenWidth, screenWidth), getId() + "." + tileLevel + "." + i + "," + j); image.setCode(new TileCode(tileLevel, i, j)); image.setUrl("http://tile.openstreetmap.org/" + tileLevel + "/" + i + "/" + j + ".png"); log.debug("adding OSM image {}", image); result.add(image);
/** * Add image with a exception message in the PDF document. * * @param context PDF context * @param e exception to put in image */ protected void addLoadError(PdfContext context, ImageException e) { Bbox imageBounds = e.getRasterImage().getBounds(); float scaleFactor = (float) (72 / getMap().getRasterResolution()); float width = (float) imageBounds.getWidth() * scaleFactor; float height = (float) imageBounds.getHeight() * scaleFactor; // subtract screen position of lower-left corner float x = (float) (imageBounds.getX() - rasterScale * bbox.getMinX()) * scaleFactor; // shift y to lower left corner, flip y to user space and subtract // screen position of lower-left // corner float y = (float) (-imageBounds.getY() - imageBounds.getHeight() - rasterScale * bbox.getMinY()) * scaleFactor; if (log.isDebugEnabled()) { log.debug("adding failed message=" + width + ",height=" + height + ",x=" + x + ",y=" + y); } float textHeight = context.getTextSize("failed", ERROR_FONT).getHeight() * 3f; Rectangle rec = new Rectangle(x, y, x + width, y + height); context.strokeRectangle(rec, Color.RED, 0.5f); context.drawText(getNlsString("RasterLayerComponent.loaderror.line1"), ERROR_FONT, new Rectangle(x, y + textHeight, x + width, y + height), Color.RED); context.drawText(getNlsString("RasterLayerComponent.loaderror.line2"), ERROR_FONT, rec, Color.RED); context.drawText(getNlsString("RasterLayerComponent.loaderror.line3"), ERROR_FONT, new Rectangle(x, y - textHeight, x + width, y + height), Color.RED); }
- Math.round(scale * worldBox.getY())); RasterTile image = new RasterTile(screenBox, getId() + "." + zoomLevel + "." + i + "," + j); image.setCode(new TileCode(zoomLevel, i, j)); image.setUrl(url); log.debug("adding image {}", image); result.add(image);
- Math.round(scale * worldBox.getY())); RasterTile image = new RasterTile(screenBox, getId() + "." + zoomLevel + "." + i + "," + j); image.setCode(new TileCode(zoomLevel, i, j)); image.setUrl(url); log.debug("adding image {}", image); result.add(image);
- Math.round(scale * tileBounds.getY())); RasterTile image = new RasterTile(screenBox, getId() + "." + tileLevel + "." + i + "," + j); image.setCode(tileCode); image.setUrl(formatUrl(urlBuilder.buildUrl(tileCode, getTmsTargetUrl()))); result.add(image);