private void contents(StringBuilder str) {
    str.append("<Contents>\n");
    Iterable<TileLayer> iter = tld.getLayerList();
    for (TileLayer layer : iter) {
      if (!layer.isEnabled()) {
        continue;
      }
      layer(str, layer, baseUrl);
    }

    for (GridSet gset : gsb.getGridSets()) {
      tileMatrixSet(str, gset);
    }

    str.append("</Contents>\n");
  }
Example #2
0
  private void mockTileLayerDispatcher() throws Exception {
    when(tld.getConfiguration(same(tileLayer))).thenReturn(config);
    when(tld.getConfiguration(same(tileLayerGroup))).thenReturn(config);
    when(tld.getConfiguration(eq(tileLayer.getName()))).thenReturn(config);
    when(tld.getConfiguration(eq(tileLayerGroup.getName()))).thenReturn(config);

    when(tld.getTileLayer(eq(tileLayer.getName()))).thenReturn(tileLayer);
    when(tld.getTileLayer(eq(tileLayerGroup.getName()))).thenReturn(tileLayerGroup);

    when(tld.getLayerNames())
        .thenReturn(ImmutableSet.of(tileLayer.getName(), tileLayerGroup.getName()));
    Iterable<TileLayer> tileLayers =
        ImmutableList.of((TileLayer) tileLayer, (TileLayer) tileLayerGroup);
    when(tld.getLayerList()).thenReturn(tileLayers);

    when(tld.layerExists(eq(tileLayer.getName()))).thenReturn(true);
    when(tld.layerExists(eq(tileLayerGroup.getName()))).thenReturn(true);
  }
  private void capabilityRequestGetFeatureInfo(StringBuilder str) {

    // Find all the info formats we support
    Iterable<TileLayer> layerIter = tld.getLayerList();

    HashSet<String> formats = new HashSet<String>();

    for (TileLayer layer : layerIter) {
      if (!layer.isEnabled()) {
        continue;
      }
      if (layer.getMimeTypes() != null) {
        Iterator<MimeType> mimeIter = layer.getInfoMimeTypes().iterator();
        while (mimeIter.hasNext()) {
          MimeType mime = mimeIter.next();
          formats.add(mime.getFormat());
        }
      } else {
        formats.add("text/plain");
        formats.add("text/html");
        formats.add("application/vnd.ogc.gml");
      }
    }

    str.append("    <GetFeatureInfo>\n");
    Iterator<String> formatIter = formats.iterator();
    while (formatIter.hasNext()) {
      str.append("      <Format>" + formatIter.next() + "</Format>\n");
    }
    str.append("      <DCPType>\n");
    str.append("        <HTTP>\n");
    str.append("        <Get>\n");
    str.append(
        "          <OnlineResource xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:type=\"simple\" xlink:href=\""
            + urlStr
            + "\"/>\n");
    str.append("        </Get>\n");
    str.append("        </HTTP>\n");
    str.append("      </DCPType>\n");
    str.append("    </GetFeatureInfo>\n");
  }
  private void capabilityLayerOuter(StringBuilder str) {
    str.append("  <Layer>\n");
    str.append("    <Title>GeoWebCache WMS</Title>\n");
    str.append(
        "    <Abstract>Note that not all GeoWebCache instances provide a full WMS service.</Abstract>\n");
    str.append(
        "    <LatLonBoundingBox minx=\"-180.0\" miny=\"-90.0\" maxx=\"180.0\" maxy=\"90.0\"/>\n");

    Iterable<TileLayer> layerIter = tld.getLayerList();
    for (TileLayer layer : layerIter) {
      if (!layer.isEnabled()) {
        continue;
      }
      try {
        capabilityLayerInner(str, layer);
      } catch (GeoWebCacheException e) {
        log.error(e.getMessage());
      }
    }

    str.append("  </Layer>\n");
  }
  private void capabilityVendorSpecific(StringBuilder str) {
    str.append("  <VendorSpecificCapabilities>\n");
    Iterable<TileLayer> layerIter = tld.getLayerList();
    for (TileLayer layer : layerIter) {
      if (!layer.isEnabled()) {
        continue;
      }

      for (String gridSetId : layer.getGridSubsets()) {
        GridSubset grid = layer.getGridSubset(gridSetId);

        List<String> formats = new ArrayList<String>(2);

        if (layer.getMimeTypes() != null) {
          for (MimeType mime : layer.getMimeTypes()) {
            formats.add(mime.getFormat());
          }
        } else {
          formats.add(ImageMime.png.getFormat());
          formats.add(ImageMime.jpeg.getFormat());
        }

        List<String> styles = getStyles(layer.getParameterFilters());
        for (String format : formats) {
          for (String style : styles) {
            try {
              capabilityVendorSpecificTileset(str, layer, grid, format, style);
            } catch (GeoWebCacheException e) {
              log.error(e.getMessage());
            }
          }
        }
      }
    }
    str.append("  </VendorSpecificCapabilities>\n");
  }