Changeset 422

Show
Ignore:
Timestamp:
11/12/08 17:43:08 (8 weeks ago)
Author:
arneke
Message:

Fixes for truncation, still need to write unit tests and straighten out a few nails

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

Legend:

Unmodified
Added
Removed
  • trunk/geowebcache/src/main/java/org/geowebcache/cache/file/FilePathKey2.java

    r418 r422  
    8787        if (number > 9) { 
    8888            if(number > 11) { 
    89                 numberOrder = (int) Math.ceil(Math.log10(number) - 0.01); 
     89                numberOrder = (int) Math.ceil(Math.log10(number) - 0.02); 
    9090            } else { 
    9191                numberOrder = 2; 
  • trunk/geowebcache/src/main/java/org/geowebcache/cache/file/FilePathKey2Filter.java

    r420 r422  
    5353     *  *                 EPSG_2163_01 
    5454     */ 
    55     public boolean accept(File dir, String name) { 
    56         System.out.println(dir.getAbsolutePath() + " " + name); 
    57          
     55    public boolean accept(File dir, String name) {   
    5856        if(name.startsWith("EPSG_")) { 
    5957            // srs and zoomlevel level 
     
    8078        } else { 
    8179            int tmp = findZoomLevel(name); 
    82             if(tmp < zoomStart || tmp > zoomStop) { 
     80            if(tmp <= zoomStart || tmp >= zoomStop) { 
    8381                return false; 
    8482            } 
     
    121119 
    122120            // [2, 5, 5, 6] , why that when we've got 00_05 ? 
    123             if (x <= box[0] || x >= box[2]) { 
     121            if (x < box[0] || x > box[2]) { 
    124122                return false; 
    125123            } 
    126124 
    127             if (y <= box[1] || y >= box[3]) { 
     125            if (y < box[1] || y > box[3]) { 
    128126                return false; 
    129127            } 
    130128        } 
     129         
     130        System.out.println(dir.getAbsolutePath() + " " + name); 
    131131         
    132132        return true; 
  • trunk/geowebcache/src/main/java/org/geowebcache/layer/GridCalculator.java

    r407 r422  
    190190    } 
    191191 
     192    public int[][] getGridBounds() { 
     193        int[][] ret = new int[boundsGridLevels.length][boundsGridLevels[0].length]; 
     194         
     195        for(int i=0; i<boundsGridLevels.length; i++) { 
     196            ret[i] = boundsGridLevels[i].clone(); 
     197        } 
     198         
     199        return ret; 
     200    } 
     201     
    192202    /** 
    193203     * Determines the location in a three dimensional grid based on WMS 
     
    236246        retVals[0] = (int) Math.round(xLoc); 
    237247        double absdiff = Math.abs(retVals[0]*tileWidth - xdiff); 
    238          
    239         // This doesn't work too great 
    240         // http://localhost:8080/geowebcache/service/wms?LAYERS=topp%3Aopen_space&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A900913&BBOX=-8238077.159316406,4955673.447285157,-8218509.280078124,4965241.326523438&WIDTH=256&HEIGHT=256 
    241248        if(absdiff > 0.00005 && (absdiff / tileWidth)  > 0.05) { 
    242249            throw new BadTileException("Your bounds in the x direction are offset" 
     
    515522    } 
    516523     
     524    /** 
     525     * Expands the 2-dim array with bounds to cover complete metatiles 
     526     *  
     527     * Note that these may exceed the bounds of the layer. 
     528     *  
     529     * @param gridBounds 
     530     * @param reqBounds 
     531     * @param meta 
     532     * @return 
     533     */ 
     534    public static int[][] expandBoundsToMetaTiles(int[][] gridBounds, int[][] reqBounds, int[] meta) { 
     535        int[][] ret = new int[reqBounds.length][reqBounds[0].length]; 
     536         
     537        for (int i = 0; i < reqBounds.length; i++) { 
     538            // Go down 
     539            ret[i][0] = (reqBounds[i][0] - (reqBounds[i][0] % meta[0])); 
     540            ret[i][1] = (reqBounds[i][1] - (reqBounds[i][1] % meta[1])); 
     541 
     542            // Go up 
     543            ret[i][2] = (reqBounds[i][2] - (reqBounds[i][2] % meta[0]) + meta[0] - 1); 
     544            ret[i][3] = (reqBounds[i][3] - (reqBounds[i][3] % meta[1]) + meta[1] - 1); 
     545             
     546            // Then check against grid 
     547            //if(ret[i][0] < gridBounds[i][0]) { 
     548            //    ret[i][0] = 0; 
     549            //} 
     550            //if(ret[i][1] < gridBounds[i][1]) { 
     551            //    ret[i][1] = 0; 
     552            //} 
     553            //if(ret[i][2] > gridBounds[i][2]) { 
     554            //    ret[i][2] = gridBounds[i][2]; 
     555            //} 
     556            //if(ret[i][3] > gridBounds[i][3]) { 
     557            //    ret[i][3] = gridBounds[i][3]; 
     558            //} 
     559        } 
     560         
     561        return ret; 
     562    } 
     563     
    517564    public static double[] get900913Resolutions() { 
    518565        return GridCalculator.RESOLUTIONS900913; 
  • trunk/geowebcache/src/main/java/org/geowebcache/rest/TruncateTask.java

    r418 r422  
    2121import org.geowebcache.GeoWebCacheException; 
    2222import org.geowebcache.cache.Cache; 
     23import org.geowebcache.layer.GridCalculator; 
    2324import org.geowebcache.layer.TileLayer; 
    2425import org.geowebcache.mime.MimeType; 
     
    5051        } 
    5152         
     53        // Check if MimeType supports metatiling, in which case  
     54        // we may have to throw a wider net 
     55        MimeType mimeType = null; 
     56        if(req.getMimeFormat() != null && req.getMimeFormat().length() > 0) { 
     57            mimeType = MimeType.createFromFormat(req.getMimeFormat()); 
     58             
     59            int[] metaFactors = tl.getMetaTilingFactors(); 
     60             
     61            int gridBounds[][] = tl.getGrid(req.getSRS()).getGridCalculator().getGridBounds(); 
     62             
     63            if(metaFactors[0] > 1 || metaFactors[1] > 1 
     64                    && mimeType.supportsTiling()) { 
     65                bounds = GridCalculator.expandBoundsToMetaTiles(gridBounds, bounds, metaFactors); 
     66            } 
     67        } 
     68         
    5269        cache.truncate(tl, req.getSRS(),  
    5370                req.getZoomStart(), req.getZoomStop(),  
    54                 bounds, MimeType.createFromFormat(req.getMimeFormat())); 
     71                bounds, mimeType); 
    5572    } 
    5673