/** Builds an XMLGridSubset out of a {@link GridSubset} */ public XMLGridSubset(GridSubset sset) { setGridSetName(sset.getName()); setExtent( sset.getOriginalExtent() == null ? null : new BoundingBox(sset.getOriginalExtent())); setZoomStart(sset.getZoomStart()); setZoomStop(sset.getZoomStop()); setMinCachedLevel(sset.getMinCachedZoom()); setMaxCachedLevel(sset.getMaxCachedZoom()); }
private static CoordinateReferenceSystem getGridsetCrs(GridSubset gridSubset) { final CoordinateReferenceSystem gridSetCrs; SRS srs = gridSubset.getGridSet().getSrs(); try { int epsgCode = srs.getNumber(); String epsgId = "EPSG:" + epsgCode; boolean longitudeFirst = true; // as used by geoserver gridSetCrs = CRS.decode(epsgId, longitudeFirst); } catch (Exception e) { throw new RuntimeException("Can't decode SRS ESPG:" + srs.getNumber()); } return gridSetCrs; }
/** * Apply security filters to a conveyor. * * @param tile * @throws SecurityException if any of the filter throw it */ public void checkSecurity(final ConveyorTile tile) throws SecurityException, GeoWebCacheException { final TileLayer layer = tile.getLayer(); final GridSubset gridSubset = tile.getGridSubset(); final BoundingBox bounds; final SRS srs; if (Objects.nonNull(gridSubset)) { bounds = gridSubset.boundsFromIndex(tile.getTileIndex()); srs = gridSubset.getSRS(); } else { bounds = null; srs = null; } checkSecurity(layer, bounds, srs); }
public long[][] getCoverageIntersections(BoundingBox reqBounds) { final int zoomStart = getZoomStart(); final int zoomStop = getZoomStop(); long[][] ret = new long[1 + zoomStop - zoomStart][5]; for (int level = zoomStart; level <= zoomStop; level++) { ret[level - zoomStart] = getCoverageIntersection(level, reqBounds); } return ret; }
private long[] getGridCoverage(final int level) { long[][] coveredBounds = gridSubset.getCoverages(); coveredBounds = gridSubset.expandToMetaFactors(coveredBounds, metaTilingFactors); return coveredBounds[level]; }
public long[] getCoverageBestFit() { int level; long[] cov = null; final int zoomStart = getZoomStart(); final int zoomStop = getZoomStop(); for (level = zoomStop; level > zoomStart; level--) { cov = getCoverage(level); if (cov[0] == cov[2] && cov[1] == cov[3]) { break; } } cov = getCoverage(level); return cov; }
private void capabilityVendorSpecificTileset(StringBuilder str, TileLayer layer, GridSubset grid, String formatStr, String styleName) throws GeoWebCacheException { String srsStr = grid.getSRS().toString(); StringBuilder resolutionsStr = new StringBuilder(); double[] res = grid.getResolutions(); for (int i = 0; i < res.length; i++) { resolutionsStr.append(Double.toString(res[i]) + " "); } String[] bs = boundsPrep(grid.getCoverageBestFitBounds()); str.append(" <TileSet>\n"); str.append(" <SRS>" + srsStr + "</SRS>\n"); str.append(" <BoundingBox SRS=\"" + srsStr + "\" minx=\"" + bs[0] + "\" miny=\"" + bs[1] + "\" maxx=\"" + bs[2] + "\" maxy=\"" + bs[3] + "\" />\n"); str.append(" <Resolutions>" + resolutionsStr.toString() + "</Resolutions>\n"); str.append(" <Width>" + grid.getTileWidth() + "</Width>\n"); str.append(" <Height>" + grid.getTileHeight() + "</Height>\n"); str.append(" <Format>" + formatStr + "</Format>\n"); str.append(" <Layers>" + layer.getName() + "</Layers>\n"); str.append(" <Styles>").append(ServletUtils.URLEncode(styleName)) .append("</Styles>\n"); str.append(" </TileSet>\n"); }
xml.simpleElement("SRS", gridSub.getSRS().toString(), true); double[] coords = gridSub.getCoverageBestFitBounds().getCoords(); xml.boundingBox(null, coords[0], coords[1], coords[2], coords[3]); xml.indentElement("Origin") .attribute("width", Integer.toString(gridSub.getTileWidth())) .attribute("height", Integer.toString(gridSub.getTileHeight())) .attribute("mime-type", mimeType.getMimeType()) .attribute("extension", mimeType.getFileExtension()) .endElement(); xml.indentElement("TileSets") .attribute("profile", profileForGridSet(gridSub.getGridSet())); double[] resolutions = gridSub.getResolutions(); int resIdx = 0; for (int zoom = gridSub.getZoomStart(); zoom <= gridSub.getZoomStop(); zoom++) { xml.indentElement("TileSet"); xml.attribute(
PagePyramid newPagePyramid(final GridSubset gridSubset) { int zoomStart = gridSubset.getZoomStart(); int zoomStop = gridSubset.getZoomStop(); final long[][] coverages = gridSubset.getCoverages(); PagePyramid pagePyramid = new PagePyramid(coverages, zoomStart, zoomStop); return pagePyramid; } }
public long getGridIndex(String gridId) { final int zoomStart = getZoomStart(); final int zoomStop = getZoomStop(); for (int index = zoomStart; index <= zoomStop; index++) { if (gridSet.getGrid(index).getName().equals(gridId)) { return index; } } return -1L; }
private void truncate(final TileLayer layer, final BoundingBox bounds, final GridSubset gridSubset, String formatName, Map<String, String> parameters) { final int threadCount = 1; int zoomStart; int zoomStop; zoomStart = gridSubset.getZoomStart(); zoomStop = gridSubset.getZoomStop(); final TYPE taskType = TRUNCATE; SeedRequest req = new SeedRequest(layer.getName(), bounds, gridSubset.getName(), threadCount, zoomStart, zoomStop, formatName, taskType, parameters); GWCTask[] tasks; try { TileRange tr = TileBreeder.createTileRange(req, layer); boolean filterUpdate = false; tasks = tileBreeder.createTasks(tr, taskType, threadCount, filterUpdate); } catch (GeoWebCacheException e) { throw new RuntimeException(e); } tileBreeder.dispatchTasks(tasks); }
private void setCacheMetadataHeaders(RawMap map, ConveyorTile cachedTile, TileLayer layer) { long[] tileIndex = cachedTile.getTileIndex(); CacheResult cacheResult = cachedTile.getCacheResult(); GridSubset gridSubset = layer.getGridSubset(cachedTile.getGridSetId()); BoundingBox tileBounds = gridSubset.boundsFromIndex(tileIndex); String cacheResultHeader = cacheResult == null ? "UNKNOWN" : cacheResult.toString(); map.setResponseHeader("geowebcache-layer", layer.getName()); map.setResponseHeader("geowebcache-cache-result", cacheResultHeader); map.setResponseHeader("geowebcache-tile-index", Arrays.toString(tileIndex)); map.setResponseHeader("geowebcache-tile-bounds", tileBounds.toString()); map.setResponseHeader("geowebcache-gridset", gridSubset.getName()); map.setResponseHeader("geowebcache-crs", gridSubset.getSRS().toString()); }
protected void writeResponse(RuntimeStats stats) throws OWSException { TileLayer layer = convTile.getLayer(); GridSet gridSet = convTile.getGridSubset().getGridSet(); if (gridSet.getTileHeight() < j || j < 0) { throw new OWSException( BoundingBox bbox = convTile.getGridSubset().boundsFromIndex(convTile.getTileIndex()); data = layer.getFeatureInfo( convTile, bbox, convTile.getGridSubset().getTileHeight(), convTile.getGridSubset().getTileWidth(), i, j);
int canvasy = (int) (srcRectangle[3] - gridy) * gridSubset.getTileHeight(); int tileHeight = gridSubset.getTileHeight(); ConveyorTile tile = new ConveyorTile(sb, layer.getName(), gridSubset.getName(), gridLoc, ImageMime.png, fullParameters, null, null); int canvasx = (int) (gridx - startx) * gridSubset.getTileWidth(); int tileWidth = gridSubset.getTileWidth(); if (tileWidth != gridSubset.getTileWidth() || tileHeight != gridSubset.getTileHeight()) { log.debug("tileImg.getSubimage(" + tilex + "," + tiley + "," + tileWidth + "," + tileHeight + ")");
private String buildGetMap(final boolean directWMSIntegrationEndpoint, final String queryLayerName, final String gridsetId, String styles, final TileLayer tileLayer) { final GridSubset gridSubset = tileLayer.getGridSubset(gridsetId); long[] coverage = gridSubset.getCoverage(0); long[] tileIndex = { coverage[0], coverage[1], coverage[4] }; BoundingBox bounds = gridSubset.boundsFromIndex(tileIndex); final String endpoint = directWMSIntegrationEndpoint ? "wms" : "gwc/service/wms"; StringBuilder sb = new StringBuilder(endpoint); sb.append("?service=WMS&request=GetMap&version=1.1.1&format=image/png"); sb.append("&layers=").append(queryLayerName); sb.append("&srs=").append(gridSubset.getSRS()); sb.append("&width=").append(gridSubset.getGridSet().getTileWidth()); sb.append("&height=").append(gridSubset.getGridSet().getTileHeight()); sb.append("&styles="); if (styles != null) { sb.append(styles); } sb.append("&bbox=").append(bounds.toString()); return sb.toString(); }
public void makeRequest(ConveyorTile tile, Resource target) throws GeoWebCacheException { WMSLayer layer = (WMSLayer) tile.getLayer(); GridSubset gridSubset = layer.getGridSubset(tile.getGridSetId()); Map<String, String> wmsParams = layer.getWMSRequestTemplate(tile.getMimeType(), WMSLayer.RequestType.MAP); wmsParams.put("FORMAT", tile.getMimeType().getFormat()); wmsParams.put("SRS", layer.backendSRSOverride(gridSubset.getSRS())); wmsParams.put("HEIGHT", String.valueOf(gridSubset.getTileHeight())); wmsParams.put("WIDTH", String.valueOf(gridSubset.getTileWidth())); // strBuilder.append("&TILED=").append(requestTiled); BoundingBox bbox = gridSubset.boundsFromIndex(tile.getTileIndex()); wmsParams.put("BBOX", bbox.toString()); Map<String, String> filteringParameters = tile.getFilteringParameters(); if (filteringParameters.isEmpty()) { filteringParameters = layer.getDefaultParameterFilters(); } wmsParams.putAll(filteringParameters); if (tile.getMimeType() == XMLMime.kml) { // This is a hack for GeoServer to produce regionated KML, // but it is unlikely to do much harm, especially since nobody // else appears to produce regionated KML at this point wmsParams.put("format_options", "mode:superoverlay;overlaymode:auto"); } MimeType mimeType = tile.getMimeType(); makeRequest(tile, layer, wmsParams, mimeType, target); }
GridSet set = mock(GridSet.class); when(subset.getName()).thenReturn("testGridset"); when(subset.getGridSet()).thenReturn(set); + XMLMime.gml.getMimeType()); when(subset.getNumTilesHigh(2)).thenReturn(7L); when(subset.getGridIndex("testGridset:2")).thenReturn(2L); when(subset.getCoverage(2)).thenReturn(new long[] {1, 1, 8, 8});
public void checkCoverage(long[] index) throws OutsideCoverageException { if (covers(index)) { return; } if (index[2] < getZoomStart() || index[2] > getZoomStop()) { throw new OutsideCoverageException(index, getZoomStart(), getZoomStop()); } long[] coverage = getCoverage((int) index[2]); throw new OutsideCoverageException(index, coverage); }
Integer zoomStop = gridSubset.getMaxCachedZoom(); if (zoomStop == null) { zoomStop = gridSubset.getGridSet().getNumLevels() - 1; Grid grid = gridSubset.getGridSet().getGrid(zoomStop); double width = grid.getResolution() * gridSubset.getTileWidth(); double height = grid.getResolution() * gridSubset.getTileHeight();
final int tileWidth = crsMatch.getTileWidth(); final int tileHeight = crsMatch.getTileHeight(); if ((expectedTileWidth != null && expectedTileWidth.intValue() != tileWidth) || (expectedTileHeight != null final long[] matchingTileIndex = crsMatch.closestIndex(reqBounds); if (bestMatch == null) { bestMatch = crsMatch; BoundingBox previousBounds = bestMatch.boundsFromIndex(bestMatchingTileIndex); BoundingBox bounds = crsMatch.boundsFromIndex(matchingTileIndex);