private TileRange tileRange( String layerName, String gridSetId, int zoomStart, int zoomStop, long[][] rangeBounds, MimeType mimeType, Map<String, String> parameters) { TileRange tileRange = new TileRange( layerName, gridSetId, zoomStart, zoomStop, rangeBounds, mimeType, parameters); return tileRange; }
/** * @return the key prefix up to the coordinates (i.e. {@code * "<prefix>/<layer>/<gridset>/<format>/<parametersId>"}) */ public String coordinatesPrefix(TileRange obj) { checkNotNull(obj.getLayerName()); checkNotNull(obj.getGridSetId()); checkNotNull(obj.getMimeType()); String layer = layerId(obj.getLayerName()); String gridset = obj.getGridSetId(); MimeType mimeType = obj.getMimeType(); String shortFormat; String parametersId = obj.getParametersId(); if (parametersId == null) { Map<String, String> parameters = obj.getParameters(); parametersId = ParametersUtils.getId(parameters); if (parametersId == null) { parametersId = "default"; } else { obj.setParametersId(parametersId); } } shortFormat = mimeType.getFileExtension(); // png, png8, png24, etc String key = join(true, prefix, layer, gridset, shortFormat, parametersId); return key; }
/** * Build the paths correspondent to a tile range. For each file we return the associated tiles * range by zoom. */ Map<File, List<long[]>> getFiles(TileRange tileRange) { Map<File, List<long[]>> files = new HashMap<>(); // let's iterate of all the available zoom levels for (int z = tileRange.getZoomStart(); z <= tileRange.getZoomStop(); z++) { long[] range = tileRange.rangeBounds(z); if (range == null) { // this zoom level doesn't have any tiles associated continue; } // get the files and associated tiles for the current zoom level getFiles( files, tileRange.getParametersId(), tileRange.getLayerName(), tileRange.getGridSetId(), tileRange.getMimeType().getFormat(), tileRange.getParameters(), z, range); } return files; }
public boolean contains(long x, long y, int z) { if (null == rangeBounds) { return true; } if (z >= getZoomStart() && z <= getZoomStop()) { long[] rB = rangeBounds((int) z); if (rB[0] <= x && rB[2] >= x && rB[1] <= y && rB[3] >= y) { return true; } } return false; }
/** * Example: nyc_01, nyc_05_1,EPSG_2163_01, EPSG_2163_01_7 (i.e. {@code * <gridsetPrefix>_<zLevel>[_<parametersId>]}) */ private boolean acceptZoomLevelDir(String name) { if (!name.startsWith(gridSetPrefix)) { return false; } if (tr.getZoomStart() == -1 && tr.getZoomStop() == -1) { // All zoomlevels return true; } else { int tmp = findZoomLevel(gridSetPrefix, name); if (tmp < tr.getZoomStart() || tmp > tr.getZoomStop()) { return false; } } String parameter = findParameter(gridSetPrefix, name); if (tr.getParametersId() == null) { return parameter == null; } else { return tr.getParametersId().equals(parameter); } }
Map<String, String> fullParameters = tr.getParameters(); storageBroker, layerName, tr.getGridSetId(), gridLoc, tr.getMimeType(), fullParameters, null,
LOG.debug( "Removing TileObjects for Layer: " + obj.getLayerName() + ", min/max levels: " + "[" + obj.getZoomStart() + ", " + obj.getZoomStop() + "], Gridset: " + obj.getGridSetId()); cacheProvider.removeLayer(obj.getLayerName()); + obj.getLayerName() + ", min/max levels: " + "[" + obj.getZoomStart() + ", " + obj.getZoomStop() + "], Gridset: " + obj.getGridSetId());
/** * Create a filter for stored tiles that are within a particular range. * * @param trObj the range to find * @throws StorageException */ public FilePathFilter(TileRange trObj) throws StorageException { this.tr = trObj; if (tr.getGridSetId() == null) { throw new StorageException("Specifying the grid set id is currently mandatory."); } String layerName = tr.getLayerName(); Preconditions.checkNotNull(layerName); this.layerPrefix = filteredLayerName(layerName); gridSetPrefix = filteredGridSetId(tr.getGridSetId()); if (tr.getMimeType() != null) { mimeExtension = tr.getMimeType().getFileExtension(); } }
/** Updates any request filters */ private void runFilterUpdates() { // We will assume that all filters that can be updated should be updated List<RequestFilter> reqFilters = tl.getRequestFilters(); if (reqFilters != null && !reqFilters.isEmpty()) { Iterator<RequestFilter> iter = reqFilters.iterator(); while (iter.hasNext()) { RequestFilter reqFilter = iter.next(); if (reqFilter.update(tl, tr.getGridSetId())) { log.debug("Updated request filter " + reqFilter.getName()); } else { log.debug( "Request filter " + reqFilter.getName() + " returned false on update."); } } } }
/** * Create tasks to manipulate the cache (Seed, truncate, etc) They will still need to be * dispatched. * * @param tr The range of tiles to work on. * @param type The type of task(s) to create * @param threadCount The number of threads to use, forced to 1 if type is TRUNCATE * @param filterUpdate // TODO: What does this do? * @return Array of tasks. Will have length threadCount or 1. * @throws GeoWebCacheException */ public GWCTask[] createTasks( TileRange tr, GWCTask.TYPE type, int threadCount, boolean filterUpdate) throws GeoWebCacheException { String layerName = tr.getLayerName(); TileLayer tileLayer = layerDispatcher.getTileLayer(layerName); return createTasks(tr, tileLayer, type, threadCount, filterUpdate); }
Map<String, String> fullParameters = tr.getParameters(); storageBroker, layerName, tr.getGridSetId(), gridLoc, tr.getMimeType(), fullParameters, null, runFilterUpdates(tr.getGridSetId());
/** * helper for counting the number of tiles * * @param tr * @return -1 if too many */ private long tileCount(TileRange tr) { final int startZoom = tr.getZoomStart(); final int stopZoom = tr.getZoomStop(); long count = 0; for (int z = startZoom; z <= stopZoom; z++) { long[] gridBounds = tr.rangeBounds(z); final long minx = gridBounds[0]; final long maxx = gridBounds[2]; final long miny = gridBounds[1]; final long maxy = gridBounds[3]; long thisLevel = (1 + maxx - minx) * (1 + maxy - miny); if (thisLevel > (Long.MAX_VALUE / 4) && z != stopZoom) { return -1; } else { count += thisLevel; } } return count; }
@Override public boolean delete(TileRange obj) throws StorageException { return readFunctionUnsafe(() -> store(obj.getLayerName()).delete(obj)); }
/** * @return the key prefix up to the coordinates (i.e. {@code * "<prefix>/<layer>/<gridset>/<format>/<parametersId>"}) */ public String coordinatesPrefix(TileRange obj) { checkNotNull(obj.getLayerName()); checkNotNull(obj.getGridSetId()); checkNotNull(obj.getMimeType()); String layer = layerId(obj.getLayerName()); String gridset = obj.getGridSetId(); MimeType mimeType = obj.getMimeType(); String shortFormat; String parametersId = obj.getParametersId(); if (parametersId == null) { Map<String, String> parameters = obj.getParameters(); parametersId = ParametersUtils.getId(parameters); if (parametersId == null) { parametersId = "default"; } else { obj.setParametersId(parametersId); } } shortFormat = mimeType.getFileExtension(); // png, png8, png24, etc String key = join(true, prefix, layer, gridset, shortFormat, parametersId); return key; }
/** * Build the paths correspondent to a tile range. For each file we return the associated tiles * range by zoom. */ Map<File, List<long[]>> getFiles(TileRange tileRange) { Map<File, List<long[]>> files = new HashMap<>(); // let's iterate of all the available zoom levels for (int z = tileRange.getZoomStart(); z <= tileRange.getZoomStop(); z++) { long[] range = tileRange.rangeBounds(z); if (range == null) { // this zoom level doesn't have any tiles associated continue; } // get the files and associated tiles for the current zoom level getFiles( files, tileRange.getParametersId(), tileRange.getLayerName(), tileRange.getGridSetId(), tileRange.getMimeType().getFormat(), tileRange.getParameters(), z, range); } return files; }
private void seedTiles(StorageBroker storageBroker, TileRange tr, final WMSLayer tl) throws Exception { final String layerName = tl.getName(); // define the meta tile size to 1,1 so we hit all the tiles final TileRangeIterator trIter = new TileRangeIterator(tr, tl.getMetaTilingFactors()); long[] gridLoc = trIter.nextMetaGridLocation(new long[3]); while (gridLoc != null) { Map<String, String> fullParameters = tr.getParameters(); final ConveyorTile tile = new ConveyorTile( storageBroker, layerName, tr.getGridSetId(), gridLoc, tr.getMimeType(), fullParameters, null, null); tile.setTileLayer(tl); tl.seedTile(tile, false); gridLoc = trIter.nextMetaGridLocation(gridLoc); } }
new TileRange( layerName, gridSetId,
z = tr.getZoomStart(); levelBounds = tr.rangeBounds(z); x = levelBounds[0]; y = levelBounds[1]; levelBounds = tr.rangeBounds(z); x = lastGridLoc[0] + metaX; y = lastGridLoc[1]; for (; z <= tr.getZoomStop(); z++) { for (; y <= levelBounds[3]; y += metaY) { for (; x <= levelBounds[2]; x += metaX) { if (z < tr.getZoomStop()) { // but be careful not to go out of index levelBounds = tr.rangeBounds(z + 1); x = levelBounds[0]; y = levelBounds[1];
int count = 0; String prefix = path + File.separator + filteredLayerName(trObj.getLayerName()); final String layerName = trObj.getLayerName(); final String gridSetId = trObj.getGridSetId(); final String blobFormat = trObj.getMimeType().getFormat(); final String parametersId = trObj.getParametersId();
return new TileRange( layerName, gridSetId, zoomStart, zoomStop, coveredGridLevels, mimeType, parameters);