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");
  }
Esempio n. 2
0
  private static String generateHTML(
      TileLayerDispatcher tileLayerDispatcher, GridSetBroker gridSetBroker)
      throws GeoWebCacheException {
    String reloadPath = "rest/reload";

    String header =
        "<html>\n"
            + ServletUtils.gwcHtmlHeader("GWC Demos")
            + "<body>\n"
            + ServletUtils.gwcHtmlLogoLink("")
            + "<table>\n"
            + "<table cellspacing=\"10\" border=\"0\">\n"
            + "<tr><td><strong>Layer name:</strong></td>\n"
            + "<td><strong>Enabled:</strong></td>\n"
            + "<td><strong>Grids Sets:</strong></td>\n"
            + "</tr>\n";

    String rows = tableRows(tileLayerDispatcher, gridSetBroker);

    String footer =
        "</table>\n"
            + "<br />"
            + "<strong>These are just quick demos. GeoWebCache also supports:</strong><br />\n"
            + "<ul><li>WMTS, TMS, Virtual Earth and Google Maps</li>\n"
            + "<li>Proxying GetFeatureInfo, GetLegend and other WMS requests</li>\n"
            + "<li>Advanced request and parameter filters</li>\n"
            + "<li>Output format adjustments, such as compression level</li>\n"
            + "<li>Adjustable expiration headers and automatic cache expiration</li>\n"
            + "<li>RESTful interface for seeding and configuration (beta)</li>\n"
            + "</ul>\n"
            + "<br />\n"
            + "<strong>Reload Configuration:</strong><br />\n"
            + "<p>You can reload the configuration by pressing the following button. "
            + "The username / password is configured in WEB-INF/user.properties, or the admin "
            + " user in GeoServer if you are using the plugin.</p>\n"
            + "<form form id=\"kill\" action=\""
            + reloadPath
            + "\" method=\"post\">"
            + "<input type=\"hidden\" name=\"reload_configuration\"  value=\"1\" />"
            + "<span><input style=\"padding: 0; margin-bottom: -12px; border: 1;\"type=\"submit\" value=\"Reload Configuration\"></span>"
            + "</form>"
            + "</body></html>";

    return header + rows + footer;
  }
Esempio n. 3
0
  public ConveyorTile getConveyor(HttpServletRequest request, HttpServletResponse response)
      throws ServiceException {
    Map<String, String[]> params = request.getParameterMap();

    String layerId = super.getLayersParameter(request);

    String encoding = request.getCharacterEncoding();

    String strQuadKey = ServletUtils.stringFromMap(params, encoding, "quadkey");
    String strFormat = ServletUtils.stringFromMap(params, encoding, "format");
    String strCached = ServletUtils.stringFromMap(params, encoding, "cached");
    String strMetaTiled = ServletUtils.stringFromMap(params, encoding, "metatiled");

    long[] gridLoc = VEConverter.convert(strQuadKey);

    MimeType mimeType = null;
    if (strFormat != null) {
      try {
        mimeType = MimeType.createFromFormat(strFormat);
      } catch (MimeException me) {
        throw new ServiceException("Unable to determined requested format, " + strFormat);
      }
    }

    ConveyorTile ret =
        new ConveyorTile(
            sb, layerId, gsb.WORLD_EPSG3857.getName(), gridLoc, mimeType, null, request, response);

    if (strCached != null && !Boolean.parseBoolean(strCached)) {
      ret.setRequestHandler(ConveyorTile.RequestHandler.SERVICE);
      if (strMetaTiled != null && !Boolean.parseBoolean(strMetaTiled)) {
        ret.setHint("not_cached,not_metatiled");
      } else {
        ret.setHint("not_cached");
      }
    }

    return ret;
  }
