/** * Handles the encoding of the layers elements. * * <p>This method does a search over the SRS of all the layers to see if there are at least a * common one, as needed by the spec: "<i>The root Layer element shall include a sequence of * zero or more <SRS> elements listing all SRSes that are common to all subsidiary layers. * Use a single SRS element with empty content (like so: "<SRS></SRS>") if there is * no common SRS."</i> * * <p>By the other hand, this search is also used to collecto the whole latlon bbox, as stated * by the spec: <i>"The bounding box metadata in Capabilities XML specify the minimum enclosing * rectangle for the layer as a whole."</i> * * @task TODO: manage this differently when we have the layer list of the WMS service decoupled * from the feature types configured for the server instance. (This involves nested layers, * gridcoverages, etc) */ private void handleLayers() { start("Layer"); final List<LayerInfo> layers; // filter the layers if a namespace filter has been set if (request.getNamespace() != null) { final List<LayerInfo> allLayers = wmsConfig.getLayers(); layers = new ArrayList<LayerInfo>(); String namespace = wmsConfig.getNamespaceByPrefix(request.getNamespace()); for (LayerInfo layer : allLayers) { Name name = layer.getResource().getQualifiedName(); if (name.getNamespaceURI().equals(namespace)) { layers.add(layer); } } } else { layers = wmsConfig.getLayers(); } WMSInfo serviceInfo = wmsConfig.getServiceInfo(); element("Title", serviceInfo.getTitle()); element("Abstract", serviceInfo.getAbstract()); List<String> srsList = serviceInfo.getSRS(); Set<String> srs = new HashSet<String>(); if (srsList != null) { srs.addAll(srsList); } handleRootCrsList(srs); handleRootBbox(layers); // now encode each layer individually LayerTree featuresLayerTree = new LayerTree(layers); handleLayerTree(featuresLayerTree); try { List<LayerGroupInfo> layerGroups = wmsConfig.getLayerGroups(); handleLayerGroups(new ArrayList<LayerGroupInfo>(layerGroups)); } catch (FactoryException e) { throw new RuntimeException("Can't obtain Envelope of Layer-Groups: " + e.getMessage(), e); } catch (TransformException e) { throw new RuntimeException("Can't obtain Envelope of Layer-Groups: " + e.getMessage(), e); } end("Layer"); }
/** * @see * org.geoserver.wms.ExtendedCapabilitiesProvider#encode(org.geoserver.wms.ExtendedCapabilitiesProvider.Translator, * org.geoserver.wms.WMSInfo, org.geotools.util.Version) */ public void encode(final Translator tx, final WMSInfo wms, final GetCapabilitiesRequest request) throws IOException { Version version = WMS.version(request.getVersion(), true); if (!WMS.VERSION_1_1_1.equals(version) || !isTiled(request)) { return; } String namespacePrefixFilter = request.getNamespace(); Iterable<TileLayer> tileLayers = gwc.getTileLayersByNamespacePrefix(namespacePrefixFilter); for (TileLayer layer : tileLayers) { Set<String> layerGrids = layer.getGridSubsets(); for (String gridId : layerGrids) { GridSubset grid = layer.getGridSubset(gridId); for (MimeType mime : layer.getMimeTypes()) { vendorSpecificTileset(tx, layer, grid, mime.getFormat()); } } } }