public synchronized GridSubset getGridSubset() { if (gridSubset == null && gridSetId != null) { gridSubset = tileLayer.getGridSubset(gridSetId); } return gridSubset; }
private void makeBboxHints(StringBuilder doc, TileLayer tl) { for (String gridSetId : tl.getGridSubsets()) { GridSubset subset = tl.getGridSubset(gridSetId); doc.append("<li>" + gridSetId + ": " + subset.getOriginalExtent().toString() + "</li>\n"); } }
static class CustomLayerImplementation { private String name; private String title; private boolean isAuthorized; private List<String> formats; public CustomLayerImplementation( String name, String title, boolean isAuthorized, List<String> formats) { this.name = name; this.title = title; this.isAuthorized = isAuthorized; this.formats = formats; } }
private void makeBboxHints(StringBuilder doc, TileLayer tl) { for (String gridSetId : tl.getGridSubsets()) { GridSubset subset = tl.getGridSubset(gridSetId); doc.append( "<li>" + gridSetId + ": " + subset.getOriginalExtent().toString() + "</li>\n"); } }
/** * @param gridSetId * @param gridLoc * @return * @throws GeoWebCacheException */ public BoundingBox boundsFromIndex(String gridSetId, long[] gridLoc) { return getGridSubset(gridSetId).boundsFromIndex(gridLoc); }
/** * This method is deprecated, as a layer may be configured for more than one gridset with the * same SRS. * * @deprecated use {@link #getGridSubsetsForSRS(SRS)} in combination with {@link * GridUtil#findBestMatchingGrid} instead */ public GridSubset getGridSubsetForSRS(SRS srs) { for (String gridSet : getGridSubsets()) { GridSubset gridSubset = getGridSubset(gridSet); SRS gridSetSRS = gridSubset.getSRS(); if (gridSetSRS.equals(srs)) { return gridSubset; } } return null; }
/** * @param gridSetId * @return the resolutions (units/pixel) for the layer */ public double[] getResolutions(String gridSetId) throws GeoWebCacheException { return getGridSubset(gridSetId).getResolutions(); }
/** * Returns an immutable list of all the layer's {@link GridSubset} whose {@link GridSet} has a * SRS equal to {@code srs} (may be an alias), or the empty list of none matches. */ public List<GridSubset> getGridSubsetsForSRS(SRS srs) { List<GridSubset> matches = Collections.emptyList(); for (String gridSet : getGridSubsets()) { GridSubset gridSubset = getGridSubset(gridSet); SRS gridSetSRS = gridSubset.getSRS(); if (gridSetSRS.equals(srs)) { if (matches.isEmpty()) { matches = new ArrayList<GridSubset>(2); } matches.add(gridSubset); } } return matches.isEmpty() ? matches : Collections.unmodifiableList(matches); }
/** * Converts the given bounding box into the closest location on the grid supported by the * reference system. * * @param gridSetId * @param tileBounds * @return * @throws GeoWebCacheException * @throws GeoWebCacheException * @throws GridMismatchException */ public long[] indexFromBounds(String gridSetId, BoundingBox tileBounds) throws GridMismatchException { return getGridSubset(gridSetId).closestIndex(tileBounds); }
public void truncate(final String layerName, final ReferencedEnvelope bounds) throws GeoWebCacheException { final TileLayer tileLayer = tld.getTileLayer(layerName); final Collection<String> gridSubSets = tileLayer.getGridSubsets(); /* * Create a truncate task for each gridSubset (CRS), format and style */ for (String gridSetId : gridSubSets) { GridSubset layerGrid = tileLayer.getGridSubset(gridSetId); BoundingBox intersectingBounds = getIntersectingBounds(layerName, layerGrid, bounds); if (intersectingBounds == null) { continue; } String styleName = null;// all of them String format = null;// all of them truncate(layerName, styleName, gridSetId, intersectingBounds, format); } }
public synchronized void removeGridSet(String gridsetToRemove) { if (StreamSupport.stream(getLayerList().spliterator(), true) .anyMatch(g -> Objects.nonNull(g.getGridSubset(gridsetToRemove)))) { throw new IllegalStateException( "Can not remove gridset " + gridsetToRemove + " as it is used by layers"); } gridSetBroker.removeGridSet(gridsetToRemove); }
public void setUp() { RasterMaskTestUtils.debugToDisk = debugToDisk; layer = TestUtils.createWMSLayer( "image/png", new GridSetBroker(false, false), 3, 3, new BoundingBox(-180, -90, 180, 90)); gridsetId = layer.getGridSubsets().iterator().next(); fullCoverage = layer.getGridSubset(gridsetId).getCoverages(); }
private PagePyramid newPagePyramid(final TileSet tileSet) { final String layerName = tileSet.getLayerName(); final TileLayer tileLayer; try { tileLayer = tld.getTileLayer(layerName); } catch (GeoWebCacheException e) { throw new IllegalArgumentException(e); } final String gridsetId = tileSet.getGridsetId(); final GridSubset gridSubset = tileLayer.getGridSubset(gridsetId); return newPagePyramid(gridSubset); }
protected void tileMapsForLayer( XMLBuilder xml, TileLayer layer, String baseUrl, String contextPath) throws IOException { for (String gridSetId : layer.getGridSubsets()) { GridSubset gridSub = layer.getGridSubset(gridSetId); for (MimeType mimeType : layer.getMimeTypes()) { // GridSubset gridSub = iter.next(); xml.indentElement("TileMap") .attribute("title", tileMapTitle(layer)) .attribute("srs", gridSub.getSRS().toString()) .attribute("profile", profileForGridSet(gridSub.getGridSet())) .attribute( "href", tileMapUrl(layer, gridSub, mimeType, baseUrl, contextPath)) .endElement(); } } }
@Test public void testLayerGridsets() throws Exception { TileLayer layer = requirePresent(((GetCapabilitiesConfiguration) config).getLayer("testExisting")); GridSet gridset = assertPresent(config.getGridSet("testExisting:EPSG:3978")); GridSubset gridSubset = layer.getGridSubset("testExisting:EPSG:3978"); GridSet gridSet2 = gridSubset.getGridSet(); assertThat(gridSet2, equalTo(gridset)); }
@Test public void testTileFuserSuperset() throws Exception { TileLayer layer = createWMSLayer(); // request larger than -30.0,15.0,45.0,30 BoundingBox bounds = new BoundingBox(-35.0, 14.0, 55.0, 39); // One in between int width = (int) bounds.getWidth() * 25; int height = (int) bounds.getHeight() * 25; GridSubset gridSubset = layer.getGridSubset(layer.getGridSubsets().iterator().next()); TileLayerDispatcher tld = mock(TileLayerDispatcher.class); Mockito.when(tld.getTileLayer("test:layer")).thenReturn(layer); StorageBroker sb = mock(StorageBroker.class); WMSTileFuser tileFuser = new WMSTileFuser(tld, sb, fuserRequest(layer, gridSubset, bounds, width, height)); tileFuser.setSecurityDispatcher(secDisp); tileFuser.determineSourceResolution(); tileFuser.determineCanvasLayout(); }
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()); }
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()); }
public void testBuildTileRangeMask() throws Exception { GeometryRasterMaskBuilder tileRangeMask = buildSampleFilterMatrix(layer, gridsetId); assertNotNull(tileRangeMask); assertEquals(0, tileRangeMask.getStartLevel()); assertEquals(11, tileRangeMask.getNumLevels()); assertEquals( layer.getGridSubset(gridsetId).getCoverages().length, tileRangeMask.getNumLevels()); }
@Test public void testModifyLayer() throws GeoWebCacheException { String modifiedLayerName = GWCConfigIntegrationTestData.LAYER_TOPP_STATES; TileLayer layer = tileLayerDispatcher.getTileLayer(modifiedLayerName); layer.removeGridSubset(GWCConfigIntegrationTestData.GRIDSET_EPSG2163); boolean advertised = !layer.isAdvertised(); layer.setAdvertised(advertised); tileLayerDispatcher.modify(layer); TileLayer modifiedLayer = tileLayerDispatcher.getTileLayer(modifiedLayerName); assertEquals(layer, modifiedLayer); assertEquals(advertised, modifiedLayer.isAdvertised()); assertNull(modifiedLayer.getGridSubset(GWCConfigIntegrationTestData.GRIDSET_EPSG2163)); }