private void runBasicTileTest(StorageBroker sb, long run, String name) throws StorageException { long start = System.currentTimeMillis(); for (int i = 1; i < TILE_GET_COUNT; i++) { long tmp = (long) Math.log(i) + 1; long tmp2 = i % tmp; long[] xyz = {tmp2, tmp2, (long) Math.log10(i)}; TileObject queryObj2 = TileObject.createQueryTileObject( "test", xyz, "hefty-gridSet:id1", "image/jpeg", null); sb.get(queryObj2); } long stop = System.currentTimeMillis(); System.out.println( name + " - run " + run + ", " + TILE_GET_COUNT + " gets took " + Long.toString(stop - start) + "ms"); }
@Test public void testEmpty() throws Exception { TileObject fromCache = TileObject.createQueryTileObject( "testLayer", new long[] {0L, 0L, 0L}, "testGridSet", "image/png", null); assertThat(store.get(fromCache), equalTo(false)); // assertThat(fromCache, hasProperty("status", is(Status.MISS))); }
private TileObject queryTile( String layer, String gridset, String extension, long x, long y, int z, Map<String, String> parameters) { String format; try { format = MimeType.createFromExtension(extension).getFormat(); } catch (MimeException e) { throw Throwables.propagate(e); } TileObject tile = TileObject.createQueryTileObject( layer, new long[] {x, y, z}, gridset, format, parameters); return tile; } }
protected void assertNoTile( String layerName, long x, long y, int z, String gridSetId, String format, Map<String, String> parameters) throws StorageException { TileObject to = TileObject.createQueryTileObject( layerName, new long[] {x, y, z}, gridSetId, format, parameters); assertThat(store.get(to), describedAs("don't get a tile", is(false))); assertThat(to, hasProperty("blob", nullValue())); assertThat(to, hasProperty("blobSize", is(0))); }
public void testTileDelete() throws Exception { fbs = setup(); Map<String, String> parameters = new HashMap<String, String>(); parameters.put("a", "x"); parameters.put("b", "ø"); Resource bytes = new ByteArrayResource("1 2 3 4 5 6 test".getBytes()); long[] xyz = {5L, 6L, 7L}; 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); try (InputStream is = to2.getBlob().getInputStream(); InputStream is2 = bytes.getInputStream()) { assertTrue(IOUtils.contentEquals(is, is2)); } TileObject to3 = TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); fbs.delete(to3); TileObject to4 = TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); assertFalse(fbs.get(to4)); }
protected void assertTile( String layerName, long x, long y, int z, String gridSetId, String format, Map<String, String> parameters, String content) throws StorageException { TileObject to = TileObject.createQueryTileObject( layerName, new long[] {x, y, z}, gridSetId, format, parameters); assertThat(store.get(to), describedAs("get a tile", is(true))); assertThat( to, hasProperty( "blob", resource(new ByteArrayResource(content.getBytes(StandardCharsets.UTF_8))))); }
private void checkThatStoreContainsReplacedTiles(String relativePathA, String relativePathB) throws Exception { // instantiating the store File rootDirectory = OperationsRestWebConfig.ROOT_DIRECTORY; MbtilesInfo configuration = new MbtilesInfo(); configuration.setRootDirectory(rootDirectory.getPath()); configuration.setTemplatePath( Utils.buildPath("{grid}", "{layer}", "{format}", "{z}", "tiles-{x}-{y}.sqlite")); MbtilesBlobStore store = new MbtilesBlobStore(configuration); addStoresToClean(store); // checking that all the files are present File fileA = new File(OperationsRestWebConfig.ROOT_DIRECTORY, relativePathA); File fileB = new File(OperationsRestWebConfig.ROOT_DIRECTORY, relativePathB); assertThat(fileA.exists(), is(true)); assertThat(fileB.exists(), is(true)); // let's query the store to see if we get the replaced tiles TileObject getTile = TileObject.createQueryTileObject( "africa", new long[] {10, 50, 5}, "EPSG:4326", "image/png", null); assertThat(store.get(getTile), is(true)); assertThat(getTile.getBlob(), notNullValue()); assertThat(TestSupport.resourceToString(getTile.getBlob()), is("IMAGE-10-50-5-B")); // let's query the second tile getTile = TileObject.createQueryTileObject( "africa", new long[] {10, 5050, 15}, "EPSG:4326", "image/png", null); assertThat(store.get(getTile), is(true)); assertThat(getTile.getBlob(), notNullValue()); assertThat(TestSupport.resourceToString(getTile.getBlob()), is("IMAGE-15-5050-5-B")); }
TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); mbs.get(to2); TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); mbs.get(to3);
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)); } }
TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); mbs.get(to2); TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); mbs.delete(to3); TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); assertFalse(mbs.get(to4));
TileObject.createQueryTileObject( "africa", new long[] {10, 50, 5}, "EPSG:4326", "image/png", null); TileObject.createQueryTileObject( "africa", new long[] {10, 50, 5}, "EPSG:4326", "image/png", null);
@Test public void testGetTileDefaultUnzip() throws Exception { MbtilesInfo configuration = getDefaultConfiguration(); MbtilesBlobStore store = new MbtilesBlobStore(configuration); addStoresToClean(store); TileObject tile = TileObject.createQueryTileObject( layer, new long[] {0, 0, 0}, "EPSG:900913", ApplicationMime.mapboxVector.getFormat(), null); assertThat(store.get(tile), is(true)); try (InputStream is = MBTilesFileVectorTileTest.class.getResourceAsStream("tile_data.pbf.gz")) { assertTrue(IOUtils.contentEquals(tile.getBlob().getInputStream(), is)); } }
@Test public void testGetTileNoUnzip() throws Exception { MbtilesInfo configuration = getDefaultConfiguration(); configuration.setGzipVector(false); MbtilesBlobStore store = new MbtilesBlobStore(configuration); addStoresToClean(store); TileObject tile = TileObject.createQueryTileObject( layer, new long[] {0, 0, 0}, "EPSG:900913", ApplicationMime.mapboxVector.getFormat(), null); assertThat(store.get(tile), is(true)); try (InputStream is = MBTilesFileVectorTileTest.class.getResourceAsStream("tile_data.pbf.gz")) { assertTrue(IOUtils.contentEquals(tile.getBlob().getInputStream(), is)); } }
TileObject.createQueryTileObject( "testLayer", new long[] {0L, 0L, 0L}, "testGridSet", "image/png", params2);
@Test public void testGetTileDoUnzip() throws Exception { MbtilesInfo configuration = getDefaultConfiguration(); configuration.setGzipVector(true); MbtilesBlobStore store = new MbtilesBlobStore(configuration); addStoresToClean(store); TileObject tile = TileObject.createQueryTileObject( layer, new long[] {0, 0, 0}, "EPSG:900913", ApplicationMime.mapboxVector.getFormat(), null); assertThat(store.get(tile), is(true)); try (InputStream is = MBTilesFileVectorTileTest.class.getResourceAsStream("tile_data.pbf")) { assertTrue(IOUtils.contentEquals(tile.getBlob().getInputStream(), is)); } }
TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); assertTrue(mem2.get(to2)); TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); mem1.delete(to3); TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); assertFalse(mem1.get(to4));
final long size = toCache.getBlobSize(); TileObject fromCache = TileObject.createQueryTileObject( "testLayer", new long[] {0L, 0L, 0L}, "testGridSet", "image/png", null);
TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); mbs.get(to2);
TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); mbs.get(to2);
TileObject.createQueryTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters); assertTrue(mem2.get(to2));