Package org.geowebcache.grid

Examples of org.geowebcache.grid.GridSubset


  
        if(tl == null) {
            throw new RestletException(layerName + " is not known", Status.CLIENT_ERROR_NOT_FOUND);
        }
       
        GridSubset grid = tl.getGridSubset(gridSetId);
       
        if(grid == null) {
            throw new RestletException(layerName + " does not support " + gridSetId, Status.CLIENT_ERROR_NOT_FOUND);
        }
       
        StringBuilder str = new StringBuilder();
        long[][] bounds = grid.getCoverages();
       
        if(type.equalsIgnoreCase("java")) {
            str.append("{");
            for(int i=0; i<bounds.length; i++) {
                str.append("{");
View Full Code Here


    }

    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");
        }

    }
View Full Code Here

        int minStart = Integer.MAX_VALUE;
        int maxStop = Integer.MIN_VALUE;

        for (String gridSetId : tl.getGridSubsets()) {
            GridSubset subset = tl.getGridSubset(gridSetId);

            int start = subset.getZoomStart();
            int stop = subset.getZoomStop();

            if (start < minStart) {
                minStart = start;
            }
            if (stop > maxStop) {
View Full Code Here

            buf.append("</td><td>" + layer.isEnabled() + "</td>");
            buf.append("<td><table width=\"100%\">");

            int count = 0;
            for (String gridSetId : layer.getGridSubsets()) {
                GridSubset gridSubset = layer.getGridSubset(gridSetId);
                String gridSetName = gridSubset.getName();
                if (gridSetName.length() > 20) {
                    gridSetName = gridSetName.substring(0, 20) + "...";
                }
                buf.append("<tr><td style=\"width: 170px;\">").append(gridSetName);

                buf.append("</td><td>OpenLayers: [");
                Iterator<MimeType> mimeIter = layer.getMimeTypes().iterator();
                boolean prependComma = false;
                while (mimeIter.hasNext()) {
                    MimeType mime = mimeIter.next();
                    if (mime instanceof ImageMime) {
                        if (prependComma) {
                            buf.append(", ");
                        } else {
                            prependComma = true;
                        }
                        buf.append(generateDemoUrl(layer.getName(), gridSubset.getName(),
                                (ImageMime) mime));
                    }
                }
                buf.append("]</td><td>\n");

                if (gridSubset.getName().equals(gridSetBroker.WORLD_EPSG4326.getName())) {
                    buf.append(" &nbsp; KML: [");
                    String prefix = "";
                    prependComma = false;
                    Iterator<MimeType> kmlIter = layer.getMimeTypes().iterator();
                    while (kmlIter.hasNext()) {
View Full Code Here

    private static String generateHTML(TileLayer layer, String gridSetStr, String formatStr,
            boolean asPlugin) throws GeoWebCacheException {
        String layerName = layer.getName();

        GridSubset gridSubset = layer.getGridSubset(gridSetStr);

        BoundingBox bbox = gridSubset.getGridSetBounds();
        BoundingBox zoomBounds = gridSubset.getOriginalExtent();

        String res = "resolutions: " + Arrays.toString(gridSubset.getResolutions()) + ",\n";

        String units = "units: \"" + gridSubset.getGridSet().guessMapUnits() + "\",\n";

        String openLayersPath;
        if (asPlugin) {
            openLayersPath = "../../openlayers/OpenLayers.js";
        } else {
            openLayersPath = "../openlayers/OpenLayers.js";
        }

        String page = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>\n"
                + "<meta http-equiv=\"imagetoolbar\" content=\"no\">\n" + "<title>"
                + layerName
                + " "
                + gridSubset.getName()
                + " "
                + formatStr
                + "</title>\n"
                + "<style type=\"text/css\">\n"
                + "body { font-family: sans-serif; font-weight: bold; font-size: .8em; }\n"
                + "body { border: 0px; margin: 0px; padding: 0px; }\n"
                + "#map { width: 85%; height: 85%; border: 0px; padding: 0px; }\n"
                + "</style>\n"

                + "<script src=\""
                + openLayersPath
                + "\"></script>    \n"
                + "<script type=\"text/javascript\">               \n"
                + "var map, demolayer;                               \n"
                + "  // sets the chosen modifiable parameter        \n"
                + "  function setParam(name, value){                \n"
                + "   str = \"demolayer.mergeNewParams({\" + name + \": '\" + value + \"'})\" \n"
                + "   // alert(str);                                   \n"
                + "   eval(str);                                    \n"
                + "  }                                              \n"

                + "OpenLayers.DOTS_PER_INCH = "
                + gridSubset.getDotsPerInch()
                + ";\n"
                + "OpenLayers.Util.onImageLoadErrorColor = 'transparent';\n"

                + "function init(){\n"
                + "var mapOptions = { \n"
                + res
                + "projection: new OpenLayers.Projection('"
                + gridSubset.getSRS().toString()
                + "'),\n"
                + "maxExtent: new OpenLayers.Bounds("
                + bbox.toString()
                + "),\n"
                + units
                + "controls: []\n"
                + "};\n"
                + "map = new OpenLayers.Map('map', mapOptions );\n"
                + "map.addControl(new OpenLayers.Control.PanZoomBar({\n"
                + "    position: new OpenLayers.Pixel(2, 15)\n"
                + "}));\n"
                + "map.addControl(new OpenLayers.Control.Navigation());\n"
                + "map.addControl(new OpenLayers.Control.Scale($('scale')));\n"
                + "map.addControl(new OpenLayers.Control.MousePosition({element: $('location')}));\n"
                + "demolayer = new OpenLayers.Layer.WMS(\n"
                + "\""
                + layerName
                + "\",\"../service/wms\",\n"
                + "{layers: '"
                + layerName
                + "', format: '"
                + formatStr
                + "' },\n"
                + "{ tileSize: new OpenLayers.Size("
                + gridSubset.getTileWidth() + "," + gridSubset.getTileHeight() + ")";

        /*
         * If the gridset has a top left tile origin, lets tell that to open layers. Otherwise it'll
         * calculate tile bounds based on the bbox bottom left corner, leading to misaligned
         * requests.
         */
        GridSet gridSet = gridSubset.getGridSet();
        if (gridSet.isTopLeftAligned()) {
            page += ",\n tileOrigin: new OpenLayers.LonLat(" + bbox.getMinX() + ", "
                    + bbox.getMaxY() + ")";
        }

        page += "});\n" + "map.addLayer(demolayer);\n" + "map.zoomToExtent(new OpenLayers.Bounds("
                + zoomBounds.toString()
                + "));\n"
                + "// The following is just for GetFeatureInfo, which is not cached. Most people do not need this \n"
                + "map.events.register('click', map, function (e) {\n"
                + "  document.getElementById('nodelist').innerHTML = \"Loading... please wait...\";\n"
                + "  var params = {\n" + "    REQUEST: \"GetFeatureInfo\",\n"
                + "    EXCEPTIONS: \"application/vnd.ogc.se_xml\",\n"
                + "    BBOX: map.getExtent().toBBOX(),\n" + "    X: e.xy.x,\n" + "    Y: e.xy.y,\n"
                + "    INFO_FORMAT: 'text/html',\n"
                + "    QUERY_LAYERS: map.layers[0].params.LAYERS,\n" + "    FEATURE_COUNT: 50,\n"
                + "    Layers: '" + layerName + "',\n" + "    Styles: '',\n" + "    Srs: '"
                + gridSubset.getSRS().toString() + "',\n" + "    WIDTH: map.size.w,\n"
                + "    HEIGHT: map.size.h,\n" + "    format: \"" + formatStr + "\" };\n"
                + "  OpenLayers.loadURL(\"../service/wms\", params, this, setHTML, setHTML);\n"
                + "  OpenLayers.Event.stop(e);\n" + "  });\n" + "}\n"
                + "function setHTML(response){\n"
                + "    document.getElementById('nodelist').innerHTML = response.responseText;\n"
View Full Code Here

     * @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;
View Full Code Here

     */
    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);
View Full Code Here

     */
    protected void saveTiles(MetaTile metaTile, ConveyorTile tileProto, long requestTime) throws GeoWebCacheException {

        final long[][] gridPositions = metaTile.getTilesGridPositions();
        final long[] gridLoc = tileProto.getTileIndex();
        final GridSubset gridSubset = getGridSubset(tileProto.getGridSetId());

        final int zoomLevel = (int) gridLoc[2];
        final boolean store = this.getExpireCache(zoomLevel) != GWCVars.CACHE_DISABLE_CACHE;

        Resource resource;
        boolean encode;
        for (int i = 0; i < gridPositions.length; i++) {
            final long[] gridPos = gridPositions[i];
            if (Arrays.equals(gridLoc, gridPos)) {
                // Is this the one we need to save? then don't use the buffer or it'll be overridden
                // by the next tile
                resource = getImageBuffer(WMS_BUFFER2);
                tileProto.setBlob(resource);
                encode = true;
            } else {
                resource = getImageBuffer(WMS_BUFFER);
                encode = store;
            }

            if (encode) {
                if (!gridSubset.covers(gridPos)) {
                    // edge tile outside coverage, do not store it
                    continue;
                }

                try {
View Full Code Here

        // str.append("    <ResourceURL format=\"image/png\" resourceType=\"tile\" template=\"http://www.maps.cat/wmts/BlueMarbleNextGeneration/default/BigWorldPixel/{TileMatrix}/{TileRow}/{TileCol}.png\"/>\n");
        xml.endElement("Layer");
    }
    
    private void layerWGS84BoundingBox(XMLBuilder xml, TileLayer layer) throws IOException {
        GridSubset subset = layer.getGridSubsetForSRS(SRS.getEPSG4326());
        if(subset != null) {
            double[] coords = subset.getOriginalExtent().getCoords();
            xml.indentElement("ows:WGS84BoundingBox");
            xml.simpleElement("ows:LowerCorner", coords[0]+" "+coords[1], true);
            xml.simpleElement("ows:UpperCorner", coords[2]+" "+coords[3], true);
            xml.endElement("ows:WGS84BoundingBox");  
        }
View Full Code Here

    
     
     private void layerGridSubSets(XMLBuilder xml, TileLayer layer) throws IOException {

        for (String gridSetId : layer.getGridSubsets()) {
            GridSubset gridSubset = layer.getGridSubset(gridSetId);
        
             xml.indentElement("TileMatrixSetLink");
             xml.simpleElement("TileMatrixSet", gridSubset.getName(), true);
            
             if (! gridSubset.fullGridSetCoverage()) {
                String[] levelNames = gridSubset.getGridNames();
                long[][] wmtsLimits = gridSubset.getWMTSCoverages();

                xml.indentElement("TileMatrixSetLimits");
                for (int i = 0; i < levelNames.length; i++) {
                    xml.indentElement("TileMatrixLimits");
                    xml.simpleElement("TileMatrix", levelNames[i], true);
View Full Code Here

TOP

Related Classes of org.geowebcache.grid.GridSubset

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.