@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; }
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; }
protected void renderTile(RasterTile tile, Callback<String, String> callback) { HtmlImage image = htmlImageFactory.create(tile.getUrl(), tile.getBounds(), callback); container.add(image); }
protected void renderTile(RasterTile tile, Callback<String, String> callback) { HtmlImage image = htmlImageFactory.create(tile.getUrl(), tile.getBounds(), callback); container.add(image); }
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; }
/** * 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"); }
/** * 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); }