Show
Ignore:
Timestamp:
09/05/08 02:30:42 (4 months ago)
Author:
arneke
Message:

Hooking zoomStart and zoomStop up to grid object instead of layer. More robust at looking for geowebcache.xml

Files:
1 modified

Legend:

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

    r387 r388  
    6969    public GridCalculator(Grid grid) throws GeoWebCacheException { 
    7070 
    71         //TODO this is messed up, ignoring Grid object 
    7271        this.grid = grid; 
    73         this.zoomStart = 0; 
    74         this.zoomStop = 30; 
    75         //this.metaWidth = metaWidth; 
    76         //this.metaHeight = metaHeight; 
    77  
     72         
    7873        if(grid.resolutions != null) { 
    7974            this.resolutions = grid.resolutions; 
    8075            this.zoomStop = resolutions.length - 1; 
     76        } else { 
     77            this.zoomStart = grid.getZoomStart(); 
     78            this.zoomStop = grid.getZoomStop(); 
    8179        } 
    8280         
     
    9694    private void determineGrid() throws GeoWebCacheException { 
    9795        if(grid.resolutions == null) { 
    98             // Figure out the approriate resolutions 
     96            // Figure out the appropriate resolutions 
    9997             
    10098            double ratio = gridWidth / gridHeight; 
     
    152150        } 
    153151         
    154         this.resolutions = new double[this.zoomStop - this.zoomStart + 1]; 
     152        // We still need the full array, even though we only care about a part of it 
     153        this.resolutions = new double[this.zoomStop + 1]; 
    155154        for(int i=this.zoomStart; i<= this.zoomStop; i++) { 
    156155            this.resolutions[i] = baseResolution; 
     
    472471    private int binarySearchForResolution(double reqResolution)  
    473472    throws BadTileException { 
    474         return binarySearchForResolution(this.resolutions, reqResolution); 
    475     } 
    476      
    477     protected static int binarySearchForResolution(double[] resolutions, double reqResolution)  
     473        return binarySearchForResolution(this.resolutions, reqResolution, this.zoomStart); 
     474    } 
     475     
     476    protected static int binarySearchForResolution(double[] resolutions, double reqResolution, int zoomStart)  
    478477    throws BadTileException { 
    479         int low = 0; 
     478        int low = zoomStart; 
    480479        int high = resolutions.length - 1; 
    481480         
     
    485484         
    486485        // Deal with the edge cases first 
    487         if(reqLower > resolutions[1]) { 
     486        if(reqLower > resolutions[low]) { 
    488487            if(resolutions[0] < reqLower) { 
    489488                throw new BadTileException("Resolution "+reqResolution+" is too big for grid,"