public static String computeTransientKey(TileObject tile) { try { MimeType mime = MimeType.createFromFormat(tile.getBlobFormat()); return keyGenerator.tilePath(tile, mime).getAbsolutePath(); } catch (Exception ex) { throw new RuntimeException(ex); } }
/** * * 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(); }
private boolean tileIsGzipped(TileObject tile) throws MimeException { return gzipVector && MimeType.createFromFormat(tile.getBlobFormat()).isVector(); }
private boolean tileIsGzipped(TileObject tile) throws MimeException { return gzipVector && MimeType.createFromFormat(tile.getBlobFormat()).isVector(); }
private File getFileHandleTile(TileObject stObj, boolean create) throws StorageException { final MimeType mimeType; try { mimeType = MimeType.createFromFormat(stObj.getBlobFormat()); } catch (MimeException me) { log.error(me.getMessage()); throw new RuntimeException(me); } final File tilePath = pathGenerator.tilePath(stObj, mimeType); if (create) { File parent = tilePath.getParentFile(); mkdirs(parent, stObj); } return tilePath; }
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 String forTile(TileObject obj) { checkNotNull(obj.getLayerName()); checkNotNull(obj.getGridSetId()); checkNotNull(obj.getBlobFormat()); checkNotNull(obj.getXYZ()); String extension; try { String format = obj.getBlobFormat(); MimeType mimeType = MimeType.createFromFormat(format);
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); }
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); } }
eq(tile.getLayerName()), eq(tile.getGridSetId()), eq(tile.getBlobFormat()), anyString(), eq(20L), eq(tile.getLayerName()), eq(tile.getGridSetId()), eq(tile.getBlobFormat()), anyString(), eq(20L),
/** 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()); }
public void testTile() throws Exception { fbs = setup(); Resource bytes = new ByteArrayResource("1 2 3 4 5 6 test".getBytes()); long[] xyz = {1L, 2L, 3L}; Map<String, String> parameters = new HashMap<String, String>(); parameters.put("a", "x"); parameters.put("b", "ΓΈ"); TileObject to = TileObject.createCompleteTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters, bytes); fbs.put(to); TileObject to2 = TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); fbs.get(to2); assertEquals(to.getBlobFormat(), to2.getBlobFormat()); try (InputStream is = to.getBlob().getInputStream(); InputStream is2 = to2.getBlob().getInputStream()) { assertTrue(IOUtils.contentEquals(is, is2)); } }
/** 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()); }
eq(tile.getLayerName()), eq(tile.getGridSetId()), eq(tile.getBlobFormat()), anyString(), eq(22L),
assertEquals(to.getBlobFormat(), to2.getBlobFormat()); assertEquals(to.getBlobFormat(), to3.getBlobFormat());
assertEquals(to.getBlobFormat(), to2.getBlobFormat()); assertEquals(to.getBlobFormat(), to3.getBlobFormat());
@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()); }
() -> { TileObject to = (TileObject) EasyMock.getCurrentArguments()[0]; assertEquals("image/vnd.jpeg-png8", to.getBlobFormat()); assertNotNull(to.getBlob()); assertTrue(to.getBlob().getSize() > 0);
TileObject value = captured.getValue(); assertNotNull(value); assertEquals("image/png", value.getBlobFormat()); assertNotNull(value.getBlob()); assertTrue(value.getBlob().getSize() > 0);
@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()); }