Esempio n. 4
0
  protected WMSTileFuser(TileLayerDispatcher tld, StorageBroker sb, HttpServletRequest servReq)
      throws GeoWebCacheException {
    this.sb = sb;

    String[] keys = {
      "layers", "format", "srs", "bbox", "width", "height", "transparent", "bgcolor"
    };

    Map<String, String> values =
        ServletUtils.selectedStringsFromMap(
            servReq.getParameterMap(), servReq.getCharacterEncoding(), keys);

    // TODO Parameter filters?

    String layerName = values.get("layers");
    layer = tld.getTileLayer(layerName);

    List<MimeType> ml = layer.getMimeTypes();
    Iterator<MimeType> iter = ml.iterator();
    while (iter.hasNext()) {
      MimeType mt = iter.next();
      if (mt.getInternalName().equalsIgnoreCase("png")) {
        this.srcFormat = (ImageMime) mt;
      }
    }

    gridSubset = layer.getGridSubsetForSRS(SRS.getSRS(values.get("srs")));

    outputFormat = (ImageMime) ImageMime.createFromFormat(values.get("format"));

    reqBounds = new BoundingBox(values.get("bbox"));

    reqWidth = Integer.valueOf(values.get("width"));

    reqHeight = Integer.valueOf(values.get("height"));

    // if(values[6] != null) {
    // this.reqTransparent = Boolean.valueOf(values[6]);
    // }

    // if(values[7] != null) {
    // this.reqBgColor = values[7];
    // }

    fullParameters =
        layer.getModifiableParameters(servReq.getParameterMap(), servReq.getCharacterEncoding());
  }
  protected WMTSGetCapabilities(
      TileLayerDispatcher tld, GridSetBroker gsb, HttpServletRequest servReq) {
    this.tld = tld;
    this.gsb = gsb;

    baseUrl =
        ServletUtils.stringFromMap(
            servReq.getParameterMap(), servReq.getCharacterEncoding(), "base_url");

    // This should prevent anyone from passing in anything nasty
    if (baseUrl != null) {
      baseUrl = encodeXmlChars(baseUrl);
    }

    if (baseUrl == null || baseUrl.length() == 0) {
      baseUrl = servReq.getRequestURL().toString();
    }
  }
  protected WMSGetCapabilities(
      TileLayerDispatcher tld,
      HttpServletRequest servReq,
      String baseUrl,
      String contextPath,
      URLMangler urlMangler) {
    this.tld = tld;

    urlStr =
        urlMangler.buildURL(baseUrl, contextPath, WMSService.SERVICE_PATH) + "?SERVICE=WMS&amp;";

    String[] tiledKey = {"TILED"};
    Map<String, String> tiledValue =
        ServletUtils.selectedStringsFromMap(
            servReq.getParameterMap(), servReq.getCharacterEncoding(), tiledKey);

    if (tiledValue != null && tiledValue.size() > 0) {
      includeVendorSpecific = Boolean.parseBoolean(tiledValue.get("TILED"));
    }
  }
Esempio n. 7
0
  public static void makeMap(
      TileLayerDispatcher tileLayerDispatcher,
      GridSetBroker gridSetBroker,
      String action,
      HttpServletRequest request,
      HttpServletResponse response)
      throws GeoWebCacheException {

    String page = null;

    // Do we have a layer, or should we make a list?
    if (action != null) {
      String layerName = ServletUtils.URLDecode(action, request.getCharacterEncoding());

      TileLayer layer = tileLayerDispatcher.getTileLayer(layerName);

      String rawGridSet = request.getParameter("gridSet");
      String gridSetStr = null;
      if (rawGridSet != null)
        gridSetStr = ServletUtils.URLDecode(rawGridSet, request.getCharacterEncoding());

      if (gridSetStr == null) {
        gridSetStr = request.getParameter("srs");

        if (gridSetStr == null) {
          gridSetStr = layer.getGridSubsets().iterator().next();
        }
      }

      String formatStr = request.getParameter("format");

      if (formatStr != null) {
        if (!layer.supportsFormat(formatStr)) {
          throw new GeoWebCacheException("Unknow or unsupported format " + formatStr);
        }
      } else {
        formatStr = layer.getDefaultMimeType().getFormat();
      }

      if (request.getPathInfo().startsWith("/demo")) {
        // Running in GeoServer
        page = generateHTML(layer, gridSetStr, formatStr, true);
      } else {
        page = generateHTML(layer, gridSetStr, formatStr, false);
      }

    } else {
      if (request.getRequestURI().endsWith("/")) {
        try {
          String reqUri = request.getRequestURI();
          response.sendRedirect(
              response.encodeRedirectURL(reqUri.substring(0, reqUri.length() - 1)));
        } catch (IOException e) {
          e.printStackTrace();
        }
        return;
      } else {
        page = generateHTML(tileLayerDispatcher, gridSetBroker);
      }
    }
    response.setContentType("text/html");
    response.setCharacterEncoding("UTF-8");

    try {
      response.getOutputStream().write(page.getBytes());
    } catch (IOException ioe) {
      throw new GeoWebCacheException("failed to render HTML");
    }
  }