// ignore to fix the build until the failing assertion is worked out @Test @Ignore public void testMinMaxCacheGetTile() throws Exception { WMSLayer tl = createWMSLayer("image/png", 5, 6); MockTileSupport mock = new MockTileSupport(tl); // we're not really seeding, just using the range SeedRequest req = createRequest(tl, GWCTask.TYPE.SEED, 4, 7); TileRange tr = TileBreeder.createTileRange(req, tl); List<ConveyorTile> tiles = getTiles(mock.storageBroker, tr, tl); // this number is determined by our tileRange minus those out of bounds assertEquals(880, tiles.size()); // tiles at zoom 4 and 7 will have non png data for (int i = 0; i < tiles.size(); i++) { ConveyorTile tile = tiles.get(i); assertNotNull(tile.getBlob()); // System.out.println(tile.getTileIndex()[2] + " " + tile.getBlob().getSize()); } // empirical numbers // this number is determined by the number of metarequests at level 5+6 assertEquals(218, mock.storagePutCounter.get()); // and the number of successful hits at level 5+6 assertEquals(176, mock.storageGetCounter.get()); // these last will vary - on a dual core machine, they appeared predictable // but on a 8 core machine, the threads compete for cache and we can only // assertain by range // @todo // assertTrue(Math.abs(532 - mock.cacheHits.get()) < 10); // assertTrue(Math.abs(494 - mock.cacheMisses.get()) < 10); // assertTrue(Math.abs(172 - mock.wmsMetaRequestCounter.get()) < 10); // stats System.out.println("transientCacheSize " + mock.transientCache.size()); System.out.println("transientCacheStorage " + mock.transientCache.storageSize()); }
protected void renderCanvas() throws OutsideCoverageException, GeoWebCacheException, IOException { // Now we loop over all the relevant tiles and write them to the canvas, // Starting at the bottom, moving to the right and up // Bottom row of tiles, in tile coordinates long starty = srcRectangle[1]; // gridy is the tile row index for (long gridy = starty; gridy <= srcRectangle[3]; gridy++) { int tiley = 0; int canvasy = (int) (srcRectangle[3] - gridy) * gridSubset.getTileHeight(); int tileHeight = gridSubset.getTileHeight(); if (canvOfs.top > 0) { // Add padding canvasy += canvOfs.top; } else { // Top tile is cut off if (gridy == srcRectangle[3]) { // This one starts at the top, so canvasy remains 0 tileHeight = tileHeight + canvOfs.top; tiley = -canvOfs.top; } else { // Offset that the first tile contributed, // rather, we subtract what it did not contribute canvasy += canvOfs.top; } } if (gridy == srcRectangle[1] && canvOfs.bottom < 0) { // Check whether we only use part of the first tiles (bottom row) // Offset is negative, slice the bottom off the tile tileHeight += canvOfs.bottom; } long startx = srcRectangle[0]; for (long gridx = startx; gridx <= srcRectangle[2]; gridx++) { long[] gridLoc = {gridx, gridy, srcIdx}; ConveyorTile tile = new ConveyorTile( sb, layer.getName(), gridSubset.getName(), gridLoc, ImageMime.png, fullParameters, null, null); // Check whether this tile is to be rendered at all try { layer.applyRequestFilters(tile); } catch (RequestFilterException e) { log.debug(e.getMessage()); continue; } layer.getTile(tile); BufferedImage tileImg = ImageIO.read(tile.getBlob().getInputStream()); int tilex = 0; int canvasx = (int) (gridx - startx) * gridSubset.getTileWidth(); int tileWidth = gridSubset.getTileWidth(); if (canvOfs.left > 0) { // Add padding canvasx += canvOfs.left; } else { // Leftmost tile is cut off if (gridx == srcRectangle[0]) { // This one starts to the left top, so canvasx remains 0 tileWidth = tileWidth + canvOfs.left; tilex = -canvOfs.left; } else { // Offset that the first tile contributed, // rather, we subtract what it did not contribute canvasx += canvOfs.left; } } if (gridx == srcRectangle[2] && canvOfs.right < 0) { // Check whether we only use part of the first tiles (bottom row) // Offset is negative, slice the bottom off the tile tileWidth = tileWidth + canvOfs.right; } // TODO We should really ensure we can never get here if (tileWidth == 0 || tileHeight == 0) { log.debug("tileWidth: " + tileWidth + " tileHeight: " + tileHeight); continue; } // Cut down the tile to the part we want if (tileWidth != gridSubset.getTileWidth() || tileHeight != gridSubset.getTileHeight()) { log.debug( "tileImg.getSubimage(" + tilex + "," + tiley + "," + tileWidth + "," + tileHeight + ")"); tileImg = tileImg.getSubimage(tilex, tiley, tileWidth, tileHeight); } // Render the tile on the big canvas log.debug( "drawImage(subtile," + canvasx + "," + canvasy + ",null) " + Arrays.toString(gridLoc)); gfx.drawImage(tileImg, canvasx, canvasy, null); // imageObserver } } gfx.dispose(); }