Changeset 389

Show
Ignore:
Timestamp:
09/06/08 22:09:30 (2 months ago)
Author:
arneke
Message:

More sane handling of zoomStart, generate all resolutions even though we'll only use some.

Location:
trunk/geowebcache/src/main/java/org/geowebcache
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/geowebcache/src/main/java/org/geowebcache/layer/Grid.java

    r388 r389  
    1717package org.geowebcache.layer; 
    1818 
    19 import java.util.List; 
    20  
     19import org.apache.commons.logging.Log; 
     20import org.apache.commons.logging.LogFactory; 
    2121import org.geowebcache.GeoWebCacheException; 
    2222import org.geowebcache.util.wms.BBOX; 
    23 import org.mortbay.log.Log; 
    2423 
    2524/** 
     
    2827 
    2928public class Grid { 
     29    private static Log log = LogFactory.getLog(org.geowebcache.layer.Grid.class); 
     30 
    3031    private SRS srs = null; 
    3132     
     
    144145    private GridCalculator initGridCalculator() throws GeoWebCacheException { 
    145146        if(zoomStart < 0 || zoomStop < zoomStart || zoomStop == 0) { 
    146             Log.debug("Missing values, setting zoomStart,zoomStop to 0,30"); 
     147            log.debug("Missing values, setting zoomStart,zoomStop to 0,30"); 
    147148            zoomStart = 0; 
    148149            zoomStop = 30; 
  • trunk/geowebcache/src/main/java/org/geowebcache/layer/GridCalculator.java

    r388 r389  
    5050     
    5151    private double[] resolutions; 
    52      
    53     // The following are for a tile, zoomed out all the way 
    54     //private double maxTileWidth; 
    55  
    56     //private double maxTileHeight; 
    5752 
    5853    private int zoomStart; 
    5954 
    6055    private int zoomStop; 
    61      
    62     // Special treatment of "zoomed out tile" for EPSG 4326 
    63     //private boolean worldBoundsCoverTwoTiles = false; 
    6456 
    6557    private int[] zoomedOutGridLoc = null; 
     
    151143         
    152144        // We still need the full array, even though we only care about a part of it 
    153         this.resolutions = new double[this.zoomStop + 1]; 
    154         for(int i=this.zoomStart; i<= this.zoomStop; i++) { 
    155             this.resolutions[i] = baseResolution; 
     145        resolutions = new double[this.zoomStop + 1]; 
     146        for(int i=0; i<= this.zoomStop; i++) { 
     147            resolutions[i] = baseResolution; 
    156148            baseResolution = baseResolution / 2; 
    157149        } 
     
    163155        // We'll just waste a few bytes, for cheap lookups 
    164156        int[][] gridLevels = new int[zoomStop + 1][4]; 
    165  
    166         //int tileCountX = (int) Math.round(gridWidth / resolutions[0]); 
    167         //int tileCountY = (int) Math.round(gridHeight / resolutions[0]); 
    168  
    169         //int metaLarger = (metaHeight > metaWidth) ? metaHeight : metaWidth; 
    170  
    171         //System.out.println("lb: " +layerBounds+ " base:" + 
    172         //  " tileWidth: " + tileWidth); 
    173157 
    174158        double[] rawNumber = new double[4]; 
     
    196180            rawNumber[3] = (layerBounds.coords[3] - gridBounds.coords[1] - 0.00001) / tileDelta; 
    197181            gridLevels[level][3] = (int) Math.floor(rawNumber[3]); 
    198  
    199             //System.out.println(Arrays.toString(rawNumber) + " "+ Arrays.toString(gridLevels[level])); 
    200             //System.out.println("postOrig: " + 
    201             //        ); 
    202             // 
    203             //System.out.println("tileCountX "+tileCountX + " metaLarger: " 
    204             // + metaLarger); 
    205  
    206             //tileCountX = tileCountX * 2; 
    207             //tileCountY = tileCountY * 2; 
    208182        } 
    209183        return gridLevels; 
     
    239213 
    240214        double reqTileWidth = tileBounds.coords[2] - tileBounds.coords[0]; 
    241  
    242         //Arrays.binarySearch(a, key) 
    243         //double zoomLevel = Math.log(gridWidth / reqTileWidth) / Math.log(2); 
    244          
    245         //long roundedZoomLevel = Math.round(zoomLevel); 
    246  
    247215         
    248216        // (Z) Zoom level 
    249217        // For EPSG 4326, reqTileWidth = 0.087 log(4096) / log(2) - 1; -> 11 
    250218        retVals[2] = this.binarySearchForResolution(reqTileWidth / GridCalculator.TILEPIXELS); 
     219         
     220        if(retVals[2] < zoomStart) { 
     221            throw new BadTileException("zoomStart is " + zoomStart  
     222                    + " but tile would be " + retVals[2]); 
     223        } 
    251224 
    252225        double tileWidth = resolutions[retVals[2]] * GridCalculator.TILEPIXELS; 
     
    458431    public double[] getResolutions() { 
    459432        return resolutions; 
    460         //double[] ret = new double[zoomStop - zoomStart + 1]; 
    461         //double tileWidth = maxTileWidth / widthPixels; 
    462          
    463         //for(int i=0; i<ret.length; i++) { 
    464         //    ret[i] = tileWidth; 
    465         //    tileWidth = tileWidth / 2; 
    466        // } 
    467          
    468         //return ret; 
    469433    } 
    470434     
    471435    private int binarySearchForResolution(double reqResolution)  
    472436    throws BadTileException { 
    473         return binarySearchForResolution(this.resolutions, reqResolution, this.zoomStart); 
    474     } 
    475      
    476     protected static int binarySearchForResolution(double[] resolutions, double reqResolution, int zoomStart)  
     437        return binarySearchForResolution(this.resolutions, reqResolution); 
     438    } 
     439     
     440    protected static int binarySearchForResolution(double[] resolutions, double reqResolution)  
    477441    throws BadTileException { 
    478         int low = zoomStart; 
     442        int low = 0; 
    479443        int high = resolutions.length - 1; 
    480444         
     
    484448         
    485449        // Deal with the edge cases first 
    486         if(reqLower > resolutions[low]) { 
     450        if(resolutions[low] < reqUpper) { 
    487451            if(resolutions[0] < reqLower) { 
    488452                throw new BadTileException("Resolution "+reqResolution+" is too big for grid," 
    489453                        +" biggest supported is " + resolutions[0]); 
    490454            } 
    491             return 0; 
    492         } 
    493          
    494         if(reqUpper < resolutions[high - 1]) { 
     455            return low; 
     456        } 
     457         
     458        if(resolutions[high] > reqLower) { 
    495459            if(resolutions[high] / 1.5 > reqUpper) { 
    496460                throw new BadTileException("Resolution "+reqResolution+" is too small for grid," 
  • trunk/geowebcache/src/main/java/org/geowebcache/rest/SeedResource.java

    r384 r389  
    182182        if(null == rq.getThreadCount()  
    183183                || rq.getThreadCount() < 1  
    184                 || type.equalsIgnoreCase("seed")) { 
     184                || type.equalsIgnoreCase("truncate")) { 
    185185            threadCount = 1; 
    186186        } else { 
  • trunk/geowebcache/src/main/java/org/geowebcache/rest/SeedTask.java

    r370 r389  
    6969            } 
    7070            SRS srs = req.getSRS(); 
     71            if(srs == null) { 
     72                srs = tl.getGrids().entrySet().iterator().next().getKey(); 
     73            } 
     74             
    7175            BBOX bounds = req.getBounds(); 
     76            if(bounds == null) { 
     77                bounds = tl.getGrid(srs).getBounds(); 
     78            } 
    7279 
    7380            int[][] coveredGridLevels = tl.getCoveredGridLevels(srs,bounds);