public long[] getTileIndex() { return stObj.getXYZ(); }
public String toString() { StringBuilder str = new StringBuilder(); str.append("ConveyorTile["); long[] idx = stObj.getXYZ(); if (idx != null && idx.length == 3) { str.append("{" + idx[0] + "," + idx[1] + "," + idx[2] + "} "); } if (getLayer() != null) { str.append(getLayerId()).append(" "); } if (this.gridSetId != null) { str.append(gridSetId).append(" "); } if (this.mimeType != null) { str.append(this.mimeType.getFormat()); } str.append(']'); return str.toString(); }
/** * * Static method for generating the {@link TileObject} cache key to use for caching. * * @param obj * @return {@link TileObject} key */ public static String generateTileKey(TileObject obj) { Map<String, String> parameters = obj.getParameters(); StringBuilder builder = new StringBuilder(obj.getLayerName()) .append(SEPARATOR) .append(obj.getGridSetId()) .append(SEPARATOR) .append(Arrays.toString(obj.getXYZ())) .append(SEPARATOR) .append(obj.getBlobFormat()); // If parameters are present they must be handled if (parameters != null && !parameters.isEmpty()) { for (String key : parameters.keySet()) { builder.append(SEPARATOR).append(key).append(SEPARATOR).append(parameters.get(key)); } } return builder.toString(); }
final long[] tileIndex = tile.getXYZ(); long x = tileIndex[0]; long y = tileIndex[1];
public void sendTileStored(final TileObject stObj) { final long[] xyz = stObj.getXYZ(); final String layerName = stObj.getLayerName(); final String gridSetId = stObj.getGridSetId(); final String blobFormat = stObj.getBlobFormat(); final String paramsId = stObj.getParametersId(); final int blobSize = stObj.getBlobSize(); sendTileStored( layerName, gridSetId, blobFormat, paramsId, xyz[0], xyz[1], (int) xyz[2], blobSize); }
public void sendTileDeleted(final TileObject stObj) { final long[] xyz = stObj.getXYZ(); final String layerName = stObj.getLayerName(); final String gridSetId = stObj.getGridSetId(); final String blobFormat = stObj.getBlobFormat(); final String paramsId = stObj.getParametersId(); final int blobSize = stObj.getBlobSize(); sendTileDeleted( layerName, gridSetId, blobFormat, paramsId, xyz[0], xyz[1], (int) xyz[2], blobSize); }
TileObject.createCompleteTileObject( obj.getLayerName(), obj.getXYZ(), obj.getGridSetId(), obj.getBlobFormat(),
public void sendTileUpdated(final TileObject stObj, final long oldSize) { final long[] xyz = stObj.getXYZ(); final String layerName = stObj.getLayerName(); final String gridSetId = stObj.getGridSetId(); final String blobFormat = stObj.getBlobFormat(); final String paramsId = stObj.getParametersId(); final int blobSize = stObj.getBlobSize(); sendTileUpdated( layerName, gridSetId, blobFormat, paramsId, xyz[0], xyz[1], (int) xyz[2], blobSize, oldSize); } }
@Test public void testDeleteLayer() throws Exception { byte[] bytes = new byte[1024]; Arrays.fill(bytes, (byte) 0xaf); TileObject tile = queryTile(20, 30, 12); tile.setBlob(new ByteArrayResource(bytes)); blobStore.put(tile); tile.getXYZ()[0] = 21; blobStore.put(tile); tile.getXYZ()[0] = 22; blobStore.put(tile); BlobStoreListener listener = mock(BlobStoreListener.class); blobStore.addListener(listener); String layerName = tile.getLayerName(); blobStore.delete(layerName); blobStore.destroy(); Thread.sleep(10000); // blobStore.delete(layerName); // verify(listener, Mockito.atLeastOnce()).layerDeleted(eq(layerName)); }
/** Builds the complete file path associated to the provided tile. */ File getFile(TileObject tile) { if (tile.getParametersId() == null && tile.getParameters() != null) { tile.setParametersId(ParametersUtils.getId(tile.getParameters())); } return getFile( tile.getParametersId(), tile.getXYZ(), tile.getLayerName(), tile.getGridSetId(), tile.getBlobFormat(), tile.getParameters()); }
/** Builds the complete file path associated to the provided tile. */ File getFile(TileObject tile) { if (tile.getParametersId() == null && tile.getParameters() != null) { tile.setParametersId(ParametersUtils.getId(tile.getParameters())); } return getFile( tile.getParametersId(), tile.getXYZ(), tile.getLayerName(), tile.getGridSetId(), tile.getBlobFormat(), tile.getParameters()); }
@Test public void testSeedJpegPng8MetaTiled() throws Exception { checkJpegPng( "image/vnd.jpeg-png8", () -> { TileObject to = (TileObject) EasyMock.getCurrentArguments()[0]; assertEquals("image/vnd.jpeg-png8", to.getBlobFormat()); assertNotNull(to.getBlob()); assertTrue(to.getBlob().getSize() > 0); String format = ImageMime.jpegPng8.getMimeType(to.getBlob()); long[] xyz = to.getXYZ(); assertEquals(10, xyz[2]); // check the ones in the full black area are jpeg, the others png if (xyz[0] == 900 || xyz[1] == 602) { assertEquals("image/jpeg", format); } else { assertEquals("image/png", format); // verify the image has been paletted try (InputStream inputStream = to.getBlob().getInputStream(); ) { BufferedImage image = ImageIO.read(inputStream); assertThat(image.getColorModel(), instanceOf(IndexColorModel.class)); } } return true; }, new RGBASourceHelper()); }
assertTrue(to.getBlob().getSize() > 0); String format = ImageMime.jpegPng8.getMimeType(to.getBlob()); long[] xyz = to.getXYZ(); assertEquals(10, xyz[2]);
@Test public void testSeedJpegPngMetaTiled() throws Exception { checkJpegPng( "image/vnd.jpeg-png", () -> { TileObject to = (TileObject) EasyMock.getCurrentArguments()[0]; assertEquals("image/vnd.jpeg-png", to.getBlobFormat()); assertNotNull(to.getBlob()); assertTrue(to.getBlob().getSize() > 0); String format = ImageMime.jpegPng.getMimeType(to.getBlob()); long[] xyz = to.getXYZ(); assertEquals(10, xyz[2]); // check the ones in the full black area are jpeg, the others png if (xyz[0] == 900 || xyz[1] == 602) { assertEquals("image/jpeg", format); } else { assertEquals("image/png", format); } return true; }, new RGBASourceHelper()); }