Examples of GridSubset


Examples of org.geowebcache.grid.GridSubset

   
    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"
View Full Code Here

Examples of org.geowebcache.grid.GridSubset

     */
    public GridSubset getGridSubsetForSRS(SRS srs) {
        Map<String, GridSubset> gridSubsets = getGridSubsets();
        Iterator<GridSubset> iter = gridSubsets.values().iterator();
        while (iter.hasNext()) {
            GridSubset gridSubset = iter.next();
            if (gridSubset.getSRS().equals(srs)) {
                return gridSubset;
            }
        }

        return null;
View Full Code Here

Examples of org.geowebcache.grid.GridSubset

     */
    protected void saveTiles(MetaTile metaTile, ConveyorTile tileProto) 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

Examples of org.geowebcache.grid.GridSubset

        String[] urls = { "http://localhost:38080/wms" };
        List<String> formatList = Collections.singletonList(format);

        Hashtable<String, GridSubset> grids = new Hashtable<String, GridSubset>();

        GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.WORLD_EPSG4326,
                boundingBox, 0, 10);

        grids.put(grid.getName(), grid);
        int[] metaWidthHeight = { metaTileFactorX, metaTileFactorY };

        WMSLayer layer = new WMSLayer("test:layer", urls, "aStyle", "test:layer", formatList,
                grids, null, metaWidthHeight, "vendorparam=true", false);
View Full Code Here

Examples of org.geowebcache.grid.GridSubset

        /*
         * Call the seed process
         */
        task.doAction();

        final GridSubset gridSubset = tl.getGridSubset(gridSetId);

        /*
         * Make sure the seed process asked for the expected tiles to be stored
         */
        final long expectedSavedTileCount;

        final long[] coveredGridLevels = gridSubset.getCoverage(zoomLevel);

        // seeding should not include edge tiles produced by the meta tiling that don't fall into
        // the gridsubset's coverage
        long starty = coveredGridLevels[1];
        long startx = coveredGridLevels[0];
View Full Code Here

Examples of org.geowebcache.grid.GridSubset

        String[] urls = { "http://localhost:38080/wms" };
        List<String> formatList = Collections.singletonList(format);

        Hashtable<String, GridSubset> grids = new Hashtable<String, GridSubset>();

        GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.WORLD_EPSG4326,
                new BoundingBox(-30.0, 15.0, 45.0, 30), 0, 10);

        grids.put(grid.getName(), grid);
        int[] metaWidthHeight = { 3, 3 };

        WMSLayer layer = new WMSLayer("test:layer", urls, "aStyle", "test:layer", formatList,
                grids, null, metaWidthHeight, "vendorparam=true", false);
View Full Code Here

Examples of org.geowebcache.grid.GridSubset

            tileH = conveyorTile.getGridSubset().getTileHeight();
        } else {
            WMSMetaTile metaTile = (WMSMetaTile) tileRespRecv;
            tiles = metaTile.getTilesGridPositions();
            format = metaTile.getResponseFormat().getInternalName().toUpperCase();
            GridSubset gridSubset = layer.getGridSubsets().values().iterator().next();
            tileW = gridSubset.getTileWidth();
            tileH = gridSubset.getTileHeight();
        }
        int width = Integer.parseInt(wmsParams.get("WIDTH"));
        int height = Integer.parseInt(wmsParams.get("HEIGHT"));
        int tilesX = width / tileW;
        int tilesY = height / tileH;
View Full Code Here

Examples of org.geowebcache.grid.GridSubset

        String[] urls = { "http://localhost:38080/wms" };
        List<String> formatList = Collections.singletonList(format);

        Hashtable<String, GridSubset> grids = new Hashtable<String, GridSubset>();

        GridSubset grid = GridSubsetFactory.createGridSubSet(gridSetBroker.WORLD_EPSG4326,
                new BoundingBox(-30.0, 15.0, 45.0, 30), 0, 10);

        grids.put(grid.getName(), grid);
        int[] metaWidthHeight = { 3, 3 };

        WMSLayer layer = new WMSLayer("test:layer", urls, "aStyle", "test:layer", formatList,
                grids, null, metaWidthHeight, "vendorparam=true", false);
View Full Code Here

Examples of org.geowebcache.grid.GridSubset

     */
    private void mockSeed(TileLayer layer, int numFiles, int fileSize) throws MimeException,
            IOException {
        final String layerName = layer.getName();

        final GridSubset gridSubset = layer.getGridSubsets().values().iterator().next();
        final String gridSetId = gridSubset.getName();
        final String prefix = this.rootCacheDir.getAbsolutePath();
        final MimeType mimeType = MimeType.createFromFormat("image/png");
        final long parameters_id = -1;

        final byte[] mockTileContents = new byte[fileSize];
        Arrays.fill(mockTileContents, (byte) 0xFF);

        // just to control the same tile is not created more than once
        Set<String> addedTiles = new HashSet<String>();

        long[] tileIndex;
        while (addedTiles.size() < numFiles) {
            int level = (int) (gridSubset.getZoomStart() + ((gridSubset.getZoomStop() - gridSubset
                    .getZoomStart()) * Math.random()));

            String tileKey = null;
            File tilePath;
            do {
                long[] coverage = gridSubset.getCoverage(level);// {minx,miny,maxx,maxy,z}
                long x = (long) (coverage[0] + ((coverage[2] - coverage[0]) * Math.random()));
                long y = (long) (coverage[1] + ((coverage[3] - coverage[1]) * Math.random()));
                tileIndex = new long[] { x, y, level };
                tilePath = FilePathGenerator.tilePath(prefix, layerName, tileIndex, gridSetId,
                        mimeType, parameters_id);
View Full Code Here

Examples of org.geowebcache.grid.GridSubset

    public void test1MetaTile() throws Exception {
        BoundingBox bbox = new BoundingBox(0, 0, 180, 90);
        int metaHeight = 1;
        int metaWidth = 1;

        GridSubset grid = GridSubsetFactory.createGridSubSet(
                gridSetBroker.WORLD_EPSG4326,
                bbox,
                0,
                30);
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.