TileObject.createCompleteTileObject( layer, new long[] {x, y, z}, gridset, format, null, null); tile.setParametersId(paramsId);
public void testPathNoParams() throws Exception { TileObject tile = TileObject.createCompleteTileObject( "states", new long[] {0, 0, 0}, "EPSG:2163", "png", null, null); File path = generator.tilePath(tile, ImageMime.png); File expected = new File(testRoot, "states/EPSG_2163_00/0_0/00_00.png"); assertEquals(expected, path); }
protected void cacheTile( String layerName, long x, long y, int z, String gridSetId, String format, Map<String, String> parameters, String content) throws StorageException { TileObject to = TileObject.createCompleteTileObject( layerName, new long[] {x, y, z}, gridSetId, format, parameters, new ByteArrayResource(content.getBytes(StandardCharsets.UTF_8))); store.put(to); }
tiles[i][2] = tile.z; fileBlobStore.put( TileObject.createCompleteTileObject( "layer", new long[] {tile.x, tile.y, tile.z},
private StorageBroker resetAndPrepStorageBroker() throws Exception { System.out.println("Deleting old test database."); String blobPath = findTempDir() + File.separator + TEST_BLOB_DIR_NAME; System.out.println("Creating new blobstore in " + blobPath); File blobDirs = new File(blobPath); if (!blobDirs.exists() && !blobDirs.mkdirs()) { throw new StorageException("Unable to create " + blobPath); } BlobStore blobStore = new FileBlobStore(blobPath); TransientCache transCache = new TransientCache(100, 1024, 2000); StorageBroker sb = new DefaultStorageBroker(blobStore); // long[] xyz = {1L,2L,3L}; Resource blob = new ByteArrayResource(new byte[20 * 1024]); System.out.println("Inserting into database, " + TILE_PUT_COUNT + " tiles"); long startInsert = System.currentTimeMillis(); for (int i = 1; i < TILE_PUT_COUNT; i++) { long tmp = (long) Math.log(i) + 1; long tmp2 = i % tmp; long[] xyz = {tmp2, tmp2, (long) Math.log10(i)}; TileObject completeObj = TileObject.createCompleteTileObject( "test", xyz, "hefty-gridSet:id1", "image/jpeg", null, blob); sb.put(completeObj); } long stopInsert = System.currentTimeMillis(); System.out.println( TILE_PUT_COUNT + " inserts took " + Long.toString(stopInsert - startInsert) + "ms"); return sb; }
public void testPathWithParams() throws Exception { Map<String, String> params = new HashMap<String, String>(); params.put("style", "population"); TileObject tile = TileObject.createCompleteTileObject( "states", new long[] {0, 0, 0}, "EPSG:2163", "png", params, null); String sha1 = DigestUtils.sha1Hex("?style=population"); // first time, this will also create the path on disk File path = generator.tilePath(tile, ImageMime.png); testParameterId(path, sha1, "?style=population"); // another time, it should go off the pre-calculated tile id path = generator.tilePath(tile, ImageMime.png); testParameterId(path, sha1, "?style=population"); // this time with a separate tile, but same params tile = TileObject.createCompleteTileObject( "states", new long[] {0, 0, 0}, "EPSG:2163", "png", params, null); path = generator.tilePath(tile, ImageMime.png); testParameterId(path, sha1, "?style=population"); // and now a separate tile, but different params params.put("style", "polygon"); tile = TileObject.createCompleteTileObject( "states", new long[] {0, 0, 0}, "EPSG:2163", "png", params, null); path = generator.tilePath(tile, ImageMime.png); sha1 = DigestUtils.sha1Hex("?style=polygon"); testParameterId(path, sha1, "?style=polygon"); }
@SuppressWarnings("unchecked") @Test public void testParameterList() throws Exception { Map<String, String> params1 = Collections.singletonMap("testKey", "testValue1"); Map<String, String> params2 = Collections.singletonMap("testKey", "testValue2"); TileObject toCache1 = TileObject.createCompleteTileObject( "testLayer", new long[] {0L, 0L, 0L}, "testGridSet", "image/png", params1, new ByteArrayResource("1,2,4,5,6 test".getBytes(StandardCharsets.UTF_8))); TileObject toCache2 = TileObject.createCompleteTileObject( "testLayer", new long[] {0L, 0L, 0L}, "testGridSet", "image/png", params2, new ByteArrayResource("7,8,9,10 test".getBytes(StandardCharsets.UTF_8))); assertThat(store.getParameters("testLayer"), empty()); store.put(toCache1); assertThat(store.getParameters("testLayer"), containsInAnyOrder(params1)); store.put(toCache2); assertThat(store.getParameters("testLayer"), containsInAnyOrder(params1, params2)); }
@Test public void testParameterIDList() throws Exception { Map<String, String> params1 = Collections.singletonMap("testKey", "testValue1"); Map<String, String> params2 = Collections.singletonMap("testKey", "testValue2"); String params1Id = ParametersUtils.getId(params1); String params2Id = ParametersUtils.getId(params2); TileObject toCache1 = TileObject.createCompleteTileObject( "testLayer", new long[] {0L, 0L, 0L}, "testGridSet", "image/png", params1, new ByteArrayResource("1,2,4,5,6 test".getBytes(StandardCharsets.UTF_8))); TileObject toCache2 = TileObject.createCompleteTileObject( "testLayer", new long[] {0L, 0L, 0L}, "testGridSet", "image/png", params2, new ByteArrayResource("7,8,9,10 test".getBytes(StandardCharsets.UTF_8))); assertThat(store.getParameterIds("testLayer"), empty()); store.put(toCache1); assertThat(store.getParameterIds("testLayer"), containsInAnyOrder(params1Id)); store.put(toCache2); assertThat(store.getParameterIds("testLayer"), containsInAnyOrder(params1Id, params2Id)); }
Map<String, String> params2 = Collections.singletonMap("testKey", "testValue2"); TileObject toCache1 = TileObject.createCompleteTileObject( "testLayer", new long[] {0L, 0L, 0L}, new ByteArrayResource("1,2,4,5,6 test".getBytes(StandardCharsets.UTF_8))); TileObject toCache2 = TileObject.createCompleteTileObject( "testLayer", new long[] {0L, 0L, 0L},
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)); } }
long[] xyz = {x + i - 1, y, zoomLevel}; tos[i] = TileObject.createCompleteTileObject( layerName, xyz, srs.toString(), mime.getFormat(), parameters, bytes); fbs.put(tos[i]);
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)); }
parameters.put("b", "ø"); TileObject to = TileObject.createCompleteTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters, bytes);
TileObject.createCompleteTileObject( "africa", new long[] {10, 50, 5},
@Test public void testPathTemplateWithTileObject() throws Exception { TileObject tile = TileObject.createCompleteTileObject( "africa", new long[] {7050, 5075, 11}, "wgs84", "jpeg", tuplesToMap(tuple("style", "dark borders"), tuple("background", "blue")), null); String pathTemplate = Utils.buildPath( "{format}-tiles", "{grid}", "{layer}-{style}", "zoom-{z}", "ranges-{x}_{y}.sqlite"); String expectedPath = Utils.buildPath( "jpeg-tiles", "wgs84", "africa-dark_borders", "zoom-11", "ranges-7000_4000.sqlite"); FileManager fileManager = new FileManager(getRootDirectory(), pathTemplate, 2000, 1000); File file = fileManager.getFile(tile); assertThat( file.getCanonicalPath(), is(getRootDirectoryPath() + File.separator + expectedPath)); }
store.addListener(listener); TileObject toCache = TileObject.createCompleteTileObject( "testLayer", new long[] {0L, 0L, 0L},
long[] xyz = {5L, 6L, 7L}; TileObject to = TileObject.createCompleteTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters, bytes);
long[] xyz = {5L, 6L, 7L}; TileObject to = TileObject.createCompleteTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters, bytes);
parameters.put("b", "ø"); TileObject to = TileObject.createCompleteTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters, bytes);
parameters.put("b", "ø"); TileObject to = TileObject.createCompleteTileObject( "test:123123 112", xyz, "EPSG:4326", "image/jpeg", parameters, bytes);